babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.vector" {
  1937. import { Viewport } from "babylonjs/Maths/math.viewport";
  1938. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1939. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1940. /**
  1941. * Class representing a vector containing 2 coordinates
  1942. */
  1943. export class Vector2 {
  1944. /** defines the first coordinate */
  1945. x: number;
  1946. /** defines the second coordinate */
  1947. y: number;
  1948. /**
  1949. * Creates a new Vector2 from the given x and y coordinates
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. */
  1953. constructor(
  1954. /** defines the first coordinate */
  1955. x?: number,
  1956. /** defines the second coordinate */
  1957. y?: number);
  1958. /**
  1959. * Gets a string with the Vector2 coordinates
  1960. * @returns a string with the Vector2 coordinates
  1961. */
  1962. toString(): string;
  1963. /**
  1964. * Gets class name
  1965. * @returns the string "Vector2"
  1966. */
  1967. getClassName(): string;
  1968. /**
  1969. * Gets current vector hash code
  1970. * @returns the Vector2 hash code as a number
  1971. */
  1972. getHashCode(): number;
  1973. /**
  1974. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1975. * @param array defines the source array
  1976. * @param index defines the offset in source array
  1977. * @returns the current Vector2
  1978. */
  1979. toArray(array: FloatArray, index?: number): Vector2;
  1980. /**
  1981. * Copy the current vector to an array
  1982. * @returns a new array with 2 elements: the Vector2 coordinates.
  1983. */
  1984. asArray(): number[];
  1985. /**
  1986. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1987. * @param source defines the source Vector2
  1988. * @returns the current updated Vector2
  1989. */
  1990. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the Vector2 coordinates with the given floats
  1993. * @param x defines the first coordinate
  1994. * @param y defines the second coordinate
  1995. * @returns the current updated Vector2
  1996. */
  1997. copyFromFloats(x: number, y: number): Vector2;
  1998. /**
  1999. * Sets the Vector2 coordinates with the given floats
  2000. * @param x defines the first coordinate
  2001. * @param y defines the second coordinate
  2002. * @returns the current updated Vector2
  2003. */
  2004. set(x: number, y: number): Vector2;
  2005. /**
  2006. * Add another vector with the current one
  2007. * @param otherVector defines the other vector
  2008. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2009. */
  2010. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2013. * @param otherVector defines the other vector
  2014. * @param result defines the target vector
  2015. * @returns the unmodified current Vector2
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2018. /**
  2019. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns the current updated Vector2
  2022. */
  2023. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2024. /**
  2025. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. addVector3(otherVector: Vector3): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2032. * @param otherVector defines the other vector
  2033. * @returns a new Vector2
  2034. */
  2035. subtract(otherVector: Vector2): Vector2;
  2036. /**
  2037. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2038. * @param otherVector defines the other vector
  2039. * @param result defines the target vector
  2040. * @returns the unmodified current Vector2
  2041. */
  2042. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2043. /**
  2044. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Multiplies in place the current Vector2 coordinates by the given ones
  2051. * @param otherVector defines the other vector
  2052. * @returns the current updated Vector2
  2053. */
  2054. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. * @returns a new Vector2
  2073. */
  2074. multiplyByFloats(x: number, y: number): Vector2;
  2075. /**
  2076. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @returns a new Vector2
  2079. */
  2080. divide(otherVector: Vector2): Vector2;
  2081. /**
  2082. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2083. * @param otherVector defines the other vector
  2084. * @param result defines the target vector
  2085. * @returns the unmodified current Vector2
  2086. */
  2087. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2088. /**
  2089. * Divides the current Vector2 coordinates by the given ones
  2090. * @param otherVector defines the other vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Gets a new Vector2 with current Vector2 negated coordinates
  2096. * @returns a new Vector2
  2097. */
  2098. negate(): Vector2;
  2099. /**
  2100. * Negate this vector in place
  2101. * @returns this
  2102. */
  2103. negateInPlace(): Vector2;
  2104. /**
  2105. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2106. * @param result defines the Vector3 object where to store the result
  2107. * @returns the current Vector2
  2108. */
  2109. negateToRef(result: Vector2): Vector2;
  2110. /**
  2111. * Multiply the Vector2 coordinates by scale
  2112. * @param scale defines the scaling factor
  2113. * @returns the current updated Vector2
  2114. */
  2115. scaleInPlace(scale: number): Vector2;
  2116. /**
  2117. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2118. * @param scale defines the scaling factor
  2119. * @returns a new Vector2
  2120. */
  2121. scale(scale: number): Vector2;
  2122. /**
  2123. * Scale the current Vector2 values by a factor to a given Vector2
  2124. * @param scale defines the scale factor
  2125. * @param result defines the Vector2 object where to store the result
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. scaleToRef(scale: number, result: Vector2): Vector2;
  2129. /**
  2130. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2131. * @param scale defines the scale factor
  2132. * @param result defines the Vector2 object where to store the result
  2133. * @returns the unmodified current Vector2
  2134. */
  2135. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2136. /**
  2137. * Gets a boolean if two vectors are equals
  2138. * @param otherVector defines the other vector
  2139. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2140. */
  2141. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2142. /**
  2143. * Gets a boolean if two vectors are equals (using an epsilon value)
  2144. * @param otherVector defines the other vector
  2145. * @param epsilon defines the minimal distance to consider equality
  2146. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2147. */
  2148. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2149. /**
  2150. * Gets a new Vector2 from current Vector2 floored values
  2151. * @returns a new Vector2
  2152. */
  2153. floor(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 from current Vector2 floored values
  2156. * @returns a new Vector2
  2157. */
  2158. fract(): Vector2;
  2159. /**
  2160. * Gets the length of the vector
  2161. * @returns the vector length (float)
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Gets the vector squared length
  2166. * @returns the vector squared length (float)
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalize the vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. normalize(): Vector2;
  2174. /**
  2175. * Gets a new Vector2 copied from the Vector2
  2176. * @returns a new Vector2
  2177. */
  2178. clone(): Vector2;
  2179. /**
  2180. * Gets a new Vector2(0, 0)
  2181. * @returns a new Vector2
  2182. */
  2183. static Zero(): Vector2;
  2184. /**
  2185. * Gets a new Vector2(1, 1)
  2186. * @returns a new Vector2
  2187. */
  2188. static One(): Vector2;
  2189. /**
  2190. * Gets a new Vector2 set from the given index element of the given array
  2191. * @param array defines the data source
  2192. * @param offset defines the offset in the data source
  2193. * @returns a new Vector2
  2194. */
  2195. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2196. /**
  2197. * Sets "result" from the given index element of the given array
  2198. * @param array defines the data source
  2199. * @param offset defines the offset in the data source
  2200. * @param result defines the target vector
  2201. */
  2202. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2203. /**
  2204. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2205. * @param value1 defines 1st point of control
  2206. * @param value2 defines 2nd point of control
  2207. * @param value3 defines 3rd point of control
  2208. * @param value4 defines 4th point of control
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2215. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2216. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2217. * @param value defines the value to clamp
  2218. * @param min defines the lower limit
  2219. * @param max defines the upper limit
  2220. * @returns a new Vector2
  2221. */
  2222. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2225. * @param value1 defines the 1st control point
  2226. * @param tangent1 defines the outgoing tangent
  2227. * @param value2 defines the 2nd control point
  2228. * @param tangent2 defines the incoming tangent
  2229. * @param amount defines the interpolation factor
  2230. * @returns a new Vector2
  2231. */
  2232. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2235. * @param start defines the start vector
  2236. * @param end defines the end vector
  2237. * @param amount defines the interpolation factor
  2238. * @returns a new Vector2
  2239. */
  2240. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2241. /**
  2242. * Gets the dot product of the vector "left" and the vector "right"
  2243. * @param left defines first vector
  2244. * @param right defines second vector
  2245. * @returns the dot product (float)
  2246. */
  2247. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2248. /**
  2249. * Returns a new Vector2 equal to the normalized given vector
  2250. * @param vector defines the vector to normalize
  2251. * @returns a new Vector2
  2252. */
  2253. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2254. /**
  2255. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2256. * @param left defines 1st vector
  2257. * @param right defines 2nd vector
  2258. * @returns a new Vector2
  2259. */
  2260. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2261. /**
  2262. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2263. * @param left defines 1st vector
  2264. * @param right defines 2nd vector
  2265. * @returns a new Vector2
  2266. */
  2267. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2268. /**
  2269. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2270. * @param vector defines the vector to transform
  2271. * @param transformation defines the matrix to apply
  2272. * @returns a new Vector2
  2273. */
  2274. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2275. /**
  2276. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2277. * @param vector defines the vector to transform
  2278. * @param transformation defines the matrix to apply
  2279. * @param result defines the target vector
  2280. */
  2281. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2282. /**
  2283. * Determines if a given vector is included in a triangle
  2284. * @param p defines the vector to test
  2285. * @param p0 defines 1st triangle point
  2286. * @param p1 defines 2nd triangle point
  2287. * @param p2 defines 3rd triangle point
  2288. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2289. */
  2290. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2291. /**
  2292. * Gets the distance between the vectors "value1" and "value2"
  2293. * @param value1 defines first vector
  2294. * @param value2 defines second vector
  2295. * @returns the distance between vectors
  2296. */
  2297. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2298. /**
  2299. * Returns the squared distance between the vectors "value1" and "value2"
  2300. * @param value1 defines first vector
  2301. * @param value2 defines second vector
  2302. * @returns the squared distance between vectors
  2303. */
  2304. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2305. /**
  2306. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2307. * @param value1 defines first vector
  2308. * @param value2 defines second vector
  2309. * @returns a new Vector2
  2310. */
  2311. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2312. /**
  2313. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2314. * @param p defines the middle point
  2315. * @param segA defines one point of the segment
  2316. * @param segB defines the other point of the segment
  2317. * @returns the shortest distance
  2318. */
  2319. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2320. }
  2321. /**
  2322. * Class used to store (x,y,z) vector representation
  2323. * A Vector3 is the main object used in 3D geometry
  2324. * It can represent etiher the coordinates of a point the space, either a direction
  2325. * Reminder: js uses a left handed forward facing system
  2326. */
  2327. export class Vector3 {
  2328. /**
  2329. * Defines the first coordinates (on X axis)
  2330. */
  2331. x: number;
  2332. /**
  2333. * Defines the second coordinates (on Y axis)
  2334. */
  2335. y: number;
  2336. /**
  2337. * Defines the third coordinates (on Z axis)
  2338. */
  2339. z: number;
  2340. private static _UpReadOnly;
  2341. private static _ZeroReadOnly;
  2342. /**
  2343. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2344. * @param x defines the first coordinates (on X axis)
  2345. * @param y defines the second coordinates (on Y axis)
  2346. * @param z defines the third coordinates (on Z axis)
  2347. */
  2348. constructor(
  2349. /**
  2350. * Defines the first coordinates (on X axis)
  2351. */
  2352. x?: number,
  2353. /**
  2354. * Defines the second coordinates (on Y axis)
  2355. */
  2356. y?: number,
  2357. /**
  2358. * Defines the third coordinates (on Z axis)
  2359. */
  2360. z?: number);
  2361. /**
  2362. * Creates a string representation of the Vector3
  2363. * @returns a string with the Vector3 coordinates.
  2364. */
  2365. toString(): string;
  2366. /**
  2367. * Gets the class name
  2368. * @returns the string "Vector3"
  2369. */
  2370. getClassName(): string;
  2371. /**
  2372. * Creates the Vector3 hash code
  2373. * @returns a number which tends to be unique between Vector3 instances
  2374. */
  2375. getHashCode(): number;
  2376. /**
  2377. * Creates an array containing three elements : the coordinates of the Vector3
  2378. * @returns a new array of numbers
  2379. */
  2380. asArray(): number[];
  2381. /**
  2382. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2383. * @param array defines the destination array
  2384. * @param index defines the offset in the destination array
  2385. * @returns the current Vector3
  2386. */
  2387. toArray(array: FloatArray, index?: number): Vector3;
  2388. /**
  2389. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2390. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2391. */
  2392. toQuaternion(): Quaternion;
  2393. /**
  2394. * Adds the given vector to the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the current updated Vector3
  2397. */
  2398. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Adds the given coordinates to the current Vector3
  2401. * @param x defines the x coordinate of the operand
  2402. * @param y defines the y coordinate of the operand
  2403. * @param z defines the z coordinate of the operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2407. /**
  2408. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Subtract the given vector from the current Vector3
  2422. * @param otherVector defines the second operand
  2423. * @returns the current updated Vector3
  2424. */
  2425. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2428. * @param otherVector defines the second operand
  2429. * @returns the resulting Vector3
  2430. */
  2431. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2434. * @param otherVector defines the second operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2439. /**
  2440. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2441. * @param x defines the x coordinate of the operand
  2442. * @param y defines the y coordinate of the operand
  2443. * @param z defines the z coordinate of the operand
  2444. * @returns the resulting Vector3
  2445. */
  2446. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2447. /**
  2448. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2456. /**
  2457. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2458. * @returns a new Vector3
  2459. */
  2460. negate(): Vector3;
  2461. /**
  2462. * Negate this vector in place
  2463. * @returns this
  2464. */
  2465. negateInPlace(): Vector3;
  2466. /**
  2467. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2468. * @param result defines the Vector3 object where to store the result
  2469. * @returns the current Vector3
  2470. */
  2471. negateToRef(result: Vector3): Vector3;
  2472. /**
  2473. * Multiplies the Vector3 coordinates by the float "scale"
  2474. * @param scale defines the multiplier factor
  2475. * @returns the current updated Vector3
  2476. */
  2477. scaleInPlace(scale: number): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2480. * @param scale defines the multiplier factor
  2481. * @returns a new Vector3
  2482. */
  2483. scale(scale: number): Vector3;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2486. * @param scale defines the multiplier factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the current Vector3
  2489. */
  2490. scaleToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2493. * @param scale defines the scale factor
  2494. * @param result defines the Vector3 object where to store the result
  2495. * @returns the unmodified current Vector3
  2496. */
  2497. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2498. /**
  2499. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2500. * @param otherVector defines the second operand
  2501. * @returns true if both vectors are equals
  2502. */
  2503. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2506. * @param otherVector defines the second operand
  2507. * @param epsilon defines the minimal distance to define values as equals
  2508. * @returns true if both vectors are distant less than epsilon
  2509. */
  2510. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2511. /**
  2512. * Returns true if the current Vector3 coordinates equals the given floats
  2513. * @param x defines the x coordinate of the operand
  2514. * @param y defines the y coordinate of the operand
  2515. * @param z defines the z coordinate of the operand
  2516. * @returns true if both vectors are equals
  2517. */
  2518. equalsToFloats(x: number, y: number, z: number): boolean;
  2519. /**
  2520. * Multiplies the current Vector3 coordinates by the given ones
  2521. * @param otherVector defines the second operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2527. * @param otherVector defines the second operand
  2528. * @returns the new Vector3
  2529. */
  2530. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2531. /**
  2532. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2533. * @param otherVector defines the second operand
  2534. * @param result defines the Vector3 object where to store the result
  2535. * @returns the current Vector3
  2536. */
  2537. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2538. /**
  2539. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2540. * @param x defines the x coordinate of the operand
  2541. * @param y defines the y coordinate of the operand
  2542. * @param z defines the z coordinate of the operand
  2543. * @returns the new Vector3
  2544. */
  2545. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2546. /**
  2547. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2548. * @param otherVector defines the second operand
  2549. * @returns the new Vector3
  2550. */
  2551. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2554. * @param otherVector defines the second operand
  2555. * @param result defines the Vector3 object where to store the result
  2556. * @returns the current Vector3
  2557. */
  2558. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2559. /**
  2560. * Divides the current Vector3 coordinates by the given ones.
  2561. * @param otherVector defines the second operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. divideInPlace(otherVector: Vector3): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2567. * @param other defines the second operand
  2568. * @returns the current updated Vector3
  2569. */
  2570. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2573. * @param other defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2579. * @param x defines the x coordinate of the operand
  2580. * @param y defines the y coordinate of the operand
  2581. * @param z defines the z coordinate of the operand
  2582. * @returns the current updated Vector3
  2583. */
  2584. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2585. /**
  2586. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2587. * @param x defines the x coordinate of the operand
  2588. * @param y defines the y coordinate of the operand
  2589. * @param z defines the z coordinate of the operand
  2590. * @returns the current updated Vector3
  2591. */
  2592. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2593. /**
  2594. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2595. * Check if is non uniform within a certain amount of decimal places to account for this
  2596. * @param epsilon the amount the values can differ
  2597. * @returns if the the vector is non uniform to a certain number of decimal places
  2598. */
  2599. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2600. /**
  2601. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2602. */
  2603. get isNonUniform(): boolean;
  2604. /**
  2605. * Gets a new Vector3 from current Vector3 floored values
  2606. * @returns a new Vector3
  2607. */
  2608. floor(): Vector3;
  2609. /**
  2610. * Gets a new Vector3 from current Vector3 floored values
  2611. * @returns a new Vector3
  2612. */
  2613. fract(): Vector3;
  2614. /**
  2615. * Gets the length of the Vector3
  2616. * @returns the length of the Vector3
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Gets the squared length of the Vector3
  2621. * @returns squared length of the Vector3
  2622. */
  2623. lengthSquared(): number;
  2624. /**
  2625. * Normalize the current Vector3.
  2626. * Please note that this is an in place operation.
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalize(): Vector3;
  2630. /**
  2631. * Reorders the x y z properties of the vector in place
  2632. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2633. * @returns the current updated vector
  2634. */
  2635. reorderInPlace(order: string): this;
  2636. /**
  2637. * Rotates the vector around 0,0,0 by a quaternion
  2638. * @param quaternion the rotation quaternion
  2639. * @param result vector to store the result
  2640. * @returns the resulting vector
  2641. */
  2642. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2643. /**
  2644. * Rotates a vector around a given point
  2645. * @param quaternion the rotation quaternion
  2646. * @param point the point to rotate around
  2647. * @param result vector to store the result
  2648. * @returns the resulting vector
  2649. */
  2650. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2651. /**
  2652. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2653. * The cross product is then orthogonal to both current and "other"
  2654. * @param other defines the right operand
  2655. * @returns the cross product
  2656. */
  2657. cross(other: Vector3): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 with the given input length.
  2660. * Please note that this is an in place operation.
  2661. * @param len the length of the vector
  2662. * @returns the current updated Vector3
  2663. */
  2664. normalizeFromLength(len: number): Vector3;
  2665. /**
  2666. * Normalize the current Vector3 to a new vector
  2667. * @returns the new Vector3
  2668. */
  2669. normalizeToNew(): Vector3;
  2670. /**
  2671. * Normalize the current Vector3 to the reference
  2672. * @param reference define the Vector3 to update
  2673. * @returns the updated Vector3
  2674. */
  2675. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2676. /**
  2677. * Creates a new Vector3 copied from the current Vector3
  2678. * @returns the new Vector3
  2679. */
  2680. clone(): Vector3;
  2681. /**
  2682. * Copies the given vector coordinates to the current Vector3 ones
  2683. * @param source defines the source Vector3
  2684. * @returns the current updated Vector3
  2685. */
  2686. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2687. /**
  2688. * Copies the given floats to the current Vector3 coordinates
  2689. * @param x defines the x coordinate of the operand
  2690. * @param y defines the y coordinate of the operand
  2691. * @param z defines the z coordinate of the operand
  2692. * @returns the current updated Vector3
  2693. */
  2694. copyFromFloats(x: number, y: number, z: number): Vector3;
  2695. /**
  2696. * Copies the given floats to the current Vector3 coordinates
  2697. * @param x defines the x coordinate of the operand
  2698. * @param y defines the y coordinate of the operand
  2699. * @param z defines the z coordinate of the operand
  2700. * @returns the current updated Vector3
  2701. */
  2702. set(x: number, y: number, z: number): Vector3;
  2703. /**
  2704. * Copies the given float to the current Vector3 coordinates
  2705. * @param v defines the x, y and z coordinates of the operand
  2706. * @returns the current updated Vector3
  2707. */
  2708. setAll(v: number): Vector3;
  2709. /**
  2710. * Get the clip factor between two vectors
  2711. * @param vector0 defines the first operand
  2712. * @param vector1 defines the second operand
  2713. * @param axis defines the axis to use
  2714. * @param size defines the size along the axis
  2715. * @returns the clip factor
  2716. */
  2717. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2718. /**
  2719. * Get angle between two vectors
  2720. * @param vector0 angle between vector0 and vector1
  2721. * @param vector1 angle between vector0 and vector1
  2722. * @param normal direction of the normal
  2723. * @return the angle between vector0 and vector1
  2724. */
  2725. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. */
  2732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2735. * @param array defines the source array
  2736. * @param offset defines the offset in the source array
  2737. * @returns the new Vector3
  2738. * @deprecated Please use FromArray instead.
  2739. */
  2740. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. */
  2747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2748. /**
  2749. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2750. * @param array defines the source array
  2751. * @param offset defines the offset in the source array
  2752. * @param result defines the Vector3 where to store the result
  2753. * @deprecated Please use FromArrayToRef instead.
  2754. */
  2755. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2756. /**
  2757. * Sets the given vector "result" with the given floats.
  2758. * @param x defines the x coordinate of the source
  2759. * @param y defines the y coordinate of the source
  2760. * @param z defines the z coordinate of the source
  2761. * @param result defines the Vector3 where to store the result
  2762. */
  2763. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2766. * @returns a new empty Vector3
  2767. */
  2768. static Zero(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2771. * @returns a new unit Vector3
  2772. */
  2773. static One(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2776. * @returns a new up Vector3
  2777. */
  2778. static Up(): Vector3;
  2779. /**
  2780. * Gets a up Vector3 that must not be updated
  2781. */
  2782. static get UpReadOnly(): DeepImmutable<Vector3>;
  2783. /**
  2784. * Gets a zero Vector3 that must not be updated
  2785. */
  2786. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2787. /**
  2788. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2789. * @returns a new down Vector3
  2790. */
  2791. static Down(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2794. * @returns a new forward Vector3
  2795. */
  2796. static Forward(): Vector3;
  2797. /**
  2798. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2799. * @returns a new forward Vector3
  2800. */
  2801. static Backward(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2804. * @returns a new right Vector3
  2805. */
  2806. static Right(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2809. * @returns a new left Vector3
  2810. */
  2811. static Left(): Vector3;
  2812. /**
  2813. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2814. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2815. * @param vector defines the Vector3 to transform
  2816. * @param transformation defines the transformation matrix
  2817. * @returns the transformed Vector3
  2818. */
  2819. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2820. /**
  2821. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2822. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2823. * @param vector defines the Vector3 to transform
  2824. * @param transformation defines the transformation matrix
  2825. * @param result defines the Vector3 where to store the result
  2826. */
  2827. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2828. /**
  2829. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2830. * This method computes tranformed coordinates only, not transformed direction vectors
  2831. * @param x define the x coordinate of the source vector
  2832. * @param y define the y coordinate of the source vector
  2833. * @param z define the z coordinate of the source vector
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2841. * @param vector defines the Vector3 to transform
  2842. * @param transformation defines the transformation matrix
  2843. * @returns the new Vector3
  2844. */
  2845. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2846. /**
  2847. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2848. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2849. * @param vector defines the Vector3 to transform
  2850. * @param transformation defines the transformation matrix
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2854. /**
  2855. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2856. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2857. * @param x define the x coordinate of the source vector
  2858. * @param y define the y coordinate of the source vector
  2859. * @param z define the z coordinate of the source vector
  2860. * @param transformation defines the transformation matrix
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2864. /**
  2865. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2866. * @param value1 defines the first control point
  2867. * @param value2 defines the second control point
  2868. * @param value3 defines the third control point
  2869. * @param value4 defines the fourth control point
  2870. * @param amount defines the amount on the spline to use
  2871. * @returns the new Vector3
  2872. */
  2873. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2874. /**
  2875. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2876. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2877. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2878. * @param value defines the current value
  2879. * @param min defines the lower range value
  2880. * @param max defines the upper range value
  2881. * @returns the new Vector3
  2882. */
  2883. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2886. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2887. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2888. * @param value defines the current value
  2889. * @param min defines the lower range value
  2890. * @param max defines the upper range value
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2894. /**
  2895. * Checks if a given vector is inside a specific range
  2896. * @param v defines the vector to test
  2897. * @param min defines the minimum range
  2898. * @param max defines the maximum range
  2899. */
  2900. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2901. /**
  2902. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2903. * @param value1 defines the first control point
  2904. * @param tangent1 defines the first tangent vector
  2905. * @param value2 defines the second control point
  2906. * @param tangent2 defines the second tangent vector
  2907. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2908. * @returns the new Vector3
  2909. */
  2910. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2911. /**
  2912. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2913. * @param start defines the start value
  2914. * @param end defines the end value
  2915. * @param amount max defines amount between both (between 0 and 1)
  2916. * @returns the new Vector3
  2917. */
  2918. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2919. /**
  2920. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2921. * @param start defines the start value
  2922. * @param end defines the end value
  2923. * @param amount max defines amount between both (between 0 and 1)
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2927. /**
  2928. * Returns the dot product (float) between the vectors "left" and "right"
  2929. * @param left defines the left operand
  2930. * @param right defines the right operand
  2931. * @returns the dot product
  2932. */
  2933. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2934. /**
  2935. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2936. * The cross product is then orthogonal to both "left" and "right"
  2937. * @param left defines the left operand
  2938. * @param right defines the right operand
  2939. * @returns the cross product
  2940. */
  2941. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the cross product of "left" and "right"
  2944. * The cross product is then orthogonal to both "left" and "right"
  2945. * @param left defines the left operand
  2946. * @param right defines the right operand
  2947. * @param result defines the Vector3 where to store the result
  2948. */
  2949. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2950. /**
  2951. * Returns a new Vector3 as the normalization of the given vector
  2952. * @param vector defines the Vector3 to normalize
  2953. * @returns the new Vector3
  2954. */
  2955. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2956. /**
  2957. * Sets the given vector "result" with the normalization of the given first vector
  2958. * @param vector defines the Vector3 to normalize
  2959. * @param result defines the Vector3 where to store the result
  2960. */
  2961. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2962. /**
  2963. * Project a Vector3 onto screen space
  2964. * @param vector defines the Vector3 to project
  2965. * @param world defines the world matrix to use
  2966. * @param transform defines the transform (view x projection) matrix to use
  2967. * @param viewport defines the screen viewport to use
  2968. * @returns the new Vector3
  2969. */
  2970. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2971. /** @hidden */
  2972. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Unproject from screen space to object space
  2975. * @param source defines the screen space Vector3 to use
  2976. * @param viewportWidth defines the current width of the viewport
  2977. * @param viewportHeight defines the current height of the viewport
  2978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2979. * @param transform defines the transform (view x projection) matrix to use
  2980. * @returns the new Vector3
  2981. */
  2982. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2983. /**
  2984. * Unproject from screen space to object space
  2985. * @param source defines the screen space Vector3 to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param view defines the view matrix to use
  2990. * @param projection defines the projection matrix to use
  2991. * @returns the new Vector3
  2992. */
  2993. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Unproject from screen space to object space
  2996. * @param source defines the screen space Vector3 to use
  2997. * @param viewportWidth defines the current width of the viewport
  2998. * @param viewportHeight defines the current height of the viewport
  2999. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3000. * @param view defines the view matrix to use
  3001. * @param projection defines the projection matrix to use
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Unproject from screen space to object space
  3007. * @param sourceX defines the screen space x coordinate to use
  3008. * @param sourceY defines the screen space y coordinate to use
  3009. * @param sourceZ defines the screen space z coordinate to use
  3010. * @param viewportWidth defines the current width of the viewport
  3011. * @param viewportHeight defines the current height of the viewport
  3012. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3013. * @param view defines the view matrix to use
  3014. * @param projection defines the projection matrix to use
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3018. /**
  3019. * Gets the minimal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Gets the maximal coordinate values between two Vector3
  3027. * @param left defines the first operand
  3028. * @param right defines the second operand
  3029. * @returns the new Vector3
  3030. */
  3031. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3032. /**
  3033. * Returns the distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the distance
  3037. */
  3038. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns the squared distance between the vectors "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the squared distance
  3044. */
  3045. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3046. /**
  3047. * Returns a new Vector3 located at the center between "value1" and "value2"
  3048. * @param value1 defines the first operand
  3049. * @param value2 defines the second operand
  3050. * @returns the new Vector3
  3051. */
  3052. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3055. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3056. * to something in order to rotate it from its local system to the given target system
  3057. * Note: axis1, axis2 and axis3 are normalized during this operation
  3058. * @param axis1 defines the first axis
  3059. * @param axis2 defines the second axis
  3060. * @param axis3 defines the third axis
  3061. * @returns a new Vector3
  3062. */
  3063. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3064. /**
  3065. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3066. * @param axis1 defines the first axis
  3067. * @param axis2 defines the second axis
  3068. * @param axis3 defines the third axis
  3069. * @param ref defines the Vector3 where to store the result
  3070. */
  3071. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3072. }
  3073. /**
  3074. * Vector4 class created for EulerAngle class conversion to Quaternion
  3075. */
  3076. export class Vector4 {
  3077. /** x value of the vector */
  3078. x: number;
  3079. /** y value of the vector */
  3080. y: number;
  3081. /** z value of the vector */
  3082. z: number;
  3083. /** w value of the vector */
  3084. w: number;
  3085. /**
  3086. * Creates a Vector4 object from the given floats.
  3087. * @param x x value of the vector
  3088. * @param y y value of the vector
  3089. * @param z z value of the vector
  3090. * @param w w value of the vector
  3091. */
  3092. constructor(
  3093. /** x value of the vector */
  3094. x: number,
  3095. /** y value of the vector */
  3096. y: number,
  3097. /** z value of the vector */
  3098. z: number,
  3099. /** w value of the vector */
  3100. w: number);
  3101. /**
  3102. * Returns the string with the Vector4 coordinates.
  3103. * @returns a string containing all the vector values
  3104. */
  3105. toString(): string;
  3106. /**
  3107. * Returns the string "Vector4".
  3108. * @returns "Vector4"
  3109. */
  3110. getClassName(): string;
  3111. /**
  3112. * Returns the Vector4 hash code.
  3113. * @returns a unique hash code
  3114. */
  3115. getHashCode(): number;
  3116. /**
  3117. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3118. * @returns the resulting array
  3119. */
  3120. asArray(): number[];
  3121. /**
  3122. * Populates the given array from the given index with the Vector4 coordinates.
  3123. * @param array array to populate
  3124. * @param index index of the array to start at (default: 0)
  3125. * @returns the Vector4.
  3126. */
  3127. toArray(array: FloatArray, index?: number): Vector4;
  3128. /**
  3129. * Adds the given vector to the current Vector4.
  3130. * @param otherVector the vector to add
  3131. * @returns the updated Vector4.
  3132. */
  3133. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3134. /**
  3135. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3136. * @param otherVector the vector to add
  3137. * @returns the resulting vector
  3138. */
  3139. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3140. /**
  3141. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3142. * @param otherVector the vector to add
  3143. * @param result the vector to store the result
  3144. * @returns the current Vector4.
  3145. */
  3146. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3147. /**
  3148. * Subtract in place the given vector from the current Vector4.
  3149. * @param otherVector the vector to subtract
  3150. * @returns the updated Vector4.
  3151. */
  3152. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3153. /**
  3154. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3155. * @param otherVector the vector to add
  3156. * @returns the new vector with the result
  3157. */
  3158. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3159. /**
  3160. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3161. * @param otherVector the vector to subtract
  3162. * @param result the vector to store the result
  3163. * @returns the current Vector4.
  3164. */
  3165. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3166. /**
  3167. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3168. */
  3169. /**
  3170. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @returns new vector containing the result
  3176. */
  3177. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3180. * @param x value to subtract
  3181. * @param y value to subtract
  3182. * @param z value to subtract
  3183. * @param w value to subtract
  3184. * @param result the vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3188. /**
  3189. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3190. * @returns a new vector with the negated values
  3191. */
  3192. negate(): Vector4;
  3193. /**
  3194. * Negate this vector in place
  3195. * @returns this
  3196. */
  3197. negateInPlace(): Vector4;
  3198. /**
  3199. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3200. * @param result defines the Vector3 object where to store the result
  3201. * @returns the current Vector4
  3202. */
  3203. negateToRef(result: Vector4): Vector4;
  3204. /**
  3205. * Multiplies the current Vector4 coordinates by scale (float).
  3206. * @param scale the number to scale with
  3207. * @returns the updated Vector4.
  3208. */
  3209. scaleInPlace(scale: number): Vector4;
  3210. /**
  3211. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3212. * @param scale the number to scale with
  3213. * @returns a new vector with the result
  3214. */
  3215. scale(scale: number): Vector4;
  3216. /**
  3217. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3218. * @param scale the number to scale with
  3219. * @param result a vector to store the result in
  3220. * @returns the current Vector4.
  3221. */
  3222. scaleToRef(scale: number, result: Vector4): Vector4;
  3223. /**
  3224. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3225. * @param scale defines the scale factor
  3226. * @param result defines the Vector4 object where to store the result
  3227. * @returns the unmodified current Vector4
  3228. */
  3229. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3230. /**
  3231. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3232. * @param otherVector the vector to compare against
  3233. * @returns true if they are equal
  3234. */
  3235. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3236. /**
  3237. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3238. * @param otherVector vector to compare against
  3239. * @param epsilon (Default: very small number)
  3240. * @returns true if they are equal
  3241. */
  3242. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3243. /**
  3244. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3245. * @param x x value to compare against
  3246. * @param y y value to compare against
  3247. * @param z z value to compare against
  3248. * @param w w value to compare against
  3249. * @returns true if equal
  3250. */
  3251. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3252. /**
  3253. * Multiplies in place the current Vector4 by the given one.
  3254. * @param otherVector vector to multiple with
  3255. * @returns the updated Vector4.
  3256. */
  3257. multiplyInPlace(otherVector: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3260. * @param otherVector vector to multiple with
  3261. * @returns resulting new vector
  3262. */
  3263. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3266. * @param otherVector vector to multiple with
  3267. * @param result vector to store the result
  3268. * @returns the current Vector4.
  3269. */
  3270. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3273. * @param x x value multiply with
  3274. * @param y y value multiply with
  3275. * @param z z value multiply with
  3276. * @param w w value multiply with
  3277. * @returns resulting new vector
  3278. */
  3279. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3282. * @param otherVector vector to devide with
  3283. * @returns resulting new vector
  3284. */
  3285. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3288. * @param otherVector vector to devide with
  3289. * @param result vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Divides the current Vector3 coordinates by the given ones.
  3295. * @param otherVector vector to devide with
  3296. * @returns the updated Vector3.
  3297. */
  3298. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3299. /**
  3300. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3301. * @param other defines the second operand
  3302. * @returns the current updated Vector4
  3303. */
  3304. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3305. /**
  3306. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3307. * @param other defines the second operand
  3308. * @returns the current updated Vector4
  3309. */
  3310. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Gets a new Vector4 from current Vector4 floored values
  3313. * @returns a new Vector4
  3314. */
  3315. floor(): Vector4;
  3316. /**
  3317. * Gets a new Vector4 from current Vector3 floored values
  3318. * @returns a new Vector4
  3319. */
  3320. fract(): Vector4;
  3321. /**
  3322. * Returns the Vector4 length (float).
  3323. * @returns the length
  3324. */
  3325. length(): number;
  3326. /**
  3327. * Returns the Vector4 squared length (float).
  3328. * @returns the length squared
  3329. */
  3330. lengthSquared(): number;
  3331. /**
  3332. * Normalizes in place the Vector4.
  3333. * @returns the updated Vector4.
  3334. */
  3335. normalize(): Vector4;
  3336. /**
  3337. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3338. * @returns this converted to a new vector3
  3339. */
  3340. toVector3(): Vector3;
  3341. /**
  3342. * Returns a new Vector4 copied from the current one.
  3343. * @returns the new cloned vector
  3344. */
  3345. clone(): Vector4;
  3346. /**
  3347. * Updates the current Vector4 with the given one coordinates.
  3348. * @param source the source vector to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to copy from
  3355. * @param y float to copy from
  3356. * @param z float to copy from
  3357. * @param w float to copy from
  3358. * @returns the updated Vector4.
  3359. */
  3360. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Updates the current Vector4 coordinates with the given floats.
  3363. * @param x float to set from
  3364. * @param y float to set from
  3365. * @param z float to set from
  3366. * @param w float to set from
  3367. * @returns the updated Vector4.
  3368. */
  3369. set(x: number, y: number, z: number, w: number): Vector4;
  3370. /**
  3371. * Copies the given float to the current Vector3 coordinates
  3372. * @param v defines the x, y, z and w coordinates of the operand
  3373. * @returns the current updated Vector3
  3374. */
  3375. setAll(v: number): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set from the starting index of the given array.
  3378. * @param array the array to pull values from
  3379. * @param offset the offset into the array to start at
  3380. * @returns the new vector
  3381. */
  3382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3383. /**
  3384. * Updates the given vector "result" from the starting index of the given array.
  3385. * @param array the array to pull values from
  3386. * @param offset the offset into the array to start at
  3387. * @param result the vector to store the result in
  3388. */
  3389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3390. /**
  3391. * Updates the given vector "result" from the starting index of the given Float32Array.
  3392. * @param array the array to pull values from
  3393. * @param offset the offset into the array to start at
  3394. * @param result the vector to store the result in
  3395. */
  3396. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3397. /**
  3398. * Updates the given vector "result" coordinates from the given floats.
  3399. * @param x float to set from
  3400. * @param y float to set from
  3401. * @param z float to set from
  3402. * @param w float to set from
  3403. * @param result the vector to the floats in
  3404. */
  3405. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3406. /**
  3407. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3408. * @returns the new vector
  3409. */
  3410. static Zero(): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3413. * @returns the new vector
  3414. */
  3415. static One(): Vector4;
  3416. /**
  3417. * Returns a new normalized Vector4 from the given one.
  3418. * @param vector the vector to normalize
  3419. * @returns the vector
  3420. */
  3421. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Updates the given vector "result" from the normalization of the given one.
  3424. * @param vector the vector to normalize
  3425. * @param result the vector to store the result in
  3426. */
  3427. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3428. /**
  3429. * Returns a vector with the minimum values from the left and right vectors
  3430. * @param left left vector to minimize
  3431. * @param right right vector to minimize
  3432. * @returns a new vector with the minimum of the left and right vector values
  3433. */
  3434. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3435. /**
  3436. * Returns a vector with the maximum values from the left and right vectors
  3437. * @param left left vector to maximize
  3438. * @param right right vector to maximize
  3439. * @returns a new vector with the maximum of the left and right vector values
  3440. */
  3441. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3442. /**
  3443. * Returns the distance (float) between the vectors "value1" and "value2".
  3444. * @param value1 value to calulate the distance between
  3445. * @param value2 value to calulate the distance between
  3446. * @return the distance between the two vectors
  3447. */
  3448. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3449. /**
  3450. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3451. * @param value1 value to calulate the distance between
  3452. * @param value2 value to calulate the distance between
  3453. * @return the distance between the two vectors squared
  3454. */
  3455. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3456. /**
  3457. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3458. * @param value1 value to calulate the center between
  3459. * @param value2 value to calulate the center between
  3460. * @return the center between the two vectors
  3461. */
  3462. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3463. /**
  3464. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3465. * This methods computes transformed normalized direction vectors only.
  3466. * @param vector the vector to transform
  3467. * @param transformation the transformation matrix to apply
  3468. * @returns the new vector
  3469. */
  3470. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3471. /**
  3472. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3473. * This methods computes transformed normalized direction vectors only.
  3474. * @param vector the vector to transform
  3475. * @param transformation the transformation matrix to apply
  3476. * @param result the vector to store the result in
  3477. */
  3478. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3479. /**
  3480. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3481. * This methods computes transformed normalized direction vectors only.
  3482. * @param x value to transform
  3483. * @param y value to transform
  3484. * @param z value to transform
  3485. * @param w value to transform
  3486. * @param transformation the transformation matrix to apply
  3487. * @param result the vector to store the results in
  3488. */
  3489. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3490. /**
  3491. * Creates a new Vector4 from a Vector3
  3492. * @param source defines the source data
  3493. * @param w defines the 4th component (default is 0)
  3494. * @returns a new Vector4
  3495. */
  3496. static FromVector3(source: Vector3, w?: number): Vector4;
  3497. }
  3498. /**
  3499. * Class used to store quaternion data
  3500. * @see https://en.wikipedia.org/wiki/Quaternion
  3501. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3502. */
  3503. export class Quaternion {
  3504. /** defines the first component (0 by default) */
  3505. x: number;
  3506. /** defines the second component (0 by default) */
  3507. y: number;
  3508. /** defines the third component (0 by default) */
  3509. z: number;
  3510. /** defines the fourth component (1.0 by default) */
  3511. w: number;
  3512. /**
  3513. * Creates a new Quaternion from the given floats
  3514. * @param x defines the first component (0 by default)
  3515. * @param y defines the second component (0 by default)
  3516. * @param z defines the third component (0 by default)
  3517. * @param w defines the fourth component (1.0 by default)
  3518. */
  3519. constructor(
  3520. /** defines the first component (0 by default) */
  3521. x?: number,
  3522. /** defines the second component (0 by default) */
  3523. y?: number,
  3524. /** defines the third component (0 by default) */
  3525. z?: number,
  3526. /** defines the fourth component (1.0 by default) */
  3527. w?: number);
  3528. /**
  3529. * Gets a string representation for the current quaternion
  3530. * @returns a string with the Quaternion coordinates
  3531. */
  3532. toString(): string;
  3533. /**
  3534. * Gets the class name of the quaternion
  3535. * @returns the string "Quaternion"
  3536. */
  3537. getClassName(): string;
  3538. /**
  3539. * Gets a hash code for this quaternion
  3540. * @returns the quaternion hash code
  3541. */
  3542. getHashCode(): number;
  3543. /**
  3544. * Copy the quaternion to an array
  3545. * @returns a new array populated with 4 elements from the quaternion coordinates
  3546. */
  3547. asArray(): number[];
  3548. /**
  3549. * Check if two quaternions are equals
  3550. * @param otherQuaternion defines the second operand
  3551. * @return true if the current quaternion and the given one coordinates are strictly equals
  3552. */
  3553. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3554. /**
  3555. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3556. * @param otherQuaternion defines the other quaternion
  3557. * @param epsilon defines the minimal distance to consider equality
  3558. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3559. */
  3560. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3561. /**
  3562. * Clone the current quaternion
  3563. * @returns a new quaternion copied from the current one
  3564. */
  3565. clone(): Quaternion;
  3566. /**
  3567. * Copy a quaternion to the current one
  3568. * @param other defines the other quaternion
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3572. /**
  3573. * Updates the current quaternion with the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Updates the current quaternion from the given float coordinates
  3583. * @param x defines the x coordinate
  3584. * @param y defines the y coordinate
  3585. * @param z defines the z coordinate
  3586. * @param w defines the w coordinate
  3587. * @returns the updated current quaternion
  3588. */
  3589. set(x: number, y: number, z: number, w: number): Quaternion;
  3590. /**
  3591. * Adds two quaternions
  3592. * @param other defines the second operand
  3593. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3594. */
  3595. add(other: DeepImmutable<Quaternion>): Quaternion;
  3596. /**
  3597. * Add a quaternion to the current one
  3598. * @param other defines the quaternion to add
  3599. * @returns the current quaternion
  3600. */
  3601. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3602. /**
  3603. * Subtract two quaternions
  3604. * @param other defines the second operand
  3605. * @returns a new quaternion as the subtraction result of the given one from the current one
  3606. */
  3607. subtract(other: Quaternion): Quaternion;
  3608. /**
  3609. * Multiplies the current quaternion by a scale factor
  3610. * @param value defines the scale factor
  3611. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3612. */
  3613. scale(value: number): Quaternion;
  3614. /**
  3615. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3616. * @param scale defines the scale factor
  3617. * @param result defines the Quaternion object where to store the result
  3618. * @returns the unmodified current quaternion
  3619. */
  3620. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3621. /**
  3622. * Multiplies in place the current quaternion by a scale factor
  3623. * @param value defines the scale factor
  3624. * @returns the current modified quaternion
  3625. */
  3626. scaleInPlace(value: number): Quaternion;
  3627. /**
  3628. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3629. * @param scale defines the scale factor
  3630. * @param result defines the Quaternion object where to store the result
  3631. * @returns the unmodified current quaternion
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3634. /**
  3635. * Multiplies two quaternions
  3636. * @param q1 defines the second operand
  3637. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3638. */
  3639. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3640. /**
  3641. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3642. * @param q1 defines the second operand
  3643. * @param result defines the target quaternion
  3644. * @returns the current quaternion
  3645. */
  3646. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3647. /**
  3648. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3649. * @param q1 defines the second operand
  3650. * @returns the currentupdated quaternion
  3651. */
  3652. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3653. /**
  3654. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3655. * @param ref defines the target quaternion
  3656. * @returns the current quaternion
  3657. */
  3658. conjugateToRef(ref: Quaternion): Quaternion;
  3659. /**
  3660. * Conjugates in place (1-q) the current quaternion
  3661. * @returns the current updated quaternion
  3662. */
  3663. conjugateInPlace(): Quaternion;
  3664. /**
  3665. * Conjugates in place (1-q) the current quaternion
  3666. * @returns a new quaternion
  3667. */
  3668. conjugate(): Quaternion;
  3669. /**
  3670. * Gets length of current quaternion
  3671. * @returns the quaternion length (float)
  3672. */
  3673. length(): number;
  3674. /**
  3675. * Normalize in place the current quaternion
  3676. * @returns the current updated quaternion
  3677. */
  3678. normalize(): Quaternion;
  3679. /**
  3680. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3681. * @param order is a reserved parameter and is ignore for now
  3682. * @returns a new Vector3 containing the Euler angles
  3683. */
  3684. toEulerAngles(order?: string): Vector3;
  3685. /**
  3686. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3687. * @param result defines the vector which will be filled with the Euler angles
  3688. * @param order is a reserved parameter and is ignore for now
  3689. * @returns the current unchanged quaternion
  3690. */
  3691. toEulerAnglesToRef(result: Vector3): Quaternion;
  3692. /**
  3693. * Updates the given rotation matrix with the current quaternion values
  3694. * @param result defines the target matrix
  3695. * @returns the current unchanged quaternion
  3696. */
  3697. toRotationMatrix(result: Matrix): Quaternion;
  3698. /**
  3699. * Updates the current quaternion from the given rotation matrix values
  3700. * @param matrix defines the source matrix
  3701. * @returns the current updated quaternion
  3702. */
  3703. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3704. /**
  3705. * Creates a new quaternion from a rotation matrix
  3706. * @param matrix defines the source matrix
  3707. * @returns a new quaternion created from the given rotation matrix values
  3708. */
  3709. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3710. /**
  3711. * Updates the given quaternion with the given rotation matrix values
  3712. * @param matrix defines the source matrix
  3713. * @param result defines the target quaternion
  3714. */
  3715. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3716. /**
  3717. * Returns the dot product (float) between the quaternions "left" and "right"
  3718. * @param left defines the left operand
  3719. * @param right defines the right operand
  3720. * @returns the dot product
  3721. */
  3722. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3723. /**
  3724. * Checks if the two quaternions are close to each other
  3725. * @param quat0 defines the first quaternion to check
  3726. * @param quat1 defines the second quaternion to check
  3727. * @returns true if the two quaternions are close to each other
  3728. */
  3729. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3730. /**
  3731. * Creates an empty quaternion
  3732. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3733. */
  3734. static Zero(): Quaternion;
  3735. /**
  3736. * Inverse a given quaternion
  3737. * @param q defines the source quaternion
  3738. * @returns a new quaternion as the inverted current quaternion
  3739. */
  3740. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3741. /**
  3742. * Inverse a given quaternion
  3743. * @param q defines the source quaternion
  3744. * @param result the quaternion the result will be stored in
  3745. * @returns the result quaternion
  3746. */
  3747. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3748. /**
  3749. * Creates an identity quaternion
  3750. * @returns the identity quaternion
  3751. */
  3752. static Identity(): Quaternion;
  3753. /**
  3754. * Gets a boolean indicating if the given quaternion is identity
  3755. * @param quaternion defines the quaternion to check
  3756. * @returns true if the quaternion is identity
  3757. */
  3758. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3759. /**
  3760. * Creates a quaternion from a rotation around an axis
  3761. * @param axis defines the axis to use
  3762. * @param angle defines the angle to use
  3763. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3764. */
  3765. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3766. /**
  3767. * Creates a rotation around an axis and stores it into the given quaternion
  3768. * @param axis defines the axis to use
  3769. * @param angle defines the angle to use
  3770. * @param result defines the target quaternion
  3771. * @returns the target quaternion
  3772. */
  3773. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Creates a new quaternion from data stored into an array
  3776. * @param array defines the data source
  3777. * @param offset defines the offset in the source array where the data starts
  3778. * @returns a new quaternion
  3779. */
  3780. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3781. /**
  3782. * Updates the given quaternion "result" from the starting index of the given array.
  3783. * @param array the array to pull values from
  3784. * @param offset the offset into the array to start at
  3785. * @param result the quaternion to store the result in
  3786. */
  3787. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3788. /**
  3789. * Create a quaternion from Euler rotation angles
  3790. * @param x Pitch
  3791. * @param y Yaw
  3792. * @param z Roll
  3793. * @returns the new Quaternion
  3794. */
  3795. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3796. /**
  3797. * Updates a quaternion from Euler rotation angles
  3798. * @param x Pitch
  3799. * @param y Yaw
  3800. * @param z Roll
  3801. * @param result the quaternion to store the result
  3802. * @returns the updated quaternion
  3803. */
  3804. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3805. /**
  3806. * Create a quaternion from Euler rotation vector
  3807. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3808. * @returns the new Quaternion
  3809. */
  3810. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3811. /**
  3812. * Updates a quaternion from Euler rotation vector
  3813. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3814. * @param result the quaternion to store the result
  3815. * @returns the updated quaternion
  3816. */
  3817. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3818. /**
  3819. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3820. * @param yaw defines the rotation around Y axis
  3821. * @param pitch defines the rotation around X axis
  3822. * @param roll defines the rotation around Z axis
  3823. * @returns the new quaternion
  3824. */
  3825. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3826. /**
  3827. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3828. * @param yaw defines the rotation around Y axis
  3829. * @param pitch defines the rotation around X axis
  3830. * @param roll defines the rotation around Z axis
  3831. * @param result defines the target quaternion
  3832. */
  3833. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3834. /**
  3835. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3836. * @param alpha defines the rotation around first axis
  3837. * @param beta defines the rotation around second axis
  3838. * @param gamma defines the rotation around third axis
  3839. * @returns the new quaternion
  3840. */
  3841. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3842. /**
  3843. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3844. * @param alpha defines the rotation around first axis
  3845. * @param beta defines the rotation around second axis
  3846. * @param gamma defines the rotation around third axis
  3847. * @param result defines the target quaternion
  3848. */
  3849. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3850. /**
  3851. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3852. * @param axis1 defines the first axis
  3853. * @param axis2 defines the second axis
  3854. * @param axis3 defines the third axis
  3855. * @returns the new quaternion
  3856. */
  3857. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3858. /**
  3859. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3860. * @param axis1 defines the first axis
  3861. * @param axis2 defines the second axis
  3862. * @param axis3 defines the third axis
  3863. * @param ref defines the target quaternion
  3864. */
  3865. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3866. /**
  3867. * Interpolates between two quaternions
  3868. * @param left defines first quaternion
  3869. * @param right defines second quaternion
  3870. * @param amount defines the gradient to use
  3871. * @returns the new interpolated quaternion
  3872. */
  3873. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3874. /**
  3875. * Interpolates between two quaternions and stores it into a target quaternion
  3876. * @param left defines first quaternion
  3877. * @param right defines second quaternion
  3878. * @param amount defines the gradient to use
  3879. * @param result defines the target quaternion
  3880. */
  3881. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3882. /**
  3883. * Interpolate between two quaternions using Hermite interpolation
  3884. * @param value1 defines first quaternion
  3885. * @param tangent1 defines the incoming tangent
  3886. * @param value2 defines second quaternion
  3887. * @param tangent2 defines the outgoing tangent
  3888. * @param amount defines the target quaternion
  3889. * @returns the new interpolated quaternion
  3890. */
  3891. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3892. }
  3893. /**
  3894. * Class used to store matrix data (4x4)
  3895. */
  3896. export class Matrix {
  3897. private static _updateFlagSeed;
  3898. private static _identityReadOnly;
  3899. private _isIdentity;
  3900. private _isIdentityDirty;
  3901. private _isIdentity3x2;
  3902. private _isIdentity3x2Dirty;
  3903. /**
  3904. * Gets the update flag of the matrix which is an unique number for the matrix.
  3905. * It will be incremented every time the matrix data change.
  3906. * You can use it to speed the comparison between two versions of the same matrix.
  3907. */
  3908. updateFlag: number;
  3909. private readonly _m;
  3910. /**
  3911. * Gets the internal data of the matrix
  3912. */
  3913. get m(): DeepImmutable<Float32Array>;
  3914. /** @hidden */
  3915. _markAsUpdated(): void;
  3916. /** @hidden */
  3917. private _updateIdentityStatus;
  3918. /**
  3919. * Creates an empty matrix (filled with zeros)
  3920. */
  3921. constructor();
  3922. /**
  3923. * Check if the current matrix is identity
  3924. * @returns true is the matrix is the identity matrix
  3925. */
  3926. isIdentity(): boolean;
  3927. /**
  3928. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3929. * @returns true is the matrix is the identity matrix
  3930. */
  3931. isIdentityAs3x2(): boolean;
  3932. /**
  3933. * Gets the determinant of the matrix
  3934. * @returns the matrix determinant
  3935. */
  3936. determinant(): number;
  3937. /**
  3938. * Returns the matrix as a Float32Array
  3939. * @returns the matrix underlying array
  3940. */
  3941. toArray(): DeepImmutable<Float32Array>;
  3942. /**
  3943. * Returns the matrix as a Float32Array
  3944. * @returns the matrix underlying array.
  3945. */
  3946. asArray(): DeepImmutable<Float32Array>;
  3947. /**
  3948. * Inverts the current matrix in place
  3949. * @returns the current inverted matrix
  3950. */
  3951. invert(): Matrix;
  3952. /**
  3953. * Sets all the matrix elements to zero
  3954. * @returns the current matrix
  3955. */
  3956. reset(): Matrix;
  3957. /**
  3958. * Adds the current matrix with a second one
  3959. * @param other defines the matrix to add
  3960. * @returns a new matrix as the addition of the current matrix and the given one
  3961. */
  3962. add(other: DeepImmutable<Matrix>): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3965. * @param other defines the matrix to add
  3966. * @param result defines the target matrix
  3967. * @returns the current matrix
  3968. */
  3969. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Adds in place the given matrix to the current matrix
  3972. * @param other defines the second operand
  3973. * @returns the current updated matrix
  3974. */
  3975. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3976. /**
  3977. * Sets the given matrix to the current inverted Matrix
  3978. * @param other defines the target matrix
  3979. * @returns the unmodified current matrix
  3980. */
  3981. invertToRef(other: Matrix): Matrix;
  3982. /**
  3983. * add a value at the specified position in the current Matrix
  3984. * @param index the index of the value within the matrix. between 0 and 15.
  3985. * @param value the value to be added
  3986. * @returns the current updated matrix
  3987. */
  3988. addAtIndex(index: number, value: number): Matrix;
  3989. /**
  3990. * mutiply the specified position in the current Matrix by a value
  3991. * @param index the index of the value within the matrix. between 0 and 15.
  3992. * @param value the value to be added
  3993. * @returns the current updated matrix
  3994. */
  3995. multiplyAtIndex(index: number, value: number): Matrix;
  3996. /**
  3997. * Inserts the translation vector (using 3 floats) in the current matrix
  3998. * @param x defines the 1st component of the translation
  3999. * @param y defines the 2nd component of the translation
  4000. * @param z defines the 3rd component of the translation
  4001. * @returns the current updated matrix
  4002. */
  4003. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4004. /**
  4005. * Adds the translation vector (using 3 floats) in the current matrix
  4006. * @param x defines the 1st component of the translation
  4007. * @param y defines the 2nd component of the translation
  4008. * @param z defines the 3rd component of the translation
  4009. * @returns the current updated matrix
  4010. */
  4011. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4012. /**
  4013. * Inserts the translation vector in the current matrix
  4014. * @param vector3 defines the translation to insert
  4015. * @returns the current updated matrix
  4016. */
  4017. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4018. /**
  4019. * Gets the translation value of the current matrix
  4020. * @returns a new Vector3 as the extracted translation from the matrix
  4021. */
  4022. getTranslation(): Vector3;
  4023. /**
  4024. * Fill a Vector3 with the extracted translation from the matrix
  4025. * @param result defines the Vector3 where to store the translation
  4026. * @returns the current matrix
  4027. */
  4028. getTranslationToRef(result: Vector3): Matrix;
  4029. /**
  4030. * Remove rotation and scaling part from the matrix
  4031. * @returns the updated matrix
  4032. */
  4033. removeRotationAndScaling(): Matrix;
  4034. /**
  4035. * Multiply two matrices
  4036. * @param other defines the second operand
  4037. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4038. */
  4039. multiply(other: DeepImmutable<Matrix>): Matrix;
  4040. /**
  4041. * Copy the current matrix from the given one
  4042. * @param other defines the source matrix
  4043. * @returns the current updated matrix
  4044. */
  4045. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4046. /**
  4047. * Populates the given array from the starting index with the current matrix values
  4048. * @param array defines the target array
  4049. * @param offset defines the offset in the target array where to start storing values
  4050. * @returns the current matrix
  4051. */
  4052. copyToArray(array: Float32Array, offset?: number): Matrix;
  4053. /**
  4054. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4055. * @param other defines the second operand
  4056. * @param result defines the matrix where to store the multiplication
  4057. * @returns the current matrix
  4058. */
  4059. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4060. /**
  4061. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4062. * @param other defines the second operand
  4063. * @param result defines the array where to store the multiplication
  4064. * @param offset defines the offset in the target array where to start storing values
  4065. * @returns the current matrix
  4066. */
  4067. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4068. /**
  4069. * Check equality between this matrix and a second one
  4070. * @param value defines the second matrix to compare
  4071. * @returns true is the current matrix and the given one values are strictly equal
  4072. */
  4073. equals(value: DeepImmutable<Matrix>): boolean;
  4074. /**
  4075. * Clone the current matrix
  4076. * @returns a new matrix from the current matrix
  4077. */
  4078. clone(): Matrix;
  4079. /**
  4080. * Returns the name of the current matrix class
  4081. * @returns the string "Matrix"
  4082. */
  4083. getClassName(): string;
  4084. /**
  4085. * Gets the hash code of the current matrix
  4086. * @returns the hash code
  4087. */
  4088. getHashCode(): number;
  4089. /**
  4090. * Decomposes the current Matrix into a translation, rotation and scaling components
  4091. * @param scale defines the scale vector3 given as a reference to update
  4092. * @param rotation defines the rotation quaternion given as a reference to update
  4093. * @param translation defines the translation vector3 given as a reference to update
  4094. * @returns true if operation was successful
  4095. */
  4096. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4097. /**
  4098. * Gets specific row of the matrix
  4099. * @param index defines the number of the row to get
  4100. * @returns the index-th row of the current matrix as a new Vector4
  4101. */
  4102. getRow(index: number): Nullable<Vector4>;
  4103. /**
  4104. * Sets the index-th row of the current matrix to the vector4 values
  4105. * @param index defines the number of the row to set
  4106. * @param row defines the target vector4
  4107. * @returns the updated current matrix
  4108. */
  4109. setRow(index: number, row: Vector4): Matrix;
  4110. /**
  4111. * Compute the transpose of the matrix
  4112. * @returns the new transposed matrix
  4113. */
  4114. transpose(): Matrix;
  4115. /**
  4116. * Compute the transpose of the matrix and store it in a given matrix
  4117. * @param result defines the target matrix
  4118. * @returns the current matrix
  4119. */
  4120. transposeToRef(result: Matrix): Matrix;
  4121. /**
  4122. * Sets the index-th row of the current matrix with the given 4 x float values
  4123. * @param index defines the row index
  4124. * @param x defines the x component to set
  4125. * @param y defines the y component to set
  4126. * @param z defines the z component to set
  4127. * @param w defines the w component to set
  4128. * @returns the updated current matrix
  4129. */
  4130. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4131. /**
  4132. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4133. * @param scale defines the scale factor
  4134. * @returns a new matrix
  4135. */
  4136. scale(scale: number): Matrix;
  4137. /**
  4138. * Scale the current matrix values by a factor to a given result matrix
  4139. * @param scale defines the scale factor
  4140. * @param result defines the matrix to store the result
  4141. * @returns the current matrix
  4142. */
  4143. scaleToRef(scale: number, result: Matrix): Matrix;
  4144. /**
  4145. * Scale the current matrix values by a factor and add the result to a given matrix
  4146. * @param scale defines the scale factor
  4147. * @param result defines the Matrix to store the result
  4148. * @returns the current matrix
  4149. */
  4150. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4151. /**
  4152. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4153. * @param ref matrix to store the result
  4154. */
  4155. toNormalMatrix(ref: Matrix): void;
  4156. /**
  4157. * Gets only rotation part of the current matrix
  4158. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4159. */
  4160. getRotationMatrix(): Matrix;
  4161. /**
  4162. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4163. * @param result defines the target matrix to store data to
  4164. * @returns the current matrix
  4165. */
  4166. getRotationMatrixToRef(result: Matrix): Matrix;
  4167. /**
  4168. * Toggles model matrix from being right handed to left handed in place and vice versa
  4169. */
  4170. toggleModelMatrixHandInPlace(): void;
  4171. /**
  4172. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4173. */
  4174. toggleProjectionMatrixHandInPlace(): void;
  4175. /**
  4176. * Creates a matrix from an array
  4177. * @param array defines the source array
  4178. * @param offset defines an offset in the source array
  4179. * @returns a new Matrix set from the starting index of the given array
  4180. */
  4181. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4182. /**
  4183. * Copy the content of an array into a given matrix
  4184. * @param array defines the source array
  4185. * @param offset defines an offset in the source array
  4186. * @param result defines the target matrix
  4187. */
  4188. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4189. /**
  4190. * Stores an array into a matrix after having multiplied each component by a given factor
  4191. * @param array defines the source array
  4192. * @param offset defines the offset in the source array
  4193. * @param scale defines the scaling factor
  4194. * @param result defines the target matrix
  4195. */
  4196. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4197. /**
  4198. * Gets an identity matrix that must not be updated
  4199. */
  4200. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4201. /**
  4202. * Stores a list of values (16) inside a given matrix
  4203. * @param initialM11 defines 1st value of 1st row
  4204. * @param initialM12 defines 2nd value of 1st row
  4205. * @param initialM13 defines 3rd value of 1st row
  4206. * @param initialM14 defines 4th value of 1st row
  4207. * @param initialM21 defines 1st value of 2nd row
  4208. * @param initialM22 defines 2nd value of 2nd row
  4209. * @param initialM23 defines 3rd value of 2nd row
  4210. * @param initialM24 defines 4th value of 2nd row
  4211. * @param initialM31 defines 1st value of 3rd row
  4212. * @param initialM32 defines 2nd value of 3rd row
  4213. * @param initialM33 defines 3rd value of 3rd row
  4214. * @param initialM34 defines 4th value of 3rd row
  4215. * @param initialM41 defines 1st value of 4th row
  4216. * @param initialM42 defines 2nd value of 4th row
  4217. * @param initialM43 defines 3rd value of 4th row
  4218. * @param initialM44 defines 4th value of 4th row
  4219. * @param result defines the target matrix
  4220. */
  4221. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4222. /**
  4223. * Creates new matrix from a list of values (16)
  4224. * @param initialM11 defines 1st value of 1st row
  4225. * @param initialM12 defines 2nd value of 1st row
  4226. * @param initialM13 defines 3rd value of 1st row
  4227. * @param initialM14 defines 4th value of 1st row
  4228. * @param initialM21 defines 1st value of 2nd row
  4229. * @param initialM22 defines 2nd value of 2nd row
  4230. * @param initialM23 defines 3rd value of 2nd row
  4231. * @param initialM24 defines 4th value of 2nd row
  4232. * @param initialM31 defines 1st value of 3rd row
  4233. * @param initialM32 defines 2nd value of 3rd row
  4234. * @param initialM33 defines 3rd value of 3rd row
  4235. * @param initialM34 defines 4th value of 3rd row
  4236. * @param initialM41 defines 1st value of 4th row
  4237. * @param initialM42 defines 2nd value of 4th row
  4238. * @param initialM43 defines 3rd value of 4th row
  4239. * @param initialM44 defines 4th value of 4th row
  4240. * @returns the new matrix
  4241. */
  4242. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4243. /**
  4244. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4245. * @param scale defines the scale vector3
  4246. * @param rotation defines the rotation quaternion
  4247. * @param translation defines the translation vector3
  4248. * @returns a new matrix
  4249. */
  4250. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4253. * @param scale defines the scale vector3
  4254. * @param rotation defines the rotation quaternion
  4255. * @param translation defines the translation vector3
  4256. * @param result defines the target matrix
  4257. */
  4258. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4259. /**
  4260. * Creates a new identity matrix
  4261. * @returns a new identity matrix
  4262. */
  4263. static Identity(): Matrix;
  4264. /**
  4265. * Creates a new identity matrix and stores the result in a given matrix
  4266. * @param result defines the target matrix
  4267. */
  4268. static IdentityToRef(result: Matrix): void;
  4269. /**
  4270. * Creates a new zero matrix
  4271. * @returns a new zero matrix
  4272. */
  4273. static Zero(): Matrix;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the X axis
  4276. * @param angle defines the angle (in radians) to use
  4277. * @return the new matrix
  4278. */
  4279. static RotationX(angle: number): Matrix;
  4280. /**
  4281. * Creates a new matrix as the invert of a given matrix
  4282. * @param source defines the source matrix
  4283. * @returns the new matrix
  4284. */
  4285. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4286. /**
  4287. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4288. * @param angle defines the angle (in radians) to use
  4289. * @param result defines the target matrix
  4290. */
  4291. static RotationXToRef(angle: number, result: Matrix): void;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the Y axis
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationY(angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4300. * @param angle defines the angle (in radians) to use
  4301. * @param result defines the target matrix
  4302. */
  4303. static RotationYToRef(angle: number, result: Matrix): void;
  4304. /**
  4305. * Creates a new rotation matrix for "angle" radians around the Z axis
  4306. * @param angle defines the angle (in radians) to use
  4307. * @return the new matrix
  4308. */
  4309. static RotationZ(angle: number): Matrix;
  4310. /**
  4311. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4312. * @param angle defines the angle (in radians) to use
  4313. * @param result defines the target matrix
  4314. */
  4315. static RotationZToRef(angle: number, result: Matrix): void;
  4316. /**
  4317. * Creates a new rotation matrix for "angle" radians around the given axis
  4318. * @param axis defines the axis to use
  4319. * @param angle defines the angle (in radians) to use
  4320. * @return the new matrix
  4321. */
  4322. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4323. /**
  4324. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4325. * @param axis defines the axis to use
  4326. * @param angle defines the angle (in radians) to use
  4327. * @param result defines the target matrix
  4328. */
  4329. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4330. /**
  4331. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4332. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4333. * @param from defines the vector to align
  4334. * @param to defines the vector to align to
  4335. * @param result defines the target matrix
  4336. */
  4337. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4338. /**
  4339. * Creates a rotation matrix
  4340. * @param yaw defines the yaw angle in radians (Y axis)
  4341. * @param pitch defines the pitch angle in radians (X axis)
  4342. * @param roll defines the roll angle in radians (X axis)
  4343. * @returns the new rotation matrix
  4344. */
  4345. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4346. /**
  4347. * Creates a rotation matrix and stores it in a given matrix
  4348. * @param yaw defines the yaw angle in radians (Y axis)
  4349. * @param pitch defines the pitch angle in radians (X axis)
  4350. * @param roll defines the roll angle in radians (X axis)
  4351. * @param result defines the target matrix
  4352. */
  4353. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4354. /**
  4355. * Creates a scaling matrix
  4356. * @param x defines the scale factor on X axis
  4357. * @param y defines the scale factor on Y axis
  4358. * @param z defines the scale factor on Z axis
  4359. * @returns the new matrix
  4360. */
  4361. static Scaling(x: number, y: number, z: number): Matrix;
  4362. /**
  4363. * Creates a scaling matrix and stores it in a given matrix
  4364. * @param x defines the scale factor on X axis
  4365. * @param y defines the scale factor on Y axis
  4366. * @param z defines the scale factor on Z axis
  4367. * @param result defines the target matrix
  4368. */
  4369. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4370. /**
  4371. * Creates a translation matrix
  4372. * @param x defines the translation on X axis
  4373. * @param y defines the translation on Y axis
  4374. * @param z defines the translationon Z axis
  4375. * @returns the new matrix
  4376. */
  4377. static Translation(x: number, y: number, z: number): Matrix;
  4378. /**
  4379. * Creates a translation matrix and stores it in a given matrix
  4380. * @param x defines the translation on X axis
  4381. * @param y defines the translation on Y axis
  4382. * @param z defines the translationon Z axis
  4383. * @param result defines the target matrix
  4384. */
  4385. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4386. /**
  4387. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4388. * @param startValue defines the start value
  4389. * @param endValue defines the end value
  4390. * @param gradient defines the gradient factor
  4391. * @returns the new matrix
  4392. */
  4393. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4394. /**
  4395. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4396. * @param startValue defines the start value
  4397. * @param endValue defines the end value
  4398. * @param gradient defines the gradient factor
  4399. * @param result defines the Matrix object where to store data
  4400. */
  4401. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4402. /**
  4403. * Builds a new matrix whose values are computed by:
  4404. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4405. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4406. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4407. * @param startValue defines the first matrix
  4408. * @param endValue defines the second matrix
  4409. * @param gradient defines the gradient between the two matrices
  4410. * @returns the new matrix
  4411. */
  4412. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4413. /**
  4414. * Update a matrix to values which are computed by:
  4415. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4416. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4417. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4418. * @param startValue defines the first matrix
  4419. * @param endValue defines the second matrix
  4420. * @param gradient defines the gradient between the two matrices
  4421. * @param result defines the target matrix
  4422. */
  4423. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4424. /**
  4425. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @returns the new matrix
  4431. */
  4432. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4433. /**
  4434. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4435. * This function works in left handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @param result defines the target matrix
  4440. */
  4441. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4442. /**
  4443. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @returns the new matrix
  4449. */
  4450. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4451. /**
  4452. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4453. * This function works in right handed mode
  4454. * @param eye defines the final position of the entity
  4455. * @param target defines where the entity should look at
  4456. * @param up defines the up vector for the entity
  4457. * @param result defines the target matrix
  4458. */
  4459. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4460. /**
  4461. * Create a left-handed orthographic projection matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a left-handed orthographic projection matrix
  4467. */
  4468. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Store a left-handed orthographic projection to a given matrix
  4471. * @param width defines the viewport width
  4472. * @param height defines the viewport height
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. */
  4477. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4478. /**
  4479. * Create a left-handed orthographic projection matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed orthographic projection matrix
  4487. */
  4488. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Stores a left-handed orthographic projection into a given matrix
  4491. * @param left defines the viewport left coordinate
  4492. * @param right defines the viewport right coordinate
  4493. * @param bottom defines the viewport bottom coordinate
  4494. * @param top defines the viewport top coordinate
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @param result defines the target matrix
  4498. */
  4499. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4500. /**
  4501. * Creates a right-handed orthographic projection matrix
  4502. * @param left defines the viewport left coordinate
  4503. * @param right defines the viewport right coordinate
  4504. * @param bottom defines the viewport bottom coordinate
  4505. * @param top defines the viewport top coordinate
  4506. * @param znear defines the near clip plane
  4507. * @param zfar defines the far clip plane
  4508. * @returns a new matrix as a right-handed orthographic projection matrix
  4509. */
  4510. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4511. /**
  4512. * Stores a right-handed orthographic projection into a given matrix
  4513. * @param left defines the viewport left coordinate
  4514. * @param right defines the viewport right coordinate
  4515. * @param bottom defines the viewport bottom coordinate
  4516. * @param top defines the viewport top coordinate
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. */
  4521. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param width defines the viewport width
  4525. * @param height defines the viewport height
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Creates a left-handed perspective projection matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @returns a new matrix as a left-handed perspective projection matrix
  4538. */
  4539. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4540. /**
  4541. * Stores a left-handed perspective projection into a given matrix
  4542. * @param fov defines the horizontal field of view
  4543. * @param aspect defines the aspect ratio
  4544. * @param znear defines the near clip plane
  4545. * @param zfar defines the far clip plane
  4546. * @param result defines the target matrix
  4547. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4548. */
  4549. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4550. /**
  4551. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4552. * @param fov defines the horizontal field of view
  4553. * @param aspect defines the aspect ratio
  4554. * @param znear defines the near clip plane
  4555. * @param zfar not used as infinity is used as far clip
  4556. * @param result defines the target matrix
  4557. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4558. */
  4559. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4560. /**
  4561. * Creates a right-handed perspective projection matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @returns a new matrix as a right-handed perspective projection matrix
  4567. */
  4568. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4569. /**
  4570. * Stores a right-handed perspective projection into a given matrix
  4571. * @param fov defines the horizontal field of view
  4572. * @param aspect defines the aspect ratio
  4573. * @param znear defines the near clip plane
  4574. * @param zfar defines the far clip plane
  4575. * @param result defines the target matrix
  4576. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4577. */
  4578. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4579. /**
  4580. * Stores a right-handed perspective projection into a given matrix
  4581. * @param fov defines the horizontal field of view
  4582. * @param aspect defines the aspect ratio
  4583. * @param znear defines the near clip plane
  4584. * @param zfar not used as infinity is used as far clip
  4585. * @param result defines the target matrix
  4586. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4587. */
  4588. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4589. /**
  4590. * Stores a perspective projection for WebVR info a given matrix
  4591. * @param fov defines the field of view
  4592. * @param znear defines the near clip plane
  4593. * @param zfar defines the far clip plane
  4594. * @param result defines the target matrix
  4595. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4596. */
  4597. static PerspectiveFovWebVRToRef(fov: {
  4598. upDegrees: number;
  4599. downDegrees: number;
  4600. leftDegrees: number;
  4601. rightDegrees: number;
  4602. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4603. /**
  4604. * Computes a complete transformation matrix
  4605. * @param viewport defines the viewport to use
  4606. * @param world defines the world matrix
  4607. * @param view defines the view matrix
  4608. * @param projection defines the projection matrix
  4609. * @param zmin defines the near clip plane
  4610. * @param zmax defines the far clip plane
  4611. * @returns the transformation matrix
  4612. */
  4613. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4614. /**
  4615. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4616. * @param matrix defines the matrix to use
  4617. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4618. */
  4619. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4620. /**
  4621. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4622. * @param matrix defines the matrix to use
  4623. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4624. */
  4625. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4626. /**
  4627. * Compute the transpose of a given matrix
  4628. * @param matrix defines the matrix to transpose
  4629. * @returns the new matrix
  4630. */
  4631. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4632. /**
  4633. * Compute the transpose of a matrix and store it in a target matrix
  4634. * @param matrix defines the matrix to transpose
  4635. * @param result defines the target matrix
  4636. */
  4637. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4638. /**
  4639. * Computes a reflection matrix from a plane
  4640. * @param plane defines the reflection plane
  4641. * @returns a new matrix
  4642. */
  4643. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4644. /**
  4645. * Computes a reflection matrix from a plane
  4646. * @param plane defines the reflection plane
  4647. * @param result defines the target matrix
  4648. */
  4649. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4650. /**
  4651. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4652. * @param xaxis defines the value of the 1st axis
  4653. * @param yaxis defines the value of the 2nd axis
  4654. * @param zaxis defines the value of the 3rd axis
  4655. * @param result defines the target matrix
  4656. */
  4657. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4658. /**
  4659. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4660. * @param quat defines the quaternion to use
  4661. * @param result defines the target matrix
  4662. */
  4663. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4664. }
  4665. /**
  4666. * @hidden
  4667. */
  4668. export class TmpVectors {
  4669. static Vector2: Vector2[];
  4670. static Vector3: Vector3[];
  4671. static Vector4: Vector4[];
  4672. static Quaternion: Quaternion[];
  4673. static Matrix: Matrix[];
  4674. }
  4675. }
  4676. declare module "babylonjs/Maths/math.path" {
  4677. import { DeepImmutable, Nullable } from "babylonjs/types";
  4678. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4679. /**
  4680. * Defines potential orientation for back face culling
  4681. */
  4682. export enum Orientation {
  4683. /**
  4684. * Clockwise
  4685. */
  4686. CW = 0,
  4687. /** Counter clockwise */
  4688. CCW = 1
  4689. }
  4690. /** Class used to represent a Bezier curve */
  4691. export class BezierCurve {
  4692. /**
  4693. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4694. * @param t defines the time
  4695. * @param x1 defines the left coordinate on X axis
  4696. * @param y1 defines the left coordinate on Y axis
  4697. * @param x2 defines the right coordinate on X axis
  4698. * @param y2 defines the right coordinate on Y axis
  4699. * @returns the interpolated value
  4700. */
  4701. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4702. }
  4703. /**
  4704. * Defines angle representation
  4705. */
  4706. export class Angle {
  4707. private _radians;
  4708. /**
  4709. * Creates an Angle object of "radians" radians (float).
  4710. * @param radians the angle in radians
  4711. */
  4712. constructor(radians: number);
  4713. /**
  4714. * Get value in degrees
  4715. * @returns the Angle value in degrees (float)
  4716. */
  4717. degrees(): number;
  4718. /**
  4719. * Get value in radians
  4720. * @returns the Angle value in radians (float)
  4721. */
  4722. radians(): number;
  4723. /**
  4724. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4725. * @param a defines first vector
  4726. * @param b defines second vector
  4727. * @returns a new Angle
  4728. */
  4729. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4730. /**
  4731. * Gets a new Angle object from the given float in radians
  4732. * @param radians defines the angle value in radians
  4733. * @returns a new Angle
  4734. */
  4735. static FromRadians(radians: number): Angle;
  4736. /**
  4737. * Gets a new Angle object from the given float in degrees
  4738. * @param degrees defines the angle value in degrees
  4739. * @returns a new Angle
  4740. */
  4741. static FromDegrees(degrees: number): Angle;
  4742. }
  4743. /**
  4744. * This represents an arc in a 2d space.
  4745. */
  4746. export class Arc2 {
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2;
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2;
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2;
  4753. /**
  4754. * Defines the center point of the arc.
  4755. */
  4756. centerPoint: Vector2;
  4757. /**
  4758. * Defines the radius of the arc.
  4759. */
  4760. radius: number;
  4761. /**
  4762. * Defines the angle of the arc (from mid point to end point).
  4763. */
  4764. angle: Angle;
  4765. /**
  4766. * Defines the start angle of the arc (from start point to middle point).
  4767. */
  4768. startAngle: Angle;
  4769. /**
  4770. * Defines the orientation of the arc (clock wise/counter clock wise).
  4771. */
  4772. orientation: Orientation;
  4773. /**
  4774. * Creates an Arc object from the three given points : start, middle and end.
  4775. * @param startPoint Defines the start point of the arc
  4776. * @param midPoint Defines the midlle point of the arc
  4777. * @param endPoint Defines the end point of the arc
  4778. */
  4779. constructor(
  4780. /** Defines the start point of the arc */
  4781. startPoint: Vector2,
  4782. /** Defines the mid point of the arc */
  4783. midPoint: Vector2,
  4784. /** Defines the end point of the arc */
  4785. endPoint: Vector2);
  4786. }
  4787. /**
  4788. * Represents a 2D path made up of multiple 2D points
  4789. */
  4790. export class Path2 {
  4791. private _points;
  4792. private _length;
  4793. /**
  4794. * If the path start and end point are the same
  4795. */
  4796. closed: boolean;
  4797. /**
  4798. * Creates a Path2 object from the starting 2D coordinates x and y.
  4799. * @param x the starting points x value
  4800. * @param y the starting points y value
  4801. */
  4802. constructor(x: number, y: number);
  4803. /**
  4804. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4805. * @param x the added points x value
  4806. * @param y the added points y value
  4807. * @returns the updated Path2.
  4808. */
  4809. addLineTo(x: number, y: number): Path2;
  4810. /**
  4811. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4812. * @param midX middle point x value
  4813. * @param midY middle point y value
  4814. * @param endX end point x value
  4815. * @param endY end point y value
  4816. * @param numberOfSegments (default: 36)
  4817. * @returns the updated Path2.
  4818. */
  4819. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4820. /**
  4821. * Closes the Path2.
  4822. * @returns the Path2.
  4823. */
  4824. close(): Path2;
  4825. /**
  4826. * Gets the sum of the distance between each sequential point in the path
  4827. * @returns the Path2 total length (float).
  4828. */
  4829. length(): number;
  4830. /**
  4831. * Gets the points which construct the path
  4832. * @returns the Path2 internal array of points.
  4833. */
  4834. getPoints(): Vector2[];
  4835. /**
  4836. * Retreives the point at the distance aways from the starting point
  4837. * @param normalizedLengthPosition the length along the path to retreive the point from
  4838. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4839. */
  4840. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4841. /**
  4842. * Creates a new path starting from an x and y position
  4843. * @param x starting x value
  4844. * @param y starting y value
  4845. * @returns a new Path2 starting at the coordinates (x, y).
  4846. */
  4847. static StartingAt(x: number, y: number): Path2;
  4848. }
  4849. /**
  4850. * Represents a 3D path made up of multiple 3D points
  4851. */
  4852. export class Path3D {
  4853. /**
  4854. * an array of Vector3, the curve axis of the Path3D
  4855. */
  4856. path: Vector3[];
  4857. private _curve;
  4858. private _distances;
  4859. private _tangents;
  4860. private _normals;
  4861. private _binormals;
  4862. private _raw;
  4863. private _alignTangentsWithPath;
  4864. private readonly _pointAtData;
  4865. /**
  4866. * new Path3D(path, normal, raw)
  4867. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4868. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4869. * @param path an array of Vector3, the curve axis of the Path3D
  4870. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4871. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4872. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4873. */
  4874. constructor(
  4875. /**
  4876. * an array of Vector3, the curve axis of the Path3D
  4877. */
  4878. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4879. /**
  4880. * Returns the Path3D array of successive Vector3 designing its curve.
  4881. * @returns the Path3D array of successive Vector3 designing its curve.
  4882. */
  4883. getCurve(): Vector3[];
  4884. /**
  4885. * Returns the Path3D array of successive Vector3 designing its curve.
  4886. * @returns the Path3D array of successive Vector3 designing its curve.
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the path.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns an array populated with tangent vectors on each Path3D curve point.
  4895. * @returns an array populated with tangent vectors on each Path3D curve point.
  4896. */
  4897. getTangents(): Vector3[];
  4898. /**
  4899. * Returns an array populated with normal vectors on each Path3D curve point.
  4900. * @returns an array populated with normal vectors on each Path3D curve point.
  4901. */
  4902. getNormals(): Vector3[];
  4903. /**
  4904. * Returns an array populated with binormal vectors on each Path3D curve point.
  4905. * @returns an array populated with binormal vectors on each Path3D curve point.
  4906. */
  4907. getBinormals(): Vector3[];
  4908. /**
  4909. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4910. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4911. */
  4912. getDistances(): number[];
  4913. /**
  4914. * Returns an interpolated point along this path
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns a new Vector3 as the point
  4917. */
  4918. getPointAt(position: number): Vector3;
  4919. /**
  4920. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4921. * @param position the position of the point along this path, from 0.0 to 1.0
  4922. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4923. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4924. */
  4925. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4926. /**
  4927. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4928. * @param position the position of the point along this path, from 0.0 to 1.0
  4929. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4930. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4931. */
  4932. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4933. /**
  4934. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4935. * @param position the position of the point along this path, from 0.0 to 1.0
  4936. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4937. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4938. */
  4939. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4940. /**
  4941. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4942. * @param position the position of the point along this path, from 0.0 to 1.0
  4943. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4944. */
  4945. getDistanceAt(position: number): number;
  4946. /**
  4947. * Returns the array index of the previous point of an interpolated point along this path
  4948. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4949. * @returns the array index
  4950. */
  4951. getPreviousPointIndexAt(position: number): number;
  4952. /**
  4953. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4954. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4955. * @returns the sub position
  4956. */
  4957. getSubPositionAt(position: number): number;
  4958. /**
  4959. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4960. * @param target the vector of which to get the closest position to
  4961. * @returns the position of the closest virtual point on this path to the target vector
  4962. */
  4963. getClosestPositionTo(target: Vector3): number;
  4964. /**
  4965. * Returns a sub path (slice) of this path
  4966. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4967. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4968. * @returns a sub path (slice) of this path
  4969. */
  4970. slice(start?: number, end?: number): Path3D;
  4971. /**
  4972. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4973. * @param path path which all values are copied into the curves points
  4974. * @param firstNormal which should be projected onto the curve
  4975. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4976. * @returns the same object updated.
  4977. */
  4978. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4979. private _compute;
  4980. private _getFirstNonNullVector;
  4981. private _getLastNonNullVector;
  4982. private _normalVector;
  4983. /**
  4984. * Updates the point at data for an interpolated point along this curve
  4985. * @param position the position of the point along this curve, from 0.0 to 1.0
  4986. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4987. * @returns the (updated) point at data
  4988. */
  4989. private _updatePointAtData;
  4990. /**
  4991. * Updates the point at data from the specified parameters
  4992. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4993. * @param point the interpolated point
  4994. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4995. */
  4996. private _setPointAtData;
  4997. /**
  4998. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4999. */
  5000. private _updateInterpolationMatrix;
  5001. }
  5002. /**
  5003. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5004. * A Curve3 is designed from a series of successive Vector3.
  5005. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5006. */
  5007. export class Curve3 {
  5008. private _points;
  5009. private _length;
  5010. /**
  5011. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5013. * @param v1 (Vector3) the control point
  5014. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5015. * @param nbPoints (integer) the wanted number of points in the curve
  5016. * @returns the created Curve3
  5017. */
  5018. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5019. /**
  5020. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5021. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5022. * @param v1 (Vector3) the first control point
  5023. * @param v2 (Vector3) the second control point
  5024. * @param v3 (Vector3) the end point of the Cubic Bezier
  5025. * @param nbPoints (integer) the wanted number of points in the curve
  5026. * @returns the created Curve3
  5027. */
  5028. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5029. /**
  5030. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5031. * @param p1 (Vector3) the origin point of the Hermite Spline
  5032. * @param t1 (Vector3) the tangent vector at the origin point
  5033. * @param p2 (Vector3) the end point of the Hermite Spline
  5034. * @param t2 (Vector3) the tangent vector at the end point
  5035. * @param nbPoints (integer) the wanted number of points in the curve
  5036. * @returns the created Curve3
  5037. */
  5038. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5039. /**
  5040. * Returns a Curve3 object along a CatmullRom Spline curve :
  5041. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5042. * @param nbPoints (integer) the wanted number of points between each curve control points
  5043. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5044. * @returns the created Curve3
  5045. */
  5046. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5047. /**
  5048. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5049. * A Curve3 is designed from a series of successive Vector3.
  5050. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5051. * @param points points which make up the curve
  5052. */
  5053. constructor(points: Vector3[]);
  5054. /**
  5055. * @returns the Curve3 stored array of successive Vector3
  5056. */
  5057. getPoints(): Vector3[];
  5058. /**
  5059. * @returns the computed length (float) of the curve.
  5060. */
  5061. length(): number;
  5062. /**
  5063. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5064. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5065. * curveA and curveB keep unchanged.
  5066. * @param curve the curve to continue from this curve
  5067. * @returns the newly constructed curve
  5068. */
  5069. continue(curve: DeepImmutable<Curve3>): Curve3;
  5070. private _computeLength;
  5071. }
  5072. }
  5073. declare module "babylonjs/Animations/easing" {
  5074. /**
  5075. * This represents the main contract an easing function should follow.
  5076. * Easing functions are used throughout the animation system.
  5077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5078. */
  5079. export interface IEasingFunction {
  5080. /**
  5081. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5082. * of the easing function.
  5083. * The link below provides some of the most common examples of easing functions.
  5084. * @see https://easings.net/
  5085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5086. * @returns the corresponding value on the curve defined by the easing function
  5087. */
  5088. ease(gradient: number): number;
  5089. }
  5090. /**
  5091. * Base class used for every default easing function.
  5092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5093. */
  5094. export class EasingFunction implements IEasingFunction {
  5095. /**
  5096. * Interpolation follows the mathematical formula associated with the easing function.
  5097. */
  5098. static readonly EASINGMODE_EASEIN: number;
  5099. /**
  5100. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5101. */
  5102. static readonly EASINGMODE_EASEOUT: number;
  5103. /**
  5104. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5105. */
  5106. static readonly EASINGMODE_EASEINOUT: number;
  5107. private _easingMode;
  5108. /**
  5109. * Sets the easing mode of the current function.
  5110. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5111. */
  5112. setEasingMode(easingMode: number): void;
  5113. /**
  5114. * Gets the current easing mode.
  5115. * @returns the easing mode
  5116. */
  5117. getEasingMode(): number;
  5118. /**
  5119. * @hidden
  5120. */
  5121. easeInCore(gradient: number): number;
  5122. /**
  5123. * Given an input gradient between 0 and 1, this returns the corresponding value
  5124. * of the easing function.
  5125. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5126. * @returns the corresponding value on the curve defined by the easing function
  5127. */
  5128. ease(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a circle shape (see link below).
  5132. * @see https://easings.net/#easeInCirc
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class CircleEase extends EasingFunction implements IEasingFunction {
  5136. /** @hidden */
  5137. easeInCore(gradient: number): number;
  5138. }
  5139. /**
  5140. * Easing function with a ease back shape (see link below).
  5141. * @see https://easings.net/#easeInBack
  5142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5143. */
  5144. export class BackEase extends EasingFunction implements IEasingFunction {
  5145. /** Defines the amplitude of the function */
  5146. amplitude: number;
  5147. /**
  5148. * Instantiates a back ease easing
  5149. * @see https://easings.net/#easeInBack
  5150. * @param amplitude Defines the amplitude of the function
  5151. */
  5152. constructor(
  5153. /** Defines the amplitude of the function */
  5154. amplitude?: number);
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with a bouncing shape (see link below).
  5160. * @see https://easings.net/#easeInBounce
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class BounceEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of bounces */
  5165. bounces: number;
  5166. /** Defines the amplitude of the bounce */
  5167. bounciness: number;
  5168. /**
  5169. * Instantiates a bounce easing
  5170. * @see https://easings.net/#easeInBounce
  5171. * @param bounces Defines the number of bounces
  5172. * @param bounciness Defines the amplitude of the bounce
  5173. */
  5174. constructor(
  5175. /** Defines the number of bounces */
  5176. bounces?: number,
  5177. /** Defines the amplitude of the bounce */
  5178. bounciness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 3 shape (see link below).
  5184. * @see https://easings.net/#easeInCubic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class CubicEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with an elastic shape (see link below).
  5193. * @see https://easings.net/#easeInElastic
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5197. /** Defines the number of oscillations*/
  5198. oscillations: number;
  5199. /** Defines the amplitude of the oscillations*/
  5200. springiness: number;
  5201. /**
  5202. * Instantiates an elastic easing function
  5203. * @see https://easings.net/#easeInElastic
  5204. * @param oscillations Defines the number of oscillations
  5205. * @param springiness Defines the amplitude of the oscillations
  5206. */
  5207. constructor(
  5208. /** Defines the number of oscillations*/
  5209. oscillations?: number,
  5210. /** Defines the amplitude of the oscillations*/
  5211. springiness?: number);
  5212. /** @hidden */
  5213. easeInCore(gradient: number): number;
  5214. }
  5215. /**
  5216. * Easing function with an exponential shape (see link below).
  5217. * @see https://easings.net/#easeInExpo
  5218. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5219. */
  5220. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5221. /** Defines the exponent of the function */
  5222. exponent: number;
  5223. /**
  5224. * Instantiates an exponential easing function
  5225. * @see https://easings.net/#easeInExpo
  5226. * @param exponent Defines the exponent of the function
  5227. */
  5228. constructor(
  5229. /** Defines the exponent of the function */
  5230. exponent?: number);
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a power shape (see link below).
  5236. * @see https://easings.net/#easeInQuad
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class PowerEase extends EasingFunction implements IEasingFunction {
  5240. /** Defines the power of the function */
  5241. power: number;
  5242. /**
  5243. * Instantiates an power base easing function
  5244. * @see https://easings.net/#easeInQuad
  5245. * @param power Defines the power of the function
  5246. */
  5247. constructor(
  5248. /** Defines the power of the function */
  5249. power?: number);
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 2 shape (see link below).
  5255. * @see https://easings.net/#easeInQuad
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 4 shape (see link below).
  5264. * @see https://easings.net/#easeInQuart
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 5 shape (see link below).
  5273. * @see https://easings.net/#easeInQuint
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a sin shape (see link below).
  5282. * @see https://easings.net/#easeInSine
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class SineEase extends EasingFunction implements IEasingFunction {
  5286. /** @hidden */
  5287. easeInCore(gradient: number): number;
  5288. }
  5289. /**
  5290. * Easing function with a bezier shape (see link below).
  5291. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5293. */
  5294. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5295. /** Defines the x component of the start tangent in the bezier curve */
  5296. x1: number;
  5297. /** Defines the y component of the start tangent in the bezier curve */
  5298. y1: number;
  5299. /** Defines the x component of the end tangent in the bezier curve */
  5300. x2: number;
  5301. /** Defines the y component of the end tangent in the bezier curve */
  5302. y2: number;
  5303. /**
  5304. * Instantiates a bezier function
  5305. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5306. * @param x1 Defines the x component of the start tangent in the bezier curve
  5307. * @param y1 Defines the y component of the start tangent in the bezier curve
  5308. * @param x2 Defines the x component of the end tangent in the bezier curve
  5309. * @param y2 Defines the y component of the end tangent in the bezier curve
  5310. */
  5311. constructor(
  5312. /** Defines the x component of the start tangent in the bezier curve */
  5313. x1?: number,
  5314. /** Defines the y component of the start tangent in the bezier curve */
  5315. y1?: number,
  5316. /** Defines the x component of the end tangent in the bezier curve */
  5317. x2?: number,
  5318. /** Defines the y component of the end tangent in the bezier curve */
  5319. y2?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. }
  5324. declare module "babylonjs/Maths/math.color" {
  5325. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5326. /**
  5327. * Class used to hold a RBG color
  5328. */
  5329. export class Color3 {
  5330. /**
  5331. * Defines the red component (between 0 and 1, default is 0)
  5332. */
  5333. r: number;
  5334. /**
  5335. * Defines the green component (between 0 and 1, default is 0)
  5336. */
  5337. g: number;
  5338. /**
  5339. * Defines the blue component (between 0 and 1, default is 0)
  5340. */
  5341. b: number;
  5342. /**
  5343. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5344. * @param r defines the red component (between 0 and 1, default is 0)
  5345. * @param g defines the green component (between 0 and 1, default is 0)
  5346. * @param b defines the blue component (between 0 and 1, default is 0)
  5347. */
  5348. constructor(
  5349. /**
  5350. * Defines the red component (between 0 and 1, default is 0)
  5351. */
  5352. r?: number,
  5353. /**
  5354. * Defines the green component (between 0 and 1, default is 0)
  5355. */
  5356. g?: number,
  5357. /**
  5358. * Defines the blue component (between 0 and 1, default is 0)
  5359. */
  5360. b?: number);
  5361. /**
  5362. * Creates a string with the Color3 current values
  5363. * @returns the string representation of the Color3 object
  5364. */
  5365. toString(): string;
  5366. /**
  5367. * Returns the string "Color3"
  5368. * @returns "Color3"
  5369. */
  5370. getClassName(): string;
  5371. /**
  5372. * Compute the Color3 hash code
  5373. * @returns an unique number that can be used to hash Color3 objects
  5374. */
  5375. getHashCode(): number;
  5376. /**
  5377. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5378. * @param array defines the array where to store the r,g,b components
  5379. * @param index defines an optional index in the target array to define where to start storing values
  5380. * @returns the current Color3 object
  5381. */
  5382. toArray(array: FloatArray, index?: number): Color3;
  5383. /**
  5384. * Returns a new Color4 object from the current Color3 and the given alpha
  5385. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5386. * @returns a new Color4 object
  5387. */
  5388. toColor4(alpha?: number): Color4;
  5389. /**
  5390. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5391. * @returns the new array
  5392. */
  5393. asArray(): number[];
  5394. /**
  5395. * Returns the luminance value
  5396. * @returns a float value
  5397. */
  5398. toLuminance(): number;
  5399. /**
  5400. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5401. * @param otherColor defines the second operand
  5402. * @returns the new Color3 object
  5403. */
  5404. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5407. * @param otherColor defines the second operand
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the current Color3
  5410. */
  5411. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5412. /**
  5413. * Determines equality between Color3 objects
  5414. * @param otherColor defines the second operand
  5415. * @returns true if the rgb values are equal to the given ones
  5416. */
  5417. equals(otherColor: DeepImmutable<Color3>): boolean;
  5418. /**
  5419. * Determines equality between the current Color3 object and a set of r,b,g values
  5420. * @param r defines the red component to check
  5421. * @param g defines the green component to check
  5422. * @param b defines the blue component to check
  5423. * @returns true if the rgb values are equal to the given ones
  5424. */
  5425. equalsFloats(r: number, g: number, b: number): boolean;
  5426. /**
  5427. * Multiplies in place each rgb value by scale
  5428. * @param scale defines the scaling factor
  5429. * @returns the updated Color3
  5430. */
  5431. scale(scale: number): Color3;
  5432. /**
  5433. * Multiplies the rgb values by scale and stores the result into "result"
  5434. * @param scale defines the scaling factor
  5435. * @param result defines the Color3 object where to store the result
  5436. * @returns the unmodified current Color3
  5437. */
  5438. scaleToRef(scale: number, result: Color3): Color3;
  5439. /**
  5440. * Scale the current Color3 values by a factor and add the result to a given Color3
  5441. * @param scale defines the scale factor
  5442. * @param result defines color to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5446. /**
  5447. * Clamps the rgb values by the min and max values and stores the result into "result"
  5448. * @param min defines minimum clamping value (default is 0)
  5449. * @param max defines maximum clamping value (default is 1)
  5450. * @param result defines color to store the result into
  5451. * @returns the original Color3
  5452. */
  5453. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5454. /**
  5455. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5456. * @param otherColor defines the second operand
  5457. * @returns the new Color3
  5458. */
  5459. add(otherColor: DeepImmutable<Color3>): Color3;
  5460. /**
  5461. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5462. * @param otherColor defines the second operand
  5463. * @param result defines Color3 object to store the result into
  5464. * @returns the unmodified current Color3
  5465. */
  5466. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5467. /**
  5468. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5469. * @param otherColor defines the second operand
  5470. * @returns the new Color3
  5471. */
  5472. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5473. /**
  5474. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5475. * @param otherColor defines the second operand
  5476. * @param result defines Color3 object to store the result into
  5477. * @returns the unmodified current Color3
  5478. */
  5479. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5480. /**
  5481. * Copy the current object
  5482. * @returns a new Color3 copied the current one
  5483. */
  5484. clone(): Color3;
  5485. /**
  5486. * Copies the rgb values from the source in the current Color3
  5487. * @param source defines the source Color3 object
  5488. * @returns the updated Color3 object
  5489. */
  5490. copyFrom(source: DeepImmutable<Color3>): Color3;
  5491. /**
  5492. * Updates the Color3 rgb values from the given floats
  5493. * @param r defines the red component to read from
  5494. * @param g defines the green component to read from
  5495. * @param b defines the blue component to read from
  5496. * @returns the current Color3 object
  5497. */
  5498. copyFromFloats(r: number, g: number, b: number): Color3;
  5499. /**
  5500. * Updates the Color3 rgb values from the given floats
  5501. * @param r defines the red component to read from
  5502. * @param g defines the green component to read from
  5503. * @param b defines the blue component to read from
  5504. * @returns the current Color3 object
  5505. */
  5506. set(r: number, g: number, b: number): Color3;
  5507. /**
  5508. * Compute the Color3 hexadecimal code as a string
  5509. * @returns a string containing the hexadecimal representation of the Color3 object
  5510. */
  5511. toHexString(): string;
  5512. /**
  5513. * Computes a new Color3 converted from the current one to linear space
  5514. * @returns a new Color3 object
  5515. */
  5516. toLinearSpace(): Color3;
  5517. /**
  5518. * Converts current color in rgb space to HSV values
  5519. * @returns a new color3 representing the HSV values
  5520. */
  5521. toHSV(): Color3;
  5522. /**
  5523. * Converts current color in rgb space to HSV values
  5524. * @param result defines the Color3 where to store the HSV values
  5525. */
  5526. toHSVToRef(result: Color3): void;
  5527. /**
  5528. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5529. * @param convertedColor defines the Color3 object where to store the linear space version
  5530. * @returns the unmodified Color3
  5531. */
  5532. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5533. /**
  5534. * Computes a new Color3 converted from the current one to gamma space
  5535. * @returns a new Color3 object
  5536. */
  5537. toGammaSpace(): Color3;
  5538. /**
  5539. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5540. * @param convertedColor defines the Color3 object where to store the gamma space version
  5541. * @returns the unmodified Color3
  5542. */
  5543. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5544. private static _BlackReadOnly;
  5545. /**
  5546. * Convert Hue, saturation and value to a Color3 (RGB)
  5547. * @param hue defines the hue
  5548. * @param saturation defines the saturation
  5549. * @param value defines the value
  5550. * @param result defines the Color3 where to store the RGB values
  5551. */
  5552. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5553. /**
  5554. * Creates a new Color3 from the string containing valid hexadecimal values
  5555. * @param hex defines a string containing valid hexadecimal values
  5556. * @returns a new Color3 object
  5557. */
  5558. static FromHexString(hex: string): Color3;
  5559. /**
  5560. * Creates a new Color3 from the starting index of the given array
  5561. * @param array defines the source array
  5562. * @param offset defines an offset in the source array
  5563. * @returns a new Color3 object
  5564. */
  5565. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5566. /**
  5567. * Creates a new Color3 from integer values (< 256)
  5568. * @param r defines the red component to read from (value between 0 and 255)
  5569. * @param g defines the green component to read from (value between 0 and 255)
  5570. * @param b defines the blue component to read from (value between 0 and 255)
  5571. * @returns a new Color3 object
  5572. */
  5573. static FromInts(r: number, g: number, b: number): Color3;
  5574. /**
  5575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5576. * @param start defines the start Color3 value
  5577. * @param end defines the end Color3 value
  5578. * @param amount defines the gradient value between start and end
  5579. * @returns a new Color3 object
  5580. */
  5581. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5582. /**
  5583. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5584. * @param left defines the start value
  5585. * @param right defines the end value
  5586. * @param amount defines the gradient factor
  5587. * @param result defines the Color3 object where to store the result
  5588. */
  5589. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5590. /**
  5591. * Returns a Color3 value containing a red color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Red(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a green color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Green(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a blue color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Blue(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a black color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Black(): Color3;
  5610. /**
  5611. * Gets a Color3 value containing a black color that must not be updated
  5612. */
  5613. static get BlackReadOnly(): DeepImmutable<Color3>;
  5614. /**
  5615. * Returns a Color3 value containing a white color
  5616. * @returns a new Color3 object
  5617. */
  5618. static White(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a purple color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Purple(): Color3;
  5624. /**
  5625. * Returns a Color3 value containing a magenta color
  5626. * @returns a new Color3 object
  5627. */
  5628. static Magenta(): Color3;
  5629. /**
  5630. * Returns a Color3 value containing a yellow color
  5631. * @returns a new Color3 object
  5632. */
  5633. static Yellow(): Color3;
  5634. /**
  5635. * Returns a Color3 value containing a gray color
  5636. * @returns a new Color3 object
  5637. */
  5638. static Gray(): Color3;
  5639. /**
  5640. * Returns a Color3 value containing a teal color
  5641. * @returns a new Color3 object
  5642. */
  5643. static Teal(): Color3;
  5644. /**
  5645. * Returns a Color3 value containing a random color
  5646. * @returns a new Color3 object
  5647. */
  5648. static Random(): Color3;
  5649. }
  5650. /**
  5651. * Class used to hold a RBGA color
  5652. */
  5653. export class Color4 {
  5654. /**
  5655. * Defines the red component (between 0 and 1, default is 0)
  5656. */
  5657. r: number;
  5658. /**
  5659. * Defines the green component (between 0 and 1, default is 0)
  5660. */
  5661. g: number;
  5662. /**
  5663. * Defines the blue component (between 0 and 1, default is 0)
  5664. */
  5665. b: number;
  5666. /**
  5667. * Defines the alpha component (between 0 and 1, default is 1)
  5668. */
  5669. a: number;
  5670. /**
  5671. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5672. * @param r defines the red component (between 0 and 1, default is 0)
  5673. * @param g defines the green component (between 0 and 1, default is 0)
  5674. * @param b defines the blue component (between 0 and 1, default is 0)
  5675. * @param a defines the alpha component (between 0 and 1, default is 1)
  5676. */
  5677. constructor(
  5678. /**
  5679. * Defines the red component (between 0 and 1, default is 0)
  5680. */
  5681. r?: number,
  5682. /**
  5683. * Defines the green component (between 0 and 1, default is 0)
  5684. */
  5685. g?: number,
  5686. /**
  5687. * Defines the blue component (between 0 and 1, default is 0)
  5688. */
  5689. b?: number,
  5690. /**
  5691. * Defines the alpha component (between 0 and 1, default is 1)
  5692. */
  5693. a?: number);
  5694. /**
  5695. * Adds in place the given Color4 values to the current Color4 object
  5696. * @param right defines the second operand
  5697. * @returns the current updated Color4 object
  5698. */
  5699. addInPlace(right: DeepImmutable<Color4>): Color4;
  5700. /**
  5701. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5702. * @returns the new array
  5703. */
  5704. asArray(): number[];
  5705. /**
  5706. * Stores from the starting index in the given array the Color4 successive values
  5707. * @param array defines the array where to store the r,g,b components
  5708. * @param index defines an optional index in the target array to define where to start storing values
  5709. * @returns the current Color4 object
  5710. */
  5711. toArray(array: number[], index?: number): Color4;
  5712. /**
  5713. * Determines equality between Color4 objects
  5714. * @param otherColor defines the second operand
  5715. * @returns true if the rgba values are equal to the given ones
  5716. */
  5717. equals(otherColor: DeepImmutable<Color4>): boolean;
  5718. /**
  5719. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5720. * @param right defines the second operand
  5721. * @returns a new Color4 object
  5722. */
  5723. add(right: DeepImmutable<Color4>): Color4;
  5724. /**
  5725. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5726. * @param right defines the second operand
  5727. * @returns a new Color4 object
  5728. */
  5729. subtract(right: DeepImmutable<Color4>): Color4;
  5730. /**
  5731. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5732. * @param right defines the second operand
  5733. * @param result defines the Color4 object where to store the result
  5734. * @returns the current Color4 object
  5735. */
  5736. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5737. /**
  5738. * Creates a new Color4 with the current Color4 values multiplied by scale
  5739. * @param scale defines the scaling factor to apply
  5740. * @returns a new Color4 object
  5741. */
  5742. scale(scale: number): Color4;
  5743. /**
  5744. * Multiplies the current Color4 values by scale and stores the result in "result"
  5745. * @param scale defines the scaling factor to apply
  5746. * @param result defines the Color4 object where to store the result
  5747. * @returns the current unmodified Color4
  5748. */
  5749. scaleToRef(scale: number, result: Color4): Color4;
  5750. /**
  5751. * Scale the current Color4 values by a factor and add the result to a given Color4
  5752. * @param scale defines the scale factor
  5753. * @param result defines the Color4 object where to store the result
  5754. * @returns the unmodified current Color4
  5755. */
  5756. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5757. /**
  5758. * Clamps the rgb values by the min and max values and stores the result into "result"
  5759. * @param min defines minimum clamping value (default is 0)
  5760. * @param max defines maximum clamping value (default is 1)
  5761. * @param result defines color to store the result into.
  5762. * @returns the cuurent Color4
  5763. */
  5764. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5765. /**
  5766. * Multipy an Color4 value by another and return a new Color4 object
  5767. * @param color defines the Color4 value to multiply by
  5768. * @returns a new Color4 object
  5769. */
  5770. multiply(color: Color4): Color4;
  5771. /**
  5772. * Multipy a Color4 value by another and push the result in a reference value
  5773. * @param color defines the Color4 value to multiply by
  5774. * @param result defines the Color4 to fill the result in
  5775. * @returns the result Color4
  5776. */
  5777. multiplyToRef(color: Color4, result: Color4): Color4;
  5778. /**
  5779. * Creates a string with the Color4 current values
  5780. * @returns the string representation of the Color4 object
  5781. */
  5782. toString(): string;
  5783. /**
  5784. * Returns the string "Color4"
  5785. * @returns "Color4"
  5786. */
  5787. getClassName(): string;
  5788. /**
  5789. * Compute the Color4 hash code
  5790. * @returns an unique number that can be used to hash Color4 objects
  5791. */
  5792. getHashCode(): number;
  5793. /**
  5794. * Creates a new Color4 copied from the current one
  5795. * @returns a new Color4 object
  5796. */
  5797. clone(): Color4;
  5798. /**
  5799. * Copies the given Color4 values into the current one
  5800. * @param source defines the source Color4 object
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFrom(source: Color4): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Copies the given float values into the current one
  5815. * @param r defines the red component to read from
  5816. * @param g defines the green component to read from
  5817. * @param b defines the blue component to read from
  5818. * @param a defines the alpha component to read from
  5819. * @returns the current updated Color4 object
  5820. */
  5821. set(r: number, g: number, b: number, a: number): Color4;
  5822. /**
  5823. * Compute the Color4 hexadecimal code as a string
  5824. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5825. * @returns a string containing the hexadecimal representation of the Color4 object
  5826. */
  5827. toHexString(returnAsColor3?: boolean): string;
  5828. /**
  5829. * Computes a new Color4 converted from the current one to linear space
  5830. * @returns a new Color4 object
  5831. */
  5832. toLinearSpace(): Color4;
  5833. /**
  5834. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5835. * @param convertedColor defines the Color4 object where to store the linear space version
  5836. * @returns the unmodified Color4
  5837. */
  5838. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5839. /**
  5840. * Computes a new Color4 converted from the current one to gamma space
  5841. * @returns a new Color4 object
  5842. */
  5843. toGammaSpace(): Color4;
  5844. /**
  5845. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5846. * @param convertedColor defines the Color4 object where to store the gamma space version
  5847. * @returns the unmodified Color4
  5848. */
  5849. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5850. /**
  5851. * Creates a new Color4 from the string containing valid hexadecimal values
  5852. * @param hex defines a string containing valid hexadecimal values
  5853. * @returns a new Color4 object
  5854. */
  5855. static FromHexString(hex: string): Color4;
  5856. /**
  5857. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5858. * @param left defines the start value
  5859. * @param right defines the end value
  5860. * @param amount defines the gradient factor
  5861. * @returns a new Color4 object
  5862. */
  5863. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5864. /**
  5865. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5866. * @param left defines the start value
  5867. * @param right defines the end value
  5868. * @param amount defines the gradient factor
  5869. * @param result defines the Color4 object where to store data
  5870. */
  5871. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5872. /**
  5873. * Creates a new Color4 from a Color3 and an alpha value
  5874. * @param color3 defines the source Color3 to read from
  5875. * @param alpha defines the alpha component (1.0 by default)
  5876. * @returns a new Color4 object
  5877. */
  5878. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5879. /**
  5880. * Creates a new Color4 from the starting index element of the given array
  5881. * @param array defines the source array to read from
  5882. * @param offset defines the offset in the source array
  5883. * @returns a new Color4 object
  5884. */
  5885. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5886. /**
  5887. * Creates a new Color3 from integer values (< 256)
  5888. * @param r defines the red component to read from (value between 0 and 255)
  5889. * @param g defines the green component to read from (value between 0 and 255)
  5890. * @param b defines the blue component to read from (value between 0 and 255)
  5891. * @param a defines the alpha component to read from (value between 0 and 255)
  5892. * @returns a new Color3 object
  5893. */
  5894. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5895. /**
  5896. * Check the content of a given array and convert it to an array containing RGBA data
  5897. * If the original array was already containing count * 4 values then it is returned directly
  5898. * @param colors defines the array to check
  5899. * @param count defines the number of RGBA data to expect
  5900. * @returns an array containing count * 4 values (RGBA)
  5901. */
  5902. static CheckColors4(colors: number[], count: number): number[];
  5903. }
  5904. /**
  5905. * @hidden
  5906. */
  5907. export class TmpColors {
  5908. static Color3: Color3[];
  5909. static Color4: Color4[];
  5910. }
  5911. }
  5912. declare module "babylonjs/Animations/animationKey" {
  5913. /**
  5914. * Defines an interface which represents an animation key frame
  5915. */
  5916. export interface IAnimationKey {
  5917. /**
  5918. * Frame of the key frame
  5919. */
  5920. frame: number;
  5921. /**
  5922. * Value at the specifies key frame
  5923. */
  5924. value: any;
  5925. /**
  5926. * The input tangent for the cubic hermite spline
  5927. */
  5928. inTangent?: any;
  5929. /**
  5930. * The output tangent for the cubic hermite spline
  5931. */
  5932. outTangent?: any;
  5933. /**
  5934. * The animation interpolation type
  5935. */
  5936. interpolation?: AnimationKeyInterpolation;
  5937. }
  5938. /**
  5939. * Enum for the animation key frame interpolation type
  5940. */
  5941. export enum AnimationKeyInterpolation {
  5942. /**
  5943. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5944. */
  5945. STEP = 1
  5946. }
  5947. }
  5948. declare module "babylonjs/Animations/animationRange" {
  5949. /**
  5950. * Represents the range of an animation
  5951. */
  5952. export class AnimationRange {
  5953. /**The name of the animation range**/
  5954. name: string;
  5955. /**The starting frame of the animation */
  5956. from: number;
  5957. /**The ending frame of the animation*/
  5958. to: number;
  5959. /**
  5960. * Initializes the range of an animation
  5961. * @param name The name of the animation range
  5962. * @param from The starting frame of the animation
  5963. * @param to The ending frame of the animation
  5964. */
  5965. constructor(
  5966. /**The name of the animation range**/
  5967. name: string,
  5968. /**The starting frame of the animation */
  5969. from: number,
  5970. /**The ending frame of the animation*/
  5971. to: number);
  5972. /**
  5973. * Makes a copy of the animation range
  5974. * @returns A copy of the animation range
  5975. */
  5976. clone(): AnimationRange;
  5977. }
  5978. }
  5979. declare module "babylonjs/Animations/animationEvent" {
  5980. /**
  5981. * Composed of a frame, and an action function
  5982. */
  5983. export class AnimationEvent {
  5984. /** The frame for which the event is triggered **/
  5985. frame: number;
  5986. /** The event to perform when triggered **/
  5987. action: (currentFrame: number) => void;
  5988. /** Specifies if the event should be triggered only once**/
  5989. onlyOnce?: boolean | undefined;
  5990. /**
  5991. * Specifies if the animation event is done
  5992. */
  5993. isDone: boolean;
  5994. /**
  5995. * Initializes the animation event
  5996. * @param frame The frame for which the event is triggered
  5997. * @param action The event to perform when triggered
  5998. * @param onlyOnce Specifies if the event should be triggered only once
  5999. */
  6000. constructor(
  6001. /** The frame for which the event is triggered **/
  6002. frame: number,
  6003. /** The event to perform when triggered **/
  6004. action: (currentFrame: number) => void,
  6005. /** Specifies if the event should be triggered only once**/
  6006. onlyOnce?: boolean | undefined);
  6007. /** @hidden */
  6008. _clone(): AnimationEvent;
  6009. }
  6010. }
  6011. declare module "babylonjs/Behaviors/behavior" {
  6012. import { Nullable } from "babylonjs/types";
  6013. /**
  6014. * Interface used to define a behavior
  6015. */
  6016. export interface Behavior<T> {
  6017. /** gets or sets behavior's name */
  6018. name: string;
  6019. /**
  6020. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6021. */
  6022. init(): void;
  6023. /**
  6024. * Called when the behavior is attached to a target
  6025. * @param target defines the target where the behavior is attached to
  6026. */
  6027. attach(target: T): void;
  6028. /**
  6029. * Called when the behavior is detached from its target
  6030. */
  6031. detach(): void;
  6032. }
  6033. /**
  6034. * Interface implemented by classes supporting behaviors
  6035. */
  6036. export interface IBehaviorAware<T> {
  6037. /**
  6038. * Attach a behavior
  6039. * @param behavior defines the behavior to attach
  6040. * @returns the current host
  6041. */
  6042. addBehavior(behavior: Behavior<T>): T;
  6043. /**
  6044. * Remove a behavior from the current object
  6045. * @param behavior defines the behavior to detach
  6046. * @returns the current host
  6047. */
  6048. removeBehavior(behavior: Behavior<T>): T;
  6049. /**
  6050. * Gets a behavior using its name to search
  6051. * @param name defines the name to search
  6052. * @returns the behavior or null if not found
  6053. */
  6054. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6055. }
  6056. }
  6057. declare module "babylonjs/Misc/smartArray" {
  6058. /**
  6059. * Defines an array and its length.
  6060. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6061. */
  6062. export interface ISmartArrayLike<T> {
  6063. /**
  6064. * The data of the array.
  6065. */
  6066. data: Array<T>;
  6067. /**
  6068. * The active length of the array.
  6069. */
  6070. length: number;
  6071. }
  6072. /**
  6073. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6074. */
  6075. export class SmartArray<T> implements ISmartArrayLike<T> {
  6076. /**
  6077. * The full set of data from the array.
  6078. */
  6079. data: Array<T>;
  6080. /**
  6081. * The active length of the array.
  6082. */
  6083. length: number;
  6084. protected _id: number;
  6085. /**
  6086. * Instantiates a Smart Array.
  6087. * @param capacity defines the default capacity of the array.
  6088. */
  6089. constructor(capacity: number);
  6090. /**
  6091. * Pushes a value at the end of the active data.
  6092. * @param value defines the object to push in the array.
  6093. */
  6094. push(value: T): void;
  6095. /**
  6096. * Iterates over the active data and apply the lambda to them.
  6097. * @param func defines the action to apply on each value.
  6098. */
  6099. forEach(func: (content: T) => void): void;
  6100. /**
  6101. * Sorts the full sets of data.
  6102. * @param compareFn defines the comparison function to apply.
  6103. */
  6104. sort(compareFn: (a: T, b: T) => number): void;
  6105. /**
  6106. * Resets the active data to an empty array.
  6107. */
  6108. reset(): void;
  6109. /**
  6110. * Releases all the data from the array as well as the array.
  6111. */
  6112. dispose(): void;
  6113. /**
  6114. * Concats the active data with a given array.
  6115. * @param array defines the data to concatenate with.
  6116. */
  6117. concat(array: any): void;
  6118. /**
  6119. * Returns the position of a value in the active data.
  6120. * @param value defines the value to find the index for
  6121. * @returns the index if found in the active data otherwise -1
  6122. */
  6123. indexOf(value: T): number;
  6124. /**
  6125. * Returns whether an element is part of the active data.
  6126. * @param value defines the value to look for
  6127. * @returns true if found in the active data otherwise false
  6128. */
  6129. contains(value: T): boolean;
  6130. private static _GlobalId;
  6131. }
  6132. /**
  6133. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6134. * The data in this array can only be present once
  6135. */
  6136. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6137. private _duplicateId;
  6138. /**
  6139. * Pushes a value at the end of the active data.
  6140. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6141. * @param value defines the object to push in the array.
  6142. */
  6143. push(value: T): void;
  6144. /**
  6145. * Pushes a value at the end of the active data.
  6146. * If the data is already present, it won t be added again
  6147. * @param value defines the object to push in the array.
  6148. * @returns true if added false if it was already present
  6149. */
  6150. pushNoDuplicate(value: T): boolean;
  6151. /**
  6152. * Resets the active data to an empty array.
  6153. */
  6154. reset(): void;
  6155. /**
  6156. * Concats the active data with a given array.
  6157. * This ensures no dupplicate will be present in the result.
  6158. * @param array defines the data to concatenate with.
  6159. */
  6160. concatWithNoDuplicate(array: any): void;
  6161. }
  6162. }
  6163. declare module "babylonjs/Cameras/cameraInputsManager" {
  6164. import { Nullable } from "babylonjs/types";
  6165. import { Camera } from "babylonjs/Cameras/camera";
  6166. /**
  6167. * @ignore
  6168. * This is a list of all the different input types that are available in the application.
  6169. * Fo instance: ArcRotateCameraGamepadInput...
  6170. */
  6171. export var CameraInputTypes: {};
  6172. /**
  6173. * This is the contract to implement in order to create a new input class.
  6174. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6175. */
  6176. export interface ICameraInput<TCamera extends Camera> {
  6177. /**
  6178. * Defines the camera the input is attached to.
  6179. */
  6180. camera: Nullable<TCamera>;
  6181. /**
  6182. * Gets the class name of the current intput.
  6183. * @returns the class name
  6184. */
  6185. getClassName(): string;
  6186. /**
  6187. * Get the friendly name associated with the input class.
  6188. * @returns the input friendly name
  6189. */
  6190. getSimpleName(): string;
  6191. /**
  6192. * Attach the input controls to a specific dom element to get the input from.
  6193. * @param element Defines the element the controls should be listened from
  6194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6195. */
  6196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6197. /**
  6198. * Detach the current controls from the specified dom element.
  6199. * @param element Defines the element to stop listening the inputs from
  6200. */
  6201. detachControl(element: Nullable<HTMLElement>): void;
  6202. /**
  6203. * Update the current camera state depending on the inputs that have been used this frame.
  6204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6205. */
  6206. checkInputs?: () => void;
  6207. }
  6208. /**
  6209. * Represents a map of input types to input instance or input index to input instance.
  6210. */
  6211. export interface CameraInputsMap<TCamera extends Camera> {
  6212. /**
  6213. * Accessor to the input by input type.
  6214. */
  6215. [name: string]: ICameraInput<TCamera>;
  6216. /**
  6217. * Accessor to the input by input index.
  6218. */
  6219. [idx: number]: ICameraInput<TCamera>;
  6220. }
  6221. /**
  6222. * This represents the input manager used within a camera.
  6223. * It helps dealing with all the different kind of input attached to a camera.
  6224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6225. */
  6226. export class CameraInputsManager<TCamera extends Camera> {
  6227. /**
  6228. * Defines the list of inputs attahed to the camera.
  6229. */
  6230. attached: CameraInputsMap<TCamera>;
  6231. /**
  6232. * Defines the dom element the camera is collecting inputs from.
  6233. * This is null if the controls have not been attached.
  6234. */
  6235. attachedElement: Nullable<HTMLElement>;
  6236. /**
  6237. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6238. */
  6239. noPreventDefault: boolean;
  6240. /**
  6241. * Defined the camera the input manager belongs to.
  6242. */
  6243. camera: TCamera;
  6244. /**
  6245. * Update the current camera state depending on the inputs that have been used this frame.
  6246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6247. */
  6248. checkInputs: () => void;
  6249. /**
  6250. * Instantiate a new Camera Input Manager.
  6251. * @param camera Defines the camera the input manager blongs to
  6252. */
  6253. constructor(camera: TCamera);
  6254. /**
  6255. * Add an input method to a camera
  6256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6257. * @param input camera input method
  6258. */
  6259. add(input: ICameraInput<TCamera>): void;
  6260. /**
  6261. * Remove a specific input method from a camera
  6262. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6263. * @param inputToRemove camera input method
  6264. */
  6265. remove(inputToRemove: ICameraInput<TCamera>): void;
  6266. /**
  6267. * Remove a specific input type from a camera
  6268. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6269. * @param inputType the type of the input to remove
  6270. */
  6271. removeByType(inputType: string): void;
  6272. private _addCheckInputs;
  6273. /**
  6274. * Attach the input controls to the currently attached dom element to listen the events from.
  6275. * @param input Defines the input to attach
  6276. */
  6277. attachInput(input: ICameraInput<TCamera>): void;
  6278. /**
  6279. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6280. * @param element Defines the dom element to collect the events from
  6281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6282. */
  6283. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6284. /**
  6285. * Detach the current manager inputs controls from a specific dom element.
  6286. * @param element Defines the dom element to collect the events from
  6287. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6288. */
  6289. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6290. /**
  6291. * Rebuild the dynamic inputCheck function from the current list of
  6292. * defined inputs in the manager.
  6293. */
  6294. rebuildInputCheck(): void;
  6295. /**
  6296. * Remove all attached input methods from a camera
  6297. */
  6298. clear(): void;
  6299. /**
  6300. * Serialize the current input manager attached to a camera.
  6301. * This ensures than once parsed,
  6302. * the input associated to the camera will be identical to the current ones
  6303. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6304. */
  6305. serialize(serializedCamera: any): void;
  6306. /**
  6307. * Parses an input manager serialized JSON to restore the previous list of inputs
  6308. * and states associated to a camera.
  6309. * @param parsedCamera Defines the JSON to parse
  6310. */
  6311. parse(parsedCamera: any): void;
  6312. }
  6313. }
  6314. declare module "babylonjs/Meshes/buffer" {
  6315. import { Nullable, DataArray } from "babylonjs/types";
  6316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6317. /**
  6318. * Class used to store data that will be store in GPU memory
  6319. */
  6320. export class Buffer {
  6321. private _engine;
  6322. private _buffer;
  6323. /** @hidden */
  6324. _data: Nullable<DataArray>;
  6325. private _updatable;
  6326. private _instanced;
  6327. private _divisor;
  6328. /**
  6329. * Gets the byte stride.
  6330. */
  6331. readonly byteStride: number;
  6332. /**
  6333. * Constructor
  6334. * @param engine the engine
  6335. * @param data the data to use for this buffer
  6336. * @param updatable whether the data is updatable
  6337. * @param stride the stride (optional)
  6338. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6339. * @param instanced whether the buffer is instanced (optional)
  6340. * @param useBytes set to true if the stride in in bytes (optional)
  6341. * @param divisor sets an optional divisor for instances (1 by default)
  6342. */
  6343. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6344. /**
  6345. * Create a new VertexBuffer based on the current buffer
  6346. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6347. * @param offset defines offset in the buffer (0 by default)
  6348. * @param size defines the size in floats of attributes (position is 3 for instance)
  6349. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6350. * @param instanced defines if the vertex buffer contains indexed data
  6351. * @param useBytes defines if the offset and stride are in bytes *
  6352. * @param divisor sets an optional divisor for instances (1 by default)
  6353. * @returns the new vertex buffer
  6354. */
  6355. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6356. /**
  6357. * Gets a boolean indicating if the Buffer is updatable?
  6358. * @returns true if the buffer is updatable
  6359. */
  6360. isUpdatable(): boolean;
  6361. /**
  6362. * Gets current buffer's data
  6363. * @returns a DataArray or null
  6364. */
  6365. getData(): Nullable<DataArray>;
  6366. /**
  6367. * Gets underlying native buffer
  6368. * @returns underlying native buffer
  6369. */
  6370. getBuffer(): Nullable<DataBuffer>;
  6371. /**
  6372. * Gets the stride in float32 units (i.e. byte stride / 4).
  6373. * May not be an integer if the byte stride is not divisible by 4.
  6374. * @returns the stride in float32 units
  6375. * @deprecated Please use byteStride instead.
  6376. */
  6377. getStrideSize(): number;
  6378. /**
  6379. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6380. * @param data defines the data to store
  6381. */
  6382. create(data?: Nullable<DataArray>): void;
  6383. /** @hidden */
  6384. _rebuild(): void;
  6385. /**
  6386. * Update current buffer data
  6387. * @param data defines the data to store
  6388. */
  6389. update(data: DataArray): void;
  6390. /**
  6391. * Updates the data directly.
  6392. * @param data the new data
  6393. * @param offset the new offset
  6394. * @param vertexCount the vertex count (optional)
  6395. * @param useBytes set to true if the offset is in bytes
  6396. */
  6397. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6398. /**
  6399. * Release all resources
  6400. */
  6401. dispose(): void;
  6402. }
  6403. /**
  6404. * Specialized buffer used to store vertex data
  6405. */
  6406. export class VertexBuffer {
  6407. /** @hidden */
  6408. _buffer: Buffer;
  6409. private _kind;
  6410. private _size;
  6411. private _ownsBuffer;
  6412. private _instanced;
  6413. private _instanceDivisor;
  6414. /**
  6415. * The byte type.
  6416. */
  6417. static readonly BYTE: number;
  6418. /**
  6419. * The unsigned byte type.
  6420. */
  6421. static readonly UNSIGNED_BYTE: number;
  6422. /**
  6423. * The short type.
  6424. */
  6425. static readonly SHORT: number;
  6426. /**
  6427. * The unsigned short type.
  6428. */
  6429. static readonly UNSIGNED_SHORT: number;
  6430. /**
  6431. * The integer type.
  6432. */
  6433. static readonly INT: number;
  6434. /**
  6435. * The unsigned integer type.
  6436. */
  6437. static readonly UNSIGNED_INT: number;
  6438. /**
  6439. * The float type.
  6440. */
  6441. static readonly FLOAT: number;
  6442. /**
  6443. * Gets or sets the instance divisor when in instanced mode
  6444. */
  6445. get instanceDivisor(): number;
  6446. set instanceDivisor(value: number);
  6447. /**
  6448. * Gets the byte stride.
  6449. */
  6450. readonly byteStride: number;
  6451. /**
  6452. * Gets the byte offset.
  6453. */
  6454. readonly byteOffset: number;
  6455. /**
  6456. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6457. */
  6458. readonly normalized: boolean;
  6459. /**
  6460. * Gets the data type of each component in the array.
  6461. */
  6462. readonly type: number;
  6463. /**
  6464. * Constructor
  6465. * @param engine the engine
  6466. * @param data the data to use for this vertex buffer
  6467. * @param kind the vertex buffer kind
  6468. * @param updatable whether the data is updatable
  6469. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6470. * @param stride the stride (optional)
  6471. * @param instanced whether the buffer is instanced (optional)
  6472. * @param offset the offset of the data (optional)
  6473. * @param size the number of components (optional)
  6474. * @param type the type of the component (optional)
  6475. * @param normalized whether the data contains normalized data (optional)
  6476. * @param useBytes set to true if stride and offset are in bytes (optional)
  6477. * @param divisor defines the instance divisor to use (1 by default)
  6478. */
  6479. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6480. /** @hidden */
  6481. _rebuild(): void;
  6482. /**
  6483. * Returns the kind of the VertexBuffer (string)
  6484. * @returns a string
  6485. */
  6486. getKind(): string;
  6487. /**
  6488. * Gets a boolean indicating if the VertexBuffer is updatable?
  6489. * @returns true if the buffer is updatable
  6490. */
  6491. isUpdatable(): boolean;
  6492. /**
  6493. * Gets current buffer's data
  6494. * @returns a DataArray or null
  6495. */
  6496. getData(): Nullable<DataArray>;
  6497. /**
  6498. * Gets underlying native buffer
  6499. * @returns underlying native buffer
  6500. */
  6501. getBuffer(): Nullable<DataBuffer>;
  6502. /**
  6503. * Gets the stride in float32 units (i.e. byte stride / 4).
  6504. * May not be an integer if the byte stride is not divisible by 4.
  6505. * @returns the stride in float32 units
  6506. * @deprecated Please use byteStride instead.
  6507. */
  6508. getStrideSize(): number;
  6509. /**
  6510. * Returns the offset as a multiple of the type byte length.
  6511. * @returns the offset in bytes
  6512. * @deprecated Please use byteOffset instead.
  6513. */
  6514. getOffset(): number;
  6515. /**
  6516. * Returns the number of components per vertex attribute (integer)
  6517. * @returns the size in float
  6518. */
  6519. getSize(): number;
  6520. /**
  6521. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6522. * @returns true if this buffer is instanced
  6523. */
  6524. getIsInstanced(): boolean;
  6525. /**
  6526. * Returns the instancing divisor, zero for non-instanced (integer).
  6527. * @returns a number
  6528. */
  6529. getInstanceDivisor(): number;
  6530. /**
  6531. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6532. * @param data defines the data to store
  6533. */
  6534. create(data?: DataArray): void;
  6535. /**
  6536. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6537. * This function will create a new buffer if the current one is not updatable
  6538. * @param data defines the data to store
  6539. */
  6540. update(data: DataArray): void;
  6541. /**
  6542. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6543. * Returns the directly updated WebGLBuffer.
  6544. * @param data the new data
  6545. * @param offset the new offset
  6546. * @param useBytes set to true if the offset is in bytes
  6547. */
  6548. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6549. /**
  6550. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6551. */
  6552. dispose(): void;
  6553. /**
  6554. * Enumerates each value of this vertex buffer as numbers.
  6555. * @param count the number of values to enumerate
  6556. * @param callback the callback function called for each value
  6557. */
  6558. forEach(count: number, callback: (value: number, index: number) => void): void;
  6559. /**
  6560. * Positions
  6561. */
  6562. static readonly PositionKind: string;
  6563. /**
  6564. * Normals
  6565. */
  6566. static readonly NormalKind: string;
  6567. /**
  6568. * Tangents
  6569. */
  6570. static readonly TangentKind: string;
  6571. /**
  6572. * Texture coordinates
  6573. */
  6574. static readonly UVKind: string;
  6575. /**
  6576. * Texture coordinates 2
  6577. */
  6578. static readonly UV2Kind: string;
  6579. /**
  6580. * Texture coordinates 3
  6581. */
  6582. static readonly UV3Kind: string;
  6583. /**
  6584. * Texture coordinates 4
  6585. */
  6586. static readonly UV4Kind: string;
  6587. /**
  6588. * Texture coordinates 5
  6589. */
  6590. static readonly UV5Kind: string;
  6591. /**
  6592. * Texture coordinates 6
  6593. */
  6594. static readonly UV6Kind: string;
  6595. /**
  6596. * Colors
  6597. */
  6598. static readonly ColorKind: string;
  6599. /**
  6600. * Matrix indices (for bones)
  6601. */
  6602. static readonly MatricesIndicesKind: string;
  6603. /**
  6604. * Matrix weights (for bones)
  6605. */
  6606. static readonly MatricesWeightsKind: string;
  6607. /**
  6608. * Additional matrix indices (for bones)
  6609. */
  6610. static readonly MatricesIndicesExtraKind: string;
  6611. /**
  6612. * Additional matrix weights (for bones)
  6613. */
  6614. static readonly MatricesWeightsExtraKind: string;
  6615. /**
  6616. * Deduces the stride given a kind.
  6617. * @param kind The kind string to deduce
  6618. * @returns The deduced stride
  6619. */
  6620. static DeduceStride(kind: string): number;
  6621. /**
  6622. * Gets the byte length of the given type.
  6623. * @param type the type
  6624. * @returns the number of bytes
  6625. */
  6626. static GetTypeByteLength(type: number): number;
  6627. /**
  6628. * Enumerates each value of the given parameters as numbers.
  6629. * @param data the data to enumerate
  6630. * @param byteOffset the byte offset of the data
  6631. * @param byteStride the byte stride of the data
  6632. * @param componentCount the number of components per element
  6633. * @param componentType the type of the component
  6634. * @param count the number of values to enumerate
  6635. * @param normalized whether the data is normalized
  6636. * @param callback the callback function called for each value
  6637. */
  6638. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6639. private static _GetFloatValue;
  6640. }
  6641. }
  6642. declare module "babylonjs/Collisions/intersectionInfo" {
  6643. import { Nullable } from "babylonjs/types";
  6644. /**
  6645. * @hidden
  6646. */
  6647. export class IntersectionInfo {
  6648. bu: Nullable<number>;
  6649. bv: Nullable<number>;
  6650. distance: number;
  6651. faceId: number;
  6652. subMeshId: number;
  6653. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6654. }
  6655. }
  6656. declare module "babylonjs/Maths/math.plane" {
  6657. import { DeepImmutable } from "babylonjs/types";
  6658. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6659. /**
  6660. * Represens a plane by the equation ax + by + cz + d = 0
  6661. */
  6662. export class Plane {
  6663. private static _TmpMatrix;
  6664. /**
  6665. * Normal of the plane (a,b,c)
  6666. */
  6667. normal: Vector3;
  6668. /**
  6669. * d component of the plane
  6670. */
  6671. d: number;
  6672. /**
  6673. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6674. * @param a a component of the plane
  6675. * @param b b component of the plane
  6676. * @param c c component of the plane
  6677. * @param d d component of the plane
  6678. */
  6679. constructor(a: number, b: number, c: number, d: number);
  6680. /**
  6681. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6682. */
  6683. asArray(): number[];
  6684. /**
  6685. * @returns a new plane copied from the current Plane.
  6686. */
  6687. clone(): Plane;
  6688. /**
  6689. * @returns the string "Plane".
  6690. */
  6691. getClassName(): string;
  6692. /**
  6693. * @returns the Plane hash code.
  6694. */
  6695. getHashCode(): number;
  6696. /**
  6697. * Normalize the current Plane in place.
  6698. * @returns the updated Plane.
  6699. */
  6700. normalize(): Plane;
  6701. /**
  6702. * Applies a transformation the plane and returns the result
  6703. * @param transformation the transformation matrix to be applied to the plane
  6704. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6705. */
  6706. transform(transformation: DeepImmutable<Matrix>): Plane;
  6707. /**
  6708. * Calcualtte the dot product between the point and the plane normal
  6709. * @param point point to calculate the dot product with
  6710. * @returns the dot product (float) of the point coordinates and the plane normal.
  6711. */
  6712. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6713. /**
  6714. * Updates the current Plane from the plane defined by the three given points.
  6715. * @param point1 one of the points used to contruct the plane
  6716. * @param point2 one of the points used to contruct the plane
  6717. * @param point3 one of the points used to contruct the plane
  6718. * @returns the updated Plane.
  6719. */
  6720. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6721. /**
  6722. * Checks if the plane is facing a given direction
  6723. * @param direction the direction to check if the plane is facing
  6724. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6725. * @returns True is the vector "direction" is the same side than the plane normal.
  6726. */
  6727. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6728. /**
  6729. * Calculates the distance to a point
  6730. * @param point point to calculate distance to
  6731. * @returns the signed distance (float) from the given point to the Plane.
  6732. */
  6733. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6734. /**
  6735. * Creates a plane from an array
  6736. * @param array the array to create a plane from
  6737. * @returns a new Plane from the given array.
  6738. */
  6739. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6740. /**
  6741. * Creates a plane from three points
  6742. * @param point1 point used to create the plane
  6743. * @param point2 point used to create the plane
  6744. * @param point3 point used to create the plane
  6745. * @returns a new Plane defined by the three given points.
  6746. */
  6747. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6748. /**
  6749. * Creates a plane from an origin point and a normal
  6750. * @param origin origin of the plane to be constructed
  6751. * @param normal normal of the plane to be constructed
  6752. * @returns a new Plane the normal vector to this plane at the given origin point.
  6753. * Note : the vector "normal" is updated because normalized.
  6754. */
  6755. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6756. /**
  6757. * Calculates the distance from a plane and a point
  6758. * @param origin origin of the plane to be constructed
  6759. * @param normal normal of the plane to be constructed
  6760. * @param point point to calculate distance to
  6761. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6762. */
  6763. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6764. }
  6765. }
  6766. declare module "babylonjs/Culling/boundingSphere" {
  6767. import { DeepImmutable } from "babylonjs/types";
  6768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6769. import { Plane } from "babylonjs/Maths/math.plane";
  6770. /**
  6771. * Class used to store bounding sphere information
  6772. */
  6773. export class BoundingSphere {
  6774. /**
  6775. * Gets the center of the bounding sphere in local space
  6776. */
  6777. readonly center: Vector3;
  6778. /**
  6779. * Radius of the bounding sphere in local space
  6780. */
  6781. radius: number;
  6782. /**
  6783. * Gets the center of the bounding sphere in world space
  6784. */
  6785. readonly centerWorld: Vector3;
  6786. /**
  6787. * Radius of the bounding sphere in world space
  6788. */
  6789. radiusWorld: number;
  6790. /**
  6791. * Gets the minimum vector in local space
  6792. */
  6793. readonly minimum: Vector3;
  6794. /**
  6795. * Gets the maximum vector in local space
  6796. */
  6797. readonly maximum: Vector3;
  6798. private _worldMatrix;
  6799. private static readonly TmpVector3;
  6800. /**
  6801. * Creates a new bounding sphere
  6802. * @param min defines the minimum vector (in local space)
  6803. * @param max defines the maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6807. /**
  6808. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6809. * @param min defines the new minimum vector (in local space)
  6810. * @param max defines the new maximum vector (in local space)
  6811. * @param worldMatrix defines the new world matrix
  6812. */
  6813. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6814. /**
  6815. * Scale the current bounding sphere by applying a scale factor
  6816. * @param factor defines the scale factor to apply
  6817. * @returns the current bounding box
  6818. */
  6819. scale(factor: number): BoundingSphere;
  6820. /**
  6821. * Gets the world matrix of the bounding box
  6822. * @returns a matrix
  6823. */
  6824. getWorldMatrix(): DeepImmutable<Matrix>;
  6825. /** @hidden */
  6826. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6827. /**
  6828. * Tests if the bounding sphere is intersecting the frustum planes
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if there is an intersection
  6831. */
  6832. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if the bounding sphere center is in between the frustum planes.
  6835. * Used for optimistic fast inclusion.
  6836. * @param frustumPlanes defines the frustum planes to test
  6837. * @returns true if the sphere center is in between the frustum planes
  6838. */
  6839. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6840. /**
  6841. * Tests if a point is inside the bounding sphere
  6842. * @param point defines the point to test
  6843. * @returns true if the point is inside the bounding sphere
  6844. */
  6845. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6846. /**
  6847. * Checks if two sphere intersct
  6848. * @param sphere0 sphere 0
  6849. * @param sphere1 sphere 1
  6850. * @returns true if the speres intersect
  6851. */
  6852. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6853. }
  6854. }
  6855. declare module "babylonjs/Culling/boundingBox" {
  6856. import { DeepImmutable } from "babylonjs/types";
  6857. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6858. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6859. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6860. import { Plane } from "babylonjs/Maths/math.plane";
  6861. /**
  6862. * Class used to store bounding box information
  6863. */
  6864. export class BoundingBox implements ICullable {
  6865. /**
  6866. * Gets the 8 vectors representing the bounding box in local space
  6867. */
  6868. readonly vectors: Vector3[];
  6869. /**
  6870. * Gets the center of the bounding box in local space
  6871. */
  6872. readonly center: Vector3;
  6873. /**
  6874. * Gets the center of the bounding box in world space
  6875. */
  6876. readonly centerWorld: Vector3;
  6877. /**
  6878. * Gets the extend size in local space
  6879. */
  6880. readonly extendSize: Vector3;
  6881. /**
  6882. * Gets the extend size in world space
  6883. */
  6884. readonly extendSizeWorld: Vector3;
  6885. /**
  6886. * Gets the OBB (object bounding box) directions
  6887. */
  6888. readonly directions: Vector3[];
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in world space
  6891. */
  6892. readonly vectorsWorld: Vector3[];
  6893. /**
  6894. * Gets the minimum vector in world space
  6895. */
  6896. readonly minimumWorld: Vector3;
  6897. /**
  6898. * Gets the maximum vector in world space
  6899. */
  6900. readonly maximumWorld: Vector3;
  6901. /**
  6902. * Gets the minimum vector in local space
  6903. */
  6904. readonly minimum: Vector3;
  6905. /**
  6906. * Gets the maximum vector in local space
  6907. */
  6908. readonly maximum: Vector3;
  6909. private _worldMatrix;
  6910. private static readonly TmpVector3;
  6911. /**
  6912. * @hidden
  6913. */
  6914. _tag: number;
  6915. /**
  6916. * Creates a new bounding box
  6917. * @param min defines the minimum vector (in local space)
  6918. * @param max defines the maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6922. /**
  6923. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6924. * @param min defines the new minimum vector (in local space)
  6925. * @param max defines the new maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6929. /**
  6930. * Scale the current bounding box by applying a scale factor
  6931. * @param factor defines the scale factor to apply
  6932. * @returns the current bounding box
  6933. */
  6934. scale(factor: number): BoundingBox;
  6935. /**
  6936. * Gets the world matrix of the bounding box
  6937. * @returns a matrix
  6938. */
  6939. getWorldMatrix(): DeepImmutable<Matrix>;
  6940. /** @hidden */
  6941. _update(world: DeepImmutable<Matrix>): void;
  6942. /**
  6943. * Tests if the bounding box is intersecting the frustum planes
  6944. * @param frustumPlanes defines the frustum planes to test
  6945. * @returns true if there is an intersection
  6946. */
  6947. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /**
  6949. * Tests if the bounding box is entirely inside the frustum planes
  6950. * @param frustumPlanes defines the frustum planes to test
  6951. * @returns true if there is an inclusion
  6952. */
  6953. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6954. /**
  6955. * Tests if a point is inside the bounding box
  6956. * @param point defines the point to test
  6957. * @returns true if the point is inside the bounding box
  6958. */
  6959. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6960. /**
  6961. * Tests if the bounding box intersects with a bounding sphere
  6962. * @param sphere defines the sphere to test
  6963. * @returns true if there is an intersection
  6964. */
  6965. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6966. /**
  6967. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6968. * @param min defines the min vector to use
  6969. * @param max defines the max vector to use
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6973. /**
  6974. * Tests if two bounding boxes are intersections
  6975. * @param box0 defines the first box to test
  6976. * @param box1 defines the second box to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6980. /**
  6981. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6982. * @param minPoint defines the minimum vector of the bounding box
  6983. * @param maxPoint defines the maximum vector of the bounding box
  6984. * @param sphereCenter defines the sphere center
  6985. * @param sphereRadius defines the sphere radius
  6986. * @returns true if there is an intersection
  6987. */
  6988. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6989. /**
  6990. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6991. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @return true if there is an inclusion
  6994. */
  6995. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an intersection
  7001. */
  7002. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. }
  7004. }
  7005. declare module "babylonjs/Collisions/collider" {
  7006. import { Nullable, IndicesArray } from "babylonjs/types";
  7007. import { Vector3 } from "babylonjs/Maths/math.vector";
  7008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7009. import { Plane } from "babylonjs/Maths/math.plane";
  7010. /** @hidden */
  7011. export class Collider {
  7012. /** Define if a collision was found */
  7013. collisionFound: boolean;
  7014. /**
  7015. * Define last intersection point in local space
  7016. */
  7017. intersectionPoint: Vector3;
  7018. /**
  7019. * Define last collided mesh
  7020. */
  7021. collidedMesh: Nullable<AbstractMesh>;
  7022. private _collisionPoint;
  7023. private _planeIntersectionPoint;
  7024. private _tempVector;
  7025. private _tempVector2;
  7026. private _tempVector3;
  7027. private _tempVector4;
  7028. private _edge;
  7029. private _baseToVertex;
  7030. private _destinationPoint;
  7031. private _slidePlaneNormal;
  7032. private _displacementVector;
  7033. /** @hidden */
  7034. _radius: Vector3;
  7035. /** @hidden */
  7036. _retry: number;
  7037. private _velocity;
  7038. private _basePoint;
  7039. private _epsilon;
  7040. /** @hidden */
  7041. _velocityWorldLength: number;
  7042. /** @hidden */
  7043. _basePointWorld: Vector3;
  7044. private _velocityWorld;
  7045. private _normalizedVelocity;
  7046. /** @hidden */
  7047. _initialVelocity: Vector3;
  7048. /** @hidden */
  7049. _initialPosition: Vector3;
  7050. private _nearestDistance;
  7051. private _collisionMask;
  7052. get collisionMask(): number;
  7053. set collisionMask(mask: number);
  7054. /**
  7055. * Gets the plane normal used to compute the sliding response (in local space)
  7056. */
  7057. get slidePlaneNormal(): Vector3;
  7058. /** @hidden */
  7059. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7060. /** @hidden */
  7061. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7062. /** @hidden */
  7063. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7064. /** @hidden */
  7065. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7066. /** @hidden */
  7067. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7068. /** @hidden */
  7069. _getResponse(pos: Vector3, vel: Vector3): void;
  7070. }
  7071. }
  7072. declare module "babylonjs/Culling/boundingInfo" {
  7073. import { DeepImmutable } from "babylonjs/types";
  7074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7075. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7076. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7077. import { Plane } from "babylonjs/Maths/math.plane";
  7078. import { Collider } from "babylonjs/Collisions/collider";
  7079. /**
  7080. * Interface for cullable objects
  7081. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7082. */
  7083. export interface ICullable {
  7084. /**
  7085. * Checks if the object or part of the object is in the frustum
  7086. * @param frustumPlanes Camera near/planes
  7087. * @returns true if the object is in frustum otherwise false
  7088. */
  7089. isInFrustum(frustumPlanes: Plane[]): boolean;
  7090. /**
  7091. * Checks if a cullable object (mesh...) is in the camera frustum
  7092. * Unlike isInFrustum this cheks the full bounding box
  7093. * @param frustumPlanes Camera near/planes
  7094. * @returns true if the object is in frustum otherwise false
  7095. */
  7096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7097. }
  7098. /**
  7099. * Info for a bounding data of a mesh
  7100. */
  7101. export class BoundingInfo implements ICullable {
  7102. /**
  7103. * Bounding box for the mesh
  7104. */
  7105. readonly boundingBox: BoundingBox;
  7106. /**
  7107. * Bounding sphere for the mesh
  7108. */
  7109. readonly boundingSphere: BoundingSphere;
  7110. private _isLocked;
  7111. private static readonly TmpVector3;
  7112. /**
  7113. * Constructs bounding info
  7114. * @param minimum min vector of the bounding box/sphere
  7115. * @param maximum max vector of the bounding box/sphere
  7116. * @param worldMatrix defines the new world matrix
  7117. */
  7118. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7119. /**
  7120. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7121. * @param min defines the new minimum vector (in local space)
  7122. * @param max defines the new maximum vector (in local space)
  7123. * @param worldMatrix defines the new world matrix
  7124. */
  7125. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7126. /**
  7127. * min vector of the bounding box/sphere
  7128. */
  7129. get minimum(): Vector3;
  7130. /**
  7131. * max vector of the bounding box/sphere
  7132. */
  7133. get maximum(): Vector3;
  7134. /**
  7135. * If the info is locked and won't be updated to avoid perf overhead
  7136. */
  7137. get isLocked(): boolean;
  7138. set isLocked(value: boolean);
  7139. /**
  7140. * Updates the bounding sphere and box
  7141. * @param world world matrix to be used to update
  7142. */
  7143. update(world: DeepImmutable<Matrix>): void;
  7144. /**
  7145. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7146. * @param center New center of the bounding info
  7147. * @param extend New extend of the bounding info
  7148. * @returns the current bounding info
  7149. */
  7150. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7151. /**
  7152. * Scale the current bounding info by applying a scale factor
  7153. * @param factor defines the scale factor to apply
  7154. * @returns the current bounding info
  7155. */
  7156. scale(factor: number): BoundingInfo;
  7157. /**
  7158. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7159. * @param frustumPlanes defines the frustum to test
  7160. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7161. * @returns true if the bounding info is in the frustum planes
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7164. /**
  7165. * Gets the world distance between the min and max points of the bounding box
  7166. */
  7167. get diagonalLength(): number;
  7168. /**
  7169. * Checks if a cullable object (mesh...) is in the camera frustum
  7170. * Unlike isInFrustum this cheks the full bounding box
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7175. /** @hidden */
  7176. _checkCollision(collider: Collider): boolean;
  7177. /**
  7178. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7179. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7180. * @param point the point to check intersection with
  7181. * @returns if the point intersects
  7182. */
  7183. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7184. /**
  7185. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7186. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7187. * @param boundingInfo the bounding info to check intersection with
  7188. * @param precise if the intersection should be done using OBB
  7189. * @returns if the bounding info intersects
  7190. */
  7191. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7192. }
  7193. }
  7194. declare module "babylonjs/Maths/math.functions" {
  7195. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7196. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7197. /**
  7198. * Extracts minimum and maximum values from a list of indexed positions
  7199. * @param positions defines the positions to use
  7200. * @param indices defines the indices to the positions
  7201. * @param indexStart defines the start index
  7202. * @param indexCount defines the end index
  7203. * @param bias defines bias value to add to the result
  7204. * @return minimum and maximum values
  7205. */
  7206. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7207. minimum: Vector3;
  7208. maximum: Vector3;
  7209. };
  7210. /**
  7211. * Extracts minimum and maximum values from a list of positions
  7212. * @param positions defines the positions to use
  7213. * @param start defines the start index in the positions array
  7214. * @param count defines the number of positions to handle
  7215. * @param bias defines bias value to add to the result
  7216. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7217. * @return minimum and maximum values
  7218. */
  7219. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7220. minimum: Vector3;
  7221. maximum: Vector3;
  7222. };
  7223. }
  7224. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7226. /** @hidden */
  7227. export class WebGLDataBuffer extends DataBuffer {
  7228. private _buffer;
  7229. constructor(resource: WebGLBuffer);
  7230. get underlyingResource(): any;
  7231. }
  7232. }
  7233. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7234. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7235. import { Nullable } from "babylonjs/types";
  7236. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7237. /** @hidden */
  7238. export class WebGLPipelineContext implements IPipelineContext {
  7239. engine: ThinEngine;
  7240. program: Nullable<WebGLProgram>;
  7241. context?: WebGLRenderingContext;
  7242. vertexShader?: WebGLShader;
  7243. fragmentShader?: WebGLShader;
  7244. isParallelCompiled: boolean;
  7245. onCompiled?: () => void;
  7246. transformFeedback?: WebGLTransformFeedback | null;
  7247. vertexCompilationError: Nullable<string>;
  7248. fragmentCompilationError: Nullable<string>;
  7249. programLinkError: Nullable<string>;
  7250. programValidationError: Nullable<string>;
  7251. get isAsync(): boolean;
  7252. get isReady(): boolean;
  7253. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7254. _getVertexShaderCode(): string | null;
  7255. _getFragmentShaderCode(): string | null;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7259. import { FloatArray, Nullable } from "babylonjs/types";
  7260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7262. module "babylonjs/Engines/thinEngine" {
  7263. interface ThinEngine {
  7264. /**
  7265. * Create an uniform buffer
  7266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7267. * @param elements defines the content of the uniform buffer
  7268. * @returns the webGL uniform buffer
  7269. */
  7270. createUniformBuffer(elements: FloatArray): DataBuffer;
  7271. /**
  7272. * Create a dynamic uniform buffer
  7273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7274. * @param elements defines the content of the uniform buffer
  7275. * @returns the webGL uniform buffer
  7276. */
  7277. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7278. /**
  7279. * Update an existing uniform buffer
  7280. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7281. * @param uniformBuffer defines the target uniform buffer
  7282. * @param elements defines the content to update
  7283. * @param offset defines the offset in the uniform buffer where update should start
  7284. * @param count defines the size of the data to update
  7285. */
  7286. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7287. /**
  7288. * Bind an uniform buffer to the current webGL context
  7289. * @param buffer defines the buffer to bind
  7290. */
  7291. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7292. /**
  7293. * Bind a buffer to the current webGL context at a given location
  7294. * @param buffer defines the buffer to bind
  7295. * @param location defines the index where to bind the buffer
  7296. */
  7297. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7298. /**
  7299. * Bind a specific block at a given index in a specific shader program
  7300. * @param pipelineContext defines the pipeline context to use
  7301. * @param blockName defines the block name
  7302. * @param index defines the index where to bind the block
  7303. */
  7304. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7305. }
  7306. }
  7307. }
  7308. declare module "babylonjs/Materials/uniformBuffer" {
  7309. import { Nullable, FloatArray } from "babylonjs/types";
  7310. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7311. import { Engine } from "babylonjs/Engines/engine";
  7312. import { Effect } from "babylonjs/Materials/effect";
  7313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7315. import { Color3 } from "babylonjs/Maths/math.color";
  7316. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7317. /**
  7318. * Uniform buffer objects.
  7319. *
  7320. * Handles blocks of uniform on the GPU.
  7321. *
  7322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7323. *
  7324. * For more information, please refer to :
  7325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7326. */
  7327. export class UniformBuffer {
  7328. private _engine;
  7329. private _buffer;
  7330. private _data;
  7331. private _bufferData;
  7332. private _dynamic?;
  7333. private _uniformLocations;
  7334. private _uniformSizes;
  7335. private _uniformLocationPointer;
  7336. private _needSync;
  7337. private _noUBO;
  7338. private _currentEffect;
  7339. /** @hidden */
  7340. _alreadyBound: boolean;
  7341. private static _MAX_UNIFORM_SIZE;
  7342. private static _tempBuffer;
  7343. /**
  7344. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7349. /**
  7350. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7355. /**
  7356. * Lambda to Update a single float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat: (name: string, x: number) => void;
  7361. /**
  7362. * Lambda to Update a vec2 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a vec3 of float in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update a vec4 of float in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateMatrix: (name: string, mat: Matrix) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateVector3: (name: string, vector: Vector3) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateVector4: (name: string, vector: Vector4) => void;
  7397. /**
  7398. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7409. /**
  7410. * Instantiates a new Uniform buffer objects.
  7411. *
  7412. * Handles blocks of uniform on the GPU.
  7413. *
  7414. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7415. *
  7416. * For more information, please refer to :
  7417. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7418. * @param engine Define the engine the buffer is associated with
  7419. * @param data Define the data contained in the buffer
  7420. * @param dynamic Define if the buffer is updatable
  7421. */
  7422. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7423. /**
  7424. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7425. * or just falling back on setUniformXXX calls.
  7426. */
  7427. get useUbo(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is in sync
  7430. * with the javascript cache data.
  7431. */
  7432. get isSync(): boolean;
  7433. /**
  7434. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7435. * Also, a dynamic UniformBuffer will disable cache verification and always
  7436. * update the underlying WebGL uniform buffer to the GPU.
  7437. * @returns if Dynamic, otherwise false
  7438. */
  7439. isDynamic(): boolean;
  7440. /**
  7441. * The data cache on JS side.
  7442. * @returns the underlying data as a float array
  7443. */
  7444. getData(): Float32Array;
  7445. /**
  7446. * The underlying WebGL Uniform buffer.
  7447. * @returns the webgl buffer
  7448. */
  7449. getBuffer(): Nullable<DataBuffer>;
  7450. /**
  7451. * std140 layout specifies how to align data within an UBO structure.
  7452. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7453. * for specs.
  7454. */
  7455. private _fillAlignment;
  7456. /**
  7457. * Adds an uniform in the buffer.
  7458. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7459. * for the layout to be correct !
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param size Data size, or data directly.
  7462. */
  7463. addUniform(name: string, size: number | number[]): void;
  7464. /**
  7465. * Adds a Matrix 4x4 to the uniform buffer.
  7466. * @param name Name of the uniform, as used in the uniform block in the shader.
  7467. * @param mat A 4x4 matrix.
  7468. */
  7469. addMatrix(name: string, mat: Matrix): void;
  7470. /**
  7471. * Adds a vec2 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param x Define the x component value of the vec2
  7474. * @param y Define the y component value of the vec2
  7475. */
  7476. addFloat2(name: string, x: number, y: number): void;
  7477. /**
  7478. * Adds a vec3 to the uniform buffer.
  7479. * @param name Name of the uniform, as used in the uniform block in the shader.
  7480. * @param x Define the x component value of the vec3
  7481. * @param y Define the y component value of the vec3
  7482. * @param z Define the z component value of the vec3
  7483. */
  7484. addFloat3(name: string, x: number, y: number, z: number): void;
  7485. /**
  7486. * Adds a vec3 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param color Define the vec3 from a Color
  7489. */
  7490. addColor3(name: string, color: Color3): void;
  7491. /**
  7492. * Adds a vec4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param color Define the rgb components from a Color
  7495. * @param alpha Define the a component of the vec4
  7496. */
  7497. addColor4(name: string, color: Color3, alpha: number): void;
  7498. /**
  7499. * Adds a vec3 to the uniform buffer.
  7500. * @param name Name of the uniform, as used in the uniform block in the shader.
  7501. * @param vector Define the vec3 components from a Vector
  7502. */
  7503. addVector3(name: string, vector: Vector3): void;
  7504. /**
  7505. * Adds a Matrix 3x3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix3x3(name: string): void;
  7509. /**
  7510. * Adds a Matrix 2x2 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. */
  7513. addMatrix2x2(name: string): void;
  7514. /**
  7515. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7516. */
  7517. create(): void;
  7518. /** @hidden */
  7519. _rebuild(): void;
  7520. /**
  7521. * Updates the WebGL Uniform Buffer on the GPU.
  7522. * If the `dynamic` flag is set to true, no cache comparison is done.
  7523. * Otherwise, the buffer will be updated only if the cache differs.
  7524. */
  7525. update(): void;
  7526. /**
  7527. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7529. * @param data Define the flattened data
  7530. * @param size Define the size of the data.
  7531. */
  7532. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7533. private _valueCache;
  7534. private _cacheMatrix;
  7535. private _updateMatrix3x3ForUniform;
  7536. private _updateMatrix3x3ForEffect;
  7537. private _updateMatrix2x2ForEffect;
  7538. private _updateMatrix2x2ForUniform;
  7539. private _updateFloatForEffect;
  7540. private _updateFloatForUniform;
  7541. private _updateFloat2ForEffect;
  7542. private _updateFloat2ForUniform;
  7543. private _updateFloat3ForEffect;
  7544. private _updateFloat3ForUniform;
  7545. private _updateFloat4ForEffect;
  7546. private _updateFloat4ForUniform;
  7547. private _updateMatrixForEffect;
  7548. private _updateMatrixForUniform;
  7549. private _updateVector3ForEffect;
  7550. private _updateVector3ForUniform;
  7551. private _updateVector4ForEffect;
  7552. private _updateVector4ForUniform;
  7553. private _updateColor3ForEffect;
  7554. private _updateColor3ForUniform;
  7555. private _updateColor4ForEffect;
  7556. private _updateColor4ForUniform;
  7557. /**
  7558. * Sets a sampler uniform on the effect.
  7559. * @param name Define the name of the sampler.
  7560. * @param texture Define the texture to set in the sampler
  7561. */
  7562. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7563. /**
  7564. * Directly updates the value of the uniform in the cache AND on the GPU.
  7565. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7566. * @param data Define the flattened data
  7567. */
  7568. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7569. /**
  7570. * Binds this uniform buffer to an effect.
  7571. * @param effect Define the effect to bind the buffer to
  7572. * @param name Name of the uniform block in the shader.
  7573. */
  7574. bindToEffect(effect: Effect, name: string): void;
  7575. /**
  7576. * Disposes the uniform buffer.
  7577. */
  7578. dispose(): void;
  7579. }
  7580. }
  7581. declare module "babylonjs/Misc/iInspectable" {
  7582. /**
  7583. * Enum that determines the text-wrapping mode to use.
  7584. */
  7585. export enum InspectableType {
  7586. /**
  7587. * Checkbox for booleans
  7588. */
  7589. Checkbox = 0,
  7590. /**
  7591. * Sliders for numbers
  7592. */
  7593. Slider = 1,
  7594. /**
  7595. * Vector3
  7596. */
  7597. Vector3 = 2,
  7598. /**
  7599. * Quaternions
  7600. */
  7601. Quaternion = 3,
  7602. /**
  7603. * Color3
  7604. */
  7605. Color3 = 4,
  7606. /**
  7607. * String
  7608. */
  7609. String = 5
  7610. }
  7611. /**
  7612. * Interface used to define custom inspectable properties.
  7613. * This interface is used by the inspector to display custom property grids
  7614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7615. */
  7616. export interface IInspectable {
  7617. /**
  7618. * Gets the label to display
  7619. */
  7620. label: string;
  7621. /**
  7622. * Gets the name of the property to edit
  7623. */
  7624. propertyName: string;
  7625. /**
  7626. * Gets the type of the editor to use
  7627. */
  7628. type: InspectableType;
  7629. /**
  7630. * Gets the minimum value of the property when using in "slider" mode
  7631. */
  7632. min?: number;
  7633. /**
  7634. * Gets the maximum value of the property when using in "slider" mode
  7635. */
  7636. max?: number;
  7637. /**
  7638. * Gets the setp to use when using in "slider" mode
  7639. */
  7640. step?: number;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/timingTools" {
  7644. /**
  7645. * Class used to provide helper for timing
  7646. */
  7647. export class TimingTools {
  7648. /**
  7649. * Polyfill for setImmediate
  7650. * @param action defines the action to execute after the current execution block
  7651. */
  7652. static SetImmediate(action: () => void): void;
  7653. }
  7654. }
  7655. declare module "babylonjs/Misc/instantiationTools" {
  7656. /**
  7657. * Class used to enable instatition of objects by class name
  7658. */
  7659. export class InstantiationTools {
  7660. /**
  7661. * Use this object to register external classes like custom textures or material
  7662. * to allow the laoders to instantiate them
  7663. */
  7664. static RegisteredExternalClasses: {
  7665. [key: string]: Object;
  7666. };
  7667. /**
  7668. * Tries to instantiate a new object from a given class name
  7669. * @param className defines the class name to instantiate
  7670. * @returns the new object or null if the system was not able to do the instantiation
  7671. */
  7672. static Instantiate(className: string): any;
  7673. }
  7674. }
  7675. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7676. /**
  7677. * Define options used to create a depth texture
  7678. */
  7679. export class DepthTextureCreationOptions {
  7680. /** Specifies whether or not a stencil should be allocated in the texture */
  7681. generateStencil?: boolean;
  7682. /** Specifies whether or not bilinear filtering is enable on the texture */
  7683. bilinearFiltering?: boolean;
  7684. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7685. comparisonFunction?: number;
  7686. /** Specifies if the created texture is a cube texture */
  7687. isCube?: boolean;
  7688. }
  7689. }
  7690. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7692. import { Nullable } from "babylonjs/types";
  7693. import { Scene } from "babylonjs/scene";
  7694. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7695. module "babylonjs/Engines/thinEngine" {
  7696. interface ThinEngine {
  7697. /**
  7698. * Creates a depth stencil cube texture.
  7699. * This is only available in WebGL 2.
  7700. * @param size The size of face edge in the cube texture.
  7701. * @param options The options defining the cube texture.
  7702. * @returns The cube texture
  7703. */
  7704. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7719. * @returns the cube texture as an InternalTexture
  7720. */
  7721. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7735. /**
  7736. * Creates a cube texture
  7737. * @param rootUrl defines the url where the files to load is located
  7738. * @param scene defines the current scene
  7739. * @param files defines the list of files to load (1 per face)
  7740. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7741. * @param onLoad defines an optional callback raised when the texture is loaded
  7742. * @param onError defines an optional callback raised if there is an issue to load the texture
  7743. * @param format defines the format of the data
  7744. * @param forcedExtension defines the extension to use to pick the right loader
  7745. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7746. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7747. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7748. * @returns the cube texture as an InternalTexture
  7749. */
  7750. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7751. /** @hidden */
  7752. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7753. /** @hidden */
  7754. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7755. /** @hidden */
  7756. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7757. /** @hidden */
  7758. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7759. /**
  7760. * @hidden
  7761. */
  7762. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7763. }
  7764. }
  7765. }
  7766. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7767. import { Nullable } from "babylonjs/types";
  7768. import { Scene } from "babylonjs/scene";
  7769. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7771. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7772. import { Observable } from "babylonjs/Misc/observable";
  7773. /**
  7774. * Class for creating a cube texture
  7775. */
  7776. export class CubeTexture extends BaseTexture {
  7777. private _delayedOnLoad;
  7778. /**
  7779. * Observable triggered once the texture has been loaded.
  7780. */
  7781. onLoadObservable: Observable<CubeTexture>;
  7782. /**
  7783. * The url of the texture
  7784. */
  7785. url: string;
  7786. /**
  7787. * Gets or sets the center of the bounding box associated with the cube texture.
  7788. * It must define where the camera used to render the texture was set
  7789. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7790. */
  7791. boundingBoxPosition: Vector3;
  7792. private _boundingBoxSize;
  7793. /**
  7794. * Gets or sets the size of the bounding box associated with the cube texture
  7795. * When defined, the cubemap will switch to local mode
  7796. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7797. * @example https://www.babylonjs-playground.com/#RNASML
  7798. */
  7799. set boundingBoxSize(value: Vector3);
  7800. /**
  7801. * Returns the bounding box size
  7802. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7803. */
  7804. get boundingBoxSize(): Vector3;
  7805. protected _rotationY: number;
  7806. /**
  7807. * Sets texture matrix rotation angle around Y axis in radians.
  7808. */
  7809. set rotationY(value: number);
  7810. /**
  7811. * Gets texture matrix rotation angle around Y axis radians.
  7812. */
  7813. get rotationY(): number;
  7814. /**
  7815. * Are mip maps generated for this texture or not.
  7816. */
  7817. get noMipmap(): boolean;
  7818. private _noMipmap;
  7819. private _files;
  7820. protected _forcedExtension: Nullable<string>;
  7821. private _extensions;
  7822. private _textureMatrix;
  7823. private _format;
  7824. private _createPolynomials;
  7825. /** @hidden */
  7826. _prefiltered: boolean;
  7827. /**
  7828. * Creates a cube texture from an array of image urls
  7829. * @param files defines an array of image urls
  7830. * @param scene defines the hosting scene
  7831. * @param noMipmap specifies if mip maps are not used
  7832. * @returns a cube texture
  7833. */
  7834. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7835. /**
  7836. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7837. * @param url defines the url of the prefiltered texture
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param forcedExtension defines the extension of the file if different from the url
  7840. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7841. * @return the prefiltered texture
  7842. */
  7843. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7844. /**
  7845. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7846. * as prefiltered data.
  7847. * @param rootUrl defines the url of the texture or the root name of the six images
  7848. * @param scene defines the scene the texture is attached to
  7849. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7850. * @param noMipmap defines if mipmaps should be created or not
  7851. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7852. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7853. * @param onError defines a callback triggered in case of error during load
  7854. * @param format defines the internal format to use for the texture once loaded
  7855. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7856. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7857. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7858. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7859. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7860. * @return the cube texture
  7861. */
  7862. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7863. /**
  7864. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7865. */
  7866. get isPrefiltered(): boolean;
  7867. /**
  7868. * Get the current class name of the texture useful for serialization or dynamic coding.
  7869. * @returns "CubeTexture"
  7870. */
  7871. getClassName(): string;
  7872. /**
  7873. * Update the url (and optional buffer) of this texture if url was null during construction.
  7874. * @param url the url of the texture
  7875. * @param forcedExtension defines the extension to use
  7876. * @param onLoad callback called when the texture is loaded (defaults to null)
  7877. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7878. */
  7879. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7880. /**
  7881. * Delays loading of the cube texture
  7882. * @param forcedExtension defines the extension to use
  7883. */
  7884. delayLoad(forcedExtension?: string): void;
  7885. /**
  7886. * Returns the reflection texture matrix
  7887. * @returns the reflection texture matrix
  7888. */
  7889. getReflectionTextureMatrix(): Matrix;
  7890. /**
  7891. * Sets the reflection texture matrix
  7892. * @param value Reflection texture matrix
  7893. */
  7894. setReflectionTextureMatrix(value: Matrix): void;
  7895. /**
  7896. * Parses text to create a cube texture
  7897. * @param parsedTexture define the serialized text to read from
  7898. * @param scene defines the hosting scene
  7899. * @param rootUrl defines the root url of the cube texture
  7900. * @returns a cube texture
  7901. */
  7902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7903. /**
  7904. * Makes a clone, or deep copy, of the cube texture
  7905. * @returns a new cube texture
  7906. */
  7907. clone(): CubeTexture;
  7908. }
  7909. }
  7910. declare module "babylonjs/Materials/materialDefines" {
  7911. /**
  7912. * Manages the defines for the Material
  7913. */
  7914. export class MaterialDefines {
  7915. /** @hidden */
  7916. protected _keys: string[];
  7917. private _isDirty;
  7918. /** @hidden */
  7919. _renderId: number;
  7920. /** @hidden */
  7921. _areLightsDirty: boolean;
  7922. /** @hidden */
  7923. _areLightsDisposed: boolean;
  7924. /** @hidden */
  7925. _areAttributesDirty: boolean;
  7926. /** @hidden */
  7927. _areTexturesDirty: boolean;
  7928. /** @hidden */
  7929. _areFresnelDirty: boolean;
  7930. /** @hidden */
  7931. _areMiscDirty: boolean;
  7932. /** @hidden */
  7933. _areImageProcessingDirty: boolean;
  7934. /** @hidden */
  7935. _normals: boolean;
  7936. /** @hidden */
  7937. _uvs: boolean;
  7938. /** @hidden */
  7939. _needNormals: boolean;
  7940. /** @hidden */
  7941. _needUVs: boolean;
  7942. [id: string]: any;
  7943. /**
  7944. * Specifies if the material needs to be re-calculated
  7945. */
  7946. get isDirty(): boolean;
  7947. /**
  7948. * Marks the material to indicate that it has been re-calculated
  7949. */
  7950. markAsProcessed(): void;
  7951. /**
  7952. * Marks the material to indicate that it needs to be re-calculated
  7953. */
  7954. markAsUnprocessed(): void;
  7955. /**
  7956. * Marks the material to indicate all of its defines need to be re-calculated
  7957. */
  7958. markAllAsDirty(): void;
  7959. /**
  7960. * Marks the material to indicate that image processing needs to be re-calculated
  7961. */
  7962. markAsImageProcessingDirty(): void;
  7963. /**
  7964. * Marks the material to indicate the lights need to be re-calculated
  7965. * @param disposed Defines whether the light is dirty due to dispose or not
  7966. */
  7967. markAsLightDirty(disposed?: boolean): void;
  7968. /**
  7969. * Marks the attribute state as changed
  7970. */
  7971. markAsAttributesDirty(): void;
  7972. /**
  7973. * Marks the texture state as changed
  7974. */
  7975. markAsTexturesDirty(): void;
  7976. /**
  7977. * Marks the fresnel state as changed
  7978. */
  7979. markAsFresnelDirty(): void;
  7980. /**
  7981. * Marks the misc state as changed
  7982. */
  7983. markAsMiscDirty(): void;
  7984. /**
  7985. * Rebuilds the material defines
  7986. */
  7987. rebuild(): void;
  7988. /**
  7989. * Specifies if two material defines are equal
  7990. * @param other - A material define instance to compare to
  7991. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7992. */
  7993. isEqual(other: MaterialDefines): boolean;
  7994. /**
  7995. * Clones this instance's defines to another instance
  7996. * @param other - material defines to clone values to
  7997. */
  7998. cloneTo(other: MaterialDefines): void;
  7999. /**
  8000. * Resets the material define values
  8001. */
  8002. reset(): void;
  8003. /**
  8004. * Converts the material define values to a string
  8005. * @returns - String of material define information
  8006. */
  8007. toString(): string;
  8008. }
  8009. }
  8010. declare module "babylonjs/Materials/colorCurves" {
  8011. import { Effect } from "babylonjs/Materials/effect";
  8012. /**
  8013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8015. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8017. */
  8018. export class ColorCurves {
  8019. private _dirty;
  8020. private _tempColor;
  8021. private _globalCurve;
  8022. private _highlightsCurve;
  8023. private _midtonesCurve;
  8024. private _shadowsCurve;
  8025. private _positiveCurve;
  8026. private _negativeCurve;
  8027. private _globalHue;
  8028. private _globalDensity;
  8029. private _globalSaturation;
  8030. private _globalExposure;
  8031. /**
  8032. * Gets the global Hue value.
  8033. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8034. */
  8035. get globalHue(): number;
  8036. /**
  8037. * Sets the global Hue value.
  8038. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8039. */
  8040. set globalHue(value: number);
  8041. /**
  8042. * Gets the global Density value.
  8043. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. get globalDensity(): number;
  8047. /**
  8048. * Sets the global Density value.
  8049. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8050. * Values less than zero provide a filter of opposite hue.
  8051. */
  8052. set globalDensity(value: number);
  8053. /**
  8054. * Gets the global Saturation value.
  8055. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8056. */
  8057. get globalSaturation(): number;
  8058. /**
  8059. * Sets the global Saturation value.
  8060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8061. */
  8062. set globalSaturation(value: number);
  8063. /**
  8064. * Gets the global Exposure value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8066. */
  8067. get globalExposure(): number;
  8068. /**
  8069. * Sets the global Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. set globalExposure(value: number);
  8073. private _highlightsHue;
  8074. private _highlightsDensity;
  8075. private _highlightsSaturation;
  8076. private _highlightsExposure;
  8077. /**
  8078. * Gets the highlights Hue value.
  8079. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8080. */
  8081. get highlightsHue(): number;
  8082. /**
  8083. * Sets the highlights Hue value.
  8084. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8085. */
  8086. set highlightsHue(value: number);
  8087. /**
  8088. * Gets the highlights Density value.
  8089. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. get highlightsDensity(): number;
  8093. /**
  8094. * Sets the highlights Density value.
  8095. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8096. * Values less than zero provide a filter of opposite hue.
  8097. */
  8098. set highlightsDensity(value: number);
  8099. /**
  8100. * Gets the highlights Saturation value.
  8101. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8102. */
  8103. get highlightsSaturation(): number;
  8104. /**
  8105. * Sets the highlights Saturation value.
  8106. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8107. */
  8108. set highlightsSaturation(value: number);
  8109. /**
  8110. * Gets the highlights Exposure value.
  8111. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8112. */
  8113. get highlightsExposure(): number;
  8114. /**
  8115. * Sets the highlights Exposure value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8117. */
  8118. set highlightsExposure(value: number);
  8119. private _midtonesHue;
  8120. private _midtonesDensity;
  8121. private _midtonesSaturation;
  8122. private _midtonesExposure;
  8123. /**
  8124. * Gets the midtones Hue value.
  8125. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8126. */
  8127. get midtonesHue(): number;
  8128. /**
  8129. * Sets the midtones Hue value.
  8130. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8131. */
  8132. set midtonesHue(value: number);
  8133. /**
  8134. * Gets the midtones Density value.
  8135. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8136. * Values less than zero provide a filter of opposite hue.
  8137. */
  8138. get midtonesDensity(): number;
  8139. /**
  8140. * Sets the midtones Density value.
  8141. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8142. * Values less than zero provide a filter of opposite hue.
  8143. */
  8144. set midtonesDensity(value: number);
  8145. /**
  8146. * Gets the midtones Saturation value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8148. */
  8149. get midtonesSaturation(): number;
  8150. /**
  8151. * Sets the midtones Saturation value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8153. */
  8154. set midtonesSaturation(value: number);
  8155. /**
  8156. * Gets the midtones Exposure value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8158. */
  8159. get midtonesExposure(): number;
  8160. /**
  8161. * Sets the midtones Exposure value.
  8162. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8163. */
  8164. set midtonesExposure(value: number);
  8165. private _shadowsHue;
  8166. private _shadowsDensity;
  8167. private _shadowsSaturation;
  8168. private _shadowsExposure;
  8169. /**
  8170. * Gets the shadows Hue value.
  8171. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8172. */
  8173. get shadowsHue(): number;
  8174. /**
  8175. * Sets the shadows Hue value.
  8176. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8177. */
  8178. set shadowsHue(value: number);
  8179. /**
  8180. * Gets the shadows Density value.
  8181. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8182. * Values less than zero provide a filter of opposite hue.
  8183. */
  8184. get shadowsDensity(): number;
  8185. /**
  8186. * Sets the shadows Density value.
  8187. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8188. * Values less than zero provide a filter of opposite hue.
  8189. */
  8190. set shadowsDensity(value: number);
  8191. /**
  8192. * Gets the shadows Saturation value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8194. */
  8195. get shadowsSaturation(): number;
  8196. /**
  8197. * Sets the shadows Saturation value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8199. */
  8200. set shadowsSaturation(value: number);
  8201. /**
  8202. * Gets the shadows Exposure value.
  8203. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8204. */
  8205. get shadowsExposure(): number;
  8206. /**
  8207. * Sets the shadows Exposure value.
  8208. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8209. */
  8210. set shadowsExposure(value: number);
  8211. /**
  8212. * Returns the class name
  8213. * @returns The class name
  8214. */
  8215. getClassName(): string;
  8216. /**
  8217. * Binds the color curves to the shader.
  8218. * @param colorCurves The color curve to bind
  8219. * @param effect The effect to bind to
  8220. * @param positiveUniform The positive uniform shader parameter
  8221. * @param neutralUniform The neutral uniform shader parameter
  8222. * @param negativeUniform The negative uniform shader parameter
  8223. */
  8224. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8225. /**
  8226. * Prepare the list of uniforms associated with the ColorCurves effects.
  8227. * @param uniformsList The list of uniforms used in the effect
  8228. */
  8229. static PrepareUniforms(uniformsList: string[]): void;
  8230. /**
  8231. * Returns color grading data based on a hue, density, saturation and exposure value.
  8232. * @param filterHue The hue of the color filter.
  8233. * @param filterDensity The density of the color filter.
  8234. * @param saturation The saturation.
  8235. * @param exposure The exposure.
  8236. * @param result The result data container.
  8237. */
  8238. private getColorGradingDataToRef;
  8239. /**
  8240. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8241. * @param value The input slider value in range [-100,100].
  8242. * @returns Adjusted value.
  8243. */
  8244. private static applyColorGradingSliderNonlinear;
  8245. /**
  8246. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8247. * @param hue The hue (H) input.
  8248. * @param saturation The saturation (S) input.
  8249. * @param brightness The brightness (B) input.
  8250. * @result An RGBA color represented as Vector4.
  8251. */
  8252. private static fromHSBToRef;
  8253. /**
  8254. * Returns a value clamped between min and max
  8255. * @param value The value to clamp
  8256. * @param min The minimum of value
  8257. * @param max The maximum of value
  8258. * @returns The clamped value.
  8259. */
  8260. private static clamp;
  8261. /**
  8262. * Clones the current color curve instance.
  8263. * @return The cloned curves
  8264. */
  8265. clone(): ColorCurves;
  8266. /**
  8267. * Serializes the current color curve instance to a json representation.
  8268. * @return a JSON representation
  8269. */
  8270. serialize(): any;
  8271. /**
  8272. * Parses the color curve from a json representation.
  8273. * @param source the JSON source to parse
  8274. * @return The parsed curves
  8275. */
  8276. static Parse(source: any): ColorCurves;
  8277. }
  8278. }
  8279. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8280. import { Observable } from "babylonjs/Misc/observable";
  8281. import { Nullable } from "babylonjs/types";
  8282. import { Color4 } from "babylonjs/Maths/math.color";
  8283. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8284. import { Effect } from "babylonjs/Materials/effect";
  8285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8286. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8287. /**
  8288. * Interface to follow in your material defines to integrate easily the
  8289. * Image proccessing functions.
  8290. * @hidden
  8291. */
  8292. export interface IImageProcessingConfigurationDefines {
  8293. IMAGEPROCESSING: boolean;
  8294. VIGNETTE: boolean;
  8295. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8296. VIGNETTEBLENDMODEOPAQUE: boolean;
  8297. TONEMAPPING: boolean;
  8298. TONEMAPPING_ACES: boolean;
  8299. CONTRAST: boolean;
  8300. EXPOSURE: boolean;
  8301. COLORCURVES: boolean;
  8302. COLORGRADING: boolean;
  8303. COLORGRADING3D: boolean;
  8304. SAMPLER3DGREENDEPTH: boolean;
  8305. SAMPLER3DBGRMAP: boolean;
  8306. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8307. }
  8308. /**
  8309. * @hidden
  8310. */
  8311. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8312. IMAGEPROCESSING: boolean;
  8313. VIGNETTE: boolean;
  8314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8315. VIGNETTEBLENDMODEOPAQUE: boolean;
  8316. TONEMAPPING: boolean;
  8317. TONEMAPPING_ACES: boolean;
  8318. CONTRAST: boolean;
  8319. COLORCURVES: boolean;
  8320. COLORGRADING: boolean;
  8321. COLORGRADING3D: boolean;
  8322. SAMPLER3DGREENDEPTH: boolean;
  8323. SAMPLER3DBGRMAP: boolean;
  8324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8325. EXPOSURE: boolean;
  8326. constructor();
  8327. }
  8328. /**
  8329. * This groups together the common properties used for image processing either in direct forward pass
  8330. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8331. * or not.
  8332. */
  8333. export class ImageProcessingConfiguration {
  8334. /**
  8335. * Default tone mapping applied in BabylonJS.
  8336. */
  8337. static readonly TONEMAPPING_STANDARD: number;
  8338. /**
  8339. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8340. * to other engines rendering to increase portability.
  8341. */
  8342. static readonly TONEMAPPING_ACES: number;
  8343. /**
  8344. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8345. */
  8346. colorCurves: Nullable<ColorCurves>;
  8347. private _colorCurvesEnabled;
  8348. /**
  8349. * Gets wether the color curves effect is enabled.
  8350. */
  8351. get colorCurvesEnabled(): boolean;
  8352. /**
  8353. * Sets wether the color curves effect is enabled.
  8354. */
  8355. set colorCurvesEnabled(value: boolean);
  8356. private _colorGradingTexture;
  8357. /**
  8358. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8359. */
  8360. get colorGradingTexture(): Nullable<BaseTexture>;
  8361. /**
  8362. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8363. */
  8364. set colorGradingTexture(value: Nullable<BaseTexture>);
  8365. private _colorGradingEnabled;
  8366. /**
  8367. * Gets wether the color grading effect is enabled.
  8368. */
  8369. get colorGradingEnabled(): boolean;
  8370. /**
  8371. * Sets wether the color grading effect is enabled.
  8372. */
  8373. set colorGradingEnabled(value: boolean);
  8374. private _colorGradingWithGreenDepth;
  8375. /**
  8376. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8377. */
  8378. get colorGradingWithGreenDepth(): boolean;
  8379. /**
  8380. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8381. */
  8382. set colorGradingWithGreenDepth(value: boolean);
  8383. private _colorGradingBGR;
  8384. /**
  8385. * Gets wether the color grading texture contains BGR values.
  8386. */
  8387. get colorGradingBGR(): boolean;
  8388. /**
  8389. * Sets wether the color grading texture contains BGR values.
  8390. */
  8391. set colorGradingBGR(value: boolean);
  8392. /** @hidden */
  8393. _exposure: number;
  8394. /**
  8395. * Gets the Exposure used in the effect.
  8396. */
  8397. get exposure(): number;
  8398. /**
  8399. * Sets the Exposure used in the effect.
  8400. */
  8401. set exposure(value: number);
  8402. private _toneMappingEnabled;
  8403. /**
  8404. * Gets wether the tone mapping effect is enabled.
  8405. */
  8406. get toneMappingEnabled(): boolean;
  8407. /**
  8408. * Sets wether the tone mapping effect is enabled.
  8409. */
  8410. set toneMappingEnabled(value: boolean);
  8411. private _toneMappingType;
  8412. /**
  8413. * Gets the type of tone mapping effect.
  8414. */
  8415. get toneMappingType(): number;
  8416. /**
  8417. * Sets the type of tone mapping effect used in BabylonJS.
  8418. */
  8419. set toneMappingType(value: number);
  8420. protected _contrast: number;
  8421. /**
  8422. * Gets the contrast used in the effect.
  8423. */
  8424. get contrast(): number;
  8425. /**
  8426. * Sets the contrast used in the effect.
  8427. */
  8428. set contrast(value: number);
  8429. /**
  8430. * Vignette stretch size.
  8431. */
  8432. vignetteStretch: number;
  8433. /**
  8434. * Vignette centre X Offset.
  8435. */
  8436. vignetteCentreX: number;
  8437. /**
  8438. * Vignette centre Y Offset.
  8439. */
  8440. vignetteCentreY: number;
  8441. /**
  8442. * Vignette weight or intensity of the vignette effect.
  8443. */
  8444. vignetteWeight: number;
  8445. /**
  8446. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8447. * if vignetteEnabled is set to true.
  8448. */
  8449. vignetteColor: Color4;
  8450. /**
  8451. * Camera field of view used by the Vignette effect.
  8452. */
  8453. vignetteCameraFov: number;
  8454. private _vignetteBlendMode;
  8455. /**
  8456. * Gets the vignette blend mode allowing different kind of effect.
  8457. */
  8458. get vignetteBlendMode(): number;
  8459. /**
  8460. * Sets the vignette blend mode allowing different kind of effect.
  8461. */
  8462. set vignetteBlendMode(value: number);
  8463. private _vignetteEnabled;
  8464. /**
  8465. * Gets wether the vignette effect is enabled.
  8466. */
  8467. get vignetteEnabled(): boolean;
  8468. /**
  8469. * Sets wether the vignette effect is enabled.
  8470. */
  8471. set vignetteEnabled(value: boolean);
  8472. private _applyByPostProcess;
  8473. /**
  8474. * Gets wether the image processing is applied through a post process or not.
  8475. */
  8476. get applyByPostProcess(): boolean;
  8477. /**
  8478. * Sets wether the image processing is applied through a post process or not.
  8479. */
  8480. set applyByPostProcess(value: boolean);
  8481. private _isEnabled;
  8482. /**
  8483. * Gets wether the image processing is enabled or not.
  8484. */
  8485. get isEnabled(): boolean;
  8486. /**
  8487. * Sets wether the image processing is enabled or not.
  8488. */
  8489. set isEnabled(value: boolean);
  8490. /**
  8491. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8492. */
  8493. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8494. /**
  8495. * Method called each time the image processing information changes requires to recompile the effect.
  8496. */
  8497. protected _updateParameters(): void;
  8498. /**
  8499. * Gets the current class name.
  8500. * @return "ImageProcessingConfiguration"
  8501. */
  8502. getClassName(): string;
  8503. /**
  8504. * Prepare the list of uniforms associated with the Image Processing effects.
  8505. * @param uniforms The list of uniforms used in the effect
  8506. * @param defines the list of defines currently in use
  8507. */
  8508. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8509. /**
  8510. * Prepare the list of samplers associated with the Image Processing effects.
  8511. * @param samplersList The list of uniforms used in the effect
  8512. * @param defines the list of defines currently in use
  8513. */
  8514. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8515. /**
  8516. * Prepare the list of defines associated to the shader.
  8517. * @param defines the list of defines to complete
  8518. * @param forPostProcess Define if we are currently in post process mode or not
  8519. */
  8520. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8521. /**
  8522. * Returns true if all the image processing information are ready.
  8523. * @returns True if ready, otherwise, false
  8524. */
  8525. isReady(): boolean;
  8526. /**
  8527. * Binds the image processing to the shader.
  8528. * @param effect The effect to bind to
  8529. * @param overrideAspectRatio Override the aspect ratio of the effect
  8530. */
  8531. bind(effect: Effect, overrideAspectRatio?: number): void;
  8532. /**
  8533. * Clones the current image processing instance.
  8534. * @return The cloned image processing
  8535. */
  8536. clone(): ImageProcessingConfiguration;
  8537. /**
  8538. * Serializes the current image processing instance to a json representation.
  8539. * @return a JSON representation
  8540. */
  8541. serialize(): any;
  8542. /**
  8543. * Parses the image processing from a json representation.
  8544. * @param source the JSON source to parse
  8545. * @return The parsed image processing
  8546. */
  8547. static Parse(source: any): ImageProcessingConfiguration;
  8548. private static _VIGNETTEMODE_MULTIPLY;
  8549. private static _VIGNETTEMODE_OPAQUE;
  8550. /**
  8551. * Used to apply the vignette as a mix with the pixel color.
  8552. */
  8553. static get VIGNETTEMODE_MULTIPLY(): number;
  8554. /**
  8555. * Used to apply the vignette as a replacement of the pixel color.
  8556. */
  8557. static get VIGNETTEMODE_OPAQUE(): number;
  8558. }
  8559. }
  8560. declare module "babylonjs/Shaders/postprocess.vertex" {
  8561. /** @hidden */
  8562. export var postprocessVertexShader: {
  8563. name: string;
  8564. shader: string;
  8565. };
  8566. }
  8567. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8568. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8569. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8570. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8571. module "babylonjs/Engines/thinEngine" {
  8572. interface ThinEngine {
  8573. /**
  8574. * Creates a new render target texture
  8575. * @param size defines the size of the texture
  8576. * @param options defines the options used to create the texture
  8577. * @returns a new render target texture stored in an InternalTexture
  8578. */
  8579. createRenderTargetTexture(size: number | {
  8580. width: number;
  8581. height: number;
  8582. layers?: number;
  8583. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8584. /**
  8585. * Creates a depth stencil texture.
  8586. * This is only available in WebGL 2 or with the depth texture extension available.
  8587. * @param size The size of face edge in the texture.
  8588. * @param options The options defining the texture.
  8589. * @returns The texture
  8590. */
  8591. createDepthStencilTexture(size: number | {
  8592. width: number;
  8593. height: number;
  8594. layers?: number;
  8595. }, options: DepthTextureCreationOptions): InternalTexture;
  8596. /** @hidden */
  8597. _createDepthStencilTexture(size: number | {
  8598. width: number;
  8599. height: number;
  8600. layers?: number;
  8601. }, options: DepthTextureCreationOptions): InternalTexture;
  8602. }
  8603. }
  8604. }
  8605. declare module "babylonjs/Maths/math.axis" {
  8606. import { Vector3 } from "babylonjs/Maths/math.vector";
  8607. /** Defines supported spaces */
  8608. export enum Space {
  8609. /** Local (object) space */
  8610. LOCAL = 0,
  8611. /** World space */
  8612. WORLD = 1,
  8613. /** Bone space */
  8614. BONE = 2
  8615. }
  8616. /** Defines the 3 main axes */
  8617. export class Axis {
  8618. /** X axis */
  8619. static X: Vector3;
  8620. /** Y axis */
  8621. static Y: Vector3;
  8622. /** Z axis */
  8623. static Z: Vector3;
  8624. }
  8625. }
  8626. declare module "babylonjs/Cameras/targetCamera" {
  8627. import { Nullable } from "babylonjs/types";
  8628. import { Camera } from "babylonjs/Cameras/camera";
  8629. import { Scene } from "babylonjs/scene";
  8630. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8631. /**
  8632. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8633. * This is the base of the follow, arc rotate cameras and Free camera
  8634. * @see http://doc.babylonjs.com/features/cameras
  8635. */
  8636. export class TargetCamera extends Camera {
  8637. private static _RigCamTransformMatrix;
  8638. private static _TargetTransformMatrix;
  8639. private static _TargetFocalPoint;
  8640. /**
  8641. * Define the current direction the camera is moving to
  8642. */
  8643. cameraDirection: Vector3;
  8644. /**
  8645. * Define the current rotation the camera is rotating to
  8646. */
  8647. cameraRotation: Vector2;
  8648. /**
  8649. * When set, the up vector of the camera will be updated by the rotation of the camera
  8650. */
  8651. updateUpVectorFromRotation: boolean;
  8652. private _tmpQuaternion;
  8653. /**
  8654. * Define the current rotation of the camera
  8655. */
  8656. rotation: Vector3;
  8657. /**
  8658. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8659. */
  8660. rotationQuaternion: Quaternion;
  8661. /**
  8662. * Define the current speed of the camera
  8663. */
  8664. speed: number;
  8665. /**
  8666. * Add constraint to the camera to prevent it to move freely in all directions and
  8667. * around all axis.
  8668. */
  8669. noRotationConstraint: boolean;
  8670. /**
  8671. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8672. * panning
  8673. */
  8674. invertRotation: boolean;
  8675. /**
  8676. * Speed multiplier for inverse camera panning
  8677. */
  8678. inverseRotationSpeed: number;
  8679. /**
  8680. * Define the current target of the camera as an object or a position.
  8681. */
  8682. lockedTarget: any;
  8683. /** @hidden */
  8684. _currentTarget: Vector3;
  8685. /** @hidden */
  8686. _initialFocalDistance: number;
  8687. /** @hidden */
  8688. _viewMatrix: Matrix;
  8689. /** @hidden */
  8690. _camMatrix: Matrix;
  8691. /** @hidden */
  8692. _cameraTransformMatrix: Matrix;
  8693. /** @hidden */
  8694. _cameraRotationMatrix: Matrix;
  8695. /** @hidden */
  8696. _referencePoint: Vector3;
  8697. /** @hidden */
  8698. _transformedReferencePoint: Vector3;
  8699. protected _globalCurrentTarget: Vector3;
  8700. protected _globalCurrentUpVector: Vector3;
  8701. /** @hidden */
  8702. _reset: () => void;
  8703. private _defaultUp;
  8704. /**
  8705. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8706. * This is the base of the follow, arc rotate cameras and Free camera
  8707. * @see http://doc.babylonjs.com/features/cameras
  8708. * @param name Defines the name of the camera in the scene
  8709. * @param position Defines the start position of the camera in the scene
  8710. * @param scene Defines the scene the camera belongs to
  8711. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8712. */
  8713. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8714. /**
  8715. * Gets the position in front of the camera at a given distance.
  8716. * @param distance The distance from the camera we want the position to be
  8717. * @returns the position
  8718. */
  8719. getFrontPosition(distance: number): Vector3;
  8720. /** @hidden */
  8721. _getLockedTargetPosition(): Nullable<Vector3>;
  8722. private _storedPosition;
  8723. private _storedRotation;
  8724. private _storedRotationQuaternion;
  8725. /**
  8726. * Store current camera state of the camera (fov, position, rotation, etc..)
  8727. * @returns the camera
  8728. */
  8729. storeState(): Camera;
  8730. /**
  8731. * Restored camera state. You must call storeState() first
  8732. * @returns whether it was successful or not
  8733. * @hidden
  8734. */
  8735. _restoreStateValues(): boolean;
  8736. /** @hidden */
  8737. _initCache(): void;
  8738. /** @hidden */
  8739. _updateCache(ignoreParentClass?: boolean): void;
  8740. /** @hidden */
  8741. _isSynchronizedViewMatrix(): boolean;
  8742. /** @hidden */
  8743. _computeLocalCameraSpeed(): number;
  8744. /**
  8745. * Defines the target the camera should look at.
  8746. * @param target Defines the new target as a Vector or a mesh
  8747. */
  8748. setTarget(target: Vector3): void;
  8749. /**
  8750. * Return the current target position of the camera. This value is expressed in local space.
  8751. * @returns the target position
  8752. */
  8753. getTarget(): Vector3;
  8754. /** @hidden */
  8755. _decideIfNeedsToMove(): boolean;
  8756. /** @hidden */
  8757. _updatePosition(): void;
  8758. /** @hidden */
  8759. _checkInputs(): void;
  8760. protected _updateCameraRotationMatrix(): void;
  8761. /**
  8762. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8763. * @returns the current camera
  8764. */
  8765. private _rotateUpVectorWithCameraRotationMatrix;
  8766. private _cachedRotationZ;
  8767. private _cachedQuaternionRotationZ;
  8768. /** @hidden */
  8769. _getViewMatrix(): Matrix;
  8770. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8771. /**
  8772. * @hidden
  8773. */
  8774. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8775. /**
  8776. * @hidden
  8777. */
  8778. _updateRigCameras(): void;
  8779. private _getRigCamPositionAndTarget;
  8780. /**
  8781. * Gets the current object class name.
  8782. * @return the class name
  8783. */
  8784. getClassName(): string;
  8785. }
  8786. }
  8787. declare module "babylonjs/Events/keyboardEvents" {
  8788. /**
  8789. * Gather the list of keyboard event types as constants.
  8790. */
  8791. export class KeyboardEventTypes {
  8792. /**
  8793. * The keydown event is fired when a key becomes active (pressed).
  8794. */
  8795. static readonly KEYDOWN: number;
  8796. /**
  8797. * The keyup event is fired when a key has been released.
  8798. */
  8799. static readonly KEYUP: number;
  8800. }
  8801. /**
  8802. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8803. */
  8804. export class KeyboardInfo {
  8805. /**
  8806. * Defines the type of event (KeyboardEventTypes)
  8807. */
  8808. type: number;
  8809. /**
  8810. * Defines the related dom event
  8811. */
  8812. event: KeyboardEvent;
  8813. /**
  8814. * Instantiates a new keyboard info.
  8815. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. /**
  8830. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8831. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8832. */
  8833. export class KeyboardInfoPre extends KeyboardInfo {
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number;
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent;
  8842. /**
  8843. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8844. */
  8845. skipOnPointerObservable: boolean;
  8846. /**
  8847. * Instantiates a new keyboard pre info.
  8848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8849. * @param type Defines the type of event (KeyboardEventTypes)
  8850. * @param event Defines the related dom event
  8851. */
  8852. constructor(
  8853. /**
  8854. * Defines the type of event (KeyboardEventTypes)
  8855. */
  8856. type: number,
  8857. /**
  8858. * Defines the related dom event
  8859. */
  8860. event: KeyboardEvent);
  8861. }
  8862. }
  8863. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8864. import { Nullable } from "babylonjs/types";
  8865. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8867. /**
  8868. * Manage the keyboard inputs to control the movement of a free camera.
  8869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8870. */
  8871. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8872. /**
  8873. * Defines the camera the input is attached to.
  8874. */
  8875. camera: FreeCamera;
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8878. */
  8879. keysUp: number[];
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8882. */
  8883. keysUpward: number[];
  8884. /**
  8885. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8886. */
  8887. keysDown: number[];
  8888. /**
  8889. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8890. */
  8891. keysDownward: number[];
  8892. /**
  8893. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8894. */
  8895. keysLeft: number[];
  8896. /**
  8897. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8898. */
  8899. keysRight: number[];
  8900. private _keys;
  8901. private _onCanvasBlurObserver;
  8902. private _onKeyboardObserver;
  8903. private _engine;
  8904. private _scene;
  8905. /**
  8906. * Attach the input controls to a specific dom element to get the input from.
  8907. * @param element Defines the element the controls should be listened from
  8908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8909. */
  8910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8911. /**
  8912. * Detach the current controls from the specified dom element.
  8913. * @param element Defines the element to stop listening the inputs from
  8914. */
  8915. detachControl(element: Nullable<HTMLElement>): void;
  8916. /**
  8917. * Update the current camera state depending on the inputs that have been used this frame.
  8918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8919. */
  8920. checkInputs(): void;
  8921. /**
  8922. * Gets the class name of the current intput.
  8923. * @returns the class name
  8924. */
  8925. getClassName(): string;
  8926. /** @hidden */
  8927. _onLostFocus(): void;
  8928. /**
  8929. * Get the friendly name associated with the input class.
  8930. * @returns the input friendly name
  8931. */
  8932. getSimpleName(): string;
  8933. }
  8934. }
  8935. declare module "babylonjs/Lights/shadowLight" {
  8936. import { Camera } from "babylonjs/Cameras/camera";
  8937. import { Scene } from "babylonjs/scene";
  8938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8940. import { Light } from "babylonjs/Lights/light";
  8941. /**
  8942. * Interface describing all the common properties and methods a shadow light needs to implement.
  8943. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8944. * as well as binding the different shadow properties to the effects.
  8945. */
  8946. export interface IShadowLight extends Light {
  8947. /**
  8948. * The light id in the scene (used in scene.findLighById for instance)
  8949. */
  8950. id: string;
  8951. /**
  8952. * The position the shdow will be casted from.
  8953. */
  8954. position: Vector3;
  8955. /**
  8956. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8957. */
  8958. direction: Vector3;
  8959. /**
  8960. * The transformed position. Position of the light in world space taking parenting in account.
  8961. */
  8962. transformedPosition: Vector3;
  8963. /**
  8964. * The transformed direction. Direction of the light in world space taking parenting in account.
  8965. */
  8966. transformedDirection: Vector3;
  8967. /**
  8968. * The friendly name of the light in the scene.
  8969. */
  8970. name: string;
  8971. /**
  8972. * Defines the shadow projection clipping minimum z value.
  8973. */
  8974. shadowMinZ: number;
  8975. /**
  8976. * Defines the shadow projection clipping maximum z value.
  8977. */
  8978. shadowMaxZ: number;
  8979. /**
  8980. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8981. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8982. */
  8983. computeTransformedInformation(): boolean;
  8984. /**
  8985. * Gets the scene the light belongs to.
  8986. * @returns The scene
  8987. */
  8988. getScene(): Scene;
  8989. /**
  8990. * Callback defining a custom Projection Matrix Builder.
  8991. * This can be used to override the default projection matrix computation.
  8992. */
  8993. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8994. /**
  8995. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8996. * @param matrix The materix to updated with the projection information
  8997. * @param viewMatrix The transform matrix of the light
  8998. * @param renderList The list of mesh to render in the map
  8999. * @returns The current light
  9000. */
  9001. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9002. /**
  9003. * Gets the current depth scale used in ESM.
  9004. * @returns The scale
  9005. */
  9006. getDepthScale(): number;
  9007. /**
  9008. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9009. * @returns true if a cube texture needs to be use
  9010. */
  9011. needCube(): boolean;
  9012. /**
  9013. * Detects if the projection matrix requires to be recomputed this frame.
  9014. * @returns true if it requires to be recomputed otherwise, false.
  9015. */
  9016. needProjectionMatrixCompute(): boolean;
  9017. /**
  9018. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9019. */
  9020. forceProjectionMatrixCompute(): void;
  9021. /**
  9022. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9023. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9024. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9025. */
  9026. getShadowDirection(faceIndex?: number): Vector3;
  9027. /**
  9028. * Gets the minZ used for shadow according to both the scene and the light.
  9029. * @param activeCamera The camera we are returning the min for
  9030. * @returns the depth min z
  9031. */
  9032. getDepthMinZ(activeCamera: Camera): number;
  9033. /**
  9034. * Gets the maxZ used for shadow according to both the scene and the light.
  9035. * @param activeCamera The camera we are returning the max for
  9036. * @returns the depth max z
  9037. */
  9038. getDepthMaxZ(activeCamera: Camera): number;
  9039. }
  9040. /**
  9041. * Base implementation IShadowLight
  9042. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9043. */
  9044. export abstract class ShadowLight extends Light implements IShadowLight {
  9045. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9046. protected _position: Vector3;
  9047. protected _setPosition(value: Vector3): void;
  9048. /**
  9049. * Sets the position the shadow will be casted from. Also use as the light position for both
  9050. * point and spot lights.
  9051. */
  9052. get position(): Vector3;
  9053. /**
  9054. * Sets the position the shadow will be casted from. Also use as the light position for both
  9055. * point and spot lights.
  9056. */
  9057. set position(value: Vector3);
  9058. protected _direction: Vector3;
  9059. protected _setDirection(value: Vector3): void;
  9060. /**
  9061. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9062. * Also use as the light direction on spot and directional lights.
  9063. */
  9064. get direction(): Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9067. * Also use as the light direction on spot and directional lights.
  9068. */
  9069. set direction(value: Vector3);
  9070. protected _shadowMinZ: number;
  9071. /**
  9072. * Gets the shadow projection clipping minimum z value.
  9073. */
  9074. get shadowMinZ(): number;
  9075. /**
  9076. * Sets the shadow projection clipping minimum z value.
  9077. */
  9078. set shadowMinZ(value: number);
  9079. protected _shadowMaxZ: number;
  9080. /**
  9081. * Sets the shadow projection clipping maximum z value.
  9082. */
  9083. get shadowMaxZ(): number;
  9084. /**
  9085. * Gets the shadow projection clipping maximum z value.
  9086. */
  9087. set shadowMaxZ(value: number);
  9088. /**
  9089. * Callback defining a custom Projection Matrix Builder.
  9090. * This can be used to override the default projection matrix computation.
  9091. */
  9092. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9093. /**
  9094. * The transformed position. Position of the light in world space taking parenting in account.
  9095. */
  9096. transformedPosition: Vector3;
  9097. /**
  9098. * The transformed direction. Direction of the light in world space taking parenting in account.
  9099. */
  9100. transformedDirection: Vector3;
  9101. private _needProjectionMatrixCompute;
  9102. /**
  9103. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9104. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9105. */
  9106. computeTransformedInformation(): boolean;
  9107. /**
  9108. * Return the depth scale used for the shadow map.
  9109. * @returns the depth scale.
  9110. */
  9111. getDepthScale(): number;
  9112. /**
  9113. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9114. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9115. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9116. */
  9117. getShadowDirection(faceIndex?: number): Vector3;
  9118. /**
  9119. * Returns the ShadowLight absolute position in the World.
  9120. * @returns the position vector in world space
  9121. */
  9122. getAbsolutePosition(): Vector3;
  9123. /**
  9124. * Sets the ShadowLight direction toward the passed target.
  9125. * @param target The point to target in local space
  9126. * @returns the updated ShadowLight direction
  9127. */
  9128. setDirectionToTarget(target: Vector3): Vector3;
  9129. /**
  9130. * Returns the light rotation in euler definition.
  9131. * @returns the x y z rotation in local space.
  9132. */
  9133. getRotation(): Vector3;
  9134. /**
  9135. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9136. * @returns true if a cube texture needs to be use
  9137. */
  9138. needCube(): boolean;
  9139. /**
  9140. * Detects if the projection matrix requires to be recomputed this frame.
  9141. * @returns true if it requires to be recomputed otherwise, false.
  9142. */
  9143. needProjectionMatrixCompute(): boolean;
  9144. /**
  9145. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9146. */
  9147. forceProjectionMatrixCompute(): void;
  9148. /** @hidden */
  9149. _initCache(): void;
  9150. /** @hidden */
  9151. _isSynchronized(): boolean;
  9152. /**
  9153. * Computes the world matrix of the node
  9154. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9155. * @returns the world matrix
  9156. */
  9157. computeWorldMatrix(force?: boolean): Matrix;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. /**
  9171. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9172. * @param matrix The materix to updated with the projection information
  9173. * @param viewMatrix The transform matrix of the light
  9174. * @param renderList The list of mesh to render in the map
  9175. * @returns The current light
  9176. */
  9177. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9178. }
  9179. }
  9180. declare module "babylonjs/Materials/effectFallbacks" {
  9181. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9182. import { Effect } from "babylonjs/Materials/effect";
  9183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9184. /**
  9185. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9186. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9187. */
  9188. export class EffectFallbacks implements IEffectFallbacks {
  9189. private _defines;
  9190. private _currentRank;
  9191. private _maxRank;
  9192. private _mesh;
  9193. /**
  9194. * Removes the fallback from the bound mesh.
  9195. */
  9196. unBindMesh(): void;
  9197. /**
  9198. * Adds a fallback on the specified property.
  9199. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9200. * @param define The name of the define in the shader
  9201. */
  9202. addFallback(rank: number, define: string): void;
  9203. /**
  9204. * Sets the mesh to use CPU skinning when needing to fallback.
  9205. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9206. * @param mesh The mesh to use the fallbacks.
  9207. */
  9208. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9209. /**
  9210. * Checks to see if more fallbacks are still availible.
  9211. */
  9212. get hasMoreFallbacks(): boolean;
  9213. /**
  9214. * Removes the defines that should be removed when falling back.
  9215. * @param currentDefines defines the current define statements for the shader.
  9216. * @param effect defines the current effect we try to compile
  9217. * @returns The resulting defines with defines of the current rank removed.
  9218. */
  9219. reduce(currentDefines: string, effect: Effect): string;
  9220. }
  9221. }
  9222. declare module "babylonjs/Materials/materialHelper" {
  9223. import { Nullable } from "babylonjs/types";
  9224. import { Scene } from "babylonjs/scene";
  9225. import { Engine } from "babylonjs/Engines/engine";
  9226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9227. import { Light } from "babylonjs/Lights/light";
  9228. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9229. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9231. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9232. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9233. /**
  9234. * "Static Class" containing the most commonly used helper while dealing with material for
  9235. * rendering purpose.
  9236. *
  9237. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9238. *
  9239. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9240. */
  9241. export class MaterialHelper {
  9242. /**
  9243. * Bind the current view position to an effect.
  9244. * @param effect The effect to be bound
  9245. * @param scene The scene the eyes position is used from
  9246. */
  9247. static BindEyePosition(effect: Effect, scene: Scene): void;
  9248. /**
  9249. * Helps preparing the defines values about the UVs in used in the effect.
  9250. * UVs are shared as much as we can accross channels in the shaders.
  9251. * @param texture The texture we are preparing the UVs for
  9252. * @param defines The defines to update
  9253. * @param key The channel key "diffuse", "specular"... used in the shader
  9254. */
  9255. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9256. /**
  9257. * Binds a texture matrix value to its corrsponding uniform
  9258. * @param texture The texture to bind the matrix for
  9259. * @param uniformBuffer The uniform buffer receivin the data
  9260. * @param key The channel key "diffuse", "specular"... used in the shader
  9261. */
  9262. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9263. /**
  9264. * Gets the current status of the fog (should it be enabled?)
  9265. * @param mesh defines the mesh to evaluate for fog support
  9266. * @param scene defines the hosting scene
  9267. * @returns true if fog must be enabled
  9268. */
  9269. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9270. /**
  9271. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9272. * @param mesh defines the current mesh
  9273. * @param scene defines the current scene
  9274. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9275. * @param pointsCloud defines if point cloud rendering has to be turned on
  9276. * @param fogEnabled defines if fog has to be turned on
  9277. * @param alphaTest defines if alpha testing has to be turned on
  9278. * @param defines defines the current list of defines
  9279. */
  9280. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9281. /**
  9282. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9283. * @param scene defines the current scene
  9284. * @param engine defines the current engine
  9285. * @param defines specifies the list of active defines
  9286. * @param useInstances defines if instances have to be turned on
  9287. * @param useClipPlane defines if clip plane have to be turned on
  9288. */
  9289. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9290. /**
  9291. * Prepares the defines for bones
  9292. * @param mesh The mesh containing the geometry data we will draw
  9293. * @param defines The defines to update
  9294. */
  9295. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9296. /**
  9297. * Prepares the defines for morph targets
  9298. * @param mesh The mesh containing the geometry data we will draw
  9299. * @param defines The defines to update
  9300. */
  9301. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9302. /**
  9303. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9304. * @param mesh The mesh containing the geometry data we will draw
  9305. * @param defines The defines to update
  9306. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9307. * @param useBones Precise whether bones should be used or not (override mesh info)
  9308. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9309. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9310. * @returns false if defines are considered not dirty and have not been checked
  9311. */
  9312. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9313. /**
  9314. * Prepares the defines related to multiview
  9315. * @param scene The scene we are intending to draw
  9316. * @param defines The defines to update
  9317. */
  9318. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9319. /**
  9320. * Prepares the defines related to the light information passed in parameter
  9321. * @param scene The scene we are intending to draw
  9322. * @param mesh The mesh the effect is compiling for
  9323. * @param light The light the effect is compiling for
  9324. * @param lightIndex The index of the light
  9325. * @param defines The defines to update
  9326. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9327. * @param state Defines the current state regarding what is needed (normals, etc...)
  9328. */
  9329. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9330. needNormals: boolean;
  9331. needRebuild: boolean;
  9332. shadowEnabled: boolean;
  9333. specularEnabled: boolean;
  9334. lightmapMode: boolean;
  9335. }): void;
  9336. /**
  9337. * Prepares the defines related to the light information passed in parameter
  9338. * @param scene The scene we are intending to draw
  9339. * @param mesh The mesh the effect is compiling for
  9340. * @param defines The defines to update
  9341. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9342. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9343. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9344. * @returns true if normals will be required for the rest of the effect
  9345. */
  9346. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9347. /**
  9348. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9349. * @param lightIndex defines the light index
  9350. * @param uniformsList The uniform list
  9351. * @param samplersList The sampler list
  9352. * @param projectedLightTexture defines if projected texture must be used
  9353. * @param uniformBuffersList defines an optional list of uniform buffers
  9354. */
  9355. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9356. /**
  9357. * Prepares the uniforms and samplers list to be used in the effect
  9358. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9359. * @param samplersList The sampler list
  9360. * @param defines The defines helping in the list generation
  9361. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9362. */
  9363. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9364. /**
  9365. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9366. * @param defines The defines to update while falling back
  9367. * @param fallbacks The authorized effect fallbacks
  9368. * @param maxSimultaneousLights The maximum number of lights allowed
  9369. * @param rank the current rank of the Effect
  9370. * @returns The newly affected rank
  9371. */
  9372. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9373. private static _TmpMorphInfluencers;
  9374. /**
  9375. * Prepares the list of attributes required for morph targets according to the effect defines.
  9376. * @param attribs The current list of supported attribs
  9377. * @param mesh The mesh to prepare the morph targets attributes for
  9378. * @param influencers The number of influencers
  9379. */
  9380. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9381. /**
  9382. * Prepares the list of attributes required for morph targets according to the effect defines.
  9383. * @param attribs The current list of supported attribs
  9384. * @param mesh The mesh to prepare the morph targets attributes for
  9385. * @param defines The current Defines of the effect
  9386. */
  9387. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9388. /**
  9389. * Prepares the list of attributes required for bones according to the effect defines.
  9390. * @param attribs The current list of supported attribs
  9391. * @param mesh The mesh to prepare the bones attributes for
  9392. * @param defines The current Defines of the effect
  9393. * @param fallbacks The current efffect fallback strategy
  9394. */
  9395. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9396. /**
  9397. * Check and prepare the list of attributes required for instances according to the effect defines.
  9398. * @param attribs The current list of supported attribs
  9399. * @param defines The current MaterialDefines of the effect
  9400. */
  9401. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9402. /**
  9403. * Add the list of attributes required for instances to the attribs array.
  9404. * @param attribs The current list of supported attribs
  9405. */
  9406. static PushAttributesForInstances(attribs: string[]): void;
  9407. /**
  9408. * Binds the light information to the effect.
  9409. * @param light The light containing the generator
  9410. * @param effect The effect we are binding the data to
  9411. * @param lightIndex The light index in the effect used to render
  9412. */
  9413. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9414. /**
  9415. * Binds the lights information from the scene to the effect for the given mesh.
  9416. * @param light Light to bind
  9417. * @param lightIndex Light index
  9418. * @param scene The scene where the light belongs to
  9419. * @param effect The effect we are binding the data to
  9420. * @param useSpecular Defines if specular is supported
  9421. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9422. */
  9423. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9424. /**
  9425. * Binds the lights information from the scene to the effect for the given mesh.
  9426. * @param scene The scene the lights belongs to
  9427. * @param mesh The mesh we are binding the information to render
  9428. * @param effect The effect we are binding the data to
  9429. * @param defines The generated defines for the effect
  9430. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9431. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9432. */
  9433. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9434. private static _tempFogColor;
  9435. /**
  9436. * Binds the fog information from the scene to the effect for the given mesh.
  9437. * @param scene The scene the lights belongs to
  9438. * @param mesh The mesh we are binding the information to render
  9439. * @param effect The effect we are binding the data to
  9440. * @param linearSpace Defines if the fog effect is applied in linear space
  9441. */
  9442. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9443. /**
  9444. * Binds the bones information from the mesh to the effect.
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. */
  9448. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9449. /**
  9450. * Binds the morph targets information from the mesh to the effect.
  9451. * @param abstractMesh The mesh we are binding the information to render
  9452. * @param effect The effect we are binding the data to
  9453. */
  9454. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9455. /**
  9456. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9457. * @param defines The generated defines used in the effect
  9458. * @param effect The effect we are binding the data to
  9459. * @param scene The scene we are willing to render with logarithmic scale for
  9460. */
  9461. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9462. /**
  9463. * Binds the clip plane information from the scene to the effect.
  9464. * @param scene The scene the clip plane information are extracted from
  9465. * @param effect The effect we are binding the data to
  9466. */
  9467. static BindClipPlane(effect: Effect, scene: Scene): void;
  9468. }
  9469. }
  9470. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9471. /** @hidden */
  9472. export var packingFunctions: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9478. /** @hidden */
  9479. export var clipPlaneFragmentDeclaration: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9485. /** @hidden */
  9486. export var clipPlaneFragment: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9492. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9493. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9495. /** @hidden */
  9496. export var shadowMapPixelShader: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9502. /** @hidden */
  9503. export var bonesDeclaration: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9509. /** @hidden */
  9510. export var morphTargetsVertexGlobalDeclaration: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9516. /** @hidden */
  9517. export var morphTargetsVertexDeclaration: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9523. /** @hidden */
  9524. export var instancesDeclaration: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9530. /** @hidden */
  9531. export var helperFunctions: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9537. /** @hidden */
  9538. export var clipPlaneVertexDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9544. /** @hidden */
  9545. export var morphTargetsVertex: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9551. /** @hidden */
  9552. export var instancesVertex: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9558. /** @hidden */
  9559. export var bonesVertex: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9565. /** @hidden */
  9566. export var clipPlaneVertex: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9572. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9575. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9577. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9579. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9580. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9581. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9582. /** @hidden */
  9583. export var shadowMapVertexShader: {
  9584. name: string;
  9585. shader: string;
  9586. };
  9587. }
  9588. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9589. /** @hidden */
  9590. export var depthBoxBlurPixelShader: {
  9591. name: string;
  9592. shader: string;
  9593. };
  9594. }
  9595. declare module "babylonjs/Culling/ray" {
  9596. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9599. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9600. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9601. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9602. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9603. import { Plane } from "babylonjs/Maths/math.plane";
  9604. /**
  9605. * Class representing a ray with position and direction
  9606. */
  9607. export class Ray {
  9608. /** origin point */
  9609. origin: Vector3;
  9610. /** direction */
  9611. direction: Vector3;
  9612. /** length of the ray */
  9613. length: number;
  9614. private static readonly TmpVector3;
  9615. private _tmpRay;
  9616. /**
  9617. * Creates a new ray
  9618. * @param origin origin point
  9619. * @param direction direction
  9620. * @param length length of the ray
  9621. */
  9622. constructor(
  9623. /** origin point */
  9624. origin: Vector3,
  9625. /** direction */
  9626. direction: Vector3,
  9627. /** length of the ray */
  9628. length?: number);
  9629. /**
  9630. * Checks if the ray intersects a box
  9631. * @param minimum bound of the box
  9632. * @param maximum bound of the box
  9633. * @param intersectionTreshold extra extend to be added to the box in all direction
  9634. * @returns if the box was hit
  9635. */
  9636. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9637. /**
  9638. * Checks if the ray intersects a box
  9639. * @param box the bounding box to check
  9640. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9641. * @returns if the box was hit
  9642. */
  9643. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9644. /**
  9645. * If the ray hits a sphere
  9646. * @param sphere the bounding sphere to check
  9647. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9648. * @returns true if it hits the sphere
  9649. */
  9650. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9651. /**
  9652. * If the ray hits a triange
  9653. * @param vertex0 triangle vertex
  9654. * @param vertex1 triangle vertex
  9655. * @param vertex2 triangle vertex
  9656. * @returns intersection information if hit
  9657. */
  9658. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9659. /**
  9660. * Checks if ray intersects a plane
  9661. * @param plane the plane to check
  9662. * @returns the distance away it was hit
  9663. */
  9664. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9665. /**
  9666. * Calculate the intercept of a ray on a given axis
  9667. * @param axis to check 'x' | 'y' | 'z'
  9668. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9669. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9670. */
  9671. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9672. /**
  9673. * Checks if ray intersects a mesh
  9674. * @param mesh the mesh to check
  9675. * @param fastCheck if only the bounding box should checked
  9676. * @returns picking info of the intersecton
  9677. */
  9678. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9679. /**
  9680. * Checks if ray intersects a mesh
  9681. * @param meshes the meshes to check
  9682. * @param fastCheck if only the bounding box should checked
  9683. * @param results array to store result in
  9684. * @returns Array of picking infos
  9685. */
  9686. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9687. private _comparePickingInfo;
  9688. private static smallnum;
  9689. private static rayl;
  9690. /**
  9691. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9692. * @param sega the first point of the segment to test the intersection against
  9693. * @param segb the second point of the segment to test the intersection against
  9694. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9695. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9696. */
  9697. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9698. /**
  9699. * Update the ray from viewport position
  9700. * @param x position
  9701. * @param y y position
  9702. * @param viewportWidth viewport width
  9703. * @param viewportHeight viewport height
  9704. * @param world world matrix
  9705. * @param view view matrix
  9706. * @param projection projection matrix
  9707. * @returns this ray updated
  9708. */
  9709. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9710. /**
  9711. * Creates a ray with origin and direction of 0,0,0
  9712. * @returns the new ray
  9713. */
  9714. static Zero(): Ray;
  9715. /**
  9716. * Creates a new ray from screen space and viewport
  9717. * @param x position
  9718. * @param y y position
  9719. * @param viewportWidth viewport width
  9720. * @param viewportHeight viewport height
  9721. * @param world world matrix
  9722. * @param view view matrix
  9723. * @param projection projection matrix
  9724. * @returns new ray
  9725. */
  9726. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9727. /**
  9728. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9729. * transformed to the given world matrix.
  9730. * @param origin The origin point
  9731. * @param end The end point
  9732. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9733. * @returns the new ray
  9734. */
  9735. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9736. /**
  9737. * Transforms a ray by a matrix
  9738. * @param ray ray to transform
  9739. * @param matrix matrix to apply
  9740. * @returns the resulting new ray
  9741. */
  9742. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9743. /**
  9744. * Transforms a ray by a matrix
  9745. * @param ray ray to transform
  9746. * @param matrix matrix to apply
  9747. * @param result ray to store result in
  9748. */
  9749. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9750. /**
  9751. * Unproject a ray from screen space to object space
  9752. * @param sourceX defines the screen space x coordinate to use
  9753. * @param sourceY defines the screen space y coordinate to use
  9754. * @param viewportWidth defines the current width of the viewport
  9755. * @param viewportHeight defines the current height of the viewport
  9756. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9757. * @param view defines the view matrix to use
  9758. * @param projection defines the projection matrix to use
  9759. */
  9760. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9761. }
  9762. /**
  9763. * Type used to define predicate used to select faces when a mesh intersection is detected
  9764. */
  9765. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9766. module "babylonjs/scene" {
  9767. interface Scene {
  9768. /** @hidden */
  9769. _tempPickingRay: Nullable<Ray>;
  9770. /** @hidden */
  9771. _cachedRayForTransform: Ray;
  9772. /** @hidden */
  9773. _pickWithRayInverseMatrix: Matrix;
  9774. /** @hidden */
  9775. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9776. /** @hidden */
  9777. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9778. }
  9779. }
  9780. }
  9781. declare module "babylonjs/sceneComponent" {
  9782. import { Scene } from "babylonjs/scene";
  9783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9785. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9786. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9787. import { Nullable } from "babylonjs/types";
  9788. import { Camera } from "babylonjs/Cameras/camera";
  9789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9790. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9791. import { AbstractScene } from "babylonjs/abstractScene";
  9792. import { Mesh } from "babylonjs/Meshes/mesh";
  9793. /**
  9794. * Groups all the scene component constants in one place to ease maintenance.
  9795. * @hidden
  9796. */
  9797. export class SceneComponentConstants {
  9798. static readonly NAME_EFFECTLAYER: string;
  9799. static readonly NAME_LAYER: string;
  9800. static readonly NAME_LENSFLARESYSTEM: string;
  9801. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9802. static readonly NAME_PARTICLESYSTEM: string;
  9803. static readonly NAME_GAMEPAD: string;
  9804. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9805. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9806. static readonly NAME_DEPTHRENDERER: string;
  9807. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9808. static readonly NAME_SPRITE: string;
  9809. static readonly NAME_OUTLINERENDERER: string;
  9810. static readonly NAME_PROCEDURALTEXTURE: string;
  9811. static readonly NAME_SHADOWGENERATOR: string;
  9812. static readonly NAME_OCTREE: string;
  9813. static readonly NAME_PHYSICSENGINE: string;
  9814. static readonly NAME_AUDIO: string;
  9815. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9816. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9817. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9818. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9819. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9820. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9821. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9822. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9823. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9824. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9825. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9826. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9827. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9828. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9829. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9830. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9831. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9832. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9833. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9834. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9835. static readonly STEP_AFTERRENDER_AUDIO: number;
  9836. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9837. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9838. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9839. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9840. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9841. static readonly STEP_POINTERMOVE_SPRITE: number;
  9842. static readonly STEP_POINTERDOWN_SPRITE: number;
  9843. static readonly STEP_POINTERUP_SPRITE: number;
  9844. }
  9845. /**
  9846. * This represents a scene component.
  9847. *
  9848. * This is used to decouple the dependency the scene is having on the different workloads like
  9849. * layers, post processes...
  9850. */
  9851. export interface ISceneComponent {
  9852. /**
  9853. * The name of the component. Each component must have a unique name.
  9854. */
  9855. name: string;
  9856. /**
  9857. * The scene the component belongs to.
  9858. */
  9859. scene: Scene;
  9860. /**
  9861. * Register the component to one instance of a scene.
  9862. */
  9863. register(): void;
  9864. /**
  9865. * Rebuilds the elements related to this component in case of
  9866. * context lost for instance.
  9867. */
  9868. rebuild(): void;
  9869. /**
  9870. * Disposes the component and the associated ressources.
  9871. */
  9872. dispose(): void;
  9873. }
  9874. /**
  9875. * This represents a SERIALIZABLE scene component.
  9876. *
  9877. * This extends Scene Component to add Serialization methods on top.
  9878. */
  9879. export interface ISceneSerializableComponent extends ISceneComponent {
  9880. /**
  9881. * Adds all the elements from the container to the scene
  9882. * @param container the container holding the elements
  9883. */
  9884. addFromContainer(container: AbstractScene): void;
  9885. /**
  9886. * Removes all the elements in the container from the scene
  9887. * @param container contains the elements to remove
  9888. * @param dispose if the removed element should be disposed (default: false)
  9889. */
  9890. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9891. /**
  9892. * Serializes the component data to the specified json object
  9893. * @param serializationObject The object to serialize to
  9894. */
  9895. serialize(serializationObject: any): void;
  9896. }
  9897. /**
  9898. * Strong typing of a Mesh related stage step action
  9899. */
  9900. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9901. /**
  9902. * Strong typing of a Evaluate Sub Mesh related stage step action
  9903. */
  9904. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9905. /**
  9906. * Strong typing of a Active Mesh related stage step action
  9907. */
  9908. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9909. /**
  9910. * Strong typing of a Camera related stage step action
  9911. */
  9912. export type CameraStageAction = (camera: Camera) => void;
  9913. /**
  9914. * Strong typing of a Camera Frame buffer related stage step action
  9915. */
  9916. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9917. /**
  9918. * Strong typing of a Render Target related stage step action
  9919. */
  9920. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9921. /**
  9922. * Strong typing of a RenderingGroup related stage step action
  9923. */
  9924. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9925. /**
  9926. * Strong typing of a Mesh Render related stage step action
  9927. */
  9928. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9929. /**
  9930. * Strong typing of a simple stage step action
  9931. */
  9932. export type SimpleStageAction = () => void;
  9933. /**
  9934. * Strong typing of a render target action.
  9935. */
  9936. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9937. /**
  9938. * Strong typing of a pointer move action.
  9939. */
  9940. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9941. /**
  9942. * Strong typing of a pointer up/down action.
  9943. */
  9944. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9945. /**
  9946. * Representation of a stage in the scene (Basically a list of ordered steps)
  9947. * @hidden
  9948. */
  9949. export class Stage<T extends Function> extends Array<{
  9950. index: number;
  9951. component: ISceneComponent;
  9952. action: T;
  9953. }> {
  9954. /**
  9955. * Hide ctor from the rest of the world.
  9956. * @param items The items to add.
  9957. */
  9958. private constructor();
  9959. /**
  9960. * Creates a new Stage.
  9961. * @returns A new instance of a Stage
  9962. */
  9963. static Create<T extends Function>(): Stage<T>;
  9964. /**
  9965. * Registers a step in an ordered way in the targeted stage.
  9966. * @param index Defines the position to register the step in
  9967. * @param component Defines the component attached to the step
  9968. * @param action Defines the action to launch during the step
  9969. */
  9970. registerStep(index: number, component: ISceneComponent, action: T): void;
  9971. /**
  9972. * Clears all the steps from the stage.
  9973. */
  9974. clear(): void;
  9975. }
  9976. }
  9977. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9978. import { Nullable } from "babylonjs/types";
  9979. import { Observable } from "babylonjs/Misc/observable";
  9980. import { Scene } from "babylonjs/scene";
  9981. import { Sprite } from "babylonjs/Sprites/sprite";
  9982. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9983. import { Ray } from "babylonjs/Culling/ray";
  9984. import { Camera } from "babylonjs/Cameras/camera";
  9985. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9986. import { ISceneComponent } from "babylonjs/sceneComponent";
  9987. module "babylonjs/scene" {
  9988. interface Scene {
  9989. /** @hidden */
  9990. _pointerOverSprite: Nullable<Sprite>;
  9991. /** @hidden */
  9992. _pickedDownSprite: Nullable<Sprite>;
  9993. /** @hidden */
  9994. _tempSpritePickingRay: Nullable<Ray>;
  9995. /**
  9996. * All of the sprite managers added to this scene
  9997. * @see http://doc.babylonjs.com/babylon101/sprites
  9998. */
  9999. spriteManagers: Array<ISpriteManager>;
  10000. /**
  10001. * An event triggered when sprites rendering is about to start
  10002. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10003. */
  10004. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10005. /**
  10006. * An event triggered when sprites rendering is done
  10007. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10008. */
  10009. onAfterSpritesRenderingObservable: Observable<Scene>;
  10010. /** @hidden */
  10011. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10012. /** Launch a ray to try to pick a sprite in the scene
  10013. * @param x position on screen
  10014. * @param y position on screen
  10015. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10016. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10017. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10018. * @returns a PickingInfo
  10019. */
  10020. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10021. /** Use the given ray to pick a sprite in the scene
  10022. * @param ray The ray (in world space) to use to pick meshes
  10023. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10024. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10025. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10026. * @returns a PickingInfo
  10027. */
  10028. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10029. /** @hidden */
  10030. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10031. /** Launch a ray to try to pick sprites in the scene
  10032. * @param x position on screen
  10033. * @param y position on screen
  10034. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10035. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10036. * @returns a PickingInfo array
  10037. */
  10038. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10039. /** Use the given ray to pick sprites in the scene
  10040. * @param ray The ray (in world space) to use to pick meshes
  10041. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10042. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10043. * @returns a PickingInfo array
  10044. */
  10045. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10046. /**
  10047. * Force the sprite under the pointer
  10048. * @param sprite defines the sprite to use
  10049. */
  10050. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10051. /**
  10052. * Gets the sprite under the pointer
  10053. * @returns a Sprite or null if no sprite is under the pointer
  10054. */
  10055. getPointerOverSprite(): Nullable<Sprite>;
  10056. }
  10057. }
  10058. /**
  10059. * Defines the sprite scene component responsible to manage sprites
  10060. * in a given scene.
  10061. */
  10062. export class SpriteSceneComponent implements ISceneComponent {
  10063. /**
  10064. * The component name helpfull to identify the component in the list of scene components.
  10065. */
  10066. readonly name: string;
  10067. /**
  10068. * The scene the component belongs to.
  10069. */
  10070. scene: Scene;
  10071. /** @hidden */
  10072. private _spritePredicate;
  10073. /**
  10074. * Creates a new instance of the component for the given scene
  10075. * @param scene Defines the scene to register the component in
  10076. */
  10077. constructor(scene: Scene);
  10078. /**
  10079. * Registers the component in a given scene
  10080. */
  10081. register(): void;
  10082. /**
  10083. * Rebuilds the elements related to this component in case of
  10084. * context lost for instance.
  10085. */
  10086. rebuild(): void;
  10087. /**
  10088. * Disposes the component and the associated ressources.
  10089. */
  10090. dispose(): void;
  10091. private _pickSpriteButKeepRay;
  10092. private _pointerMove;
  10093. private _pointerDown;
  10094. private _pointerUp;
  10095. }
  10096. }
  10097. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10098. /** @hidden */
  10099. export var fogFragmentDeclaration: {
  10100. name: string;
  10101. shader: string;
  10102. };
  10103. }
  10104. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10105. /** @hidden */
  10106. export var fogFragment: {
  10107. name: string;
  10108. shader: string;
  10109. };
  10110. }
  10111. declare module "babylonjs/Shaders/sprites.fragment" {
  10112. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10113. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10114. /** @hidden */
  10115. export var spritesPixelShader: {
  10116. name: string;
  10117. shader: string;
  10118. };
  10119. }
  10120. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10121. /** @hidden */
  10122. export var fogVertexDeclaration: {
  10123. name: string;
  10124. shader: string;
  10125. };
  10126. }
  10127. declare module "babylonjs/Shaders/sprites.vertex" {
  10128. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10129. /** @hidden */
  10130. export var spritesVertexShader: {
  10131. name: string;
  10132. shader: string;
  10133. };
  10134. }
  10135. declare module "babylonjs/Sprites/spriteManager" {
  10136. import { IDisposable, Scene } from "babylonjs/scene";
  10137. import { Nullable } from "babylonjs/types";
  10138. import { Observable } from "babylonjs/Misc/observable";
  10139. import { Sprite } from "babylonjs/Sprites/sprite";
  10140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10141. import { Camera } from "babylonjs/Cameras/camera";
  10142. import { Texture } from "babylonjs/Materials/Textures/texture";
  10143. import "babylonjs/Shaders/sprites.fragment";
  10144. import "babylonjs/Shaders/sprites.vertex";
  10145. import { Ray } from "babylonjs/Culling/ray";
  10146. /**
  10147. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10148. */
  10149. export interface ISpriteManager extends IDisposable {
  10150. /**
  10151. * Restricts the camera to viewing objects with the same layerMask.
  10152. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10153. */
  10154. layerMask: number;
  10155. /**
  10156. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10157. */
  10158. isPickable: boolean;
  10159. /**
  10160. * Specifies the rendering group id for this mesh (0 by default)
  10161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10162. */
  10163. renderingGroupId: number;
  10164. /**
  10165. * Defines the list of sprites managed by the manager.
  10166. */
  10167. sprites: Array<Sprite>;
  10168. /**
  10169. * Tests the intersection of a sprite with a specific ray.
  10170. * @param ray The ray we are sending to test the collision
  10171. * @param camera The camera space we are sending rays in
  10172. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10173. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10174. * @returns picking info or null.
  10175. */
  10176. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10177. /**
  10178. * Intersects the sprites with a ray
  10179. * @param ray defines the ray to intersect with
  10180. * @param camera defines the current active camera
  10181. * @param predicate defines a predicate used to select candidate sprites
  10182. * @returns null if no hit or a PickingInfo array
  10183. */
  10184. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10185. /**
  10186. * Renders the list of sprites on screen.
  10187. */
  10188. render(): void;
  10189. }
  10190. /**
  10191. * Class used to manage multiple sprites on the same spritesheet
  10192. * @see http://doc.babylonjs.com/babylon101/sprites
  10193. */
  10194. export class SpriteManager implements ISpriteManager {
  10195. /** defines the manager's name */
  10196. name: string;
  10197. /** Gets the list of sprites */
  10198. sprites: Sprite[];
  10199. /** Gets or sets the rendering group id (0 by default) */
  10200. renderingGroupId: number;
  10201. /** Gets or sets camera layer mask */
  10202. layerMask: number;
  10203. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10204. fogEnabled: boolean;
  10205. /** Gets or sets a boolean indicating if the sprites are pickable */
  10206. isPickable: boolean;
  10207. /** Defines the default width of a cell in the spritesheet */
  10208. cellWidth: number;
  10209. /** Defines the default height of a cell in the spritesheet */
  10210. cellHeight: number;
  10211. /** Associative array from JSON sprite data file */
  10212. private _cellData;
  10213. /** Array of sprite names from JSON sprite data file */
  10214. private _spriteMap;
  10215. /** True when packed cell data from JSON file is ready*/
  10216. private _packedAndReady;
  10217. /**
  10218. * An event triggered when the manager is disposed.
  10219. */
  10220. onDisposeObservable: Observable<SpriteManager>;
  10221. private _onDisposeObserver;
  10222. /**
  10223. * Callback called when the manager is disposed
  10224. */
  10225. set onDispose(callback: () => void);
  10226. private _capacity;
  10227. private _fromPacked;
  10228. private _spriteTexture;
  10229. private _epsilon;
  10230. private _scene;
  10231. private _vertexData;
  10232. private _buffer;
  10233. private _vertexBuffers;
  10234. private _indexBuffer;
  10235. private _effectBase;
  10236. private _effectFog;
  10237. /**
  10238. * Gets or sets the spritesheet texture
  10239. */
  10240. get texture(): Texture;
  10241. set texture(value: Texture);
  10242. private _blendMode;
  10243. /**
  10244. * Blend mode use to render the particle, it can be any of
  10245. * the static Constants.ALPHA_x properties provided in this class.
  10246. * Default value is Constants.ALPHA_COMBINE
  10247. */
  10248. get blendMode(): number;
  10249. set blendMode(blendMode: number);
  10250. /** Disables writing to the depth buffer when rendering the sprites.
  10251. * It can be handy to disable depth writing when using textures without alpha channel
  10252. * and setting some specific blend modes.
  10253. */
  10254. disableDepthWrite: boolean;
  10255. /**
  10256. * Creates a new sprite manager
  10257. * @param name defines the manager's name
  10258. * @param imgUrl defines the sprite sheet url
  10259. * @param capacity defines the maximum allowed number of sprites
  10260. * @param cellSize defines the size of a sprite cell
  10261. * @param scene defines the hosting scene
  10262. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10263. * @param samplingMode defines the smapling mode to use with spritesheet
  10264. * @param fromPacked set to false; do not alter
  10265. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10266. */
  10267. constructor(
  10268. /** defines the manager's name */
  10269. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10270. private _makePacked;
  10271. private _appendSpriteVertex;
  10272. /**
  10273. * Intersects the sprites with a ray
  10274. * @param ray defines the ray to intersect with
  10275. * @param camera defines the current active camera
  10276. * @param predicate defines a predicate used to select candidate sprites
  10277. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10278. * @returns null if no hit or a PickingInfo
  10279. */
  10280. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10281. /**
  10282. * Intersects the sprites with a ray
  10283. * @param ray defines the ray to intersect with
  10284. * @param camera defines the current active camera
  10285. * @param predicate defines a predicate used to select candidate sprites
  10286. * @returns null if no hit or a PickingInfo array
  10287. */
  10288. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10289. /**
  10290. * Render all child sprites
  10291. */
  10292. render(): void;
  10293. /**
  10294. * Release associated resources
  10295. */
  10296. dispose(): void;
  10297. }
  10298. }
  10299. declare module "babylonjs/Misc/gradients" {
  10300. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10301. /** Interface used by value gradients (color, factor, ...) */
  10302. export interface IValueGradient {
  10303. /**
  10304. * Gets or sets the gradient value (between 0 and 1)
  10305. */
  10306. gradient: number;
  10307. }
  10308. /** Class used to store color4 gradient */
  10309. export class ColorGradient implements IValueGradient {
  10310. /**
  10311. * Gets or sets the gradient value (between 0 and 1)
  10312. */
  10313. gradient: number;
  10314. /**
  10315. * Gets or sets first associated color
  10316. */
  10317. color1: Color4;
  10318. /**
  10319. * Gets or sets second associated color
  10320. */
  10321. color2?: Color4 | undefined;
  10322. /**
  10323. * Creates a new color4 gradient
  10324. * @param gradient gets or sets the gradient value (between 0 and 1)
  10325. * @param color1 gets or sets first associated color
  10326. * @param color2 gets or sets first second color
  10327. */
  10328. constructor(
  10329. /**
  10330. * Gets or sets the gradient value (between 0 and 1)
  10331. */
  10332. gradient: number,
  10333. /**
  10334. * Gets or sets first associated color
  10335. */
  10336. color1: Color4,
  10337. /**
  10338. * Gets or sets second associated color
  10339. */
  10340. color2?: Color4 | undefined);
  10341. /**
  10342. * Will get a color picked randomly between color1 and color2.
  10343. * If color2 is undefined then color1 will be used
  10344. * @param result defines the target Color4 to store the result in
  10345. */
  10346. getColorToRef(result: Color4): void;
  10347. }
  10348. /** Class used to store color 3 gradient */
  10349. export class Color3Gradient implements IValueGradient {
  10350. /**
  10351. * Gets or sets the gradient value (between 0 and 1)
  10352. */
  10353. gradient: number;
  10354. /**
  10355. * Gets or sets the associated color
  10356. */
  10357. color: Color3;
  10358. /**
  10359. * Creates a new color3 gradient
  10360. * @param gradient gets or sets the gradient value (between 0 and 1)
  10361. * @param color gets or sets associated color
  10362. */
  10363. constructor(
  10364. /**
  10365. * Gets or sets the gradient value (between 0 and 1)
  10366. */
  10367. gradient: number,
  10368. /**
  10369. * Gets or sets the associated color
  10370. */
  10371. color: Color3);
  10372. }
  10373. /** Class used to store factor gradient */
  10374. export class FactorGradient implements IValueGradient {
  10375. /**
  10376. * Gets or sets the gradient value (between 0 and 1)
  10377. */
  10378. gradient: number;
  10379. /**
  10380. * Gets or sets first associated factor
  10381. */
  10382. factor1: number;
  10383. /**
  10384. * Gets or sets second associated factor
  10385. */
  10386. factor2?: number | undefined;
  10387. /**
  10388. * Creates a new factor gradient
  10389. * @param gradient gets or sets the gradient value (between 0 and 1)
  10390. * @param factor1 gets or sets first associated factor
  10391. * @param factor2 gets or sets second associated factor
  10392. */
  10393. constructor(
  10394. /**
  10395. * Gets or sets the gradient value (between 0 and 1)
  10396. */
  10397. gradient: number,
  10398. /**
  10399. * Gets or sets first associated factor
  10400. */
  10401. factor1: number,
  10402. /**
  10403. * Gets or sets second associated factor
  10404. */
  10405. factor2?: number | undefined);
  10406. /**
  10407. * Will get a number picked randomly between factor1 and factor2.
  10408. * If factor2 is undefined then factor1 will be used
  10409. * @returns the picked number
  10410. */
  10411. getFactor(): number;
  10412. }
  10413. /**
  10414. * Helper used to simplify some generic gradient tasks
  10415. */
  10416. export class GradientHelper {
  10417. /**
  10418. * Gets the current gradient from an array of IValueGradient
  10419. * @param ratio defines the current ratio to get
  10420. * @param gradients defines the array of IValueGradient
  10421. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10422. */
  10423. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10424. }
  10425. }
  10426. declare module "babylonjs/Maths/math.size" {
  10427. /**
  10428. * Interface for the size containing width and height
  10429. */
  10430. export interface ISize {
  10431. /**
  10432. * Width
  10433. */
  10434. width: number;
  10435. /**
  10436. * Heighht
  10437. */
  10438. height: number;
  10439. }
  10440. /**
  10441. * Size containing widht and height
  10442. */
  10443. export class Size implements ISize {
  10444. /**
  10445. * Width
  10446. */
  10447. width: number;
  10448. /**
  10449. * Height
  10450. */
  10451. height: number;
  10452. /**
  10453. * Creates a Size object from the given width and height (floats).
  10454. * @param width width of the new size
  10455. * @param height height of the new size
  10456. */
  10457. constructor(width: number, height: number);
  10458. /**
  10459. * Returns a string with the Size width and height
  10460. * @returns a string with the Size width and height
  10461. */
  10462. toString(): string;
  10463. /**
  10464. * "Size"
  10465. * @returns the string "Size"
  10466. */
  10467. getClassName(): string;
  10468. /**
  10469. * Returns the Size hash code.
  10470. * @returns a hash code for a unique width and height
  10471. */
  10472. getHashCode(): number;
  10473. /**
  10474. * Updates the current size from the given one.
  10475. * @param src the given size
  10476. */
  10477. copyFrom(src: Size): void;
  10478. /**
  10479. * Updates in place the current Size from the given floats.
  10480. * @param width width of the new size
  10481. * @param height height of the new size
  10482. * @returns the updated Size.
  10483. */
  10484. copyFromFloats(width: number, height: number): Size;
  10485. /**
  10486. * Updates in place the current Size from the given floats.
  10487. * @param width width to set
  10488. * @param height height to set
  10489. * @returns the updated Size.
  10490. */
  10491. set(width: number, height: number): Size;
  10492. /**
  10493. * Multiplies the width and height by numbers
  10494. * @param w factor to multiple the width by
  10495. * @param h factor to multiple the height by
  10496. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10497. */
  10498. multiplyByFloats(w: number, h: number): Size;
  10499. /**
  10500. * Clones the size
  10501. * @returns a new Size copied from the given one.
  10502. */
  10503. clone(): Size;
  10504. /**
  10505. * True if the current Size and the given one width and height are strictly equal.
  10506. * @param other the other size to compare against
  10507. * @returns True if the current Size and the given one width and height are strictly equal.
  10508. */
  10509. equals(other: Size): boolean;
  10510. /**
  10511. * The surface of the Size : width * height (float).
  10512. */
  10513. get surface(): number;
  10514. /**
  10515. * Create a new size of zero
  10516. * @returns a new Size set to (0.0, 0.0)
  10517. */
  10518. static Zero(): Size;
  10519. /**
  10520. * Sums the width and height of two sizes
  10521. * @param otherSize size to add to this size
  10522. * @returns a new Size set as the addition result of the current Size and the given one.
  10523. */
  10524. add(otherSize: Size): Size;
  10525. /**
  10526. * Subtracts the width and height of two
  10527. * @param otherSize size to subtract to this size
  10528. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10529. */
  10530. subtract(otherSize: Size): Size;
  10531. /**
  10532. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10533. * @param start starting size to lerp between
  10534. * @param end end size to lerp between
  10535. * @param amount amount to lerp between the start and end values
  10536. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10537. */
  10538. static Lerp(start: Size, end: Size, amount: number): Size;
  10539. }
  10540. }
  10541. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10543. import { Nullable } from "babylonjs/types";
  10544. module "babylonjs/Engines/thinEngine" {
  10545. interface ThinEngine {
  10546. /**
  10547. * Creates a dynamic texture
  10548. * @param width defines the width of the texture
  10549. * @param height defines the height of the texture
  10550. * @param generateMipMaps defines if the engine should generate the mip levels
  10551. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10552. * @returns the dynamic texture inside an InternalTexture
  10553. */
  10554. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10555. /**
  10556. * Update the content of a dynamic texture
  10557. * @param texture defines the texture to update
  10558. * @param canvas defines the canvas containing the source
  10559. * @param invertY defines if data must be stored with Y axis inverted
  10560. * @param premulAlpha defines if alpha is stored as premultiplied
  10561. * @param format defines the format of the data
  10562. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10563. */
  10564. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10565. }
  10566. }
  10567. }
  10568. declare module "babylonjs/Misc/canvasGenerator" {
  10569. /**
  10570. * Helper class used to generate a canvas to manipulate images
  10571. */
  10572. export class CanvasGenerator {
  10573. /**
  10574. * Create a new canvas (or offscreen canvas depending on the context)
  10575. * @param width defines the expected width
  10576. * @param height defines the expected height
  10577. * @return a new canvas or offscreen canvas
  10578. */
  10579. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10580. }
  10581. }
  10582. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10583. import { Scene } from "babylonjs/scene";
  10584. import { Texture } from "babylonjs/Materials/Textures/texture";
  10585. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10586. /**
  10587. * A class extending Texture allowing drawing on a texture
  10588. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10589. */
  10590. export class DynamicTexture extends Texture {
  10591. private _generateMipMaps;
  10592. private _canvas;
  10593. private _context;
  10594. private _engine;
  10595. /**
  10596. * Creates a DynamicTexture
  10597. * @param name defines the name of the texture
  10598. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10599. * @param scene defines the scene where you want the texture
  10600. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10601. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10602. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10603. */
  10604. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10605. /**
  10606. * Get the current class name of the texture useful for serialization or dynamic coding.
  10607. * @returns "DynamicTexture"
  10608. */
  10609. getClassName(): string;
  10610. /**
  10611. * Gets the current state of canRescale
  10612. */
  10613. get canRescale(): boolean;
  10614. private _recreate;
  10615. /**
  10616. * Scales the texture
  10617. * @param ratio the scale factor to apply to both width and height
  10618. */
  10619. scale(ratio: number): void;
  10620. /**
  10621. * Resizes the texture
  10622. * @param width the new width
  10623. * @param height the new height
  10624. */
  10625. scaleTo(width: number, height: number): void;
  10626. /**
  10627. * Gets the context of the canvas used by the texture
  10628. * @returns the canvas context of the dynamic texture
  10629. */
  10630. getContext(): CanvasRenderingContext2D;
  10631. /**
  10632. * Clears the texture
  10633. */
  10634. clear(): void;
  10635. /**
  10636. * Updates the texture
  10637. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10638. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10639. */
  10640. update(invertY?: boolean, premulAlpha?: boolean): void;
  10641. /**
  10642. * Draws text onto the texture
  10643. * @param text defines the text to be drawn
  10644. * @param x defines the placement of the text from the left
  10645. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10646. * @param font defines the font to be used with font-style, font-size, font-name
  10647. * @param color defines the color used for the text
  10648. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10650. * @param update defines whether texture is immediately update (default is true)
  10651. */
  10652. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10653. /**
  10654. * Clones the texture
  10655. * @returns the clone of the texture.
  10656. */
  10657. clone(): DynamicTexture;
  10658. /**
  10659. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10660. * @returns a serialized dynamic texture object
  10661. */
  10662. serialize(): any;
  10663. /** @hidden */
  10664. _rebuild(): void;
  10665. }
  10666. }
  10667. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10668. import { Nullable } from "babylonjs/types";
  10669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10670. import { Scene } from "babylonjs/scene";
  10671. module "babylonjs/Engines/engine" {
  10672. interface Engine {
  10673. /**
  10674. * Creates a raw texture
  10675. * @param data defines the data to store in the texture
  10676. * @param width defines the width of the texture
  10677. * @param height defines the height of the texture
  10678. * @param format defines the format of the data
  10679. * @param generateMipMaps defines if the engine should generate the mip levels
  10680. * @param invertY defines if data must be stored with Y axis inverted
  10681. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10682. * @param compression defines the compression used (null by default)
  10683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10684. * @returns the raw texture inside an InternalTexture
  10685. */
  10686. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10687. /**
  10688. * Update a raw texture
  10689. * @param texture defines the texture to update
  10690. * @param data defines the data to store in the texture
  10691. * @param format defines the format of the data
  10692. * @param invertY defines if data must be stored with Y axis inverted
  10693. */
  10694. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10695. /**
  10696. * Update a raw texture
  10697. * @param texture defines the texture to update
  10698. * @param data defines the data to store in the texture
  10699. * @param format defines the format of the data
  10700. * @param invertY defines if data must be stored with Y axis inverted
  10701. * @param compression defines the compression used (null by default)
  10702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10703. */
  10704. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10705. /**
  10706. * Creates a new raw cube texture
  10707. * @param data defines the array of data to use to create each face
  10708. * @param size defines the size of the textures
  10709. * @param format defines the format of the data
  10710. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10711. * @param generateMipMaps defines if the engine should generate the mip levels
  10712. * @param invertY defines if data must be stored with Y axis inverted
  10713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10714. * @param compression defines the compression used (null by default)
  10715. * @returns the cube texture as an InternalTexture
  10716. */
  10717. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10718. /**
  10719. * Update a raw cube texture
  10720. * @param texture defines the texture to udpdate
  10721. * @param data defines the data to store
  10722. * @param format defines the data format
  10723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10724. * @param invertY defines if data must be stored with Y axis inverted
  10725. */
  10726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10727. /**
  10728. * Update a raw cube texture
  10729. * @param texture defines the texture to udpdate
  10730. * @param data defines the data to store
  10731. * @param format defines the data format
  10732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10733. * @param invertY defines if data must be stored with Y axis inverted
  10734. * @param compression defines the compression used (null by default)
  10735. */
  10736. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10737. /**
  10738. * Update a raw cube texture
  10739. * @param texture defines the texture to udpdate
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10743. * @param invertY defines if data must be stored with Y axis inverted
  10744. * @param compression defines the compression used (null by default)
  10745. * @param level defines which level of the texture to update
  10746. */
  10747. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10748. /**
  10749. * Creates a new raw cube texture from a specified url
  10750. * @param url defines the url where the data is located
  10751. * @param scene defines the current scene
  10752. * @param size defines the size of the textures
  10753. * @param format defines the format of the data
  10754. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10755. * @param noMipmap defines if the engine should avoid generating the mip levels
  10756. * @param callback defines a callback used to extract texture data from loaded data
  10757. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10758. * @param onLoad defines a callback called when texture is loaded
  10759. * @param onError defines a callback called if there is an error
  10760. * @returns the cube texture as an InternalTexture
  10761. */
  10762. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10763. /**
  10764. * Creates a new raw cube texture from a specified url
  10765. * @param url defines the url where the data is located
  10766. * @param scene defines the current scene
  10767. * @param size defines the size of the textures
  10768. * @param format defines the format of the data
  10769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10770. * @param noMipmap defines if the engine should avoid generating the mip levels
  10771. * @param callback defines a callback used to extract texture data from loaded data
  10772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10773. * @param onLoad defines a callback called when texture is loaded
  10774. * @param onError defines a callback called if there is an error
  10775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10776. * @param invertY defines if data must be stored with Y axis inverted
  10777. * @returns the cube texture as an InternalTexture
  10778. */
  10779. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10780. /**
  10781. * Creates a new raw 3D texture
  10782. * @param data defines the data used to create the texture
  10783. * @param width defines the width of the texture
  10784. * @param height defines the height of the texture
  10785. * @param depth defines the depth of the texture
  10786. * @param format defines the format of the texture
  10787. * @param generateMipMaps defines if the engine must generate mip levels
  10788. * @param invertY defines if data must be stored with Y axis inverted
  10789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10790. * @param compression defines the compressed used (can be null)
  10791. * @param textureType defines the compressed used (can be null)
  10792. * @returns a new raw 3D texture (stored in an InternalTexture)
  10793. */
  10794. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10795. /**
  10796. * Update a raw 3D texture
  10797. * @param texture defines the texture to update
  10798. * @param data defines the data to store
  10799. * @param format defines the data format
  10800. * @param invertY defines if data must be stored with Y axis inverted
  10801. */
  10802. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10803. /**
  10804. * Update a raw 3D texture
  10805. * @param texture defines the texture to update
  10806. * @param data defines the data to store
  10807. * @param format defines the data format
  10808. * @param invertY defines if data must be stored with Y axis inverted
  10809. * @param compression defines the used compression (can be null)
  10810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10811. */
  10812. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10813. /**
  10814. * Creates a new raw 2D array texture
  10815. * @param data defines the data used to create the texture
  10816. * @param width defines the width of the texture
  10817. * @param height defines the height of the texture
  10818. * @param depth defines the number of layers of the texture
  10819. * @param format defines the format of the texture
  10820. * @param generateMipMaps defines if the engine must generate mip levels
  10821. * @param invertY defines if data must be stored with Y axis inverted
  10822. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10823. * @param compression defines the compressed used (can be null)
  10824. * @param textureType defines the compressed used (can be null)
  10825. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10826. */
  10827. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10828. /**
  10829. * Update a raw 2D array texture
  10830. * @param texture defines the texture to update
  10831. * @param data defines the data to store
  10832. * @param format defines the data format
  10833. * @param invertY defines if data must be stored with Y axis inverted
  10834. */
  10835. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10836. /**
  10837. * Update a raw 2D array texture
  10838. * @param texture defines the texture to update
  10839. * @param data defines the data to store
  10840. * @param format defines the data format
  10841. * @param invertY defines if data must be stored with Y axis inverted
  10842. * @param compression defines the used compression (can be null)
  10843. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10844. */
  10845. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/Materials/Textures/rawTexture" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { Texture } from "babylonjs/Materials/Textures/texture";
  10852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10853. /**
  10854. * Raw texture can help creating a texture directly from an array of data.
  10855. * This can be super useful if you either get the data from an uncompressed source or
  10856. * if you wish to create your texture pixel by pixel.
  10857. */
  10858. export class RawTexture extends Texture {
  10859. /**
  10860. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10861. */
  10862. format: number;
  10863. private _engine;
  10864. /**
  10865. * Instantiates a new RawTexture.
  10866. * Raw texture can help creating a texture directly from an array of data.
  10867. * This can be super useful if you either get the data from an uncompressed source or
  10868. * if you wish to create your texture pixel by pixel.
  10869. * @param data define the array of data to use to create the texture
  10870. * @param width define the width of the texture
  10871. * @param height define the height of the texture
  10872. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10873. * @param scene define the scene the texture belongs to
  10874. * @param generateMipMaps define whether mip maps should be generated or not
  10875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10877. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10878. */
  10879. constructor(data: ArrayBufferView, width: number, height: number,
  10880. /**
  10881. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10882. */
  10883. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10884. /**
  10885. * Updates the texture underlying data.
  10886. * @param data Define the new data of the texture
  10887. */
  10888. update(data: ArrayBufferView): void;
  10889. /**
  10890. * Creates a luminance texture from some data.
  10891. * @param data Define the texture data
  10892. * @param width Define the width of the texture
  10893. * @param height Define the height of the texture
  10894. * @param scene Define the scene the texture belongs to
  10895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10898. * @returns the luminance texture
  10899. */
  10900. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10901. /**
  10902. * Creates a luminance alpha texture from some data.
  10903. * @param data Define the texture data
  10904. * @param width Define the width of the texture
  10905. * @param height Define the height of the texture
  10906. * @param scene Define the scene the texture belongs to
  10907. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10908. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10909. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10910. * @returns the luminance alpha texture
  10911. */
  10912. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10913. /**
  10914. * Creates an alpha texture from some data.
  10915. * @param data Define the texture data
  10916. * @param width Define the width of the texture
  10917. * @param height Define the height of the texture
  10918. * @param scene Define the scene the texture belongs to
  10919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10922. * @returns the alpha texture
  10923. */
  10924. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10925. /**
  10926. * Creates a RGB texture from some data.
  10927. * @param data Define the texture data
  10928. * @param width Define the width of the texture
  10929. * @param height Define the height of the texture
  10930. * @param scene Define the scene the texture belongs to
  10931. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10932. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10933. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10934. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10935. * @returns the RGB alpha texture
  10936. */
  10937. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10938. /**
  10939. * Creates a RGBA texture from some data.
  10940. * @param data Define the texture data
  10941. * @param width Define the width of the texture
  10942. * @param height Define the height of the texture
  10943. * @param scene Define the scene the texture belongs to
  10944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10947. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10948. * @returns the RGBA texture
  10949. */
  10950. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10951. /**
  10952. * Creates a R texture from some data.
  10953. * @param data Define the texture data
  10954. * @param width Define the width of the texture
  10955. * @param height Define the height of the texture
  10956. * @param scene Define the scene the texture belongs to
  10957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10960. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10961. * @returns the R texture
  10962. */
  10963. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10964. }
  10965. }
  10966. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10967. import { Scene } from "babylonjs/scene";
  10968. import { ISceneComponent } from "babylonjs/sceneComponent";
  10969. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10970. module "babylonjs/abstractScene" {
  10971. interface AbstractScene {
  10972. /**
  10973. * The list of procedural textures added to the scene
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10975. */
  10976. proceduralTextures: Array<ProceduralTexture>;
  10977. }
  10978. }
  10979. /**
  10980. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10981. * in a given scene.
  10982. */
  10983. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10984. /**
  10985. * The component name helpfull to identify the component in the list of scene components.
  10986. */
  10987. readonly name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _beforeClear;
  11011. }
  11012. }
  11013. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11015. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11016. module "babylonjs/Engines/thinEngine" {
  11017. interface ThinEngine {
  11018. /**
  11019. * Creates a new render target cube texture
  11020. * @param size defines the size of the texture
  11021. * @param options defines the options used to create the texture
  11022. * @returns a new render target cube texture stored in an InternalTexture
  11023. */
  11024. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11025. }
  11026. }
  11027. }
  11028. declare module "babylonjs/Shaders/procedural.vertex" {
  11029. /** @hidden */
  11030. export var proceduralVertexShader: {
  11031. name: string;
  11032. shader: string;
  11033. };
  11034. }
  11035. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11036. import { Observable } from "babylonjs/Misc/observable";
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11041. import { Effect } from "babylonjs/Materials/effect";
  11042. import { Texture } from "babylonjs/Materials/Textures/texture";
  11043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11045. import "babylonjs/Shaders/procedural.vertex";
  11046. /**
  11047. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11048. * This is the base class of any Procedural texture and contains most of the shareable code.
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11050. */
  11051. export class ProceduralTexture extends Texture {
  11052. isCube: boolean;
  11053. /**
  11054. * Define if the texture is enabled or not (disabled texture will not render)
  11055. */
  11056. isEnabled: boolean;
  11057. /**
  11058. * Define if the texture must be cleared before rendering (default is true)
  11059. */
  11060. autoClear: boolean;
  11061. /**
  11062. * Callback called when the texture is generated
  11063. */
  11064. onGenerated: () => void;
  11065. /**
  11066. * Event raised when the texture is generated
  11067. */
  11068. onGeneratedObservable: Observable<ProceduralTexture>;
  11069. /** @hidden */
  11070. _generateMipMaps: boolean;
  11071. /** @hidden **/
  11072. _effect: Effect;
  11073. /** @hidden */
  11074. _textures: {
  11075. [key: string]: Texture;
  11076. };
  11077. /** @hidden */
  11078. protected _fallbackTexture: Nullable<Texture>;
  11079. private _size;
  11080. private _currentRefreshId;
  11081. private _frameId;
  11082. private _refreshRate;
  11083. private _vertexBuffers;
  11084. private _indexBuffer;
  11085. private _uniforms;
  11086. private _samplers;
  11087. private _fragment;
  11088. private _floats;
  11089. private _ints;
  11090. private _floatsArrays;
  11091. private _colors3;
  11092. private _colors4;
  11093. private _vectors2;
  11094. private _vectors3;
  11095. private _matrices;
  11096. private _fallbackTextureUsed;
  11097. private _engine;
  11098. private _cachedDefines;
  11099. private _contentUpdateId;
  11100. private _contentData;
  11101. /**
  11102. * Instantiates a new procedural texture.
  11103. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11104. * This is the base class of any Procedural texture and contains most of the shareable code.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11106. * @param name Define the name of the texture
  11107. * @param size Define the size of the texture to create
  11108. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11109. * @param scene Define the scene the texture belongs to
  11110. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11111. * @param generateMipMaps Define if the texture should creates mip maps or not
  11112. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11113. */
  11114. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11115. /**
  11116. * The effect that is created when initializing the post process.
  11117. * @returns The created effect corresponding the the postprocess.
  11118. */
  11119. getEffect(): Effect;
  11120. /**
  11121. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11122. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11123. */
  11124. getContent(): Nullable<ArrayBufferView>;
  11125. private _createIndexBuffer;
  11126. /** @hidden */
  11127. _rebuild(): void;
  11128. /**
  11129. * Resets the texture in order to recreate its associated resources.
  11130. * This can be called in case of context loss
  11131. */
  11132. reset(): void;
  11133. protected _getDefines(): string;
  11134. /**
  11135. * Is the texture ready to be used ? (rendered at least once)
  11136. * @returns true if ready, otherwise, false.
  11137. */
  11138. isReady(): boolean;
  11139. /**
  11140. * Resets the refresh counter of the texture and start bak from scratch.
  11141. * Could be useful to regenerate the texture if it is setup to render only once.
  11142. */
  11143. resetRefreshCounter(): void;
  11144. /**
  11145. * Set the fragment shader to use in order to render the texture.
  11146. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11147. */
  11148. setFragment(fragment: any): void;
  11149. /**
  11150. * Define the refresh rate of the texture or the rendering frequency.
  11151. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11152. */
  11153. get refreshRate(): number;
  11154. set refreshRate(value: number);
  11155. /** @hidden */
  11156. _shouldRender(): boolean;
  11157. /**
  11158. * Get the size the texture is rendering at.
  11159. * @returns the size (texture is always squared)
  11160. */
  11161. getRenderSize(): number;
  11162. /**
  11163. * Resize the texture to new value.
  11164. * @param size Define the new size the texture should have
  11165. * @param generateMipMaps Define whether the new texture should create mip maps
  11166. */
  11167. resize(size: number, generateMipMaps: boolean): void;
  11168. private _checkUniform;
  11169. /**
  11170. * Set a texture in the shader program used to render.
  11171. * @param name Define the name of the uniform samplers as defined in the shader
  11172. * @param texture Define the texture to bind to this sampler
  11173. * @return the texture itself allowing "fluent" like uniform updates
  11174. */
  11175. setTexture(name: string, texture: Texture): ProceduralTexture;
  11176. /**
  11177. * Set a float in the shader.
  11178. * @param name Define the name of the uniform as defined in the shader
  11179. * @param value Define the value to give to the uniform
  11180. * @return the texture itself allowing "fluent" like uniform updates
  11181. */
  11182. setFloat(name: string, value: number): ProceduralTexture;
  11183. /**
  11184. * Set a int in the shader.
  11185. * @param name Define the name of the uniform as defined in the shader
  11186. * @param value Define the value to give to the uniform
  11187. * @return the texture itself allowing "fluent" like uniform updates
  11188. */
  11189. setInt(name: string, value: number): ProceduralTexture;
  11190. /**
  11191. * Set an array of floats in the shader.
  11192. * @param name Define the name of the uniform as defined in the shader
  11193. * @param value Define the value to give to the uniform
  11194. * @return the texture itself allowing "fluent" like uniform updates
  11195. */
  11196. setFloats(name: string, value: number[]): ProceduralTexture;
  11197. /**
  11198. * Set a vec3 in the shader from a Color3.
  11199. * @param name Define the name of the uniform as defined in the shader
  11200. * @param value Define the value to give to the uniform
  11201. * @return the texture itself allowing "fluent" like uniform updates
  11202. */
  11203. setColor3(name: string, value: Color3): ProceduralTexture;
  11204. /**
  11205. * Set a vec4 in the shader from a Color4.
  11206. * @param name Define the name of the uniform as defined in the shader
  11207. * @param value Define the value to give to the uniform
  11208. * @return the texture itself allowing "fluent" like uniform updates
  11209. */
  11210. setColor4(name: string, value: Color4): ProceduralTexture;
  11211. /**
  11212. * Set a vec2 in the shader from a Vector2.
  11213. * @param name Define the name of the uniform as defined in the shader
  11214. * @param value Define the value to give to the uniform
  11215. * @return the texture itself allowing "fluent" like uniform updates
  11216. */
  11217. setVector2(name: string, value: Vector2): ProceduralTexture;
  11218. /**
  11219. * Set a vec3 in the shader from a Vector3.
  11220. * @param name Define the name of the uniform as defined in the shader
  11221. * @param value Define the value to give to the uniform
  11222. * @return the texture itself allowing "fluent" like uniform updates
  11223. */
  11224. setVector3(name: string, value: Vector3): ProceduralTexture;
  11225. /**
  11226. * Set a mat4 in the shader from a MAtrix.
  11227. * @param name Define the name of the uniform as defined in the shader
  11228. * @param value Define the value to give to the uniform
  11229. * @return the texture itself allowing "fluent" like uniform updates
  11230. */
  11231. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11232. /**
  11233. * Render the texture to its associated render target.
  11234. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11235. */
  11236. render(useCameraPostProcess?: boolean): void;
  11237. /**
  11238. * Clone the texture.
  11239. * @returns the cloned texture
  11240. */
  11241. clone(): ProceduralTexture;
  11242. /**
  11243. * Dispose the texture and release its asoociated resources.
  11244. */
  11245. dispose(): void;
  11246. }
  11247. }
  11248. declare module "babylonjs/Particles/baseParticleSystem" {
  11249. import { Nullable } from "babylonjs/types";
  11250. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11252. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11253. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11254. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11255. import { Scene } from "babylonjs/scene";
  11256. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11257. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11258. import { Texture } from "babylonjs/Materials/Textures/texture";
  11259. import { Color4 } from "babylonjs/Maths/math.color";
  11260. import { Animation } from "babylonjs/Animations/animation";
  11261. /**
  11262. * This represents the base class for particle system in Babylon.
  11263. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11264. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11265. * @example https://doc.babylonjs.com/babylon101/particles
  11266. */
  11267. export class BaseParticleSystem {
  11268. /**
  11269. * Source color is added to the destination color without alpha affecting the result
  11270. */
  11271. static BLENDMODE_ONEONE: number;
  11272. /**
  11273. * Blend current color and particle color using particle’s alpha
  11274. */
  11275. static BLENDMODE_STANDARD: number;
  11276. /**
  11277. * Add current color and particle color multiplied by particle’s alpha
  11278. */
  11279. static BLENDMODE_ADD: number;
  11280. /**
  11281. * Multiply current color with particle color
  11282. */
  11283. static BLENDMODE_MULTIPLY: number;
  11284. /**
  11285. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11286. */
  11287. static BLENDMODE_MULTIPLYADD: number;
  11288. /**
  11289. * List of animations used by the particle system.
  11290. */
  11291. animations: Animation[];
  11292. /**
  11293. * Gets or sets the unique id of the particle system
  11294. */
  11295. uniqueId: number;
  11296. /**
  11297. * The id of the Particle system.
  11298. */
  11299. id: string;
  11300. /**
  11301. * The friendly name of the Particle system.
  11302. */
  11303. name: string;
  11304. /**
  11305. * Snippet ID if the particle system was created from the snippet server
  11306. */
  11307. snippetId: string;
  11308. /**
  11309. * The rendering group used by the Particle system to chose when to render.
  11310. */
  11311. renderingGroupId: number;
  11312. /**
  11313. * The emitter represents the Mesh or position we are attaching the particle system to.
  11314. */
  11315. emitter: Nullable<AbstractMesh | Vector3>;
  11316. /**
  11317. * The maximum number of particles to emit per frame
  11318. */
  11319. emitRate: number;
  11320. /**
  11321. * If you want to launch only a few particles at once, that can be done, as well.
  11322. */
  11323. manualEmitCount: number;
  11324. /**
  11325. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11326. */
  11327. updateSpeed: number;
  11328. /**
  11329. * The amount of time the particle system is running (depends of the overall update speed).
  11330. */
  11331. targetStopDuration: number;
  11332. /**
  11333. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11334. */
  11335. disposeOnStop: boolean;
  11336. /**
  11337. * Minimum power of emitting particles.
  11338. */
  11339. minEmitPower: number;
  11340. /**
  11341. * Maximum power of emitting particles.
  11342. */
  11343. maxEmitPower: number;
  11344. /**
  11345. * Minimum life time of emitting particles.
  11346. */
  11347. minLifeTime: number;
  11348. /**
  11349. * Maximum life time of emitting particles.
  11350. */
  11351. maxLifeTime: number;
  11352. /**
  11353. * Minimum Size of emitting particles.
  11354. */
  11355. minSize: number;
  11356. /**
  11357. * Maximum Size of emitting particles.
  11358. */
  11359. maxSize: number;
  11360. /**
  11361. * Minimum scale of emitting particles on X axis.
  11362. */
  11363. minScaleX: number;
  11364. /**
  11365. * Maximum scale of emitting particles on X axis.
  11366. */
  11367. maxScaleX: number;
  11368. /**
  11369. * Minimum scale of emitting particles on Y axis.
  11370. */
  11371. minScaleY: number;
  11372. /**
  11373. * Maximum scale of emitting particles on Y axis.
  11374. */
  11375. maxScaleY: number;
  11376. /**
  11377. * Gets or sets the minimal initial rotation in radians.
  11378. */
  11379. minInitialRotation: number;
  11380. /**
  11381. * Gets or sets the maximal initial rotation in radians.
  11382. */
  11383. maxInitialRotation: number;
  11384. /**
  11385. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11386. */
  11387. minAngularSpeed: number;
  11388. /**
  11389. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11390. */
  11391. maxAngularSpeed: number;
  11392. /**
  11393. * The texture used to render each particle. (this can be a spritesheet)
  11394. */
  11395. particleTexture: Nullable<Texture>;
  11396. /**
  11397. * The layer mask we are rendering the particles through.
  11398. */
  11399. layerMask: number;
  11400. /**
  11401. * This can help using your own shader to render the particle system.
  11402. * The according effect will be created
  11403. */
  11404. customShader: any;
  11405. /**
  11406. * By default particle system starts as soon as they are created. This prevents the
  11407. * automatic start to happen and let you decide when to start emitting particles.
  11408. */
  11409. preventAutoStart: boolean;
  11410. private _noiseTexture;
  11411. /**
  11412. * Gets or sets a texture used to add random noise to particle positions
  11413. */
  11414. get noiseTexture(): Nullable<ProceduralTexture>;
  11415. set noiseTexture(value: Nullable<ProceduralTexture>);
  11416. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11417. noiseStrength: Vector3;
  11418. /**
  11419. * Callback triggered when the particle animation is ending.
  11420. */
  11421. onAnimationEnd: Nullable<() => void>;
  11422. /**
  11423. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11424. */
  11425. blendMode: number;
  11426. /**
  11427. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11428. * to override the particles.
  11429. */
  11430. forceDepthWrite: boolean;
  11431. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11432. preWarmCycles: number;
  11433. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11434. preWarmStepOffset: number;
  11435. /**
  11436. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11437. */
  11438. spriteCellChangeSpeed: number;
  11439. /**
  11440. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11441. */
  11442. startSpriteCellID: number;
  11443. /**
  11444. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11445. */
  11446. endSpriteCellID: number;
  11447. /**
  11448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11449. */
  11450. spriteCellWidth: number;
  11451. /**
  11452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11453. */
  11454. spriteCellHeight: number;
  11455. /**
  11456. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11457. */
  11458. spriteRandomStartCell: boolean;
  11459. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11460. translationPivot: Vector2;
  11461. /** @hidden */
  11462. protected _isAnimationSheetEnabled: boolean;
  11463. /**
  11464. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11465. */
  11466. beginAnimationOnStart: boolean;
  11467. /**
  11468. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11469. */
  11470. beginAnimationFrom: number;
  11471. /**
  11472. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11473. */
  11474. beginAnimationTo: number;
  11475. /**
  11476. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11477. */
  11478. beginAnimationLoop: boolean;
  11479. /**
  11480. * Gets or sets a world offset applied to all particles
  11481. */
  11482. worldOffset: Vector3;
  11483. /**
  11484. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11485. */
  11486. get isAnimationSheetEnabled(): boolean;
  11487. set isAnimationSheetEnabled(value: boolean);
  11488. /**
  11489. * Get hosting scene
  11490. * @returns the scene
  11491. */
  11492. getScene(): Scene;
  11493. /**
  11494. * You can use gravity if you want to give an orientation to your particles.
  11495. */
  11496. gravity: Vector3;
  11497. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11498. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11499. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11500. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11501. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11502. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11503. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11504. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11505. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11506. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11507. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11508. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11509. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11510. /**
  11511. * Defines the delay in milliseconds before starting the system (0 by default)
  11512. */
  11513. startDelay: number;
  11514. /**
  11515. * Gets the current list of drag gradients.
  11516. * You must use addDragGradient and removeDragGradient to udpate this list
  11517. * @returns the list of drag gradients
  11518. */
  11519. getDragGradients(): Nullable<Array<FactorGradient>>;
  11520. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11521. limitVelocityDamping: number;
  11522. /**
  11523. * Gets the current list of limit velocity gradients.
  11524. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11525. * @returns the list of limit velocity gradients
  11526. */
  11527. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11528. /**
  11529. * Gets the current list of color gradients.
  11530. * You must use addColorGradient and removeColorGradient to udpate this list
  11531. * @returns the list of color gradients
  11532. */
  11533. getColorGradients(): Nullable<Array<ColorGradient>>;
  11534. /**
  11535. * Gets the current list of size gradients.
  11536. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11537. * @returns the list of size gradients
  11538. */
  11539. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11540. /**
  11541. * Gets the current list of color remap gradients.
  11542. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11543. * @returns the list of color remap gradients
  11544. */
  11545. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11546. /**
  11547. * Gets the current list of alpha remap gradients.
  11548. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11549. * @returns the list of alpha remap gradients
  11550. */
  11551. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11552. /**
  11553. * Gets the current list of life time gradients.
  11554. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11555. * @returns the list of life time gradients
  11556. */
  11557. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11558. /**
  11559. * Gets the current list of angular speed gradients.
  11560. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11561. * @returns the list of angular speed gradients
  11562. */
  11563. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11564. /**
  11565. * Gets the current list of velocity gradients.
  11566. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11567. * @returns the list of velocity gradients
  11568. */
  11569. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11570. /**
  11571. * Gets the current list of start size gradients.
  11572. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11573. * @returns the list of start size gradients
  11574. */
  11575. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11576. /**
  11577. * Gets the current list of emit rate gradients.
  11578. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11579. * @returns the list of emit rate gradients
  11580. */
  11581. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11582. /**
  11583. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11584. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11585. */
  11586. get direction1(): Vector3;
  11587. set direction1(value: Vector3);
  11588. /**
  11589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11591. */
  11592. get direction2(): Vector3;
  11593. set direction2(value: Vector3);
  11594. /**
  11595. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11597. */
  11598. get minEmitBox(): Vector3;
  11599. set minEmitBox(value: Vector3);
  11600. /**
  11601. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11603. */
  11604. get maxEmitBox(): Vector3;
  11605. set maxEmitBox(value: Vector3);
  11606. /**
  11607. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11608. */
  11609. color1: Color4;
  11610. /**
  11611. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11612. */
  11613. color2: Color4;
  11614. /**
  11615. * Color the particle will have at the end of its lifetime
  11616. */
  11617. colorDead: Color4;
  11618. /**
  11619. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11620. */
  11621. textureMask: Color4;
  11622. /**
  11623. * The particle emitter type defines the emitter used by the particle system.
  11624. * It can be for example box, sphere, or cone...
  11625. */
  11626. particleEmitterType: IParticleEmitterType;
  11627. /** @hidden */
  11628. _isSubEmitter: boolean;
  11629. /**
  11630. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11631. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11632. */
  11633. billboardMode: number;
  11634. protected _isBillboardBased: boolean;
  11635. /**
  11636. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11637. */
  11638. get isBillboardBased(): boolean;
  11639. set isBillboardBased(value: boolean);
  11640. /**
  11641. * The scene the particle system belongs to.
  11642. */
  11643. protected _scene: Scene;
  11644. /**
  11645. * Local cache of defines for image processing.
  11646. */
  11647. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11648. /**
  11649. * Default configuration related to image processing available in the standard Material.
  11650. */
  11651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11652. /**
  11653. * Gets the image processing configuration used either in this material.
  11654. */
  11655. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11656. /**
  11657. * Sets the Default image processing configuration used either in the this material.
  11658. *
  11659. * If sets to null, the scene one is in use.
  11660. */
  11661. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11662. /**
  11663. * Attaches a new image processing configuration to the Standard Material.
  11664. * @param configuration
  11665. */
  11666. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11667. /** @hidden */
  11668. protected _reset(): void;
  11669. /** @hidden */
  11670. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11671. /**
  11672. * Instantiates a particle system.
  11673. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11674. * @param name The name of the particle system
  11675. */
  11676. constructor(name: string);
  11677. /**
  11678. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11681. * @returns the emitter
  11682. */
  11683. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11684. /**
  11685. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11686. * @param radius The radius of the hemisphere to emit from
  11687. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11688. * @returns the emitter
  11689. */
  11690. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11691. /**
  11692. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11693. * @param radius The radius of the sphere to emit from
  11694. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11695. * @returns the emitter
  11696. */
  11697. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11698. /**
  11699. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11700. * @param radius The radius of the sphere to emit from
  11701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11703. * @returns the emitter
  11704. */
  11705. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11706. /**
  11707. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11708. * @param radius The radius of the emission cylinder
  11709. * @param height The height of the emission cylinder
  11710. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11711. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11712. * @returns the emitter
  11713. */
  11714. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11715. /**
  11716. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11717. * @param radius The radius of the cylinder to emit from
  11718. * @param height The height of the emission cylinder
  11719. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11720. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11721. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11722. * @returns the emitter
  11723. */
  11724. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11725. /**
  11726. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11727. * @param radius The radius of the cone to emit from
  11728. * @param angle The base angle of the cone
  11729. * @returns the emitter
  11730. */
  11731. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11732. /**
  11733. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11734. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11735. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11736. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11737. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11738. * @returns the emitter
  11739. */
  11740. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11741. }
  11742. }
  11743. declare module "babylonjs/Particles/subEmitter" {
  11744. import { Scene } from "babylonjs/scene";
  11745. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11746. /**
  11747. * Type of sub emitter
  11748. */
  11749. export enum SubEmitterType {
  11750. /**
  11751. * Attached to the particle over it's lifetime
  11752. */
  11753. ATTACHED = 0,
  11754. /**
  11755. * Created when the particle dies
  11756. */
  11757. END = 1
  11758. }
  11759. /**
  11760. * Sub emitter class used to emit particles from an existing particle
  11761. */
  11762. export class SubEmitter {
  11763. /**
  11764. * the particle system to be used by the sub emitter
  11765. */
  11766. particleSystem: ParticleSystem;
  11767. /**
  11768. * Type of the submitter (Default: END)
  11769. */
  11770. type: SubEmitterType;
  11771. /**
  11772. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11773. * Note: This only is supported when using an emitter of type Mesh
  11774. */
  11775. inheritDirection: boolean;
  11776. /**
  11777. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11778. */
  11779. inheritedVelocityAmount: number;
  11780. /**
  11781. * Creates a sub emitter
  11782. * @param particleSystem the particle system to be used by the sub emitter
  11783. */
  11784. constructor(
  11785. /**
  11786. * the particle system to be used by the sub emitter
  11787. */
  11788. particleSystem: ParticleSystem);
  11789. /**
  11790. * Clones the sub emitter
  11791. * @returns the cloned sub emitter
  11792. */
  11793. clone(): SubEmitter;
  11794. /**
  11795. * Serialize current object to a JSON object
  11796. * @returns the serialized object
  11797. */
  11798. serialize(): any;
  11799. /** @hidden */
  11800. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11801. /**
  11802. * Creates a new SubEmitter from a serialized JSON version
  11803. * @param serializationObject defines the JSON object to read from
  11804. * @param scene defines the hosting scene
  11805. * @param rootUrl defines the rootUrl for data loading
  11806. * @returns a new SubEmitter
  11807. */
  11808. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11809. /** Release associated resources */
  11810. dispose(): void;
  11811. }
  11812. }
  11813. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11814. /** @hidden */
  11815. export var imageProcessingDeclaration: {
  11816. name: string;
  11817. shader: string;
  11818. };
  11819. }
  11820. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11821. /** @hidden */
  11822. export var imageProcessingFunctions: {
  11823. name: string;
  11824. shader: string;
  11825. };
  11826. }
  11827. declare module "babylonjs/Shaders/particles.fragment" {
  11828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11829. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11831. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11833. /** @hidden */
  11834. export var particlesPixelShader: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/particles.vertex" {
  11840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11842. /** @hidden */
  11843. export var particlesVertexShader: {
  11844. name: string;
  11845. shader: string;
  11846. };
  11847. }
  11848. declare module "babylonjs/Particles/particleSystem" {
  11849. import { Nullable } from "babylonjs/types";
  11850. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11851. import { Observable } from "babylonjs/Misc/observable";
  11852. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11853. import { Effect } from "babylonjs/Materials/effect";
  11854. import { Scene, IDisposable } from "babylonjs/scene";
  11855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11856. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11857. import { Particle } from "babylonjs/Particles/particle";
  11858. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11859. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11860. import "babylonjs/Shaders/particles.fragment";
  11861. import "babylonjs/Shaders/particles.vertex";
  11862. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11863. /**
  11864. * This represents a particle system in Babylon.
  11865. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11867. * @example https://doc.babylonjs.com/babylon101/particles
  11868. */
  11869. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11870. /**
  11871. * Billboard mode will only apply to Y axis
  11872. */
  11873. static readonly BILLBOARDMODE_Y: number;
  11874. /**
  11875. * Billboard mode will apply to all axes
  11876. */
  11877. static readonly BILLBOARDMODE_ALL: number;
  11878. /**
  11879. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11880. */
  11881. static readonly BILLBOARDMODE_STRETCHED: number;
  11882. /**
  11883. * This function can be defined to provide custom update for active particles.
  11884. * This function will be called instead of regular update (age, position, color, etc.).
  11885. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11886. */
  11887. updateFunction: (particles: Particle[]) => void;
  11888. private _emitterWorldMatrix;
  11889. /**
  11890. * This function can be defined to specify initial direction for every new particle.
  11891. * It by default use the emitterType defined function
  11892. */
  11893. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11894. /**
  11895. * This function can be defined to specify initial position for every new particle.
  11896. * It by default use the emitterType defined function
  11897. */
  11898. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11899. /**
  11900. * @hidden
  11901. */
  11902. _inheritedVelocityOffset: Vector3;
  11903. /**
  11904. * An event triggered when the system is disposed
  11905. */
  11906. onDisposeObservable: Observable<ParticleSystem>;
  11907. private _onDisposeObserver;
  11908. /**
  11909. * Sets a callback that will be triggered when the system is disposed
  11910. */
  11911. set onDispose(callback: () => void);
  11912. private _particles;
  11913. private _epsilon;
  11914. private _capacity;
  11915. private _stockParticles;
  11916. private _newPartsExcess;
  11917. private _vertexData;
  11918. private _vertexBuffer;
  11919. private _vertexBuffers;
  11920. private _spriteBuffer;
  11921. private _indexBuffer;
  11922. private _effect;
  11923. private _customEffect;
  11924. private _cachedDefines;
  11925. private _scaledColorStep;
  11926. private _colorDiff;
  11927. private _scaledDirection;
  11928. private _scaledGravity;
  11929. private _currentRenderId;
  11930. private _alive;
  11931. private _useInstancing;
  11932. private _started;
  11933. private _stopped;
  11934. private _actualFrame;
  11935. private _scaledUpdateSpeed;
  11936. private _vertexBufferSize;
  11937. /** @hidden */
  11938. _currentEmitRateGradient: Nullable<FactorGradient>;
  11939. /** @hidden */
  11940. _currentEmitRate1: number;
  11941. /** @hidden */
  11942. _currentEmitRate2: number;
  11943. /** @hidden */
  11944. _currentStartSizeGradient: Nullable<FactorGradient>;
  11945. /** @hidden */
  11946. _currentStartSize1: number;
  11947. /** @hidden */
  11948. _currentStartSize2: number;
  11949. private readonly _rawTextureWidth;
  11950. private _rampGradientsTexture;
  11951. private _useRampGradients;
  11952. /** Gets or sets a boolean indicating that ramp gradients must be used
  11953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11954. */
  11955. get useRampGradients(): boolean;
  11956. set useRampGradients(value: boolean);
  11957. /**
  11958. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11959. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11960. */
  11961. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11962. private _subEmitters;
  11963. /**
  11964. * @hidden
  11965. * If the particle systems emitter should be disposed when the particle system is disposed
  11966. */
  11967. _disposeEmitterOnDispose: boolean;
  11968. /**
  11969. * The current active Sub-systems, this property is used by the root particle system only.
  11970. */
  11971. activeSubSystems: Array<ParticleSystem>;
  11972. /**
  11973. * Specifies if the particles are updated in emitter local space or world space
  11974. */
  11975. isLocal: boolean;
  11976. private _rootParticleSystem;
  11977. /**
  11978. * Gets the current list of active particles
  11979. */
  11980. get particles(): Particle[];
  11981. /**
  11982. * Gets the number of particles active at the same time.
  11983. * @returns The number of active particles.
  11984. */
  11985. getActiveCount(): number;
  11986. /**
  11987. * Returns the string "ParticleSystem"
  11988. * @returns a string containing the class name
  11989. */
  11990. getClassName(): string;
  11991. /**
  11992. * Gets a boolean indicating that the system is stopping
  11993. * @returns true if the system is currently stopping
  11994. */
  11995. isStopping(): boolean;
  11996. /**
  11997. * Instantiates a particle system.
  11998. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11999. * @param name The name of the particle system
  12000. * @param capacity The max number of particles alive at the same time
  12001. * @param scene The scene the particle system belongs to
  12002. * @param customEffect a custom effect used to change the way particles are rendered by default
  12003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12004. * @param epsilon Offset used to render the particles
  12005. */
  12006. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12007. private _addFactorGradient;
  12008. private _removeFactorGradient;
  12009. /**
  12010. * Adds a new life time gradient
  12011. * @param gradient defines the gradient to use (between 0 and 1)
  12012. * @param factor defines the life time factor to affect to the specified gradient
  12013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12014. * @returns the current particle system
  12015. */
  12016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12017. /**
  12018. * Remove a specific life time gradient
  12019. * @param gradient defines the gradient to remove
  12020. * @returns the current particle system
  12021. */
  12022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12023. /**
  12024. * Adds a new size gradient
  12025. * @param gradient defines the gradient to use (between 0 and 1)
  12026. * @param factor defines the size factor to affect to the specified gradient
  12027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12028. * @returns the current particle system
  12029. */
  12030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12031. /**
  12032. * Remove a specific size gradient
  12033. * @param gradient defines the gradient to remove
  12034. * @returns the current particle system
  12035. */
  12036. removeSizeGradient(gradient: number): IParticleSystem;
  12037. /**
  12038. * Adds a new color remap gradient
  12039. * @param gradient defines the gradient to use (between 0 and 1)
  12040. * @param min defines the color remap minimal range
  12041. * @param max defines the color remap maximal range
  12042. * @returns the current particle system
  12043. */
  12044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12045. /**
  12046. * Remove a specific color remap gradient
  12047. * @param gradient defines the gradient to remove
  12048. * @returns the current particle system
  12049. */
  12050. removeColorRemapGradient(gradient: number): IParticleSystem;
  12051. /**
  12052. * Adds a new alpha remap gradient
  12053. * @param gradient defines the gradient to use (between 0 and 1)
  12054. * @param min defines the alpha remap minimal range
  12055. * @param max defines the alpha remap maximal range
  12056. * @returns the current particle system
  12057. */
  12058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12059. /**
  12060. * Remove a specific alpha remap gradient
  12061. * @param gradient defines the gradient to remove
  12062. * @returns the current particle system
  12063. */
  12064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12065. /**
  12066. * Adds a new angular speed gradient
  12067. * @param gradient defines the gradient to use (between 0 and 1)
  12068. * @param factor defines the angular speed to affect to the specified gradient
  12069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12070. * @returns the current particle system
  12071. */
  12072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12073. /**
  12074. * Remove a specific angular speed gradient
  12075. * @param gradient defines the gradient to remove
  12076. * @returns the current particle system
  12077. */
  12078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12079. /**
  12080. * Adds a new velocity gradient
  12081. * @param gradient defines the gradient to use (between 0 and 1)
  12082. * @param factor defines the velocity to affect to the specified gradient
  12083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12084. * @returns the current particle system
  12085. */
  12086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12087. /**
  12088. * Remove a specific velocity gradient
  12089. * @param gradient defines the gradient to remove
  12090. * @returns the current particle system
  12091. */
  12092. removeVelocityGradient(gradient: number): IParticleSystem;
  12093. /**
  12094. * Adds a new limit velocity gradient
  12095. * @param gradient defines the gradient to use (between 0 and 1)
  12096. * @param factor defines the limit velocity value to affect to the specified gradient
  12097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12098. * @returns the current particle system
  12099. */
  12100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12101. /**
  12102. * Remove a specific limit velocity gradient
  12103. * @param gradient defines the gradient to remove
  12104. * @returns the current particle system
  12105. */
  12106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12107. /**
  12108. * Adds a new drag gradient
  12109. * @param gradient defines the gradient to use (between 0 and 1)
  12110. * @param factor defines the drag value to affect to the specified gradient
  12111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12112. * @returns the current particle system
  12113. */
  12114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12115. /**
  12116. * Remove a specific drag gradient
  12117. * @param gradient defines the gradient to remove
  12118. * @returns the current particle system
  12119. */
  12120. removeDragGradient(gradient: number): IParticleSystem;
  12121. /**
  12122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12123. * @param gradient defines the gradient to use (between 0 and 1)
  12124. * @param factor defines the emit rate value to affect to the specified gradient
  12125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12126. * @returns the current particle system
  12127. */
  12128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12129. /**
  12130. * Remove a specific emit rate gradient
  12131. * @param gradient defines the gradient to remove
  12132. * @returns the current particle system
  12133. */
  12134. removeEmitRateGradient(gradient: number): IParticleSystem;
  12135. /**
  12136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12137. * @param gradient defines the gradient to use (between 0 and 1)
  12138. * @param factor defines the start size value to affect to the specified gradient
  12139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12140. * @returns the current particle system
  12141. */
  12142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12143. /**
  12144. * Remove a specific start size gradient
  12145. * @param gradient defines the gradient to remove
  12146. * @returns the current particle system
  12147. */
  12148. removeStartSizeGradient(gradient: number): IParticleSystem;
  12149. private _createRampGradientTexture;
  12150. /**
  12151. * Gets the current list of ramp gradients.
  12152. * You must use addRampGradient and removeRampGradient to udpate this list
  12153. * @returns the list of ramp gradients
  12154. */
  12155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12156. /** Force the system to rebuild all gradients that need to be resync */
  12157. forceRefreshGradients(): void;
  12158. private _syncRampGradientTexture;
  12159. /**
  12160. * Adds a new ramp gradient used to remap particle colors
  12161. * @param gradient defines the gradient to use (between 0 and 1)
  12162. * @param color defines the color to affect to the specified gradient
  12163. * @returns the current particle system
  12164. */
  12165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12166. /**
  12167. * Remove a specific ramp gradient
  12168. * @param gradient defines the gradient to remove
  12169. * @returns the current particle system
  12170. */
  12171. removeRampGradient(gradient: number): ParticleSystem;
  12172. /**
  12173. * Adds a new color gradient
  12174. * @param gradient defines the gradient to use (between 0 and 1)
  12175. * @param color1 defines the color to affect to the specified gradient
  12176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12177. * @returns this particle system
  12178. */
  12179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12180. /**
  12181. * Remove a specific color gradient
  12182. * @param gradient defines the gradient to remove
  12183. * @returns this particle system
  12184. */
  12185. removeColorGradient(gradient: number): IParticleSystem;
  12186. private _fetchR;
  12187. protected _reset(): void;
  12188. private _resetEffect;
  12189. private _createVertexBuffers;
  12190. private _createIndexBuffer;
  12191. /**
  12192. * Gets the maximum number of particles active at the same time.
  12193. * @returns The max number of active particles.
  12194. */
  12195. getCapacity(): number;
  12196. /**
  12197. * Gets whether there are still active particles in the system.
  12198. * @returns True if it is alive, otherwise false.
  12199. */
  12200. isAlive(): boolean;
  12201. /**
  12202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12203. * @returns True if it has been started, otherwise false.
  12204. */
  12205. isStarted(): boolean;
  12206. private _prepareSubEmitterInternalArray;
  12207. /**
  12208. * Starts the particle system and begins to emit
  12209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12210. */
  12211. start(delay?: number): void;
  12212. /**
  12213. * Stops the particle system.
  12214. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12215. */
  12216. stop(stopSubEmitters?: boolean): void;
  12217. /**
  12218. * Remove all active particles
  12219. */
  12220. reset(): void;
  12221. /**
  12222. * @hidden (for internal use only)
  12223. */
  12224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12225. /**
  12226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12227. * Its lifetime will start back at 0.
  12228. */
  12229. recycleParticle: (particle: Particle) => void;
  12230. private _stopSubEmitters;
  12231. private _createParticle;
  12232. private _removeFromRoot;
  12233. private _emitFromParticle;
  12234. private _update;
  12235. /** @hidden */
  12236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12237. /** @hidden */
  12238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12239. /** @hidden */
  12240. private _getEffect;
  12241. /**
  12242. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12243. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12244. */
  12245. animate(preWarmOnly?: boolean): void;
  12246. private _appendParticleVertices;
  12247. /**
  12248. * Rebuilds the particle system.
  12249. */
  12250. rebuild(): void;
  12251. /**
  12252. * Is this system ready to be used/rendered
  12253. * @return true if the system is ready
  12254. */
  12255. isReady(): boolean;
  12256. private _render;
  12257. /**
  12258. * Renders the particle system in its current state.
  12259. * @returns the current number of particles
  12260. */
  12261. render(): number;
  12262. /**
  12263. * Disposes the particle system and free the associated resources
  12264. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12265. */
  12266. dispose(disposeTexture?: boolean): void;
  12267. /**
  12268. * Clones the particle system.
  12269. * @param name The name of the cloned object
  12270. * @param newEmitter The new emitter to use
  12271. * @returns the cloned particle system
  12272. */
  12273. clone(name: string, newEmitter: any): ParticleSystem;
  12274. /**
  12275. * Serializes the particle system to a JSON object
  12276. * @param serializeTexture defines if the texture must be serialized as well
  12277. * @returns the JSON object
  12278. */
  12279. serialize(serializeTexture?: boolean): any;
  12280. /** @hidden */
  12281. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12282. /** @hidden */
  12283. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12284. /**
  12285. * Parses a JSON object to create a particle system.
  12286. * @param parsedParticleSystem The JSON object to parse
  12287. * @param scene The scene to create the particle system in
  12288. * @param rootUrl The root url to use to load external dependencies like texture
  12289. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12290. * @returns the Parsed particle system
  12291. */
  12292. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12293. }
  12294. }
  12295. declare module "babylonjs/Particles/particle" {
  12296. import { Nullable } from "babylonjs/types";
  12297. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12298. import { Color4 } from "babylonjs/Maths/math.color";
  12299. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12300. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12301. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12302. /**
  12303. * A particle represents one of the element emitted by a particle system.
  12304. * This is mainly define by its coordinates, direction, velocity and age.
  12305. */
  12306. export class Particle {
  12307. /**
  12308. * The particle system the particle belongs to.
  12309. */
  12310. particleSystem: ParticleSystem;
  12311. private static _Count;
  12312. /**
  12313. * Unique ID of the particle
  12314. */
  12315. id: number;
  12316. /**
  12317. * The world position of the particle in the scene.
  12318. */
  12319. position: Vector3;
  12320. /**
  12321. * The world direction of the particle in the scene.
  12322. */
  12323. direction: Vector3;
  12324. /**
  12325. * The color of the particle.
  12326. */
  12327. color: Color4;
  12328. /**
  12329. * The color change of the particle per step.
  12330. */
  12331. colorStep: Color4;
  12332. /**
  12333. * Defines how long will the life of the particle be.
  12334. */
  12335. lifeTime: number;
  12336. /**
  12337. * The current age of the particle.
  12338. */
  12339. age: number;
  12340. /**
  12341. * The current size of the particle.
  12342. */
  12343. size: number;
  12344. /**
  12345. * The current scale of the particle.
  12346. */
  12347. scale: Vector2;
  12348. /**
  12349. * The current angle of the particle.
  12350. */
  12351. angle: number;
  12352. /**
  12353. * Defines how fast is the angle changing.
  12354. */
  12355. angularSpeed: number;
  12356. /**
  12357. * Defines the cell index used by the particle to be rendered from a sprite.
  12358. */
  12359. cellIndex: number;
  12360. /**
  12361. * The information required to support color remapping
  12362. */
  12363. remapData: Vector4;
  12364. /** @hidden */
  12365. _randomCellOffset?: number;
  12366. /** @hidden */
  12367. _initialDirection: Nullable<Vector3>;
  12368. /** @hidden */
  12369. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12370. /** @hidden */
  12371. _initialStartSpriteCellID: number;
  12372. /** @hidden */
  12373. _initialEndSpriteCellID: number;
  12374. /** @hidden */
  12375. _currentColorGradient: Nullable<ColorGradient>;
  12376. /** @hidden */
  12377. _currentColor1: Color4;
  12378. /** @hidden */
  12379. _currentColor2: Color4;
  12380. /** @hidden */
  12381. _currentSizeGradient: Nullable<FactorGradient>;
  12382. /** @hidden */
  12383. _currentSize1: number;
  12384. /** @hidden */
  12385. _currentSize2: number;
  12386. /** @hidden */
  12387. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12388. /** @hidden */
  12389. _currentAngularSpeed1: number;
  12390. /** @hidden */
  12391. _currentAngularSpeed2: number;
  12392. /** @hidden */
  12393. _currentVelocityGradient: Nullable<FactorGradient>;
  12394. /** @hidden */
  12395. _currentVelocity1: number;
  12396. /** @hidden */
  12397. _currentVelocity2: number;
  12398. /** @hidden */
  12399. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12400. /** @hidden */
  12401. _currentLimitVelocity1: number;
  12402. /** @hidden */
  12403. _currentLimitVelocity2: number;
  12404. /** @hidden */
  12405. _currentDragGradient: Nullable<FactorGradient>;
  12406. /** @hidden */
  12407. _currentDrag1: number;
  12408. /** @hidden */
  12409. _currentDrag2: number;
  12410. /** @hidden */
  12411. _randomNoiseCoordinates1: Vector3;
  12412. /** @hidden */
  12413. _randomNoiseCoordinates2: Vector3;
  12414. /** @hidden */
  12415. _localPosition?: Vector3;
  12416. /**
  12417. * Creates a new instance Particle
  12418. * @param particleSystem the particle system the particle belongs to
  12419. */
  12420. constructor(
  12421. /**
  12422. * The particle system the particle belongs to.
  12423. */
  12424. particleSystem: ParticleSystem);
  12425. private updateCellInfoFromSystem;
  12426. /**
  12427. * Defines how the sprite cell index is updated for the particle
  12428. */
  12429. updateCellIndex(): void;
  12430. /** @hidden */
  12431. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12432. /** @hidden */
  12433. _inheritParticleInfoToSubEmitters(): void;
  12434. /** @hidden */
  12435. _reset(): void;
  12436. /**
  12437. * Copy the properties of particle to another one.
  12438. * @param other the particle to copy the information to.
  12439. */
  12440. copyTo(other: Particle): void;
  12441. }
  12442. }
  12443. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12444. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12445. import { Effect } from "babylonjs/Materials/effect";
  12446. import { Particle } from "babylonjs/Particles/particle";
  12447. import { Scene } from "babylonjs/scene";
  12448. /**
  12449. * Particle emitter represents a volume emitting particles.
  12450. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12451. */
  12452. export interface IParticleEmitterType {
  12453. /**
  12454. * Called by the particle System when the direction is computed for the created particle.
  12455. * @param worldMatrix is the world matrix of the particle system
  12456. * @param directionToUpdate is the direction vector to update with the result
  12457. * @param particle is the particle we are computed the direction for
  12458. * @param isLocal defines if the direction should be set in local space
  12459. */
  12460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12461. /**
  12462. * Called by the particle System when the position is computed for the created particle.
  12463. * @param worldMatrix is the world matrix of the particle system
  12464. * @param positionToUpdate is the position vector to update with the result
  12465. * @param particle is the particle we are computed the position for
  12466. * @param isLocal defines if the position should be set in local space
  12467. */
  12468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12469. /**
  12470. * Clones the current emitter and returns a copy of it
  12471. * @returns the new emitter
  12472. */
  12473. clone(): IParticleEmitterType;
  12474. /**
  12475. * Called by the GPUParticleSystem to setup the update shader
  12476. * @param effect defines the update shader
  12477. */
  12478. applyToShader(effect: Effect): void;
  12479. /**
  12480. * Returns a string to use to update the GPU particles update shader
  12481. * @returns the effect defines string
  12482. */
  12483. getEffectDefines(): string;
  12484. /**
  12485. * Returns a string representing the class name
  12486. * @returns a string containing the class name
  12487. */
  12488. getClassName(): string;
  12489. /**
  12490. * Serializes the particle system to a JSON object.
  12491. * @returns the JSON object
  12492. */
  12493. serialize(): any;
  12494. /**
  12495. * Parse properties from a JSON object
  12496. * @param serializationObject defines the JSON object
  12497. * @param scene defines the hosting scene
  12498. */
  12499. parse(serializationObject: any, scene: Scene): void;
  12500. }
  12501. }
  12502. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12503. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12504. import { Effect } from "babylonjs/Materials/effect";
  12505. import { Particle } from "babylonjs/Particles/particle";
  12506. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12507. /**
  12508. * Particle emitter emitting particles from the inside of a box.
  12509. * It emits the particles randomly between 2 given directions.
  12510. */
  12511. export class BoxParticleEmitter implements IParticleEmitterType {
  12512. /**
  12513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12514. */
  12515. direction1: Vector3;
  12516. /**
  12517. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12518. */
  12519. direction2: Vector3;
  12520. /**
  12521. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12522. */
  12523. minEmitBox: Vector3;
  12524. /**
  12525. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12526. */
  12527. maxEmitBox: Vector3;
  12528. /**
  12529. * Creates a new instance BoxParticleEmitter
  12530. */
  12531. constructor();
  12532. /**
  12533. * Called by the particle System when the direction is computed for the created particle.
  12534. * @param worldMatrix is the world matrix of the particle system
  12535. * @param directionToUpdate is the direction vector to update with the result
  12536. * @param particle is the particle we are computed the direction for
  12537. * @param isLocal defines if the direction should be set in local space
  12538. */
  12539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12540. /**
  12541. * Called by the particle System when the position is computed for the created particle.
  12542. * @param worldMatrix is the world matrix of the particle system
  12543. * @param positionToUpdate is the position vector to update with the result
  12544. * @param particle is the particle we are computed the position for
  12545. * @param isLocal defines if the position should be set in local space
  12546. */
  12547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12548. /**
  12549. * Clones the current emitter and returns a copy of it
  12550. * @returns the new emitter
  12551. */
  12552. clone(): BoxParticleEmitter;
  12553. /**
  12554. * Called by the GPUParticleSystem to setup the update shader
  12555. * @param effect defines the update shader
  12556. */
  12557. applyToShader(effect: Effect): void;
  12558. /**
  12559. * Returns a string to use to update the GPU particles update shader
  12560. * @returns a string containng the defines string
  12561. */
  12562. getEffectDefines(): string;
  12563. /**
  12564. * Returns the string "BoxParticleEmitter"
  12565. * @returns a string containing the class name
  12566. */
  12567. getClassName(): string;
  12568. /**
  12569. * Serializes the particle system to a JSON object.
  12570. * @returns the JSON object
  12571. */
  12572. serialize(): any;
  12573. /**
  12574. * Parse properties from a JSON object
  12575. * @param serializationObject defines the JSON object
  12576. */
  12577. parse(serializationObject: any): void;
  12578. }
  12579. }
  12580. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12581. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12582. import { Effect } from "babylonjs/Materials/effect";
  12583. import { Particle } from "babylonjs/Particles/particle";
  12584. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12585. /**
  12586. * Particle emitter emitting particles from the inside of a cone.
  12587. * It emits the particles alongside the cone volume from the base to the particle.
  12588. * The emission direction might be randomized.
  12589. */
  12590. export class ConeParticleEmitter implements IParticleEmitterType {
  12591. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12592. directionRandomizer: number;
  12593. private _radius;
  12594. private _angle;
  12595. private _height;
  12596. /**
  12597. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12598. */
  12599. radiusRange: number;
  12600. /**
  12601. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12602. */
  12603. heightRange: number;
  12604. /**
  12605. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12606. */
  12607. emitFromSpawnPointOnly: boolean;
  12608. /**
  12609. * Gets or sets the radius of the emission cone
  12610. */
  12611. get radius(): number;
  12612. set radius(value: number);
  12613. /**
  12614. * Gets or sets the angle of the emission cone
  12615. */
  12616. get angle(): number;
  12617. set angle(value: number);
  12618. private _buildHeight;
  12619. /**
  12620. * Creates a new instance ConeParticleEmitter
  12621. * @param radius the radius of the emission cone (1 by default)
  12622. * @param angle the cone base angle (PI by default)
  12623. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12624. */
  12625. constructor(radius?: number, angle?: number,
  12626. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12627. directionRandomizer?: number);
  12628. /**
  12629. * Called by the particle System when the direction is computed for the created particle.
  12630. * @param worldMatrix is the world matrix of the particle system
  12631. * @param directionToUpdate is the direction vector to update with the result
  12632. * @param particle is the particle we are computed the direction for
  12633. * @param isLocal defines if the direction should be set in local space
  12634. */
  12635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12636. /**
  12637. * Called by the particle System when the position is computed for the created particle.
  12638. * @param worldMatrix is the world matrix of the particle system
  12639. * @param positionToUpdate is the position vector to update with the result
  12640. * @param particle is the particle we are computed the position for
  12641. * @param isLocal defines if the position should be set in local space
  12642. */
  12643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12644. /**
  12645. * Clones the current emitter and returns a copy of it
  12646. * @returns the new emitter
  12647. */
  12648. clone(): ConeParticleEmitter;
  12649. /**
  12650. * Called by the GPUParticleSystem to setup the update shader
  12651. * @param effect defines the update shader
  12652. */
  12653. applyToShader(effect: Effect): void;
  12654. /**
  12655. * Returns a string to use to update the GPU particles update shader
  12656. * @returns a string containng the defines string
  12657. */
  12658. getEffectDefines(): string;
  12659. /**
  12660. * Returns the string "ConeParticleEmitter"
  12661. * @returns a string containing the class name
  12662. */
  12663. getClassName(): string;
  12664. /**
  12665. * Serializes the particle system to a JSON object.
  12666. * @returns the JSON object
  12667. */
  12668. serialize(): any;
  12669. /**
  12670. * Parse properties from a JSON object
  12671. * @param serializationObject defines the JSON object
  12672. */
  12673. parse(serializationObject: any): void;
  12674. }
  12675. }
  12676. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12677. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12678. import { Effect } from "babylonjs/Materials/effect";
  12679. import { Particle } from "babylonjs/Particles/particle";
  12680. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12681. /**
  12682. * Particle emitter emitting particles from the inside of a cylinder.
  12683. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12684. */
  12685. export class CylinderParticleEmitter implements IParticleEmitterType {
  12686. /**
  12687. * The radius of the emission cylinder.
  12688. */
  12689. radius: number;
  12690. /**
  12691. * The height of the emission cylinder.
  12692. */
  12693. height: number;
  12694. /**
  12695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12696. */
  12697. radiusRange: number;
  12698. /**
  12699. * How much to randomize the particle direction [0-1].
  12700. */
  12701. directionRandomizer: number;
  12702. /**
  12703. * Creates a new instance CylinderParticleEmitter
  12704. * @param radius the radius of the emission cylinder (1 by default)
  12705. * @param height the height of the emission cylinder (1 by default)
  12706. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12707. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12708. */
  12709. constructor(
  12710. /**
  12711. * The radius of the emission cylinder.
  12712. */
  12713. radius?: number,
  12714. /**
  12715. * The height of the emission cylinder.
  12716. */
  12717. height?: number,
  12718. /**
  12719. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12720. */
  12721. radiusRange?: number,
  12722. /**
  12723. * How much to randomize the particle direction [0-1].
  12724. */
  12725. directionRandomizer?: number);
  12726. /**
  12727. * Called by the particle System when the direction is computed for the created particle.
  12728. * @param worldMatrix is the world matrix of the particle system
  12729. * @param directionToUpdate is the direction vector to update with the result
  12730. * @param particle is the particle we are computed the direction for
  12731. * @param isLocal defines if the direction should be set in local space
  12732. */
  12733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12734. /**
  12735. * Called by the particle System when the position is computed for the created particle.
  12736. * @param worldMatrix is the world matrix of the particle system
  12737. * @param positionToUpdate is the position vector to update with the result
  12738. * @param particle is the particle we are computed the position for
  12739. * @param isLocal defines if the position should be set in local space
  12740. */
  12741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12742. /**
  12743. * Clones the current emitter and returns a copy of it
  12744. * @returns the new emitter
  12745. */
  12746. clone(): CylinderParticleEmitter;
  12747. /**
  12748. * Called by the GPUParticleSystem to setup the update shader
  12749. * @param effect defines the update shader
  12750. */
  12751. applyToShader(effect: Effect): void;
  12752. /**
  12753. * Returns a string to use to update the GPU particles update shader
  12754. * @returns a string containng the defines string
  12755. */
  12756. getEffectDefines(): string;
  12757. /**
  12758. * Returns the string "CylinderParticleEmitter"
  12759. * @returns a string containing the class name
  12760. */
  12761. getClassName(): string;
  12762. /**
  12763. * Serializes the particle system to a JSON object.
  12764. * @returns the JSON object
  12765. */
  12766. serialize(): any;
  12767. /**
  12768. * Parse properties from a JSON object
  12769. * @param serializationObject defines the JSON object
  12770. */
  12771. parse(serializationObject: any): void;
  12772. }
  12773. /**
  12774. * Particle emitter emitting particles from the inside of a cylinder.
  12775. * It emits the particles randomly between two vectors.
  12776. */
  12777. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12778. /**
  12779. * The min limit of the emission direction.
  12780. */
  12781. direction1: Vector3;
  12782. /**
  12783. * The max limit of the emission direction.
  12784. */
  12785. direction2: Vector3;
  12786. /**
  12787. * Creates a new instance CylinderDirectedParticleEmitter
  12788. * @param radius the radius of the emission cylinder (1 by default)
  12789. * @param height the height of the emission cylinder (1 by default)
  12790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12791. * @param direction1 the min limit of the emission direction (up vector by default)
  12792. * @param direction2 the max limit of the emission direction (up vector by default)
  12793. */
  12794. constructor(radius?: number, height?: number, radiusRange?: number,
  12795. /**
  12796. * The min limit of the emission direction.
  12797. */
  12798. direction1?: Vector3,
  12799. /**
  12800. * The max limit of the emission direction.
  12801. */
  12802. direction2?: Vector3);
  12803. /**
  12804. * Called by the particle System when the direction is computed for the created particle.
  12805. * @param worldMatrix is the world matrix of the particle system
  12806. * @param directionToUpdate is the direction vector to update with the result
  12807. * @param particle is the particle we are computed the direction for
  12808. */
  12809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12810. /**
  12811. * Clones the current emitter and returns a copy of it
  12812. * @returns the new emitter
  12813. */
  12814. clone(): CylinderDirectedParticleEmitter;
  12815. /**
  12816. * Called by the GPUParticleSystem to setup the update shader
  12817. * @param effect defines the update shader
  12818. */
  12819. applyToShader(effect: Effect): void;
  12820. /**
  12821. * Returns a string to use to update the GPU particles update shader
  12822. * @returns a string containng the defines string
  12823. */
  12824. getEffectDefines(): string;
  12825. /**
  12826. * Returns the string "CylinderDirectedParticleEmitter"
  12827. * @returns a string containing the class name
  12828. */
  12829. getClassName(): string;
  12830. /**
  12831. * Serializes the particle system to a JSON object.
  12832. * @returns the JSON object
  12833. */
  12834. serialize(): any;
  12835. /**
  12836. * Parse properties from a JSON object
  12837. * @param serializationObject defines the JSON object
  12838. */
  12839. parse(serializationObject: any): void;
  12840. }
  12841. }
  12842. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12844. import { Effect } from "babylonjs/Materials/effect";
  12845. import { Particle } from "babylonjs/Particles/particle";
  12846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12847. /**
  12848. * Particle emitter emitting particles from the inside of a hemisphere.
  12849. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12850. */
  12851. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12852. /**
  12853. * The radius of the emission hemisphere.
  12854. */
  12855. radius: number;
  12856. /**
  12857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12858. */
  12859. radiusRange: number;
  12860. /**
  12861. * How much to randomize the particle direction [0-1].
  12862. */
  12863. directionRandomizer: number;
  12864. /**
  12865. * Creates a new instance HemisphericParticleEmitter
  12866. * @param radius the radius of the emission hemisphere (1 by default)
  12867. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12868. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12869. */
  12870. constructor(
  12871. /**
  12872. * The radius of the emission hemisphere.
  12873. */
  12874. radius?: number,
  12875. /**
  12876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12877. */
  12878. radiusRange?: number,
  12879. /**
  12880. * How much to randomize the particle direction [0-1].
  12881. */
  12882. directionRandomizer?: number);
  12883. /**
  12884. * Called by the particle System when the direction is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param directionToUpdate is the direction vector to update with the result
  12887. * @param particle is the particle we are computed the direction for
  12888. * @param isLocal defines if the direction should be set in local space
  12889. */
  12890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Called by the particle System when the position is computed for the created particle.
  12893. * @param worldMatrix is the world matrix of the particle system
  12894. * @param positionToUpdate is the position vector to update with the result
  12895. * @param particle is the particle we are computed the position for
  12896. * @param isLocal defines if the position should be set in local space
  12897. */
  12898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12899. /**
  12900. * Clones the current emitter and returns a copy of it
  12901. * @returns the new emitter
  12902. */
  12903. clone(): HemisphericParticleEmitter;
  12904. /**
  12905. * Called by the GPUParticleSystem to setup the update shader
  12906. * @param effect defines the update shader
  12907. */
  12908. applyToShader(effect: Effect): void;
  12909. /**
  12910. * Returns a string to use to update the GPU particles update shader
  12911. * @returns a string containng the defines string
  12912. */
  12913. getEffectDefines(): string;
  12914. /**
  12915. * Returns the string "HemisphericParticleEmitter"
  12916. * @returns a string containing the class name
  12917. */
  12918. getClassName(): string;
  12919. /**
  12920. * Serializes the particle system to a JSON object.
  12921. * @returns the JSON object
  12922. */
  12923. serialize(): any;
  12924. /**
  12925. * Parse properties from a JSON object
  12926. * @param serializationObject defines the JSON object
  12927. */
  12928. parse(serializationObject: any): void;
  12929. }
  12930. }
  12931. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12932. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12933. import { Effect } from "babylonjs/Materials/effect";
  12934. import { Particle } from "babylonjs/Particles/particle";
  12935. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12936. /**
  12937. * Particle emitter emitting particles from a point.
  12938. * It emits the particles randomly between 2 given directions.
  12939. */
  12940. export class PointParticleEmitter implements IParticleEmitterType {
  12941. /**
  12942. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12943. */
  12944. direction1: Vector3;
  12945. /**
  12946. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12947. */
  12948. direction2: Vector3;
  12949. /**
  12950. * Creates a new instance PointParticleEmitter
  12951. */
  12952. constructor();
  12953. /**
  12954. * Called by the particle System when the direction is computed for the created particle.
  12955. * @param worldMatrix is the world matrix of the particle system
  12956. * @param directionToUpdate is the direction vector to update with the result
  12957. * @param particle is the particle we are computed the direction for
  12958. * @param isLocal defines if the direction should be set in local space
  12959. */
  12960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12961. /**
  12962. * Called by the particle System when the position is computed for the created particle.
  12963. * @param worldMatrix is the world matrix of the particle system
  12964. * @param positionToUpdate is the position vector to update with the result
  12965. * @param particle is the particle we are computed the position for
  12966. * @param isLocal defines if the position should be set in local space
  12967. */
  12968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12969. /**
  12970. * Clones the current emitter and returns a copy of it
  12971. * @returns the new emitter
  12972. */
  12973. clone(): PointParticleEmitter;
  12974. /**
  12975. * Called by the GPUParticleSystem to setup the update shader
  12976. * @param effect defines the update shader
  12977. */
  12978. applyToShader(effect: Effect): void;
  12979. /**
  12980. * Returns a string to use to update the GPU particles update shader
  12981. * @returns a string containng the defines string
  12982. */
  12983. getEffectDefines(): string;
  12984. /**
  12985. * Returns the string "PointParticleEmitter"
  12986. * @returns a string containing the class name
  12987. */
  12988. getClassName(): string;
  12989. /**
  12990. * Serializes the particle system to a JSON object.
  12991. * @returns the JSON object
  12992. */
  12993. serialize(): any;
  12994. /**
  12995. * Parse properties from a JSON object
  12996. * @param serializationObject defines the JSON object
  12997. */
  12998. parse(serializationObject: any): void;
  12999. }
  13000. }
  13001. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13002. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13003. import { Effect } from "babylonjs/Materials/effect";
  13004. import { Particle } from "babylonjs/Particles/particle";
  13005. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13006. /**
  13007. * Particle emitter emitting particles from the inside of a sphere.
  13008. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13009. */
  13010. export class SphereParticleEmitter implements IParticleEmitterType {
  13011. /**
  13012. * The radius of the emission sphere.
  13013. */
  13014. radius: number;
  13015. /**
  13016. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13017. */
  13018. radiusRange: number;
  13019. /**
  13020. * How much to randomize the particle direction [0-1].
  13021. */
  13022. directionRandomizer: number;
  13023. /**
  13024. * Creates a new instance SphereParticleEmitter
  13025. * @param radius the radius of the emission sphere (1 by default)
  13026. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13027. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13028. */
  13029. constructor(
  13030. /**
  13031. * The radius of the emission sphere.
  13032. */
  13033. radius?: number,
  13034. /**
  13035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13036. */
  13037. radiusRange?: number,
  13038. /**
  13039. * How much to randomize the particle direction [0-1].
  13040. */
  13041. directionRandomizer?: number);
  13042. /**
  13043. * Called by the particle System when the direction is computed for the created particle.
  13044. * @param worldMatrix is the world matrix of the particle system
  13045. * @param directionToUpdate is the direction vector to update with the result
  13046. * @param particle is the particle we are computed the direction for
  13047. * @param isLocal defines if the direction should be set in local space
  13048. */
  13049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13050. /**
  13051. * Called by the particle System when the position is computed for the created particle.
  13052. * @param worldMatrix is the world matrix of the particle system
  13053. * @param positionToUpdate is the position vector to update with the result
  13054. * @param particle is the particle we are computed the position for
  13055. * @param isLocal defines if the position should be set in local space
  13056. */
  13057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13058. /**
  13059. * Clones the current emitter and returns a copy of it
  13060. * @returns the new emitter
  13061. */
  13062. clone(): SphereParticleEmitter;
  13063. /**
  13064. * Called by the GPUParticleSystem to setup the update shader
  13065. * @param effect defines the update shader
  13066. */
  13067. applyToShader(effect: Effect): void;
  13068. /**
  13069. * Returns a string to use to update the GPU particles update shader
  13070. * @returns a string containng the defines string
  13071. */
  13072. getEffectDefines(): string;
  13073. /**
  13074. * Returns the string "SphereParticleEmitter"
  13075. * @returns a string containing the class name
  13076. */
  13077. getClassName(): string;
  13078. /**
  13079. * Serializes the particle system to a JSON object.
  13080. * @returns the JSON object
  13081. */
  13082. serialize(): any;
  13083. /**
  13084. * Parse properties from a JSON object
  13085. * @param serializationObject defines the JSON object
  13086. */
  13087. parse(serializationObject: any): void;
  13088. }
  13089. /**
  13090. * Particle emitter emitting particles from the inside of a sphere.
  13091. * It emits the particles randomly between two vectors.
  13092. */
  13093. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13094. /**
  13095. * The min limit of the emission direction.
  13096. */
  13097. direction1: Vector3;
  13098. /**
  13099. * The max limit of the emission direction.
  13100. */
  13101. direction2: Vector3;
  13102. /**
  13103. * Creates a new instance SphereDirectedParticleEmitter
  13104. * @param radius the radius of the emission sphere (1 by default)
  13105. * @param direction1 the min limit of the emission direction (up vector by default)
  13106. * @param direction2 the max limit of the emission direction (up vector by default)
  13107. */
  13108. constructor(radius?: number,
  13109. /**
  13110. * The min limit of the emission direction.
  13111. */
  13112. direction1?: Vector3,
  13113. /**
  13114. * The max limit of the emission direction.
  13115. */
  13116. direction2?: Vector3);
  13117. /**
  13118. * Called by the particle System when the direction is computed for the created particle.
  13119. * @param worldMatrix is the world matrix of the particle system
  13120. * @param directionToUpdate is the direction vector to update with the result
  13121. * @param particle is the particle we are computed the direction for
  13122. */
  13123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13124. /**
  13125. * Clones the current emitter and returns a copy of it
  13126. * @returns the new emitter
  13127. */
  13128. clone(): SphereDirectedParticleEmitter;
  13129. /**
  13130. * Called by the GPUParticleSystem to setup the update shader
  13131. * @param effect defines the update shader
  13132. */
  13133. applyToShader(effect: Effect): void;
  13134. /**
  13135. * Returns a string to use to update the GPU particles update shader
  13136. * @returns a string containng the defines string
  13137. */
  13138. getEffectDefines(): string;
  13139. /**
  13140. * Returns the string "SphereDirectedParticleEmitter"
  13141. * @returns a string containing the class name
  13142. */
  13143. getClassName(): string;
  13144. /**
  13145. * Serializes the particle system to a JSON object.
  13146. * @returns the JSON object
  13147. */
  13148. serialize(): any;
  13149. /**
  13150. * Parse properties from a JSON object
  13151. * @param serializationObject defines the JSON object
  13152. */
  13153. parse(serializationObject: any): void;
  13154. }
  13155. }
  13156. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13157. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13158. import { Effect } from "babylonjs/Materials/effect";
  13159. import { Particle } from "babylonjs/Particles/particle";
  13160. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13161. import { Nullable } from "babylonjs/types";
  13162. /**
  13163. * Particle emitter emitting particles from a custom list of positions.
  13164. */
  13165. export class CustomParticleEmitter implements IParticleEmitterType {
  13166. /**
  13167. * Gets or sets the position generator that will create the inital position of each particle.
  13168. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13169. */
  13170. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13171. /**
  13172. * Gets or sets the destination generator that will create the final destination of each particle.
  13173. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13174. */
  13175. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13176. /**
  13177. * Creates a new instance CustomParticleEmitter
  13178. */
  13179. constructor();
  13180. /**
  13181. * Called by the particle System when the direction is computed for the created particle.
  13182. * @param worldMatrix is the world matrix of the particle system
  13183. * @param directionToUpdate is the direction vector to update with the result
  13184. * @param particle is the particle we are computed the direction for
  13185. * @param isLocal defines if the direction should be set in local space
  13186. */
  13187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13188. /**
  13189. * Called by the particle System when the position is computed for the created particle.
  13190. * @param worldMatrix is the world matrix of the particle system
  13191. * @param positionToUpdate is the position vector to update with the result
  13192. * @param particle is the particle we are computed the position for
  13193. * @param isLocal defines if the position should be set in local space
  13194. */
  13195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13196. /**
  13197. * Clones the current emitter and returns a copy of it
  13198. * @returns the new emitter
  13199. */
  13200. clone(): CustomParticleEmitter;
  13201. /**
  13202. * Called by the GPUParticleSystem to setup the update shader
  13203. * @param effect defines the update shader
  13204. */
  13205. applyToShader(effect: Effect): void;
  13206. /**
  13207. * Returns a string to use to update the GPU particles update shader
  13208. * @returns a string containng the defines string
  13209. */
  13210. getEffectDefines(): string;
  13211. /**
  13212. * Returns the string "PointParticleEmitter"
  13213. * @returns a string containing the class name
  13214. */
  13215. getClassName(): string;
  13216. /**
  13217. * Serializes the particle system to a JSON object.
  13218. * @returns the JSON object
  13219. */
  13220. serialize(): any;
  13221. /**
  13222. * Parse properties from a JSON object
  13223. * @param serializationObject defines the JSON object
  13224. */
  13225. parse(serializationObject: any): void;
  13226. }
  13227. }
  13228. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13229. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13230. import { Effect } from "babylonjs/Materials/effect";
  13231. import { Particle } from "babylonjs/Particles/particle";
  13232. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13233. import { Nullable } from "babylonjs/types";
  13234. import { Scene } from "babylonjs/scene";
  13235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13236. /**
  13237. * Particle emitter emitting particles from the inside of a box.
  13238. * It emits the particles randomly between 2 given directions.
  13239. */
  13240. export class MeshParticleEmitter implements IParticleEmitterType {
  13241. private _indices;
  13242. private _positions;
  13243. private _normals;
  13244. private _storedNormal;
  13245. private _mesh;
  13246. /**
  13247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13248. */
  13249. direction1: Vector3;
  13250. /**
  13251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13252. */
  13253. direction2: Vector3;
  13254. /**
  13255. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13256. */
  13257. useMeshNormalsForDirection: boolean;
  13258. /** Defines the mesh to use as source */
  13259. get mesh(): Nullable<AbstractMesh>;
  13260. set mesh(value: Nullable<AbstractMesh>);
  13261. /**
  13262. * Creates a new instance MeshParticleEmitter
  13263. * @param mesh defines the mesh to use as source
  13264. */
  13265. constructor(mesh?: Nullable<AbstractMesh>);
  13266. /**
  13267. * Called by the particle System when the direction is computed for the created particle.
  13268. * @param worldMatrix is the world matrix of the particle system
  13269. * @param directionToUpdate is the direction vector to update with the result
  13270. * @param particle is the particle we are computed the direction for
  13271. * @param isLocal defines if the direction should be set in local space
  13272. */
  13273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13274. /**
  13275. * Called by the particle System when the position is computed for the created particle.
  13276. * @param worldMatrix is the world matrix of the particle system
  13277. * @param positionToUpdate is the position vector to update with the result
  13278. * @param particle is the particle we are computed the position for
  13279. * @param isLocal defines if the position should be set in local space
  13280. */
  13281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13282. /**
  13283. * Clones the current emitter and returns a copy of it
  13284. * @returns the new emitter
  13285. */
  13286. clone(): MeshParticleEmitter;
  13287. /**
  13288. * Called by the GPUParticleSystem to setup the update shader
  13289. * @param effect defines the update shader
  13290. */
  13291. applyToShader(effect: Effect): void;
  13292. /**
  13293. * Returns a string to use to update the GPU particles update shader
  13294. * @returns a string containng the defines string
  13295. */
  13296. getEffectDefines(): string;
  13297. /**
  13298. * Returns the string "BoxParticleEmitter"
  13299. * @returns a string containing the class name
  13300. */
  13301. getClassName(): string;
  13302. /**
  13303. * Serializes the particle system to a JSON object.
  13304. * @returns the JSON object
  13305. */
  13306. serialize(): any;
  13307. /**
  13308. * Parse properties from a JSON object
  13309. * @param serializationObject defines the JSON object
  13310. * @param scene defines the hosting scene
  13311. */
  13312. parse(serializationObject: any, scene: Scene): void;
  13313. }
  13314. }
  13315. declare module "babylonjs/Particles/EmitterTypes/index" {
  13316. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13317. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13318. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13319. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13320. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13321. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13322. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13323. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13324. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13325. }
  13326. declare module "babylonjs/Particles/IParticleSystem" {
  13327. import { Nullable } from "babylonjs/types";
  13328. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13329. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13332. import { Texture } from "babylonjs/Materials/Textures/texture";
  13333. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13334. import { Scene } from "babylonjs/scene";
  13335. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13336. import { Animation } from "babylonjs/Animations/animation";
  13337. /**
  13338. * Interface representing a particle system in Babylon.js.
  13339. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13340. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13341. */
  13342. export interface IParticleSystem {
  13343. /**
  13344. * List of animations used by the particle system.
  13345. */
  13346. animations: Animation[];
  13347. /**
  13348. * The id of the Particle system.
  13349. */
  13350. id: string;
  13351. /**
  13352. * The name of the Particle system.
  13353. */
  13354. name: string;
  13355. /**
  13356. * The emitter represents the Mesh or position we are attaching the particle system to.
  13357. */
  13358. emitter: Nullable<AbstractMesh | Vector3>;
  13359. /**
  13360. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13361. */
  13362. isBillboardBased: boolean;
  13363. /**
  13364. * The rendering group used by the Particle system to chose when to render.
  13365. */
  13366. renderingGroupId: number;
  13367. /**
  13368. * The layer mask we are rendering the particles through.
  13369. */
  13370. layerMask: number;
  13371. /**
  13372. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13373. */
  13374. updateSpeed: number;
  13375. /**
  13376. * The amount of time the particle system is running (depends of the overall update speed).
  13377. */
  13378. targetStopDuration: number;
  13379. /**
  13380. * The texture used to render each particle. (this can be a spritesheet)
  13381. */
  13382. particleTexture: Nullable<Texture>;
  13383. /**
  13384. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13385. */
  13386. blendMode: number;
  13387. /**
  13388. * Minimum life time of emitting particles.
  13389. */
  13390. minLifeTime: number;
  13391. /**
  13392. * Maximum life time of emitting particles.
  13393. */
  13394. maxLifeTime: number;
  13395. /**
  13396. * Minimum Size of emitting particles.
  13397. */
  13398. minSize: number;
  13399. /**
  13400. * Maximum Size of emitting particles.
  13401. */
  13402. maxSize: number;
  13403. /**
  13404. * Minimum scale of emitting particles on X axis.
  13405. */
  13406. minScaleX: number;
  13407. /**
  13408. * Maximum scale of emitting particles on X axis.
  13409. */
  13410. maxScaleX: number;
  13411. /**
  13412. * Minimum scale of emitting particles on Y axis.
  13413. */
  13414. minScaleY: number;
  13415. /**
  13416. * Maximum scale of emitting particles on Y axis.
  13417. */
  13418. maxScaleY: number;
  13419. /**
  13420. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13421. */
  13422. color1: Color4;
  13423. /**
  13424. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13425. */
  13426. color2: Color4;
  13427. /**
  13428. * Color the particle will have at the end of its lifetime.
  13429. */
  13430. colorDead: Color4;
  13431. /**
  13432. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13433. */
  13434. emitRate: number;
  13435. /**
  13436. * You can use gravity if you want to give an orientation to your particles.
  13437. */
  13438. gravity: Vector3;
  13439. /**
  13440. * Minimum power of emitting particles.
  13441. */
  13442. minEmitPower: number;
  13443. /**
  13444. * Maximum power of emitting particles.
  13445. */
  13446. maxEmitPower: number;
  13447. /**
  13448. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13449. */
  13450. minAngularSpeed: number;
  13451. /**
  13452. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13453. */
  13454. maxAngularSpeed: number;
  13455. /**
  13456. * Gets or sets the minimal initial rotation in radians.
  13457. */
  13458. minInitialRotation: number;
  13459. /**
  13460. * Gets or sets the maximal initial rotation in radians.
  13461. */
  13462. maxInitialRotation: number;
  13463. /**
  13464. * The particle emitter type defines the emitter used by the particle system.
  13465. * It can be for example box, sphere, or cone...
  13466. */
  13467. particleEmitterType: Nullable<IParticleEmitterType>;
  13468. /**
  13469. * Defines the delay in milliseconds before starting the system (0 by default)
  13470. */
  13471. startDelay: number;
  13472. /**
  13473. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13474. */
  13475. preWarmCycles: number;
  13476. /**
  13477. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13478. */
  13479. preWarmStepOffset: number;
  13480. /**
  13481. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13482. */
  13483. spriteCellChangeSpeed: number;
  13484. /**
  13485. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13486. */
  13487. startSpriteCellID: number;
  13488. /**
  13489. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13490. */
  13491. endSpriteCellID: number;
  13492. /**
  13493. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13494. */
  13495. spriteCellWidth: number;
  13496. /**
  13497. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13498. */
  13499. spriteCellHeight: number;
  13500. /**
  13501. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13502. */
  13503. spriteRandomStartCell: boolean;
  13504. /**
  13505. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13506. */
  13507. isAnimationSheetEnabled: boolean;
  13508. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13509. translationPivot: Vector2;
  13510. /**
  13511. * Gets or sets a texture used to add random noise to particle positions
  13512. */
  13513. noiseTexture: Nullable<BaseTexture>;
  13514. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13515. noiseStrength: Vector3;
  13516. /**
  13517. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13518. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13519. */
  13520. billboardMode: number;
  13521. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13522. limitVelocityDamping: number;
  13523. /**
  13524. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13525. */
  13526. beginAnimationOnStart: boolean;
  13527. /**
  13528. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13529. */
  13530. beginAnimationFrom: number;
  13531. /**
  13532. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13533. */
  13534. beginAnimationTo: number;
  13535. /**
  13536. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13537. */
  13538. beginAnimationLoop: boolean;
  13539. /**
  13540. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13541. */
  13542. disposeOnStop: boolean;
  13543. /**
  13544. * Specifies if the particles are updated in emitter local space or world space
  13545. */
  13546. isLocal: boolean;
  13547. /** Snippet ID if the particle system was created from the snippet server */
  13548. snippetId: string;
  13549. /**
  13550. * Gets the maximum number of particles active at the same time.
  13551. * @returns The max number of active particles.
  13552. */
  13553. getCapacity(): number;
  13554. /**
  13555. * Gets the number of particles active at the same time.
  13556. * @returns The number of active particles.
  13557. */
  13558. getActiveCount(): number;
  13559. /**
  13560. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13561. * @returns True if it has been started, otherwise false.
  13562. */
  13563. isStarted(): boolean;
  13564. /**
  13565. * Animates the particle system for this frame.
  13566. */
  13567. animate(): void;
  13568. /**
  13569. * Renders the particle system in its current state.
  13570. * @returns the current number of particles
  13571. */
  13572. render(): number;
  13573. /**
  13574. * Dispose the particle system and frees its associated resources.
  13575. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13576. */
  13577. dispose(disposeTexture?: boolean): void;
  13578. /**
  13579. * Clones the particle system.
  13580. * @param name The name of the cloned object
  13581. * @param newEmitter The new emitter to use
  13582. * @returns the cloned particle system
  13583. */
  13584. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13585. /**
  13586. * Serializes the particle system to a JSON object
  13587. * @param serializeTexture defines if the texture must be serialized as well
  13588. * @returns the JSON object
  13589. */
  13590. serialize(serializeTexture: boolean): any;
  13591. /**
  13592. * Rebuild the particle system
  13593. */
  13594. rebuild(): void;
  13595. /** Force the system to rebuild all gradients that need to be resync */
  13596. forceRefreshGradients(): void;
  13597. /**
  13598. * Starts the particle system and begins to emit
  13599. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13600. */
  13601. start(delay?: number): void;
  13602. /**
  13603. * Stops the particle system.
  13604. */
  13605. stop(): void;
  13606. /**
  13607. * Remove all active particles
  13608. */
  13609. reset(): void;
  13610. /**
  13611. * Gets a boolean indicating that the system is stopping
  13612. * @returns true if the system is currently stopping
  13613. */
  13614. isStopping(): boolean;
  13615. /**
  13616. * Is this system ready to be used/rendered
  13617. * @return true if the system is ready
  13618. */
  13619. isReady(): boolean;
  13620. /**
  13621. * Returns the string "ParticleSystem"
  13622. * @returns a string containing the class name
  13623. */
  13624. getClassName(): string;
  13625. /**
  13626. * Adds a new color gradient
  13627. * @param gradient defines the gradient to use (between 0 and 1)
  13628. * @param color1 defines the color to affect to the specified gradient
  13629. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13630. * @returns the current particle system
  13631. */
  13632. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13633. /**
  13634. * Remove a specific color gradient
  13635. * @param gradient defines the gradient to remove
  13636. * @returns the current particle system
  13637. */
  13638. removeColorGradient(gradient: number): IParticleSystem;
  13639. /**
  13640. * Adds a new size gradient
  13641. * @param gradient defines the gradient to use (between 0 and 1)
  13642. * @param factor defines the size factor to affect to the specified gradient
  13643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13644. * @returns the current particle system
  13645. */
  13646. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13647. /**
  13648. * Remove a specific size gradient
  13649. * @param gradient defines the gradient to remove
  13650. * @returns the current particle system
  13651. */
  13652. removeSizeGradient(gradient: number): IParticleSystem;
  13653. /**
  13654. * Gets the current list of color gradients.
  13655. * You must use addColorGradient and removeColorGradient to udpate this list
  13656. * @returns the list of color gradients
  13657. */
  13658. getColorGradients(): Nullable<Array<ColorGradient>>;
  13659. /**
  13660. * Gets the current list of size gradients.
  13661. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13662. * @returns the list of size gradients
  13663. */
  13664. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13665. /**
  13666. * Gets the current list of angular speed gradients.
  13667. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13668. * @returns the list of angular speed gradients
  13669. */
  13670. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13671. /**
  13672. * Adds a new angular speed gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param factor defines the angular speed to affect to the specified gradient
  13675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13676. * @returns the current particle system
  13677. */
  13678. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13679. /**
  13680. * Remove a specific angular speed gradient
  13681. * @param gradient defines the gradient to remove
  13682. * @returns the current particle system
  13683. */
  13684. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13685. /**
  13686. * Gets the current list of velocity gradients.
  13687. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13688. * @returns the list of velocity gradients
  13689. */
  13690. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13691. /**
  13692. * Adds a new velocity gradient
  13693. * @param gradient defines the gradient to use (between 0 and 1)
  13694. * @param factor defines the velocity to affect to the specified gradient
  13695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13696. * @returns the current particle system
  13697. */
  13698. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13699. /**
  13700. * Remove a specific velocity gradient
  13701. * @param gradient defines the gradient to remove
  13702. * @returns the current particle system
  13703. */
  13704. removeVelocityGradient(gradient: number): IParticleSystem;
  13705. /**
  13706. * Gets the current list of limit velocity gradients.
  13707. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13708. * @returns the list of limit velocity gradients
  13709. */
  13710. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13711. /**
  13712. * Adds a new limit velocity gradient
  13713. * @param gradient defines the gradient to use (between 0 and 1)
  13714. * @param factor defines the limit velocity to affect to the specified gradient
  13715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13716. * @returns the current particle system
  13717. */
  13718. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13719. /**
  13720. * Remove a specific limit velocity gradient
  13721. * @param gradient defines the gradient to remove
  13722. * @returns the current particle system
  13723. */
  13724. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13725. /**
  13726. * Adds a new drag gradient
  13727. * @param gradient defines the gradient to use (between 0 and 1)
  13728. * @param factor defines the drag to affect to the specified gradient
  13729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13730. * @returns the current particle system
  13731. */
  13732. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13733. /**
  13734. * Remove a specific drag gradient
  13735. * @param gradient defines the gradient to remove
  13736. * @returns the current particle system
  13737. */
  13738. removeDragGradient(gradient: number): IParticleSystem;
  13739. /**
  13740. * Gets the current list of drag gradients.
  13741. * You must use addDragGradient and removeDragGradient to udpate this list
  13742. * @returns the list of drag gradients
  13743. */
  13744. getDragGradients(): Nullable<Array<FactorGradient>>;
  13745. /**
  13746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13747. * @param gradient defines the gradient to use (between 0 and 1)
  13748. * @param factor defines the emit rate to affect to the specified gradient
  13749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13750. * @returns the current particle system
  13751. */
  13752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13753. /**
  13754. * Remove a specific emit rate gradient
  13755. * @param gradient defines the gradient to remove
  13756. * @returns the current particle system
  13757. */
  13758. removeEmitRateGradient(gradient: number): IParticleSystem;
  13759. /**
  13760. * Gets the current list of emit rate gradients.
  13761. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13762. * @returns the list of emit rate gradients
  13763. */
  13764. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13765. /**
  13766. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13767. * @param gradient defines the gradient to use (between 0 and 1)
  13768. * @param factor defines the start size to affect to the specified gradient
  13769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13770. * @returns the current particle system
  13771. */
  13772. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13773. /**
  13774. * Remove a specific start size gradient
  13775. * @param gradient defines the gradient to remove
  13776. * @returns the current particle system
  13777. */
  13778. removeStartSizeGradient(gradient: number): IParticleSystem;
  13779. /**
  13780. * Gets the current list of start size gradients.
  13781. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13782. * @returns the list of start size gradients
  13783. */
  13784. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13785. /**
  13786. * Adds a new life time gradient
  13787. * @param gradient defines the gradient to use (between 0 and 1)
  13788. * @param factor defines the life time factor to affect to the specified gradient
  13789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13790. * @returns the current particle system
  13791. */
  13792. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13793. /**
  13794. * Remove a specific life time gradient
  13795. * @param gradient defines the gradient to remove
  13796. * @returns the current particle system
  13797. */
  13798. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13799. /**
  13800. * Gets the current list of life time gradients.
  13801. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13802. * @returns the list of life time gradients
  13803. */
  13804. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13805. /**
  13806. * Gets the current list of color gradients.
  13807. * You must use addColorGradient and removeColorGradient to udpate this list
  13808. * @returns the list of color gradients
  13809. */
  13810. getColorGradients(): Nullable<Array<ColorGradient>>;
  13811. /**
  13812. * Adds a new ramp gradient used to remap particle colors
  13813. * @param gradient defines the gradient to use (between 0 and 1)
  13814. * @param color defines the color to affect to the specified gradient
  13815. * @returns the current particle system
  13816. */
  13817. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13818. /**
  13819. * Gets the current list of ramp gradients.
  13820. * You must use addRampGradient and removeRampGradient to udpate this list
  13821. * @returns the list of ramp gradients
  13822. */
  13823. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13824. /** Gets or sets a boolean indicating that ramp gradients must be used
  13825. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13826. */
  13827. useRampGradients: boolean;
  13828. /**
  13829. * Adds a new color remap gradient
  13830. * @param gradient defines the gradient to use (between 0 and 1)
  13831. * @param min defines the color remap minimal range
  13832. * @param max defines the color remap maximal range
  13833. * @returns the current particle system
  13834. */
  13835. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13836. /**
  13837. * Gets the current list of color remap gradients.
  13838. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13839. * @returns the list of color remap gradients
  13840. */
  13841. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13842. /**
  13843. * Adds a new alpha remap gradient
  13844. * @param gradient defines the gradient to use (between 0 and 1)
  13845. * @param min defines the alpha remap minimal range
  13846. * @param max defines the alpha remap maximal range
  13847. * @returns the current particle system
  13848. */
  13849. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13850. /**
  13851. * Gets the current list of alpha remap gradients.
  13852. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13853. * @returns the list of alpha remap gradients
  13854. */
  13855. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13856. /**
  13857. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13860. * @returns the emitter
  13861. */
  13862. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13863. /**
  13864. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13865. * @param radius The radius of the hemisphere to emit from
  13866. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13867. * @returns the emitter
  13868. */
  13869. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13870. /**
  13871. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13872. * @param radius The radius of the sphere to emit from
  13873. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13874. * @returns the emitter
  13875. */
  13876. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13877. /**
  13878. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13879. * @param radius The radius of the sphere to emit from
  13880. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13881. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13882. * @returns the emitter
  13883. */
  13884. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13885. /**
  13886. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13887. * @param radius The radius of the emission cylinder
  13888. * @param height The height of the emission cylinder
  13889. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13890. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13891. * @returns the emitter
  13892. */
  13893. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13894. /**
  13895. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13896. * @param radius The radius of the cylinder to emit from
  13897. * @param height The height of the emission cylinder
  13898. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13901. * @returns the emitter
  13902. */
  13903. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13904. /**
  13905. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13906. * @param radius The radius of the cone to emit from
  13907. * @param angle The base angle of the cone
  13908. * @returns the emitter
  13909. */
  13910. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13911. /**
  13912. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13913. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13914. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13915. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13916. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13917. * @returns the emitter
  13918. */
  13919. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13920. /**
  13921. * Get hosting scene
  13922. * @returns the scene
  13923. */
  13924. getScene(): Scene;
  13925. }
  13926. }
  13927. declare module "babylonjs/Meshes/transformNode" {
  13928. import { DeepImmutable } from "babylonjs/types";
  13929. import { Observable } from "babylonjs/Misc/observable";
  13930. import { Nullable } from "babylonjs/types";
  13931. import { Camera } from "babylonjs/Cameras/camera";
  13932. import { Scene } from "babylonjs/scene";
  13933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13934. import { Node } from "babylonjs/node";
  13935. import { Bone } from "babylonjs/Bones/bone";
  13936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13937. import { Space } from "babylonjs/Maths/math.axis";
  13938. /**
  13939. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13940. * @see https://doc.babylonjs.com/how_to/transformnode
  13941. */
  13942. export class TransformNode extends Node {
  13943. /**
  13944. * Object will not rotate to face the camera
  13945. */
  13946. static BILLBOARDMODE_NONE: number;
  13947. /**
  13948. * Object will rotate to face the camera but only on the x axis
  13949. */
  13950. static BILLBOARDMODE_X: number;
  13951. /**
  13952. * Object will rotate to face the camera but only on the y axis
  13953. */
  13954. static BILLBOARDMODE_Y: number;
  13955. /**
  13956. * Object will rotate to face the camera but only on the z axis
  13957. */
  13958. static BILLBOARDMODE_Z: number;
  13959. /**
  13960. * Object will rotate to face the camera
  13961. */
  13962. static BILLBOARDMODE_ALL: number;
  13963. /**
  13964. * Object will rotate to face the camera's position instead of orientation
  13965. */
  13966. static BILLBOARDMODE_USE_POSITION: number;
  13967. private _forward;
  13968. private _forwardInverted;
  13969. private _up;
  13970. private _right;
  13971. private _rightInverted;
  13972. private _position;
  13973. private _rotation;
  13974. private _rotationQuaternion;
  13975. protected _scaling: Vector3;
  13976. protected _isDirty: boolean;
  13977. private _transformToBoneReferal;
  13978. private _isAbsoluteSynced;
  13979. private _billboardMode;
  13980. /**
  13981. * Gets or sets the billboard mode. Default is 0.
  13982. *
  13983. * | Value | Type | Description |
  13984. * | --- | --- | --- |
  13985. * | 0 | BILLBOARDMODE_NONE | |
  13986. * | 1 | BILLBOARDMODE_X | |
  13987. * | 2 | BILLBOARDMODE_Y | |
  13988. * | 4 | BILLBOARDMODE_Z | |
  13989. * | 7 | BILLBOARDMODE_ALL | |
  13990. *
  13991. */
  13992. get billboardMode(): number;
  13993. set billboardMode(value: number);
  13994. private _preserveParentRotationForBillboard;
  13995. /**
  13996. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13997. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13998. */
  13999. get preserveParentRotationForBillboard(): boolean;
  14000. set preserveParentRotationForBillboard(value: boolean);
  14001. /**
  14002. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14003. */
  14004. scalingDeterminant: number;
  14005. private _infiniteDistance;
  14006. /**
  14007. * Gets or sets the distance of the object to max, often used by skybox
  14008. */
  14009. get infiniteDistance(): boolean;
  14010. set infiniteDistance(value: boolean);
  14011. /**
  14012. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14013. * By default the system will update normals to compensate
  14014. */
  14015. ignoreNonUniformScaling: boolean;
  14016. /**
  14017. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14018. */
  14019. reIntegrateRotationIntoRotationQuaternion: boolean;
  14020. /** @hidden */
  14021. _poseMatrix: Nullable<Matrix>;
  14022. /** @hidden */
  14023. _localMatrix: Matrix;
  14024. private _usePivotMatrix;
  14025. private _absolutePosition;
  14026. private _absoluteScaling;
  14027. private _absoluteRotationQuaternion;
  14028. private _pivotMatrix;
  14029. private _pivotMatrixInverse;
  14030. protected _postMultiplyPivotMatrix: boolean;
  14031. protected _isWorldMatrixFrozen: boolean;
  14032. /** @hidden */
  14033. _indexInSceneTransformNodesArray: number;
  14034. /**
  14035. * An event triggered after the world matrix is updated
  14036. */
  14037. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14038. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14039. /**
  14040. * Gets a string identifying the name of the class
  14041. * @returns "TransformNode" string
  14042. */
  14043. getClassName(): string;
  14044. /**
  14045. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14046. */
  14047. get position(): Vector3;
  14048. set position(newPosition: Vector3);
  14049. /**
  14050. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14051. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14052. */
  14053. get rotation(): Vector3;
  14054. set rotation(newRotation: Vector3);
  14055. /**
  14056. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14057. */
  14058. get scaling(): Vector3;
  14059. set scaling(newScaling: Vector3);
  14060. /**
  14061. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14062. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14063. */
  14064. get rotationQuaternion(): Nullable<Quaternion>;
  14065. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14066. /**
  14067. * The forward direction of that transform in world space.
  14068. */
  14069. get forward(): Vector3;
  14070. /**
  14071. * The up direction of that transform in world space.
  14072. */
  14073. get up(): Vector3;
  14074. /**
  14075. * The right direction of that transform in world space.
  14076. */
  14077. get right(): Vector3;
  14078. /**
  14079. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14080. * @param matrix the matrix to copy the pose from
  14081. * @returns this TransformNode.
  14082. */
  14083. updatePoseMatrix(matrix: Matrix): TransformNode;
  14084. /**
  14085. * Returns the mesh Pose matrix.
  14086. * @returns the pose matrix
  14087. */
  14088. getPoseMatrix(): Matrix;
  14089. /** @hidden */
  14090. _isSynchronized(): boolean;
  14091. /** @hidden */
  14092. _initCache(): void;
  14093. /**
  14094. * Flag the transform node as dirty (Forcing it to update everything)
  14095. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14096. * @returns this transform node
  14097. */
  14098. markAsDirty(property: string): TransformNode;
  14099. /**
  14100. * Returns the current mesh absolute position.
  14101. * Returns a Vector3.
  14102. */
  14103. get absolutePosition(): Vector3;
  14104. /**
  14105. * Returns the current mesh absolute scaling.
  14106. * Returns a Vector3.
  14107. */
  14108. get absoluteScaling(): Vector3;
  14109. /**
  14110. * Returns the current mesh absolute rotation.
  14111. * Returns a Quaternion.
  14112. */
  14113. get absoluteRotationQuaternion(): Quaternion;
  14114. /**
  14115. * Sets a new matrix to apply before all other transformation
  14116. * @param matrix defines the transform matrix
  14117. * @returns the current TransformNode
  14118. */
  14119. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14120. /**
  14121. * Sets a new pivot matrix to the current node
  14122. * @param matrix defines the new pivot matrix to use
  14123. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14124. * @returns the current TransformNode
  14125. */
  14126. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14127. /**
  14128. * Returns the mesh pivot matrix.
  14129. * Default : Identity.
  14130. * @returns the matrix
  14131. */
  14132. getPivotMatrix(): Matrix;
  14133. /**
  14134. * Instantiate (when possible) or clone that node with its hierarchy
  14135. * @param newParent defines the new parent to use for the instance (or clone)
  14136. * @param options defines options to configure how copy is done
  14137. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14138. * @returns an instance (or a clone) of the current node with its hiearchy
  14139. */
  14140. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14141. doNotInstantiate: boolean;
  14142. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14143. /**
  14144. * Prevents the World matrix to be computed any longer
  14145. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14146. * @returns the TransformNode.
  14147. */
  14148. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14149. /**
  14150. * Allows back the World matrix computation.
  14151. * @returns the TransformNode.
  14152. */
  14153. unfreezeWorldMatrix(): this;
  14154. /**
  14155. * True if the World matrix has been frozen.
  14156. */
  14157. get isWorldMatrixFrozen(): boolean;
  14158. /**
  14159. * Retuns the mesh absolute position in the World.
  14160. * @returns a Vector3.
  14161. */
  14162. getAbsolutePosition(): Vector3;
  14163. /**
  14164. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14165. * @param absolutePosition the absolute position to set
  14166. * @returns the TransformNode.
  14167. */
  14168. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14169. /**
  14170. * Sets the mesh position in its local space.
  14171. * @param vector3 the position to set in localspace
  14172. * @returns the TransformNode.
  14173. */
  14174. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14175. /**
  14176. * Returns the mesh position in the local space from the current World matrix values.
  14177. * @returns a new Vector3.
  14178. */
  14179. getPositionExpressedInLocalSpace(): Vector3;
  14180. /**
  14181. * Translates the mesh along the passed Vector3 in its local space.
  14182. * @param vector3 the distance to translate in localspace
  14183. * @returns the TransformNode.
  14184. */
  14185. locallyTranslate(vector3: Vector3): TransformNode;
  14186. private static _lookAtVectorCache;
  14187. /**
  14188. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14189. * @param targetPoint the position (must be in same space as current mesh) to look at
  14190. * @param yawCor optional yaw (y-axis) correction in radians
  14191. * @param pitchCor optional pitch (x-axis) correction in radians
  14192. * @param rollCor optional roll (z-axis) correction in radians
  14193. * @param space the choosen space of the target
  14194. * @returns the TransformNode.
  14195. */
  14196. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14197. /**
  14198. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14199. * This Vector3 is expressed in the World space.
  14200. * @param localAxis axis to rotate
  14201. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14202. */
  14203. getDirection(localAxis: Vector3): Vector3;
  14204. /**
  14205. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14206. * localAxis is expressed in the mesh local space.
  14207. * result is computed in the Wordl space from the mesh World matrix.
  14208. * @param localAxis axis to rotate
  14209. * @param result the resulting transformnode
  14210. * @returns this TransformNode.
  14211. */
  14212. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14213. /**
  14214. * Sets this transform node rotation to the given local axis.
  14215. * @param localAxis the axis in local space
  14216. * @param yawCor optional yaw (y-axis) correction in radians
  14217. * @param pitchCor optional pitch (x-axis) correction in radians
  14218. * @param rollCor optional roll (z-axis) correction in radians
  14219. * @returns this TransformNode
  14220. */
  14221. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14222. /**
  14223. * Sets a new pivot point to the current node
  14224. * @param point defines the new pivot point to use
  14225. * @param space defines if the point is in world or local space (local by default)
  14226. * @returns the current TransformNode
  14227. */
  14228. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14229. /**
  14230. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14231. * @returns the pivot point
  14232. */
  14233. getPivotPoint(): Vector3;
  14234. /**
  14235. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14236. * @param result the vector3 to store the result
  14237. * @returns this TransformNode.
  14238. */
  14239. getPivotPointToRef(result: Vector3): TransformNode;
  14240. /**
  14241. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14242. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14243. */
  14244. getAbsolutePivotPoint(): Vector3;
  14245. /**
  14246. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14247. * @param result vector3 to store the result
  14248. * @returns this TransformNode.
  14249. */
  14250. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14251. /**
  14252. * Defines the passed node as the parent of the current node.
  14253. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14254. * @see https://doc.babylonjs.com/how_to/parenting
  14255. * @param node the node ot set as the parent
  14256. * @returns this TransformNode.
  14257. */
  14258. setParent(node: Nullable<Node>): TransformNode;
  14259. private _nonUniformScaling;
  14260. /**
  14261. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14262. */
  14263. get nonUniformScaling(): boolean;
  14264. /** @hidden */
  14265. _updateNonUniformScalingState(value: boolean): boolean;
  14266. /**
  14267. * Attach the current TransformNode to another TransformNode associated with a bone
  14268. * @param bone Bone affecting the TransformNode
  14269. * @param affectedTransformNode TransformNode associated with the bone
  14270. * @returns this object
  14271. */
  14272. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14273. /**
  14274. * Detach the transform node if its associated with a bone
  14275. * @returns this object
  14276. */
  14277. detachFromBone(): TransformNode;
  14278. private static _rotationAxisCache;
  14279. /**
  14280. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14281. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14282. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14283. * The passed axis is also normalized.
  14284. * @param axis the axis to rotate around
  14285. * @param amount the amount to rotate in radians
  14286. * @param space Space to rotate in (Default: local)
  14287. * @returns the TransformNode.
  14288. */
  14289. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14290. /**
  14291. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14292. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14293. * The passed axis is also normalized. .
  14294. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14295. * @param point the point to rotate around
  14296. * @param axis the axis to rotate around
  14297. * @param amount the amount to rotate in radians
  14298. * @returns the TransformNode
  14299. */
  14300. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14301. /**
  14302. * Translates the mesh along the axis vector for the passed distance in the given space.
  14303. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14304. * @param axis the axis to translate in
  14305. * @param distance the distance to translate
  14306. * @param space Space to rotate in (Default: local)
  14307. * @returns the TransformNode.
  14308. */
  14309. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14310. /**
  14311. * Adds a rotation step to the mesh current rotation.
  14312. * x, y, z are Euler angles expressed in radians.
  14313. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14314. * This means this rotation is made in the mesh local space only.
  14315. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14316. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14317. * ```javascript
  14318. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14319. * ```
  14320. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14321. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14322. * @param x Rotation to add
  14323. * @param y Rotation to add
  14324. * @param z Rotation to add
  14325. * @returns the TransformNode.
  14326. */
  14327. addRotation(x: number, y: number, z: number): TransformNode;
  14328. /**
  14329. * @hidden
  14330. */
  14331. protected _getEffectiveParent(): Nullable<Node>;
  14332. /**
  14333. * Computes the world matrix of the node
  14334. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14335. * @returns the world matrix
  14336. */
  14337. computeWorldMatrix(force?: boolean): Matrix;
  14338. /**
  14339. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14340. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14341. */
  14342. resetLocalMatrix(independentOfChildren?: boolean): void;
  14343. protected _afterComputeWorldMatrix(): void;
  14344. /**
  14345. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14346. * @param func callback function to add
  14347. *
  14348. * @returns the TransformNode.
  14349. */
  14350. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14351. /**
  14352. * Removes a registered callback function.
  14353. * @param func callback function to remove
  14354. * @returns the TransformNode.
  14355. */
  14356. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14357. /**
  14358. * Gets the position of the current mesh in camera space
  14359. * @param camera defines the camera to use
  14360. * @returns a position
  14361. */
  14362. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14363. /**
  14364. * Returns the distance from the mesh to the active camera
  14365. * @param camera defines the camera to use
  14366. * @returns the distance
  14367. */
  14368. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14369. /**
  14370. * Clone the current transform node
  14371. * @param name Name of the new clone
  14372. * @param newParent New parent for the clone
  14373. * @param doNotCloneChildren Do not clone children hierarchy
  14374. * @returns the new transform node
  14375. */
  14376. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14377. /**
  14378. * Serializes the objects information.
  14379. * @param currentSerializationObject defines the object to serialize in
  14380. * @returns the serialized object
  14381. */
  14382. serialize(currentSerializationObject?: any): any;
  14383. /**
  14384. * Returns a new TransformNode object parsed from the source provided.
  14385. * @param parsedTransformNode is the source.
  14386. * @param scene the scne the object belongs to
  14387. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14388. * @returns a new TransformNode object parsed from the source provided.
  14389. */
  14390. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14391. /**
  14392. * Get all child-transformNodes of this node
  14393. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14394. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14395. * @returns an array of TransformNode
  14396. */
  14397. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14398. /**
  14399. * Releases resources associated with this transform node.
  14400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14402. */
  14403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14404. /**
  14405. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14406. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14407. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14408. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14409. * @returns the current mesh
  14410. */
  14411. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14412. private _syncAbsoluteScalingAndRotation;
  14413. }
  14414. }
  14415. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14416. /**
  14417. * Class used to override all child animations of a given target
  14418. */
  14419. export class AnimationPropertiesOverride {
  14420. /**
  14421. * Gets or sets a value indicating if animation blending must be used
  14422. */
  14423. enableBlending: boolean;
  14424. /**
  14425. * Gets or sets the blending speed to use when enableBlending is true
  14426. */
  14427. blendingSpeed: number;
  14428. /**
  14429. * Gets or sets the default loop mode to use
  14430. */
  14431. loopMode: number;
  14432. }
  14433. }
  14434. declare module "babylonjs/Bones/bone" {
  14435. import { Skeleton } from "babylonjs/Bones/skeleton";
  14436. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14437. import { Nullable } from "babylonjs/types";
  14438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14439. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14440. import { Node } from "babylonjs/node";
  14441. import { Space } from "babylonjs/Maths/math.axis";
  14442. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14443. /**
  14444. * Class used to store bone information
  14445. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14446. */
  14447. export class Bone extends Node {
  14448. /**
  14449. * defines the bone name
  14450. */
  14451. name: string;
  14452. private static _tmpVecs;
  14453. private static _tmpQuat;
  14454. private static _tmpMats;
  14455. /**
  14456. * Gets the list of child bones
  14457. */
  14458. children: Bone[];
  14459. /** Gets the animations associated with this bone */
  14460. animations: import("babylonjs/Animations/animation").Animation[];
  14461. /**
  14462. * Gets or sets bone length
  14463. */
  14464. length: number;
  14465. /**
  14466. * @hidden Internal only
  14467. * Set this value to map this bone to a different index in the transform matrices
  14468. * Set this value to -1 to exclude the bone from the transform matrices
  14469. */
  14470. _index: Nullable<number>;
  14471. private _skeleton;
  14472. private _localMatrix;
  14473. private _restPose;
  14474. private _baseMatrix;
  14475. private _absoluteTransform;
  14476. private _invertedAbsoluteTransform;
  14477. private _parent;
  14478. private _scalingDeterminant;
  14479. private _worldTransform;
  14480. private _localScaling;
  14481. private _localRotation;
  14482. private _localPosition;
  14483. private _needToDecompose;
  14484. private _needToCompose;
  14485. /** @hidden */
  14486. _linkedTransformNode: Nullable<TransformNode>;
  14487. /** @hidden */
  14488. _waitingTransformNodeId: Nullable<string>;
  14489. /** @hidden */
  14490. get _matrix(): Matrix;
  14491. /** @hidden */
  14492. set _matrix(value: Matrix);
  14493. /**
  14494. * Create a new bone
  14495. * @param name defines the bone name
  14496. * @param skeleton defines the parent skeleton
  14497. * @param parentBone defines the parent (can be null if the bone is the root)
  14498. * @param localMatrix defines the local matrix
  14499. * @param restPose defines the rest pose matrix
  14500. * @param baseMatrix defines the base matrix
  14501. * @param index defines index of the bone in the hiearchy
  14502. */
  14503. constructor(
  14504. /**
  14505. * defines the bone name
  14506. */
  14507. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14508. /**
  14509. * Gets the current object class name.
  14510. * @return the class name
  14511. */
  14512. getClassName(): string;
  14513. /**
  14514. * Gets the parent skeleton
  14515. * @returns a skeleton
  14516. */
  14517. getSkeleton(): Skeleton;
  14518. /**
  14519. * Gets parent bone
  14520. * @returns a bone or null if the bone is the root of the bone hierarchy
  14521. */
  14522. getParent(): Nullable<Bone>;
  14523. /**
  14524. * Returns an array containing the root bones
  14525. * @returns an array containing the root bones
  14526. */
  14527. getChildren(): Array<Bone>;
  14528. /**
  14529. * Gets the node index in matrix array generated for rendering
  14530. * @returns the node index
  14531. */
  14532. getIndex(): number;
  14533. /**
  14534. * Sets the parent bone
  14535. * @param parent defines the parent (can be null if the bone is the root)
  14536. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14537. */
  14538. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14539. /**
  14540. * Gets the local matrix
  14541. * @returns a matrix
  14542. */
  14543. getLocalMatrix(): Matrix;
  14544. /**
  14545. * Gets the base matrix (initial matrix which remains unchanged)
  14546. * @returns a matrix
  14547. */
  14548. getBaseMatrix(): Matrix;
  14549. /**
  14550. * Gets the rest pose matrix
  14551. * @returns a matrix
  14552. */
  14553. getRestPose(): Matrix;
  14554. /**
  14555. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14556. */
  14557. getWorldMatrix(): Matrix;
  14558. /**
  14559. * Sets the local matrix to rest pose matrix
  14560. */
  14561. returnToRest(): void;
  14562. /**
  14563. * Gets the inverse of the absolute transform matrix.
  14564. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14565. * @returns a matrix
  14566. */
  14567. getInvertedAbsoluteTransform(): Matrix;
  14568. /**
  14569. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14570. * @returns a matrix
  14571. */
  14572. getAbsoluteTransform(): Matrix;
  14573. /**
  14574. * Links with the given transform node.
  14575. * The local matrix of this bone is copied from the transform node every frame.
  14576. * @param transformNode defines the transform node to link to
  14577. */
  14578. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14579. /**
  14580. * Gets the node used to drive the bone's transformation
  14581. * @returns a transform node or null
  14582. */
  14583. getTransformNode(): Nullable<TransformNode>;
  14584. /** Gets or sets current position (in local space) */
  14585. get position(): Vector3;
  14586. set position(newPosition: Vector3);
  14587. /** Gets or sets current rotation (in local space) */
  14588. get rotation(): Vector3;
  14589. set rotation(newRotation: Vector3);
  14590. /** Gets or sets current rotation quaternion (in local space) */
  14591. get rotationQuaternion(): Quaternion;
  14592. set rotationQuaternion(newRotation: Quaternion);
  14593. /** Gets or sets current scaling (in local space) */
  14594. get scaling(): Vector3;
  14595. set scaling(newScaling: Vector3);
  14596. /**
  14597. * Gets the animation properties override
  14598. */
  14599. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14600. private _decompose;
  14601. private _compose;
  14602. /**
  14603. * Update the base and local matrices
  14604. * @param matrix defines the new base or local matrix
  14605. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14606. * @param updateLocalMatrix defines if the local matrix should be updated
  14607. */
  14608. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14609. /** @hidden */
  14610. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14611. /**
  14612. * Flag the bone as dirty (Forcing it to update everything)
  14613. */
  14614. markAsDirty(): void;
  14615. /** @hidden */
  14616. _markAsDirtyAndCompose(): void;
  14617. private _markAsDirtyAndDecompose;
  14618. /**
  14619. * Translate the bone in local or world space
  14620. * @param vec The amount to translate the bone
  14621. * @param space The space that the translation is in
  14622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14623. */
  14624. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14625. /**
  14626. * Set the postion of the bone in local or world space
  14627. * @param position The position to set the bone
  14628. * @param space The space that the position is in
  14629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14630. */
  14631. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14632. /**
  14633. * Set the absolute position of the bone (world space)
  14634. * @param position The position to set the bone
  14635. * @param mesh The mesh that this bone is attached to
  14636. */
  14637. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14638. /**
  14639. * Scale the bone on the x, y and z axes (in local space)
  14640. * @param x The amount to scale the bone on the x axis
  14641. * @param y The amount to scale the bone on the y axis
  14642. * @param z The amount to scale the bone on the z axis
  14643. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14644. */
  14645. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14646. /**
  14647. * Set the bone scaling in local space
  14648. * @param scale defines the scaling vector
  14649. */
  14650. setScale(scale: Vector3): void;
  14651. /**
  14652. * Gets the current scaling in local space
  14653. * @returns the current scaling vector
  14654. */
  14655. getScale(): Vector3;
  14656. /**
  14657. * Gets the current scaling in local space and stores it in a target vector
  14658. * @param result defines the target vector
  14659. */
  14660. getScaleToRef(result: Vector3): void;
  14661. /**
  14662. * Set the yaw, pitch, and roll of the bone in local or world space
  14663. * @param yaw The rotation of the bone on the y axis
  14664. * @param pitch The rotation of the bone on the x axis
  14665. * @param roll The rotation of the bone on the z axis
  14666. * @param space The space that the axes of rotation are in
  14667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14668. */
  14669. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14670. /**
  14671. * Add a rotation to the bone on an axis in local or world space
  14672. * @param axis The axis to rotate the bone on
  14673. * @param amount The amount to rotate the bone
  14674. * @param space The space that the axis is in
  14675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14676. */
  14677. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14678. /**
  14679. * Set the rotation of the bone to a particular axis angle in local or world space
  14680. * @param axis The axis to rotate the bone on
  14681. * @param angle The angle that the bone should be rotated to
  14682. * @param space The space that the axis is in
  14683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14684. */
  14685. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14686. /**
  14687. * Set the euler rotation of the bone in local of world space
  14688. * @param rotation The euler rotation that the bone should be set to
  14689. * @param space The space that the rotation is in
  14690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14691. */
  14692. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14693. /**
  14694. * Set the quaternion rotation of the bone in local of world space
  14695. * @param quat The quaternion rotation that the bone should be set to
  14696. * @param space The space that the rotation is in
  14697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14698. */
  14699. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14700. /**
  14701. * Set the rotation matrix of the bone in local of world space
  14702. * @param rotMat The rotation matrix that the bone should be set to
  14703. * @param space The space that the rotation is in
  14704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14705. */
  14706. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14707. private _rotateWithMatrix;
  14708. private _getNegativeRotationToRef;
  14709. /**
  14710. * Get the position of the bone in local or world space
  14711. * @param space The space that the returned position is in
  14712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14713. * @returns The position of the bone
  14714. */
  14715. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14716. /**
  14717. * Copy the position of the bone to a vector3 in local or world space
  14718. * @param space The space that the returned position is in
  14719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14720. * @param result The vector3 to copy the position to
  14721. */
  14722. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14723. /**
  14724. * Get the absolute position of the bone (world space)
  14725. * @param mesh The mesh that this bone is attached to
  14726. * @returns The absolute position of the bone
  14727. */
  14728. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14729. /**
  14730. * Copy the absolute position of the bone (world space) to the result param
  14731. * @param mesh The mesh that this bone is attached to
  14732. * @param result The vector3 to copy the absolute position to
  14733. */
  14734. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14735. /**
  14736. * Compute the absolute transforms of this bone and its children
  14737. */
  14738. computeAbsoluteTransforms(): void;
  14739. /**
  14740. * Get the world direction from an axis that is in the local space of the bone
  14741. * @param localAxis The local direction that is used to compute the world direction
  14742. * @param mesh The mesh that this bone is attached to
  14743. * @returns The world direction
  14744. */
  14745. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14746. /**
  14747. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14748. * @param localAxis The local direction that is used to compute the world direction
  14749. * @param mesh The mesh that this bone is attached to
  14750. * @param result The vector3 that the world direction will be copied to
  14751. */
  14752. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14753. /**
  14754. * Get the euler rotation of the bone in local or world space
  14755. * @param space The space that the rotation should be in
  14756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14757. * @returns The euler rotation
  14758. */
  14759. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14760. /**
  14761. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14762. * @param space The space that the rotation should be in
  14763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14764. * @param result The vector3 that the rotation should be copied to
  14765. */
  14766. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14767. /**
  14768. * Get the quaternion rotation of the bone in either local or world space
  14769. * @param space The space that the rotation should be in
  14770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14771. * @returns The quaternion rotation
  14772. */
  14773. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14774. /**
  14775. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14776. * @param space The space that the rotation should be in
  14777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14778. * @param result The quaternion that the rotation should be copied to
  14779. */
  14780. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14781. /**
  14782. * Get the rotation matrix of the bone in local or world space
  14783. * @param space The space that the rotation should be in
  14784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14785. * @returns The rotation matrix
  14786. */
  14787. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14788. /**
  14789. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14790. * @param space The space that the rotation should be in
  14791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14792. * @param result The quaternion that the rotation should be copied to
  14793. */
  14794. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14795. /**
  14796. * Get the world position of a point that is in the local space of the bone
  14797. * @param position The local position
  14798. * @param mesh The mesh that this bone is attached to
  14799. * @returns The world position
  14800. */
  14801. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14802. /**
  14803. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14804. * @param position The local position
  14805. * @param mesh The mesh that this bone is attached to
  14806. * @param result The vector3 that the world position should be copied to
  14807. */
  14808. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14809. /**
  14810. * Get the local position of a point that is in world space
  14811. * @param position The world position
  14812. * @param mesh The mesh that this bone is attached to
  14813. * @returns The local position
  14814. */
  14815. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14816. /**
  14817. * Get the local position of a point that is in world space and copy it to the result param
  14818. * @param position The world position
  14819. * @param mesh The mesh that this bone is attached to
  14820. * @param result The vector3 that the local position should be copied to
  14821. */
  14822. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14823. }
  14824. }
  14825. declare module "babylonjs/Animations/runtimeAnimation" {
  14826. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14827. import { Animatable } from "babylonjs/Animations/animatable";
  14828. import { Scene } from "babylonjs/scene";
  14829. /**
  14830. * Defines a runtime animation
  14831. */
  14832. export class RuntimeAnimation {
  14833. private _events;
  14834. /**
  14835. * The current frame of the runtime animation
  14836. */
  14837. private _currentFrame;
  14838. /**
  14839. * The animation used by the runtime animation
  14840. */
  14841. private _animation;
  14842. /**
  14843. * The target of the runtime animation
  14844. */
  14845. private _target;
  14846. /**
  14847. * The initiating animatable
  14848. */
  14849. private _host;
  14850. /**
  14851. * The original value of the runtime animation
  14852. */
  14853. private _originalValue;
  14854. /**
  14855. * The original blend value of the runtime animation
  14856. */
  14857. private _originalBlendValue;
  14858. /**
  14859. * The offsets cache of the runtime animation
  14860. */
  14861. private _offsetsCache;
  14862. /**
  14863. * The high limits cache of the runtime animation
  14864. */
  14865. private _highLimitsCache;
  14866. /**
  14867. * Specifies if the runtime animation has been stopped
  14868. */
  14869. private _stopped;
  14870. /**
  14871. * The blending factor of the runtime animation
  14872. */
  14873. private _blendingFactor;
  14874. /**
  14875. * The BabylonJS scene
  14876. */
  14877. private _scene;
  14878. /**
  14879. * The current value of the runtime animation
  14880. */
  14881. private _currentValue;
  14882. /** @hidden */
  14883. _animationState: _IAnimationState;
  14884. /**
  14885. * The active target of the runtime animation
  14886. */
  14887. private _activeTargets;
  14888. private _currentActiveTarget;
  14889. private _directTarget;
  14890. /**
  14891. * The target path of the runtime animation
  14892. */
  14893. private _targetPath;
  14894. /**
  14895. * The weight of the runtime animation
  14896. */
  14897. private _weight;
  14898. /**
  14899. * The ratio offset of the runtime animation
  14900. */
  14901. private _ratioOffset;
  14902. /**
  14903. * The previous delay of the runtime animation
  14904. */
  14905. private _previousDelay;
  14906. /**
  14907. * The previous ratio of the runtime animation
  14908. */
  14909. private _previousRatio;
  14910. private _enableBlending;
  14911. private _keys;
  14912. private _minFrame;
  14913. private _maxFrame;
  14914. private _minValue;
  14915. private _maxValue;
  14916. private _targetIsArray;
  14917. /**
  14918. * Gets the current frame of the runtime animation
  14919. */
  14920. get currentFrame(): number;
  14921. /**
  14922. * Gets the weight of the runtime animation
  14923. */
  14924. get weight(): number;
  14925. /**
  14926. * Gets the current value of the runtime animation
  14927. */
  14928. get currentValue(): any;
  14929. /**
  14930. * Gets the target path of the runtime animation
  14931. */
  14932. get targetPath(): string;
  14933. /**
  14934. * Gets the actual target of the runtime animation
  14935. */
  14936. get target(): any;
  14937. /**
  14938. * Gets the additive state of the runtime animation
  14939. */
  14940. get isAdditive(): boolean;
  14941. /** @hidden */
  14942. _onLoop: () => void;
  14943. /**
  14944. * Create a new RuntimeAnimation object
  14945. * @param target defines the target of the animation
  14946. * @param animation defines the source animation object
  14947. * @param scene defines the hosting scene
  14948. * @param host defines the initiating Animatable
  14949. */
  14950. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14951. private _preparePath;
  14952. /**
  14953. * Gets the animation from the runtime animation
  14954. */
  14955. get animation(): Animation;
  14956. /**
  14957. * Resets the runtime animation to the beginning
  14958. * @param restoreOriginal defines whether to restore the target property to the original value
  14959. */
  14960. reset(restoreOriginal?: boolean): void;
  14961. /**
  14962. * Specifies if the runtime animation is stopped
  14963. * @returns Boolean specifying if the runtime animation is stopped
  14964. */
  14965. isStopped(): boolean;
  14966. /**
  14967. * Disposes of the runtime animation
  14968. */
  14969. dispose(): void;
  14970. /**
  14971. * Apply the interpolated value to the target
  14972. * @param currentValue defines the value computed by the animation
  14973. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14974. */
  14975. setValue(currentValue: any, weight: number): void;
  14976. private _getOriginalValues;
  14977. private _setValue;
  14978. /**
  14979. * Gets the loop pmode of the runtime animation
  14980. * @returns Loop Mode
  14981. */
  14982. private _getCorrectLoopMode;
  14983. /**
  14984. * Move the current animation to a given frame
  14985. * @param frame defines the frame to move to
  14986. */
  14987. goToFrame(frame: number): void;
  14988. /**
  14989. * @hidden Internal use only
  14990. */
  14991. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14992. /**
  14993. * Execute the current animation
  14994. * @param delay defines the delay to add to the current frame
  14995. * @param from defines the lower bound of the animation range
  14996. * @param to defines the upper bound of the animation range
  14997. * @param loop defines if the current animation must loop
  14998. * @param speedRatio defines the current speed ratio
  14999. * @param weight defines the weight of the animation (default is -1 so no weight)
  15000. * @param onLoop optional callback called when animation loops
  15001. * @returns a boolean indicating if the animation is running
  15002. */
  15003. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15004. }
  15005. }
  15006. declare module "babylonjs/Animations/animatable" {
  15007. import { Animation } from "babylonjs/Animations/animation";
  15008. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15009. import { Nullable } from "babylonjs/types";
  15010. import { Observable } from "babylonjs/Misc/observable";
  15011. import { Scene } from "babylonjs/scene";
  15012. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15013. import { Node } from "babylonjs/node";
  15014. /**
  15015. * Class used to store an actual running animation
  15016. */
  15017. export class Animatable {
  15018. /** defines the target object */
  15019. target: any;
  15020. /** defines the starting frame number (default is 0) */
  15021. fromFrame: number;
  15022. /** defines the ending frame number (default is 100) */
  15023. toFrame: number;
  15024. /** defines if the animation must loop (default is false) */
  15025. loopAnimation: boolean;
  15026. /** defines a callback to call when animation ends if it is not looping */
  15027. onAnimationEnd?: (() => void) | null | undefined;
  15028. /** defines a callback to call when animation loops */
  15029. onAnimationLoop?: (() => void) | null | undefined;
  15030. /** defines whether the animation should be evaluated additively */
  15031. isAdditive: boolean;
  15032. private _localDelayOffset;
  15033. private _pausedDelay;
  15034. private _runtimeAnimations;
  15035. private _paused;
  15036. private _scene;
  15037. private _speedRatio;
  15038. private _weight;
  15039. private _syncRoot;
  15040. /**
  15041. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15042. * This will only apply for non looping animation (default is true)
  15043. */
  15044. disposeOnEnd: boolean;
  15045. /**
  15046. * Gets a boolean indicating if the animation has started
  15047. */
  15048. animationStarted: boolean;
  15049. /**
  15050. * Observer raised when the animation ends
  15051. */
  15052. onAnimationEndObservable: Observable<Animatable>;
  15053. /**
  15054. * Observer raised when the animation loops
  15055. */
  15056. onAnimationLoopObservable: Observable<Animatable>;
  15057. /**
  15058. * Gets the root Animatable used to synchronize and normalize animations
  15059. */
  15060. get syncRoot(): Nullable<Animatable>;
  15061. /**
  15062. * Gets the current frame of the first RuntimeAnimation
  15063. * Used to synchronize Animatables
  15064. */
  15065. get masterFrame(): number;
  15066. /**
  15067. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15068. */
  15069. get weight(): number;
  15070. set weight(value: number);
  15071. /**
  15072. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15073. */
  15074. get speedRatio(): number;
  15075. set speedRatio(value: number);
  15076. /**
  15077. * Creates a new Animatable
  15078. * @param scene defines the hosting scene
  15079. * @param target defines the target object
  15080. * @param fromFrame defines the starting frame number (default is 0)
  15081. * @param toFrame defines the ending frame number (default is 100)
  15082. * @param loopAnimation defines if the animation must loop (default is false)
  15083. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15084. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15085. * @param animations defines a group of animation to add to the new Animatable
  15086. * @param onAnimationLoop defines a callback to call when animation loops
  15087. * @param isAdditive defines whether the animation should be evaluated additively
  15088. */
  15089. constructor(scene: Scene,
  15090. /** defines the target object */
  15091. target: any,
  15092. /** defines the starting frame number (default is 0) */
  15093. fromFrame?: number,
  15094. /** defines the ending frame number (default is 100) */
  15095. toFrame?: number,
  15096. /** defines if the animation must loop (default is false) */
  15097. loopAnimation?: boolean, speedRatio?: number,
  15098. /** defines a callback to call when animation ends if it is not looping */
  15099. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15100. /** defines a callback to call when animation loops */
  15101. onAnimationLoop?: (() => void) | null | undefined,
  15102. /** defines whether the animation should be evaluated additively */
  15103. isAdditive?: boolean);
  15104. /**
  15105. * Synchronize and normalize current Animatable with a source Animatable
  15106. * This is useful when using animation weights and when animations are not of the same length
  15107. * @param root defines the root Animatable to synchronize with
  15108. * @returns the current Animatable
  15109. */
  15110. syncWith(root: Animatable): Animatable;
  15111. /**
  15112. * Gets the list of runtime animations
  15113. * @returns an array of RuntimeAnimation
  15114. */
  15115. getAnimations(): RuntimeAnimation[];
  15116. /**
  15117. * Adds more animations to the current animatable
  15118. * @param target defines the target of the animations
  15119. * @param animations defines the new animations to add
  15120. */
  15121. appendAnimations(target: any, animations: Animation[]): void;
  15122. /**
  15123. * Gets the source animation for a specific property
  15124. * @param property defines the propertyu to look for
  15125. * @returns null or the source animation for the given property
  15126. */
  15127. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15128. /**
  15129. * Gets the runtime animation for a specific property
  15130. * @param property defines the propertyu to look for
  15131. * @returns null or the runtime animation for the given property
  15132. */
  15133. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15134. /**
  15135. * Resets the animatable to its original state
  15136. */
  15137. reset(): void;
  15138. /**
  15139. * Allows the animatable to blend with current running animations
  15140. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15141. * @param blendingSpeed defines the blending speed to use
  15142. */
  15143. enableBlending(blendingSpeed: number): void;
  15144. /**
  15145. * Disable animation blending
  15146. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15147. */
  15148. disableBlending(): void;
  15149. /**
  15150. * Jump directly to a given frame
  15151. * @param frame defines the frame to jump to
  15152. */
  15153. goToFrame(frame: number): void;
  15154. /**
  15155. * Pause the animation
  15156. */
  15157. pause(): void;
  15158. /**
  15159. * Restart the animation
  15160. */
  15161. restart(): void;
  15162. private _raiseOnAnimationEnd;
  15163. /**
  15164. * Stop and delete the current animation
  15165. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15166. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15167. */
  15168. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15169. /**
  15170. * Wait asynchronously for the animation to end
  15171. * @returns a promise which will be fullfilled when the animation ends
  15172. */
  15173. waitAsync(): Promise<Animatable>;
  15174. /** @hidden */
  15175. _animate(delay: number): boolean;
  15176. }
  15177. module "babylonjs/scene" {
  15178. interface Scene {
  15179. /** @hidden */
  15180. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15181. /** @hidden */
  15182. _processLateAnimationBindingsForMatrices(holder: {
  15183. totalWeight: number;
  15184. totalAdditiveWeight: number;
  15185. animations: RuntimeAnimation[];
  15186. additiveAnimations: RuntimeAnimation[];
  15187. originalValue: Matrix;
  15188. }): any;
  15189. /** @hidden */
  15190. _processLateAnimationBindingsForQuaternions(holder: {
  15191. totalWeight: number;
  15192. totalAdditiveWeight: number;
  15193. animations: RuntimeAnimation[];
  15194. additiveAnimations: RuntimeAnimation[];
  15195. originalValue: Quaternion;
  15196. }, refQuaternion: Quaternion): Quaternion;
  15197. /** @hidden */
  15198. _processLateAnimationBindings(): void;
  15199. /**
  15200. * Will start the animation sequence of a given target
  15201. * @param target defines the target
  15202. * @param from defines from which frame should animation start
  15203. * @param to defines until which frame should animation run.
  15204. * @param weight defines the weight to apply to the animation (1.0 by default)
  15205. * @param loop defines if the animation loops
  15206. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15207. * @param onAnimationEnd defines the function to be executed when the animation ends
  15208. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15209. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15210. * @param onAnimationLoop defines the callback to call when an animation loops
  15211. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15212. * @returns the animatable object created for this animation
  15213. */
  15214. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15215. /**
  15216. * Will start the animation sequence of a given target
  15217. * @param target defines the target
  15218. * @param from defines from which frame should animation start
  15219. * @param to defines until which frame should animation run.
  15220. * @param loop defines if the animation loops
  15221. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15222. * @param onAnimationEnd defines the function to be executed when the animation ends
  15223. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15224. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15225. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15226. * @param onAnimationLoop defines the callback to call when an animation loops
  15227. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15228. * @returns the animatable object created for this animation
  15229. */
  15230. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15231. /**
  15232. * Will start the animation sequence of a given target and its hierarchy
  15233. * @param target defines the target
  15234. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15235. * @param from defines from which frame should animation start
  15236. * @param to defines until which frame should animation run.
  15237. * @param loop defines if the animation loops
  15238. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15239. * @param onAnimationEnd defines the function to be executed when the animation ends
  15240. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15241. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15242. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15243. * @param onAnimationLoop defines the callback to call when an animation loops
  15244. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15245. * @returns the list of created animatables
  15246. */
  15247. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15248. /**
  15249. * Begin a new animation on a given node
  15250. * @param target defines the target where the animation will take place
  15251. * @param animations defines the list of animations to start
  15252. * @param from defines the initial value
  15253. * @param to defines the final value
  15254. * @param loop defines if you want animation to loop (off by default)
  15255. * @param speedRatio defines the speed ratio to apply to all animations
  15256. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15257. * @param onAnimationLoop defines the callback to call when an animation loops
  15258. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15259. * @returns the list of created animatables
  15260. */
  15261. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15262. /**
  15263. * Begin a new animation on a given node and its hierarchy
  15264. * @param target defines the root node where the animation will take place
  15265. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15266. * @param animations defines the list of animations to start
  15267. * @param from defines the initial value
  15268. * @param to defines the final value
  15269. * @param loop defines if you want animation to loop (off by default)
  15270. * @param speedRatio defines the speed ratio to apply to all animations
  15271. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15272. * @param onAnimationLoop defines the callback to call when an animation loops
  15273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15274. * @returns the list of animatables created for all nodes
  15275. */
  15276. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15277. /**
  15278. * Gets the animatable associated with a specific target
  15279. * @param target defines the target of the animatable
  15280. * @returns the required animatable if found
  15281. */
  15282. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15283. /**
  15284. * Gets all animatables associated with a given target
  15285. * @param target defines the target to look animatables for
  15286. * @returns an array of Animatables
  15287. */
  15288. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15289. /**
  15290. * Stops and removes all animations that have been applied to the scene
  15291. */
  15292. stopAllAnimations(): void;
  15293. /**
  15294. * Gets the current delta time used by animation engine
  15295. */
  15296. deltaTime: number;
  15297. }
  15298. }
  15299. module "babylonjs/Bones/bone" {
  15300. interface Bone {
  15301. /**
  15302. * Copy an animation range from another bone
  15303. * @param source defines the source bone
  15304. * @param rangeName defines the range name to copy
  15305. * @param frameOffset defines the frame offset
  15306. * @param rescaleAsRequired defines if rescaling must be applied if required
  15307. * @param skelDimensionsRatio defines the scaling ratio
  15308. * @returns true if operation was successful
  15309. */
  15310. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15311. }
  15312. }
  15313. }
  15314. declare module "babylonjs/Bones/skeleton" {
  15315. import { Bone } from "babylonjs/Bones/bone";
  15316. import { Observable } from "babylonjs/Misc/observable";
  15317. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15318. import { Scene } from "babylonjs/scene";
  15319. import { Nullable } from "babylonjs/types";
  15320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15321. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15322. import { Animatable } from "babylonjs/Animations/animatable";
  15323. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15324. import { Animation } from "babylonjs/Animations/animation";
  15325. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15326. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15328. /**
  15329. * Class used to handle skinning animations
  15330. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15331. */
  15332. export class Skeleton implements IAnimatable {
  15333. /** defines the skeleton name */
  15334. name: string;
  15335. /** defines the skeleton Id */
  15336. id: string;
  15337. /**
  15338. * Defines the list of child bones
  15339. */
  15340. bones: Bone[];
  15341. /**
  15342. * Defines an estimate of the dimension of the skeleton at rest
  15343. */
  15344. dimensionsAtRest: Vector3;
  15345. /**
  15346. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15347. */
  15348. needInitialSkinMatrix: boolean;
  15349. /**
  15350. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15351. */
  15352. overrideMesh: Nullable<AbstractMesh>;
  15353. /**
  15354. * Gets the list of animations attached to this skeleton
  15355. */
  15356. animations: Array<Animation>;
  15357. private _scene;
  15358. private _isDirty;
  15359. private _transformMatrices;
  15360. private _transformMatrixTexture;
  15361. private _meshesWithPoseMatrix;
  15362. private _animatables;
  15363. private _identity;
  15364. private _synchronizedWithMesh;
  15365. private _ranges;
  15366. private _lastAbsoluteTransformsUpdateId;
  15367. private _canUseTextureForBones;
  15368. private _uniqueId;
  15369. /** @hidden */
  15370. _numBonesWithLinkedTransformNode: number;
  15371. /** @hidden */
  15372. _hasWaitingData: Nullable<boolean>;
  15373. /**
  15374. * Specifies if the skeleton should be serialized
  15375. */
  15376. doNotSerialize: boolean;
  15377. private _useTextureToStoreBoneMatrices;
  15378. /**
  15379. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15380. * Please note that this option is not available if the hardware does not support it
  15381. */
  15382. get useTextureToStoreBoneMatrices(): boolean;
  15383. set useTextureToStoreBoneMatrices(value: boolean);
  15384. private _animationPropertiesOverride;
  15385. /**
  15386. * Gets or sets the animation properties override
  15387. */
  15388. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15389. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15390. /**
  15391. * List of inspectable custom properties (used by the Inspector)
  15392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15393. */
  15394. inspectableCustomProperties: IInspectable[];
  15395. /**
  15396. * An observable triggered before computing the skeleton's matrices
  15397. */
  15398. onBeforeComputeObservable: Observable<Skeleton>;
  15399. /**
  15400. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15401. */
  15402. get isUsingTextureForMatrices(): boolean;
  15403. /**
  15404. * Gets the unique ID of this skeleton
  15405. */
  15406. get uniqueId(): number;
  15407. /**
  15408. * Creates a new skeleton
  15409. * @param name defines the skeleton name
  15410. * @param id defines the skeleton Id
  15411. * @param scene defines the hosting scene
  15412. */
  15413. constructor(
  15414. /** defines the skeleton name */
  15415. name: string,
  15416. /** defines the skeleton Id */
  15417. id: string, scene: Scene);
  15418. /**
  15419. * Gets the current object class name.
  15420. * @return the class name
  15421. */
  15422. getClassName(): string;
  15423. /**
  15424. * Returns an array containing the root bones
  15425. * @returns an array containing the root bones
  15426. */
  15427. getChildren(): Array<Bone>;
  15428. /**
  15429. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15430. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15431. * @returns a Float32Array containing matrices data
  15432. */
  15433. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15434. /**
  15435. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15436. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15437. * @returns a raw texture containing the data
  15438. */
  15439. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15440. /**
  15441. * Gets the current hosting scene
  15442. * @returns a scene object
  15443. */
  15444. getScene(): Scene;
  15445. /**
  15446. * Gets a string representing the current skeleton data
  15447. * @param fullDetails defines a boolean indicating if we want a verbose version
  15448. * @returns a string representing the current skeleton data
  15449. */
  15450. toString(fullDetails?: boolean): string;
  15451. /**
  15452. * Get bone's index searching by name
  15453. * @param name defines bone's name to search for
  15454. * @return the indice of the bone. Returns -1 if not found
  15455. */
  15456. getBoneIndexByName(name: string): number;
  15457. /**
  15458. * Creater a new animation range
  15459. * @param name defines the name of the range
  15460. * @param from defines the start key
  15461. * @param to defines the end key
  15462. */
  15463. createAnimationRange(name: string, from: number, to: number): void;
  15464. /**
  15465. * Delete a specific animation range
  15466. * @param name defines the name of the range
  15467. * @param deleteFrames defines if frames must be removed as well
  15468. */
  15469. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15470. /**
  15471. * Gets a specific animation range
  15472. * @param name defines the name of the range to look for
  15473. * @returns the requested animation range or null if not found
  15474. */
  15475. getAnimationRange(name: string): Nullable<AnimationRange>;
  15476. /**
  15477. * Gets the list of all animation ranges defined on this skeleton
  15478. * @returns an array
  15479. */
  15480. getAnimationRanges(): Nullable<AnimationRange>[];
  15481. /**
  15482. * Copy animation range from a source skeleton.
  15483. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15484. * @param source defines the source skeleton
  15485. * @param name defines the name of the range to copy
  15486. * @param rescaleAsRequired defines if rescaling must be applied if required
  15487. * @returns true if operation was successful
  15488. */
  15489. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15490. /**
  15491. * Forces the skeleton to go to rest pose
  15492. */
  15493. returnToRest(): void;
  15494. private _getHighestAnimationFrame;
  15495. /**
  15496. * Begin a specific animation range
  15497. * @param name defines the name of the range to start
  15498. * @param loop defines if looping must be turned on (false by default)
  15499. * @param speedRatio defines the speed ratio to apply (1 by default)
  15500. * @param onAnimationEnd defines a callback which will be called when animation will end
  15501. * @returns a new animatable
  15502. */
  15503. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15504. /**
  15505. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15506. * @param skeleton defines the Skeleton containing the animation range to convert
  15507. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15508. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15509. * @returns the original skeleton
  15510. */
  15511. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15512. /** @hidden */
  15513. _markAsDirty(): void;
  15514. /** @hidden */
  15515. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15516. /** @hidden */
  15517. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15518. private _computeTransformMatrices;
  15519. /**
  15520. * Build all resources required to render a skeleton
  15521. */
  15522. prepare(): void;
  15523. /**
  15524. * Gets the list of animatables currently running for this skeleton
  15525. * @returns an array of animatables
  15526. */
  15527. getAnimatables(): IAnimatable[];
  15528. /**
  15529. * Clone the current skeleton
  15530. * @param name defines the name of the new skeleton
  15531. * @param id defines the id of the new skeleton
  15532. * @returns the new skeleton
  15533. */
  15534. clone(name: string, id?: string): Skeleton;
  15535. /**
  15536. * Enable animation blending for this skeleton
  15537. * @param blendingSpeed defines the blending speed to apply
  15538. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15539. */
  15540. enableBlending(blendingSpeed?: number): void;
  15541. /**
  15542. * Releases all resources associated with the current skeleton
  15543. */
  15544. dispose(): void;
  15545. /**
  15546. * Serialize the skeleton in a JSON object
  15547. * @returns a JSON object
  15548. */
  15549. serialize(): any;
  15550. /**
  15551. * Creates a new skeleton from serialized data
  15552. * @param parsedSkeleton defines the serialized data
  15553. * @param scene defines the hosting scene
  15554. * @returns a new skeleton
  15555. */
  15556. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15557. /**
  15558. * Compute all node absolute transforms
  15559. * @param forceUpdate defines if computation must be done even if cache is up to date
  15560. */
  15561. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15562. /**
  15563. * Gets the root pose matrix
  15564. * @returns a matrix
  15565. */
  15566. getPoseMatrix(): Nullable<Matrix>;
  15567. /**
  15568. * Sorts bones per internal index
  15569. */
  15570. sortBones(): void;
  15571. private _sortBones;
  15572. }
  15573. }
  15574. declare module "babylonjs/Meshes/instancedMesh" {
  15575. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15577. import { Camera } from "babylonjs/Cameras/camera";
  15578. import { Node } from "babylonjs/node";
  15579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15580. import { Mesh } from "babylonjs/Meshes/mesh";
  15581. import { Material } from "babylonjs/Materials/material";
  15582. import { Skeleton } from "babylonjs/Bones/skeleton";
  15583. import { Light } from "babylonjs/Lights/light";
  15584. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15585. /**
  15586. * Creates an instance based on a source mesh.
  15587. */
  15588. export class InstancedMesh extends AbstractMesh {
  15589. private _sourceMesh;
  15590. private _currentLOD;
  15591. /** @hidden */
  15592. _indexInSourceMeshInstanceArray: number;
  15593. constructor(name: string, source: Mesh);
  15594. /**
  15595. * Returns the string "InstancedMesh".
  15596. */
  15597. getClassName(): string;
  15598. /** Gets the list of lights affecting that mesh */
  15599. get lightSources(): Light[];
  15600. _resyncLightSources(): void;
  15601. _resyncLightSource(light: Light): void;
  15602. _removeLightSource(light: Light, dispose: boolean): void;
  15603. /**
  15604. * If the source mesh receives shadows
  15605. */
  15606. get receiveShadows(): boolean;
  15607. /**
  15608. * The material of the source mesh
  15609. */
  15610. get material(): Nullable<Material>;
  15611. /**
  15612. * Visibility of the source mesh
  15613. */
  15614. get visibility(): number;
  15615. /**
  15616. * Skeleton of the source mesh
  15617. */
  15618. get skeleton(): Nullable<Skeleton>;
  15619. /**
  15620. * Rendering ground id of the source mesh
  15621. */
  15622. get renderingGroupId(): number;
  15623. set renderingGroupId(value: number);
  15624. /**
  15625. * Returns the total number of vertices (integer).
  15626. */
  15627. getTotalVertices(): number;
  15628. /**
  15629. * Returns a positive integer : the total number of indices in this mesh geometry.
  15630. * @returns the numner of indices or zero if the mesh has no geometry.
  15631. */
  15632. getTotalIndices(): number;
  15633. /**
  15634. * The source mesh of the instance
  15635. */
  15636. get sourceMesh(): Mesh;
  15637. /**
  15638. * Is this node ready to be used/rendered
  15639. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15640. * @return {boolean} is it ready
  15641. */
  15642. isReady(completeCheck?: boolean): boolean;
  15643. /**
  15644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15645. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15646. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15647. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15648. */
  15649. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15650. /**
  15651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15653. * The `data` are either a numeric array either a Float32Array.
  15654. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15655. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15656. * Note that a new underlying VertexBuffer object is created each call.
  15657. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15658. *
  15659. * Possible `kind` values :
  15660. * - VertexBuffer.PositionKind
  15661. * - VertexBuffer.UVKind
  15662. * - VertexBuffer.UV2Kind
  15663. * - VertexBuffer.UV3Kind
  15664. * - VertexBuffer.UV4Kind
  15665. * - VertexBuffer.UV5Kind
  15666. * - VertexBuffer.UV6Kind
  15667. * - VertexBuffer.ColorKind
  15668. * - VertexBuffer.MatricesIndicesKind
  15669. * - VertexBuffer.MatricesIndicesExtraKind
  15670. * - VertexBuffer.MatricesWeightsKind
  15671. * - VertexBuffer.MatricesWeightsExtraKind
  15672. *
  15673. * Returns the Mesh.
  15674. */
  15675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15676. /**
  15677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15678. * If the mesh has no geometry, it is simply returned as it is.
  15679. * The `data` are either a numeric array either a Float32Array.
  15680. * No new underlying VertexBuffer object is created.
  15681. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15682. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15683. *
  15684. * Possible `kind` values :
  15685. * - VertexBuffer.PositionKind
  15686. * - VertexBuffer.UVKind
  15687. * - VertexBuffer.UV2Kind
  15688. * - VertexBuffer.UV3Kind
  15689. * - VertexBuffer.UV4Kind
  15690. * - VertexBuffer.UV5Kind
  15691. * - VertexBuffer.UV6Kind
  15692. * - VertexBuffer.ColorKind
  15693. * - VertexBuffer.MatricesIndicesKind
  15694. * - VertexBuffer.MatricesIndicesExtraKind
  15695. * - VertexBuffer.MatricesWeightsKind
  15696. * - VertexBuffer.MatricesWeightsExtraKind
  15697. *
  15698. * Returns the Mesh.
  15699. */
  15700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15701. /**
  15702. * Sets the mesh indices.
  15703. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15704. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15705. * This method creates a new index buffer each call.
  15706. * Returns the Mesh.
  15707. */
  15708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15709. /**
  15710. * Boolean : True if the mesh owns the requested kind of data.
  15711. */
  15712. isVerticesDataPresent(kind: string): boolean;
  15713. /**
  15714. * Returns an array of indices (IndicesArray).
  15715. */
  15716. getIndices(): Nullable<IndicesArray>;
  15717. get _positions(): Nullable<Vector3[]>;
  15718. /**
  15719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15720. * This means the mesh underlying bounding box and sphere are recomputed.
  15721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15722. * @returns the current mesh
  15723. */
  15724. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15725. /** @hidden */
  15726. _preActivate(): InstancedMesh;
  15727. /** @hidden */
  15728. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15729. /** @hidden */
  15730. _postActivate(): void;
  15731. getWorldMatrix(): Matrix;
  15732. get isAnInstance(): boolean;
  15733. /**
  15734. * Returns the current associated LOD AbstractMesh.
  15735. */
  15736. getLOD(camera: Camera): AbstractMesh;
  15737. /** @hidden */
  15738. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15739. /** @hidden */
  15740. _syncSubMeshes(): InstancedMesh;
  15741. /** @hidden */
  15742. _generatePointsArray(): boolean;
  15743. /**
  15744. * Creates a new InstancedMesh from the current mesh.
  15745. * - name (string) : the cloned mesh name
  15746. * - newParent (optional Node) : the optional Node to parent the clone to.
  15747. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15748. *
  15749. * Returns the clone.
  15750. */
  15751. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15752. /**
  15753. * Disposes the InstancedMesh.
  15754. * Returns nothing.
  15755. */
  15756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15757. }
  15758. module "babylonjs/Meshes/mesh" {
  15759. interface Mesh {
  15760. /**
  15761. * Register a custom buffer that will be instanced
  15762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15763. * @param kind defines the buffer kind
  15764. * @param stride defines the stride in floats
  15765. */
  15766. registerInstancedBuffer(kind: string, stride: number): void;
  15767. /** @hidden */
  15768. _userInstancedBuffersStorage: {
  15769. data: {
  15770. [key: string]: Float32Array;
  15771. };
  15772. sizes: {
  15773. [key: string]: number;
  15774. };
  15775. vertexBuffers: {
  15776. [key: string]: Nullable<VertexBuffer>;
  15777. };
  15778. strides: {
  15779. [key: string]: number;
  15780. };
  15781. };
  15782. }
  15783. }
  15784. module "babylonjs/Meshes/abstractMesh" {
  15785. interface AbstractMesh {
  15786. /**
  15787. * Object used to store instanced buffers defined by user
  15788. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15789. */
  15790. instancedBuffers: {
  15791. [key: string]: any;
  15792. };
  15793. }
  15794. }
  15795. }
  15796. declare module "babylonjs/Materials/shaderMaterial" {
  15797. import { Scene } from "babylonjs/scene";
  15798. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15800. import { Mesh } from "babylonjs/Meshes/mesh";
  15801. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15803. import { Material } from "babylonjs/Materials/material";
  15804. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15805. /**
  15806. * Defines the options associated with the creation of a shader material.
  15807. */
  15808. export interface IShaderMaterialOptions {
  15809. /**
  15810. * Does the material work in alpha blend mode
  15811. */
  15812. needAlphaBlending: boolean;
  15813. /**
  15814. * Does the material work in alpha test mode
  15815. */
  15816. needAlphaTesting: boolean;
  15817. /**
  15818. * The list of attribute names used in the shader
  15819. */
  15820. attributes: string[];
  15821. /**
  15822. * The list of unifrom names used in the shader
  15823. */
  15824. uniforms: string[];
  15825. /**
  15826. * The list of UBO names used in the shader
  15827. */
  15828. uniformBuffers: string[];
  15829. /**
  15830. * The list of sampler names used in the shader
  15831. */
  15832. samplers: string[];
  15833. /**
  15834. * The list of defines used in the shader
  15835. */
  15836. defines: string[];
  15837. }
  15838. /**
  15839. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15840. *
  15841. * This returned material effects how the mesh will look based on the code in the shaders.
  15842. *
  15843. * @see http://doc.babylonjs.com/how_to/shader_material
  15844. */
  15845. export class ShaderMaterial extends Material {
  15846. private _shaderPath;
  15847. private _options;
  15848. private _textures;
  15849. private _textureArrays;
  15850. private _floats;
  15851. private _ints;
  15852. private _floatsArrays;
  15853. private _colors3;
  15854. private _colors3Arrays;
  15855. private _colors4;
  15856. private _colors4Arrays;
  15857. private _vectors2;
  15858. private _vectors3;
  15859. private _vectors4;
  15860. private _matrices;
  15861. private _matrixArrays;
  15862. private _matrices3x3;
  15863. private _matrices2x2;
  15864. private _vectors2Arrays;
  15865. private _vectors3Arrays;
  15866. private _vectors4Arrays;
  15867. private _cachedWorldViewMatrix;
  15868. private _cachedWorldViewProjectionMatrix;
  15869. private _renderId;
  15870. private _multiview;
  15871. /**
  15872. * Instantiate a new shader material.
  15873. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15874. * This returned material effects how the mesh will look based on the code in the shaders.
  15875. * @see http://doc.babylonjs.com/how_to/shader_material
  15876. * @param name Define the name of the material in the scene
  15877. * @param scene Define the scene the material belongs to
  15878. * @param shaderPath Defines the route to the shader code in one of three ways:
  15879. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15880. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15881. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15882. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15883. * @param options Define the options used to create the shader
  15884. */
  15885. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15886. /**
  15887. * Gets the shader path used to define the shader code
  15888. * It can be modified to trigger a new compilation
  15889. */
  15890. get shaderPath(): any;
  15891. /**
  15892. * Sets the shader path used to define the shader code
  15893. * It can be modified to trigger a new compilation
  15894. */
  15895. set shaderPath(shaderPath: any);
  15896. /**
  15897. * Gets the options used to compile the shader.
  15898. * They can be modified to trigger a new compilation
  15899. */
  15900. get options(): IShaderMaterialOptions;
  15901. /**
  15902. * Gets the current class name of the material e.g. "ShaderMaterial"
  15903. * Mainly use in serialization.
  15904. * @returns the class name
  15905. */
  15906. getClassName(): string;
  15907. /**
  15908. * Specifies if the material will require alpha blending
  15909. * @returns a boolean specifying if alpha blending is needed
  15910. */
  15911. needAlphaBlending(): boolean;
  15912. /**
  15913. * Specifies if this material should be rendered in alpha test mode
  15914. * @returns a boolean specifying if an alpha test is needed.
  15915. */
  15916. needAlphaTesting(): boolean;
  15917. private _checkUniform;
  15918. /**
  15919. * Set a texture in the shader.
  15920. * @param name Define the name of the uniform samplers as defined in the shader
  15921. * @param texture Define the texture to bind to this sampler
  15922. * @return the material itself allowing "fluent" like uniform updates
  15923. */
  15924. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15925. /**
  15926. * Set a texture array in the shader.
  15927. * @param name Define the name of the uniform sampler array as defined in the shader
  15928. * @param textures Define the list of textures to bind to this sampler
  15929. * @return the material itself allowing "fluent" like uniform updates
  15930. */
  15931. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15932. /**
  15933. * Set a float in the shader.
  15934. * @param name Define the name of the uniform as defined in the shader
  15935. * @param value Define the value to give to the uniform
  15936. * @return the material itself allowing "fluent" like uniform updates
  15937. */
  15938. setFloat(name: string, value: number): ShaderMaterial;
  15939. /**
  15940. * Set a int in the shader.
  15941. * @param name Define the name of the uniform as defined in the shader
  15942. * @param value Define the value to give to the uniform
  15943. * @return the material itself allowing "fluent" like uniform updates
  15944. */
  15945. setInt(name: string, value: number): ShaderMaterial;
  15946. /**
  15947. * Set an array of floats in the shader.
  15948. * @param name Define the name of the uniform as defined in the shader
  15949. * @param value Define the value to give to the uniform
  15950. * @return the material itself allowing "fluent" like uniform updates
  15951. */
  15952. setFloats(name: string, value: number[]): ShaderMaterial;
  15953. /**
  15954. * Set a vec3 in the shader from a Color3.
  15955. * @param name Define the name of the uniform as defined in the shader
  15956. * @param value Define the value to give to the uniform
  15957. * @return the material itself allowing "fluent" like uniform updates
  15958. */
  15959. setColor3(name: string, value: Color3): ShaderMaterial;
  15960. /**
  15961. * Set a vec3 array in the shader from a Color3 array.
  15962. * @param name Define the name of the uniform as defined in the shader
  15963. * @param value Define the value to give to the uniform
  15964. * @return the material itself allowing "fluent" like uniform updates
  15965. */
  15966. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15967. /**
  15968. * Set a vec4 in the shader from a Color4.
  15969. * @param name Define the name of the uniform as defined in the shader
  15970. * @param value Define the value to give to the uniform
  15971. * @return the material itself allowing "fluent" like uniform updates
  15972. */
  15973. setColor4(name: string, value: Color4): ShaderMaterial;
  15974. /**
  15975. * Set a vec4 array in the shader from a Color4 array.
  15976. * @param name Define the name of the uniform as defined in the shader
  15977. * @param value Define the value to give to the uniform
  15978. * @return the material itself allowing "fluent" like uniform updates
  15979. */
  15980. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15981. /**
  15982. * Set a vec2 in the shader from a Vector2.
  15983. * @param name Define the name of the uniform as defined in the shader
  15984. * @param value Define the value to give to the uniform
  15985. * @return the material itself allowing "fluent" like uniform updates
  15986. */
  15987. setVector2(name: string, value: Vector2): ShaderMaterial;
  15988. /**
  15989. * Set a vec3 in the shader from a Vector3.
  15990. * @param name Define the name of the uniform as defined in the shader
  15991. * @param value Define the value to give to the uniform
  15992. * @return the material itself allowing "fluent" like uniform updates
  15993. */
  15994. setVector3(name: string, value: Vector3): ShaderMaterial;
  15995. /**
  15996. * Set a vec4 in the shader from a Vector4.
  15997. * @param name Define the name of the uniform as defined in the shader
  15998. * @param value Define the value to give to the uniform
  15999. * @return the material itself allowing "fluent" like uniform updates
  16000. */
  16001. setVector4(name: string, value: Vector4): ShaderMaterial;
  16002. /**
  16003. * Set a mat4 in the shader from a Matrix.
  16004. * @param name Define the name of the uniform as defined in the shader
  16005. * @param value Define the value to give to the uniform
  16006. * @return the material itself allowing "fluent" like uniform updates
  16007. */
  16008. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16009. /**
  16010. * Set a float32Array in the shader from a matrix array.
  16011. * @param name Define the name of the uniform as defined in the shader
  16012. * @param value Define the value to give to the uniform
  16013. * @return the material itself allowing "fluent" like uniform updates
  16014. */
  16015. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16016. /**
  16017. * Set a mat3 in the shader from a Float32Array.
  16018. * @param name Define the name of the uniform as defined in the shader
  16019. * @param value Define the value to give to the uniform
  16020. * @return the material itself allowing "fluent" like uniform updates
  16021. */
  16022. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16023. /**
  16024. * Set a mat2 in the shader from a Float32Array.
  16025. * @param name Define the name of the uniform as defined in the shader
  16026. * @param value Define the value to give to the uniform
  16027. * @return the material itself allowing "fluent" like uniform updates
  16028. */
  16029. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16030. /**
  16031. * Set a vec2 array in the shader from a number array.
  16032. * @param name Define the name of the uniform as defined in the shader
  16033. * @param value Define the value to give to the uniform
  16034. * @return the material itself allowing "fluent" like uniform updates
  16035. */
  16036. setArray2(name: string, value: number[]): ShaderMaterial;
  16037. /**
  16038. * Set a vec3 array in the shader from a number array.
  16039. * @param name Define the name of the uniform as defined in the shader
  16040. * @param value Define the value to give to the uniform
  16041. * @return the material itself allowing "fluent" like uniform updates
  16042. */
  16043. setArray3(name: string, value: number[]): ShaderMaterial;
  16044. /**
  16045. * Set a vec4 array in the shader from a number array.
  16046. * @param name Define the name of the uniform as defined in the shader
  16047. * @param value Define the value to give to the uniform
  16048. * @return the material itself allowing "fluent" like uniform updates
  16049. */
  16050. setArray4(name: string, value: number[]): ShaderMaterial;
  16051. private _checkCache;
  16052. /**
  16053. * Specifies that the submesh is ready to be used
  16054. * @param mesh defines the mesh to check
  16055. * @param subMesh defines which submesh to check
  16056. * @param useInstances specifies that instances should be used
  16057. * @returns a boolean indicating that the submesh is ready or not
  16058. */
  16059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16060. /**
  16061. * Checks if the material is ready to render the requested mesh
  16062. * @param mesh Define the mesh to render
  16063. * @param useInstances Define whether or not the material is used with instances
  16064. * @returns true if ready, otherwise false
  16065. */
  16066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16067. /**
  16068. * Binds the world matrix to the material
  16069. * @param world defines the world transformation matrix
  16070. */
  16071. bindOnlyWorldMatrix(world: Matrix): void;
  16072. /**
  16073. * Binds the material to the mesh
  16074. * @param world defines the world transformation matrix
  16075. * @param mesh defines the mesh to bind the material to
  16076. */
  16077. bind(world: Matrix, mesh?: Mesh): void;
  16078. /**
  16079. * Gets the active textures from the material
  16080. * @returns an array of textures
  16081. */
  16082. getActiveTextures(): BaseTexture[];
  16083. /**
  16084. * Specifies if the material uses a texture
  16085. * @param texture defines the texture to check against the material
  16086. * @returns a boolean specifying if the material uses the texture
  16087. */
  16088. hasTexture(texture: BaseTexture): boolean;
  16089. /**
  16090. * Makes a duplicate of the material, and gives it a new name
  16091. * @param name defines the new name for the duplicated material
  16092. * @returns the cloned material
  16093. */
  16094. clone(name: string): ShaderMaterial;
  16095. /**
  16096. * Disposes the material
  16097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16099. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16100. */
  16101. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16102. /**
  16103. * Serializes this material in a JSON representation
  16104. * @returns the serialized material object
  16105. */
  16106. serialize(): any;
  16107. /**
  16108. * Creates a shader material from parsed shader material data
  16109. * @param source defines the JSON represnetation of the material
  16110. * @param scene defines the hosting scene
  16111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16112. * @returns a new material
  16113. */
  16114. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16115. }
  16116. }
  16117. declare module "babylonjs/Shaders/color.fragment" {
  16118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16120. /** @hidden */
  16121. export var colorPixelShader: {
  16122. name: string;
  16123. shader: string;
  16124. };
  16125. }
  16126. declare module "babylonjs/Shaders/color.vertex" {
  16127. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16128. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16130. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16131. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16132. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16133. /** @hidden */
  16134. export var colorVertexShader: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Meshes/linesMesh" {
  16140. import { Nullable } from "babylonjs/types";
  16141. import { Scene } from "babylonjs/scene";
  16142. import { Color3 } from "babylonjs/Maths/math.color";
  16143. import { Node } from "babylonjs/node";
  16144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16145. import { Mesh } from "babylonjs/Meshes/mesh";
  16146. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16147. import { Effect } from "babylonjs/Materials/effect";
  16148. import { Material } from "babylonjs/Materials/material";
  16149. import "babylonjs/Shaders/color.fragment";
  16150. import "babylonjs/Shaders/color.vertex";
  16151. /**
  16152. * Line mesh
  16153. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16154. */
  16155. export class LinesMesh extends Mesh {
  16156. /**
  16157. * If vertex color should be applied to the mesh
  16158. */
  16159. readonly useVertexColor?: boolean | undefined;
  16160. /**
  16161. * If vertex alpha should be applied to the mesh
  16162. */
  16163. readonly useVertexAlpha?: boolean | undefined;
  16164. /**
  16165. * Color of the line (Default: White)
  16166. */
  16167. color: Color3;
  16168. /**
  16169. * Alpha of the line (Default: 1)
  16170. */
  16171. alpha: number;
  16172. /**
  16173. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16174. * This margin is expressed in world space coordinates, so its value may vary.
  16175. * Default value is 0.1
  16176. */
  16177. intersectionThreshold: number;
  16178. private _colorShader;
  16179. private color4;
  16180. /**
  16181. * Creates a new LinesMesh
  16182. * @param name defines the name
  16183. * @param scene defines the hosting scene
  16184. * @param parent defines the parent mesh if any
  16185. * @param source defines the optional source LinesMesh used to clone data from
  16186. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16187. * When false, achieved by calling a clone(), also passing False.
  16188. * This will make creation of children, recursive.
  16189. * @param useVertexColor defines if this LinesMesh supports vertex color
  16190. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16191. */
  16192. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16193. /**
  16194. * If vertex color should be applied to the mesh
  16195. */
  16196. useVertexColor?: boolean | undefined,
  16197. /**
  16198. * If vertex alpha should be applied to the mesh
  16199. */
  16200. useVertexAlpha?: boolean | undefined);
  16201. private _addClipPlaneDefine;
  16202. private _removeClipPlaneDefine;
  16203. isReady(): boolean;
  16204. /**
  16205. * Returns the string "LineMesh"
  16206. */
  16207. getClassName(): string;
  16208. /**
  16209. * @hidden
  16210. */
  16211. get material(): Material;
  16212. /**
  16213. * @hidden
  16214. */
  16215. set material(value: Material);
  16216. /**
  16217. * @hidden
  16218. */
  16219. get checkCollisions(): boolean;
  16220. /** @hidden */
  16221. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16222. /** @hidden */
  16223. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16224. /**
  16225. * Disposes of the line mesh
  16226. * @param doNotRecurse If children should be disposed
  16227. */
  16228. dispose(doNotRecurse?: boolean): void;
  16229. /**
  16230. * Returns a new LineMesh object cloned from the current one.
  16231. */
  16232. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16233. /**
  16234. * Creates a new InstancedLinesMesh object from the mesh model.
  16235. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16236. * @param name defines the name of the new instance
  16237. * @returns a new InstancedLinesMesh
  16238. */
  16239. createInstance(name: string): InstancedLinesMesh;
  16240. }
  16241. /**
  16242. * Creates an instance based on a source LinesMesh
  16243. */
  16244. export class InstancedLinesMesh extends InstancedMesh {
  16245. /**
  16246. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16247. * This margin is expressed in world space coordinates, so its value may vary.
  16248. * Initilized with the intersectionThreshold value of the source LinesMesh
  16249. */
  16250. intersectionThreshold: number;
  16251. constructor(name: string, source: LinesMesh);
  16252. /**
  16253. * Returns the string "InstancedLinesMesh".
  16254. */
  16255. getClassName(): string;
  16256. }
  16257. }
  16258. declare module "babylonjs/Shaders/line.fragment" {
  16259. /** @hidden */
  16260. export var linePixelShader: {
  16261. name: string;
  16262. shader: string;
  16263. };
  16264. }
  16265. declare module "babylonjs/Shaders/line.vertex" {
  16266. /** @hidden */
  16267. export var lineVertexShader: {
  16268. name: string;
  16269. shader: string;
  16270. };
  16271. }
  16272. declare module "babylonjs/Rendering/edgesRenderer" {
  16273. import { Nullable } from "babylonjs/types";
  16274. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16276. import { Vector3 } from "babylonjs/Maths/math.vector";
  16277. import { IDisposable } from "babylonjs/scene";
  16278. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16279. import "babylonjs/Shaders/line.fragment";
  16280. import "babylonjs/Shaders/line.vertex";
  16281. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16282. module "babylonjs/Meshes/abstractMesh" {
  16283. interface AbstractMesh {
  16284. /**
  16285. * Gets the edgesRenderer associated with the mesh
  16286. */
  16287. edgesRenderer: Nullable<EdgesRenderer>;
  16288. }
  16289. }
  16290. module "babylonjs/Meshes/linesMesh" {
  16291. interface LinesMesh {
  16292. /**
  16293. * Enables the edge rendering mode on the mesh.
  16294. * This mode makes the mesh edges visible
  16295. * @param epsilon defines the maximal distance between two angles to detect a face
  16296. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16297. * @returns the currentAbstractMesh
  16298. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16299. */
  16300. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16301. }
  16302. }
  16303. module "babylonjs/Meshes/linesMesh" {
  16304. interface InstancedLinesMesh {
  16305. /**
  16306. * Enables the edge rendering mode on the mesh.
  16307. * This mode makes the mesh edges visible
  16308. * @param epsilon defines the maximal distance between two angles to detect a face
  16309. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16310. * @returns the current InstancedLinesMesh
  16311. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16312. */
  16313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16314. }
  16315. }
  16316. /**
  16317. * Defines the minimum contract an Edges renderer should follow.
  16318. */
  16319. export interface IEdgesRenderer extends IDisposable {
  16320. /**
  16321. * Gets or sets a boolean indicating if the edgesRenderer is active
  16322. */
  16323. isEnabled: boolean;
  16324. /**
  16325. * Renders the edges of the attached mesh,
  16326. */
  16327. render(): void;
  16328. /**
  16329. * Checks wether or not the edges renderer is ready to render.
  16330. * @return true if ready, otherwise false.
  16331. */
  16332. isReady(): boolean;
  16333. }
  16334. /**
  16335. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16336. */
  16337. export class EdgesRenderer implements IEdgesRenderer {
  16338. /**
  16339. * Define the size of the edges with an orthographic camera
  16340. */
  16341. edgesWidthScalerForOrthographic: number;
  16342. /**
  16343. * Define the size of the edges with a perspective camera
  16344. */
  16345. edgesWidthScalerForPerspective: number;
  16346. protected _source: AbstractMesh;
  16347. protected _linesPositions: number[];
  16348. protected _linesNormals: number[];
  16349. protected _linesIndices: number[];
  16350. protected _epsilon: number;
  16351. protected _indicesCount: number;
  16352. protected _lineShader: ShaderMaterial;
  16353. protected _ib: DataBuffer;
  16354. protected _buffers: {
  16355. [key: string]: Nullable<VertexBuffer>;
  16356. };
  16357. protected _checkVerticesInsteadOfIndices: boolean;
  16358. private _meshRebuildObserver;
  16359. private _meshDisposeObserver;
  16360. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16361. isEnabled: boolean;
  16362. /**
  16363. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16364. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16365. * @param source Mesh used to create edges
  16366. * @param epsilon sum of angles in adjacency to check for edge
  16367. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16368. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16369. */
  16370. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16371. protected _prepareRessources(): void;
  16372. /** @hidden */
  16373. _rebuild(): void;
  16374. /**
  16375. * Releases the required resources for the edges renderer
  16376. */
  16377. dispose(): void;
  16378. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16379. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16380. /**
  16381. * Checks if the pair of p0 and p1 is en edge
  16382. * @param faceIndex
  16383. * @param edge
  16384. * @param faceNormals
  16385. * @param p0
  16386. * @param p1
  16387. * @private
  16388. */
  16389. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16390. /**
  16391. * push line into the position, normal and index buffer
  16392. * @protected
  16393. */
  16394. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16395. /**
  16396. * Generates lines edges from adjacencjes
  16397. * @private
  16398. */
  16399. _generateEdgesLines(): void;
  16400. /**
  16401. * Checks wether or not the edges renderer is ready to render.
  16402. * @return true if ready, otherwise false.
  16403. */
  16404. isReady(): boolean;
  16405. /**
  16406. * Renders the edges of the attached mesh,
  16407. */
  16408. render(): void;
  16409. }
  16410. /**
  16411. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16412. */
  16413. export class LineEdgesRenderer extends EdgesRenderer {
  16414. /**
  16415. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16416. * @param source LineMesh used to generate edges
  16417. * @param epsilon not important (specified angle for edge detection)
  16418. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16419. */
  16420. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16421. /**
  16422. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16423. */
  16424. _generateEdgesLines(): void;
  16425. }
  16426. }
  16427. declare module "babylonjs/Rendering/renderingGroup" {
  16428. import { SmartArray } from "babylonjs/Misc/smartArray";
  16429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16431. import { Nullable } from "babylonjs/types";
  16432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16433. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16434. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16435. import { Material } from "babylonjs/Materials/material";
  16436. import { Scene } from "babylonjs/scene";
  16437. /**
  16438. * This represents the object necessary to create a rendering group.
  16439. * This is exclusively used and created by the rendering manager.
  16440. * To modify the behavior, you use the available helpers in your scene or meshes.
  16441. * @hidden
  16442. */
  16443. export class RenderingGroup {
  16444. index: number;
  16445. private static _zeroVector;
  16446. private _scene;
  16447. private _opaqueSubMeshes;
  16448. private _transparentSubMeshes;
  16449. private _alphaTestSubMeshes;
  16450. private _depthOnlySubMeshes;
  16451. private _particleSystems;
  16452. private _spriteManagers;
  16453. private _opaqueSortCompareFn;
  16454. private _alphaTestSortCompareFn;
  16455. private _transparentSortCompareFn;
  16456. private _renderOpaque;
  16457. private _renderAlphaTest;
  16458. private _renderTransparent;
  16459. /** @hidden */
  16460. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16461. onBeforeTransparentRendering: () => void;
  16462. /**
  16463. * Set the opaque sort comparison function.
  16464. * If null the sub meshes will be render in the order they were created
  16465. */
  16466. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16467. /**
  16468. * Set the alpha test sort comparison function.
  16469. * If null the sub meshes will be render in the order they were created
  16470. */
  16471. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16472. /**
  16473. * Set the transparent sort comparison function.
  16474. * If null the sub meshes will be render in the order they were created
  16475. */
  16476. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16477. /**
  16478. * Creates a new rendering group.
  16479. * @param index The rendering group index
  16480. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16481. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16482. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16483. */
  16484. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16485. /**
  16486. * Render all the sub meshes contained in the group.
  16487. * @param customRenderFunction Used to override the default render behaviour of the group.
  16488. * @returns true if rendered some submeshes.
  16489. */
  16490. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16491. /**
  16492. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16493. * @param subMeshes The submeshes to render
  16494. */
  16495. private renderOpaqueSorted;
  16496. /**
  16497. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16498. * @param subMeshes The submeshes to render
  16499. */
  16500. private renderAlphaTestSorted;
  16501. /**
  16502. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16503. * @param subMeshes The submeshes to render
  16504. */
  16505. private renderTransparentSorted;
  16506. /**
  16507. * Renders the submeshes in a specified order.
  16508. * @param subMeshes The submeshes to sort before render
  16509. * @param sortCompareFn The comparison function use to sort
  16510. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16511. * @param transparent Specifies to activate blending if true
  16512. */
  16513. private static renderSorted;
  16514. /**
  16515. * Renders the submeshes in the order they were dispatched (no sort applied).
  16516. * @param subMeshes The submeshes to render
  16517. */
  16518. private static renderUnsorted;
  16519. /**
  16520. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16521. * are rendered back to front if in the same alpha index.
  16522. *
  16523. * @param a The first submesh
  16524. * @param b The second submesh
  16525. * @returns The result of the comparison
  16526. */
  16527. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16528. /**
  16529. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16530. * are rendered back to front.
  16531. *
  16532. * @param a The first submesh
  16533. * @param b The second submesh
  16534. * @returns The result of the comparison
  16535. */
  16536. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16537. /**
  16538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16539. * are rendered front to back (prevent overdraw).
  16540. *
  16541. * @param a The first submesh
  16542. * @param b The second submesh
  16543. * @returns The result of the comparison
  16544. */
  16545. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16546. /**
  16547. * Resets the different lists of submeshes to prepare a new frame.
  16548. */
  16549. prepare(): void;
  16550. dispose(): void;
  16551. /**
  16552. * Inserts the submesh in its correct queue depending on its material.
  16553. * @param subMesh The submesh to dispatch
  16554. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16555. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16556. */
  16557. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16558. dispatchSprites(spriteManager: ISpriteManager): void;
  16559. dispatchParticles(particleSystem: IParticleSystem): void;
  16560. private _renderParticles;
  16561. private _renderSprites;
  16562. }
  16563. }
  16564. declare module "babylonjs/Rendering/renderingManager" {
  16565. import { Nullable } from "babylonjs/types";
  16566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16568. import { SmartArray } from "babylonjs/Misc/smartArray";
  16569. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16570. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16571. import { Material } from "babylonjs/Materials/material";
  16572. import { Scene } from "babylonjs/scene";
  16573. import { Camera } from "babylonjs/Cameras/camera";
  16574. /**
  16575. * Interface describing the different options available in the rendering manager
  16576. * regarding Auto Clear between groups.
  16577. */
  16578. export interface IRenderingManagerAutoClearSetup {
  16579. /**
  16580. * Defines whether or not autoclear is enable.
  16581. */
  16582. autoClear: boolean;
  16583. /**
  16584. * Defines whether or not to autoclear the depth buffer.
  16585. */
  16586. depth: boolean;
  16587. /**
  16588. * Defines whether or not to autoclear the stencil buffer.
  16589. */
  16590. stencil: boolean;
  16591. }
  16592. /**
  16593. * This class is used by the onRenderingGroupObservable
  16594. */
  16595. export class RenderingGroupInfo {
  16596. /**
  16597. * The Scene that being rendered
  16598. */
  16599. scene: Scene;
  16600. /**
  16601. * The camera currently used for the rendering pass
  16602. */
  16603. camera: Nullable<Camera>;
  16604. /**
  16605. * The ID of the renderingGroup being processed
  16606. */
  16607. renderingGroupId: number;
  16608. }
  16609. /**
  16610. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16611. * It is enable to manage the different groups as well as the different necessary sort functions.
  16612. * This should not be used directly aside of the few static configurations
  16613. */
  16614. export class RenderingManager {
  16615. /**
  16616. * The max id used for rendering groups (not included)
  16617. */
  16618. static MAX_RENDERINGGROUPS: number;
  16619. /**
  16620. * The min id used for rendering groups (included)
  16621. */
  16622. static MIN_RENDERINGGROUPS: number;
  16623. /**
  16624. * Used to globally prevent autoclearing scenes.
  16625. */
  16626. static AUTOCLEAR: boolean;
  16627. /**
  16628. * @hidden
  16629. */
  16630. _useSceneAutoClearSetup: boolean;
  16631. private _scene;
  16632. private _renderingGroups;
  16633. private _depthStencilBufferAlreadyCleaned;
  16634. private _autoClearDepthStencil;
  16635. private _customOpaqueSortCompareFn;
  16636. private _customAlphaTestSortCompareFn;
  16637. private _customTransparentSortCompareFn;
  16638. private _renderingGroupInfo;
  16639. /**
  16640. * Instantiates a new rendering group for a particular scene
  16641. * @param scene Defines the scene the groups belongs to
  16642. */
  16643. constructor(scene: Scene);
  16644. private _clearDepthStencilBuffer;
  16645. /**
  16646. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16647. * @hidden
  16648. */
  16649. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16650. /**
  16651. * Resets the different information of the group to prepare a new frame
  16652. * @hidden
  16653. */
  16654. reset(): void;
  16655. /**
  16656. * Dispose and release the group and its associated resources.
  16657. * @hidden
  16658. */
  16659. dispose(): void;
  16660. /**
  16661. * Clear the info related to rendering groups preventing retention points during dispose.
  16662. */
  16663. freeRenderingGroups(): void;
  16664. private _prepareRenderingGroup;
  16665. /**
  16666. * Add a sprite manager to the rendering manager in order to render it this frame.
  16667. * @param spriteManager Define the sprite manager to render
  16668. */
  16669. dispatchSprites(spriteManager: ISpriteManager): void;
  16670. /**
  16671. * Add a particle system to the rendering manager in order to render it this frame.
  16672. * @param particleSystem Define the particle system to render
  16673. */
  16674. dispatchParticles(particleSystem: IParticleSystem): void;
  16675. /**
  16676. * Add a submesh to the manager in order to render it this frame
  16677. * @param subMesh The submesh to dispatch
  16678. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16679. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16680. */
  16681. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16682. /**
  16683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16684. * This allowed control for front to back rendering or reversly depending of the special needs.
  16685. *
  16686. * @param renderingGroupId The rendering group id corresponding to its index
  16687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16690. */
  16691. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16692. /**
  16693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16694. *
  16695. * @param renderingGroupId The rendering group id corresponding to its index
  16696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16697. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16698. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16699. */
  16700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16701. /**
  16702. * Gets the current auto clear configuration for one rendering group of the rendering
  16703. * manager.
  16704. * @param index the rendering group index to get the information for
  16705. * @returns The auto clear setup for the requested rendering group
  16706. */
  16707. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16708. }
  16709. }
  16710. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16711. import { SmartArray } from "babylonjs/Misc/smartArray";
  16712. import { Nullable } from "babylonjs/types";
  16713. import { Scene } from "babylonjs/scene";
  16714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16717. import { Mesh } from "babylonjs/Meshes/mesh";
  16718. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16719. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16720. import { Effect } from "babylonjs/Materials/effect";
  16721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16723. import "babylonjs/Shaders/shadowMap.fragment";
  16724. import "babylonjs/Shaders/shadowMap.vertex";
  16725. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16726. import { Observable } from "babylonjs/Misc/observable";
  16727. /**
  16728. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16729. */
  16730. export interface ICustomShaderOptions {
  16731. /**
  16732. * Gets or sets the custom shader name to use
  16733. */
  16734. shaderName: string;
  16735. /**
  16736. * The list of attribute names used in the shader
  16737. */
  16738. attributes?: string[];
  16739. /**
  16740. * The list of unifrom names used in the shader
  16741. */
  16742. uniforms?: string[];
  16743. /**
  16744. * The list of sampler names used in the shader
  16745. */
  16746. samplers?: string[];
  16747. /**
  16748. * The list of defines used in the shader
  16749. */
  16750. defines?: string[];
  16751. }
  16752. /**
  16753. * Interface to implement to create a shadow generator compatible with BJS.
  16754. */
  16755. export interface IShadowGenerator {
  16756. /**
  16757. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16758. * @returns The render target texture if present otherwise, null
  16759. */
  16760. getShadowMap(): Nullable<RenderTargetTexture>;
  16761. /**
  16762. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16763. * @param subMesh The submesh we want to render in the shadow map
  16764. * @param useInstances Defines wether will draw in the map using instances
  16765. * @returns true if ready otherwise, false
  16766. */
  16767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16768. /**
  16769. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16770. * @param defines Defines of the material we want to update
  16771. * @param lightIndex Index of the light in the enabled light list of the material
  16772. */
  16773. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16774. /**
  16775. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16776. * defined in the generator but impacting the effect).
  16777. * It implies the unifroms available on the materials are the standard BJS ones.
  16778. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16779. * @param effect The effect we are binfing the information for
  16780. */
  16781. bindShadowLight(lightIndex: string, effect: Effect): void;
  16782. /**
  16783. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16784. * (eq to shadow prjection matrix * light transform matrix)
  16785. * @returns The transform matrix used to create the shadow map
  16786. */
  16787. getTransformMatrix(): Matrix;
  16788. /**
  16789. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16790. * Cube and 2D textures for instance.
  16791. */
  16792. recreateShadowMap(): void;
  16793. /**
  16794. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16795. * @param onCompiled Callback triggered at the and of the effects compilation
  16796. * @param options Sets of optional options forcing the compilation with different modes
  16797. */
  16798. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16799. useInstances: boolean;
  16800. }>): void;
  16801. /**
  16802. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16803. * @param options Sets of optional options forcing the compilation with different modes
  16804. * @returns A promise that resolves when the compilation completes
  16805. */
  16806. forceCompilationAsync(options?: Partial<{
  16807. useInstances: boolean;
  16808. }>): Promise<void>;
  16809. /**
  16810. * Serializes the shadow generator setup to a json object.
  16811. * @returns The serialized JSON object
  16812. */
  16813. serialize(): any;
  16814. /**
  16815. * Disposes the Shadow map and related Textures and effects.
  16816. */
  16817. dispose(): void;
  16818. }
  16819. /**
  16820. * Default implementation IShadowGenerator.
  16821. * This is the main object responsible of generating shadows in the framework.
  16822. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16823. */
  16824. export class ShadowGenerator implements IShadowGenerator {
  16825. /**
  16826. * Name of the shadow generator class
  16827. */
  16828. static CLASSNAME: string;
  16829. /**
  16830. * Shadow generator mode None: no filtering applied.
  16831. */
  16832. static readonly FILTER_NONE: number;
  16833. /**
  16834. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16836. */
  16837. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16838. /**
  16839. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16840. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16841. */
  16842. static readonly FILTER_POISSONSAMPLING: number;
  16843. /**
  16844. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16846. */
  16847. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16848. /**
  16849. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16850. * edge artifacts on steep falloff.
  16851. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16852. */
  16853. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16854. /**
  16855. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16856. * edge artifacts on steep falloff.
  16857. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16858. */
  16859. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16860. /**
  16861. * Shadow generator mode PCF: Percentage Closer Filtering
  16862. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16863. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16864. */
  16865. static readonly FILTER_PCF: number;
  16866. /**
  16867. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16868. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16869. * Contact Hardening
  16870. */
  16871. static readonly FILTER_PCSS: number;
  16872. /**
  16873. * Reserved for PCF and PCSS
  16874. * Highest Quality.
  16875. *
  16876. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16877. *
  16878. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16879. */
  16880. static readonly QUALITY_HIGH: number;
  16881. /**
  16882. * Reserved for PCF and PCSS
  16883. * Good tradeoff for quality/perf cross devices
  16884. *
  16885. * Execute PCF on a 3*3 kernel.
  16886. *
  16887. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16888. */
  16889. static readonly QUALITY_MEDIUM: number;
  16890. /**
  16891. * Reserved for PCF and PCSS
  16892. * The lowest quality but the fastest.
  16893. *
  16894. * Execute PCF on a 1*1 kernel.
  16895. *
  16896. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16897. */
  16898. static readonly QUALITY_LOW: number;
  16899. /** Gets or sets the custom shader name to use */
  16900. customShaderOptions: ICustomShaderOptions;
  16901. /**
  16902. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16903. */
  16904. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16905. /**
  16906. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16907. */
  16908. onAfterShadowMapRenderObservable: Observable<Effect>;
  16909. /**
  16910. * Observable triggered before a mesh is rendered in the shadow map.
  16911. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16912. */
  16913. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16914. /**
  16915. * Observable triggered after a mesh is rendered in the shadow map.
  16916. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16917. */
  16918. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16919. protected _bias: number;
  16920. /**
  16921. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16922. */
  16923. get bias(): number;
  16924. /**
  16925. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16926. */
  16927. set bias(bias: number);
  16928. protected _normalBias: number;
  16929. /**
  16930. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16931. */
  16932. get normalBias(): number;
  16933. /**
  16934. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16935. */
  16936. set normalBias(normalBias: number);
  16937. protected _blurBoxOffset: number;
  16938. /**
  16939. * Gets the blur box offset: offset applied during the blur pass.
  16940. * Only useful if useKernelBlur = false
  16941. */
  16942. get blurBoxOffset(): number;
  16943. /**
  16944. * Sets the blur box offset: offset applied during the blur pass.
  16945. * Only useful if useKernelBlur = false
  16946. */
  16947. set blurBoxOffset(value: number);
  16948. protected _blurScale: number;
  16949. /**
  16950. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16951. * 2 means half of the size.
  16952. */
  16953. get blurScale(): number;
  16954. /**
  16955. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16956. * 2 means half of the size.
  16957. */
  16958. set blurScale(value: number);
  16959. protected _blurKernel: number;
  16960. /**
  16961. * Gets the blur kernel: kernel size of the blur pass.
  16962. * Only useful if useKernelBlur = true
  16963. */
  16964. get blurKernel(): number;
  16965. /**
  16966. * Sets the blur kernel: kernel size of the blur pass.
  16967. * Only useful if useKernelBlur = true
  16968. */
  16969. set blurKernel(value: number);
  16970. protected _useKernelBlur: boolean;
  16971. /**
  16972. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16973. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16974. */
  16975. get useKernelBlur(): boolean;
  16976. /**
  16977. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16978. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16979. */
  16980. set useKernelBlur(value: boolean);
  16981. protected _depthScale: number;
  16982. /**
  16983. * Gets the depth scale used in ESM mode.
  16984. */
  16985. get depthScale(): number;
  16986. /**
  16987. * Sets the depth scale used in ESM mode.
  16988. * This can override the scale stored on the light.
  16989. */
  16990. set depthScale(value: number);
  16991. protected _validateFilter(filter: number): number;
  16992. protected _filter: number;
  16993. /**
  16994. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16995. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16996. */
  16997. get filter(): number;
  16998. /**
  16999. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17000. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17001. */
  17002. set filter(value: number);
  17003. /**
  17004. * Gets if the current filter is set to Poisson Sampling.
  17005. */
  17006. get usePoissonSampling(): boolean;
  17007. /**
  17008. * Sets the current filter to Poisson Sampling.
  17009. */
  17010. set usePoissonSampling(value: boolean);
  17011. /**
  17012. * Gets if the current filter is set to ESM.
  17013. */
  17014. get useExponentialShadowMap(): boolean;
  17015. /**
  17016. * Sets the current filter is to ESM.
  17017. */
  17018. set useExponentialShadowMap(value: boolean);
  17019. /**
  17020. * Gets if the current filter is set to filtered ESM.
  17021. */
  17022. get useBlurExponentialShadowMap(): boolean;
  17023. /**
  17024. * Gets if the current filter is set to filtered ESM.
  17025. */
  17026. set useBlurExponentialShadowMap(value: boolean);
  17027. /**
  17028. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17029. * exponential to prevent steep falloff artifacts).
  17030. */
  17031. get useCloseExponentialShadowMap(): boolean;
  17032. /**
  17033. * Sets the current filter to "close ESM" (using the inverse of the
  17034. * exponential to prevent steep falloff artifacts).
  17035. */
  17036. set useCloseExponentialShadowMap(value: boolean);
  17037. /**
  17038. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17039. * exponential to prevent steep falloff artifacts).
  17040. */
  17041. get useBlurCloseExponentialShadowMap(): boolean;
  17042. /**
  17043. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17044. * exponential to prevent steep falloff artifacts).
  17045. */
  17046. set useBlurCloseExponentialShadowMap(value: boolean);
  17047. /**
  17048. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17049. */
  17050. get usePercentageCloserFiltering(): boolean;
  17051. /**
  17052. * Sets the current filter to "PCF" (percentage closer filtering).
  17053. */
  17054. set usePercentageCloserFiltering(value: boolean);
  17055. protected _filteringQuality: number;
  17056. /**
  17057. * Gets the PCF or PCSS Quality.
  17058. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17059. */
  17060. get filteringQuality(): number;
  17061. /**
  17062. * Sets the PCF or PCSS Quality.
  17063. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17064. */
  17065. set filteringQuality(filteringQuality: number);
  17066. /**
  17067. * Gets if the current filter is set to "PCSS" (contact hardening).
  17068. */
  17069. get useContactHardeningShadow(): boolean;
  17070. /**
  17071. * Sets the current filter to "PCSS" (contact hardening).
  17072. */
  17073. set useContactHardeningShadow(value: boolean);
  17074. protected _contactHardeningLightSizeUVRatio: number;
  17075. /**
  17076. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17077. * Using a ratio helps keeping shape stability independently of the map size.
  17078. *
  17079. * It does not account for the light projection as it was having too much
  17080. * instability during the light setup or during light position changes.
  17081. *
  17082. * Only valid if useContactHardeningShadow is true.
  17083. */
  17084. get contactHardeningLightSizeUVRatio(): number;
  17085. /**
  17086. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17087. * Using a ratio helps keeping shape stability independently of the map size.
  17088. *
  17089. * It does not account for the light projection as it was having too much
  17090. * instability during the light setup or during light position changes.
  17091. *
  17092. * Only valid if useContactHardeningShadow is true.
  17093. */
  17094. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17095. protected _darkness: number;
  17096. /** Gets or sets the actual darkness of a shadow */
  17097. get darkness(): number;
  17098. set darkness(value: number);
  17099. /**
  17100. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17101. * 0 means strongest and 1 would means no shadow.
  17102. * @returns the darkness.
  17103. */
  17104. getDarkness(): number;
  17105. /**
  17106. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17107. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17108. * @returns the shadow generator allowing fluent coding.
  17109. */
  17110. setDarkness(darkness: number): ShadowGenerator;
  17111. protected _transparencyShadow: boolean;
  17112. /** Gets or sets the ability to have transparent shadow */
  17113. get transparencyShadow(): boolean;
  17114. set transparencyShadow(value: boolean);
  17115. /**
  17116. * Sets the ability to have transparent shadow (boolean).
  17117. * @param transparent True if transparent else False
  17118. * @returns the shadow generator allowing fluent coding
  17119. */
  17120. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17121. protected _shadowMap: Nullable<RenderTargetTexture>;
  17122. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17123. /**
  17124. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17125. * @returns The render target texture if present otherwise, null
  17126. */
  17127. getShadowMap(): Nullable<RenderTargetTexture>;
  17128. /**
  17129. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17130. * @returns The render target texture if the shadow map is present otherwise, null
  17131. */
  17132. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17133. /**
  17134. * Gets the class name of that object
  17135. * @returns "ShadowGenerator"
  17136. */
  17137. getClassName(): string;
  17138. /**
  17139. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17140. * @param mesh Mesh to add
  17141. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17142. * @returns the Shadow Generator itself
  17143. */
  17144. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17145. /**
  17146. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17147. * @param mesh Mesh to remove
  17148. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17149. * @returns the Shadow Generator itself
  17150. */
  17151. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17152. /**
  17153. * Controls the extent to which the shadows fade out at the edge of the frustum
  17154. */
  17155. frustumEdgeFalloff: number;
  17156. protected _light: IShadowLight;
  17157. /**
  17158. * Returns the associated light object.
  17159. * @returns the light generating the shadow
  17160. */
  17161. getLight(): IShadowLight;
  17162. /**
  17163. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17164. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17165. * It might on the other hand introduce peter panning.
  17166. */
  17167. forceBackFacesOnly: boolean;
  17168. protected _scene: Scene;
  17169. protected _lightDirection: Vector3;
  17170. protected _effect: Effect;
  17171. protected _viewMatrix: Matrix;
  17172. protected _projectionMatrix: Matrix;
  17173. protected _transformMatrix: Matrix;
  17174. protected _cachedPosition: Vector3;
  17175. protected _cachedDirection: Vector3;
  17176. protected _cachedDefines: string;
  17177. protected _currentRenderID: number;
  17178. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17179. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17180. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17181. protected _blurPostProcesses: PostProcess[];
  17182. protected _mapSize: number;
  17183. protected _currentFaceIndex: number;
  17184. protected _currentFaceIndexCache: number;
  17185. protected _textureType: number;
  17186. protected _defaultTextureMatrix: Matrix;
  17187. protected _storedUniqueId: Nullable<number>;
  17188. /** @hidden */
  17189. static _SceneComponentInitialization: (scene: Scene) => void;
  17190. /**
  17191. * Creates a ShadowGenerator object.
  17192. * A ShadowGenerator is the required tool to use the shadows.
  17193. * Each light casting shadows needs to use its own ShadowGenerator.
  17194. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17195. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17196. * @param light The light object generating the shadows.
  17197. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17198. */
  17199. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17200. protected _initializeGenerator(): void;
  17201. protected _createTargetRenderTexture(): void;
  17202. protected _initializeShadowMap(): void;
  17203. protected _initializeBlurRTTAndPostProcesses(): void;
  17204. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17205. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17206. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17207. protected _applyFilterValues(): void;
  17208. /**
  17209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17210. * @param onCompiled Callback triggered at the and of the effects compilation
  17211. * @param options Sets of optional options forcing the compilation with different modes
  17212. */
  17213. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17214. useInstances: boolean;
  17215. }>): void;
  17216. /**
  17217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17218. * @param options Sets of optional options forcing the compilation with different modes
  17219. * @returns A promise that resolves when the compilation completes
  17220. */
  17221. forceCompilationAsync(options?: Partial<{
  17222. useInstances: boolean;
  17223. }>): Promise<void>;
  17224. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17225. /**
  17226. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17227. * @param subMesh The submesh we want to render in the shadow map
  17228. * @param useInstances Defines wether will draw in the map using instances
  17229. * @returns true if ready otherwise, false
  17230. */
  17231. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17232. /**
  17233. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17234. * @param defines Defines of the material we want to update
  17235. * @param lightIndex Index of the light in the enabled light list of the material
  17236. */
  17237. prepareDefines(defines: any, lightIndex: number): void;
  17238. /**
  17239. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17240. * defined in the generator but impacting the effect).
  17241. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17242. * @param effect The effect we are binfing the information for
  17243. */
  17244. bindShadowLight(lightIndex: string, effect: Effect): void;
  17245. /**
  17246. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17247. * (eq to shadow prjection matrix * light transform matrix)
  17248. * @returns The transform matrix used to create the shadow map
  17249. */
  17250. getTransformMatrix(): Matrix;
  17251. /**
  17252. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17253. * Cube and 2D textures for instance.
  17254. */
  17255. recreateShadowMap(): void;
  17256. protected _disposeBlurPostProcesses(): void;
  17257. protected _disposeRTTandPostProcesses(): void;
  17258. /**
  17259. * Disposes the ShadowGenerator.
  17260. * Returns nothing.
  17261. */
  17262. dispose(): void;
  17263. /**
  17264. * Serializes the shadow generator setup to a json object.
  17265. * @returns The serialized JSON object
  17266. */
  17267. serialize(): any;
  17268. /**
  17269. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17270. * @param parsedShadowGenerator The JSON object to parse
  17271. * @param scene The scene to create the shadow map for
  17272. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17273. * @returns The parsed shadow generator
  17274. */
  17275. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17276. }
  17277. }
  17278. declare module "babylonjs/Lights/light" {
  17279. import { Nullable } from "babylonjs/types";
  17280. import { Scene } from "babylonjs/scene";
  17281. import { Vector3 } from "babylonjs/Maths/math.vector";
  17282. import { Color3 } from "babylonjs/Maths/math.color";
  17283. import { Node } from "babylonjs/node";
  17284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17285. import { Effect } from "babylonjs/Materials/effect";
  17286. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17287. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17288. /**
  17289. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17290. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17291. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17292. */
  17293. export abstract class Light extends Node {
  17294. /**
  17295. * Falloff Default: light is falling off following the material specification:
  17296. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17297. */
  17298. static readonly FALLOFF_DEFAULT: number;
  17299. /**
  17300. * Falloff Physical: light is falling off following the inverse squared distance law.
  17301. */
  17302. static readonly FALLOFF_PHYSICAL: number;
  17303. /**
  17304. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17305. * to enhance interoperability with other engines.
  17306. */
  17307. static readonly FALLOFF_GLTF: number;
  17308. /**
  17309. * Falloff Standard: light is falling off like in the standard material
  17310. * to enhance interoperability with other materials.
  17311. */
  17312. static readonly FALLOFF_STANDARD: number;
  17313. /**
  17314. * If every light affecting the material is in this lightmapMode,
  17315. * material.lightmapTexture adds or multiplies
  17316. * (depends on material.useLightmapAsShadowmap)
  17317. * after every other light calculations.
  17318. */
  17319. static readonly LIGHTMAP_DEFAULT: number;
  17320. /**
  17321. * material.lightmapTexture as only diffuse lighting from this light
  17322. * adds only specular lighting from this light
  17323. * adds dynamic shadows
  17324. */
  17325. static readonly LIGHTMAP_SPECULAR: number;
  17326. /**
  17327. * material.lightmapTexture as only lighting
  17328. * no light calculation from this light
  17329. * only adds dynamic shadows from this light
  17330. */
  17331. static readonly LIGHTMAP_SHADOWSONLY: number;
  17332. /**
  17333. * Each light type uses the default quantity according to its type:
  17334. * point/spot lights use luminous intensity
  17335. * directional lights use illuminance
  17336. */
  17337. static readonly INTENSITYMODE_AUTOMATIC: number;
  17338. /**
  17339. * lumen (lm)
  17340. */
  17341. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17342. /**
  17343. * candela (lm/sr)
  17344. */
  17345. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17346. /**
  17347. * lux (lm/m^2)
  17348. */
  17349. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17350. /**
  17351. * nit (cd/m^2)
  17352. */
  17353. static readonly INTENSITYMODE_LUMINANCE: number;
  17354. /**
  17355. * Light type const id of the point light.
  17356. */
  17357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17358. /**
  17359. * Light type const id of the directional light.
  17360. */
  17361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17362. /**
  17363. * Light type const id of the spot light.
  17364. */
  17365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17366. /**
  17367. * Light type const id of the hemispheric light.
  17368. */
  17369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17370. /**
  17371. * Diffuse gives the basic color to an object.
  17372. */
  17373. diffuse: Color3;
  17374. /**
  17375. * Specular produces a highlight color on an object.
  17376. * Note: This is note affecting PBR materials.
  17377. */
  17378. specular: Color3;
  17379. /**
  17380. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17381. * falling off base on range or angle.
  17382. * This can be set to any values in Light.FALLOFF_x.
  17383. *
  17384. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17385. * other types of materials.
  17386. */
  17387. falloffType: number;
  17388. /**
  17389. * Strength of the light.
  17390. * Note: By default it is define in the framework own unit.
  17391. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17392. */
  17393. intensity: number;
  17394. private _range;
  17395. protected _inverseSquaredRange: number;
  17396. /**
  17397. * Defines how far from the source the light is impacting in scene units.
  17398. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17399. */
  17400. get range(): number;
  17401. /**
  17402. * Defines how far from the source the light is impacting in scene units.
  17403. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17404. */
  17405. set range(value: number);
  17406. /**
  17407. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17408. * of light.
  17409. */
  17410. private _photometricScale;
  17411. private _intensityMode;
  17412. /**
  17413. * Gets the photometric scale used to interpret the intensity.
  17414. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17415. */
  17416. get intensityMode(): number;
  17417. /**
  17418. * Sets the photometric scale used to interpret the intensity.
  17419. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17420. */
  17421. set intensityMode(value: number);
  17422. private _radius;
  17423. /**
  17424. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17425. */
  17426. get radius(): number;
  17427. /**
  17428. * sets the light radius used by PBR Materials to simulate soft area lights.
  17429. */
  17430. set radius(value: number);
  17431. private _renderPriority;
  17432. /**
  17433. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17434. * exceeding the number allowed of the materials.
  17435. */
  17436. renderPriority: number;
  17437. private _shadowEnabled;
  17438. /**
  17439. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17440. * the current shadow generator.
  17441. */
  17442. get shadowEnabled(): boolean;
  17443. /**
  17444. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17445. * the current shadow generator.
  17446. */
  17447. set shadowEnabled(value: boolean);
  17448. private _includedOnlyMeshes;
  17449. /**
  17450. * Gets the only meshes impacted by this light.
  17451. */
  17452. get includedOnlyMeshes(): AbstractMesh[];
  17453. /**
  17454. * Sets the only meshes impacted by this light.
  17455. */
  17456. set includedOnlyMeshes(value: AbstractMesh[]);
  17457. private _excludedMeshes;
  17458. /**
  17459. * Gets the meshes not impacted by this light.
  17460. */
  17461. get excludedMeshes(): AbstractMesh[];
  17462. /**
  17463. * Sets the meshes not impacted by this light.
  17464. */
  17465. set excludedMeshes(value: AbstractMesh[]);
  17466. private _excludeWithLayerMask;
  17467. /**
  17468. * Gets the layer id use to find what meshes are not impacted by the light.
  17469. * Inactive if 0
  17470. */
  17471. get excludeWithLayerMask(): number;
  17472. /**
  17473. * Sets the layer id use to find what meshes are not impacted by the light.
  17474. * Inactive if 0
  17475. */
  17476. set excludeWithLayerMask(value: number);
  17477. private _includeOnlyWithLayerMask;
  17478. /**
  17479. * Gets the layer id use to find what meshes are impacted by the light.
  17480. * Inactive if 0
  17481. */
  17482. get includeOnlyWithLayerMask(): number;
  17483. /**
  17484. * Sets the layer id use to find what meshes are impacted by the light.
  17485. * Inactive if 0
  17486. */
  17487. set includeOnlyWithLayerMask(value: number);
  17488. private _lightmapMode;
  17489. /**
  17490. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17491. */
  17492. get lightmapMode(): number;
  17493. /**
  17494. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17495. */
  17496. set lightmapMode(value: number);
  17497. /**
  17498. * Shadow generator associted to the light.
  17499. * @hidden Internal use only.
  17500. */
  17501. _shadowGenerator: Nullable<IShadowGenerator>;
  17502. /**
  17503. * @hidden Internal use only.
  17504. */
  17505. _excludedMeshesIds: string[];
  17506. /**
  17507. * @hidden Internal use only.
  17508. */
  17509. _includedOnlyMeshesIds: string[];
  17510. /**
  17511. * The current light unifom buffer.
  17512. * @hidden Internal use only.
  17513. */
  17514. _uniformBuffer: UniformBuffer;
  17515. /** @hidden */
  17516. _renderId: number;
  17517. /**
  17518. * Creates a Light object in the scene.
  17519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17520. * @param name The firendly name of the light
  17521. * @param scene The scene the light belongs too
  17522. */
  17523. constructor(name: string, scene: Scene);
  17524. protected abstract _buildUniformLayout(): void;
  17525. /**
  17526. * Sets the passed Effect "effect" with the Light information.
  17527. * @param effect The effect to update
  17528. * @param lightIndex The index of the light in the effect to update
  17529. * @returns The light
  17530. */
  17531. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17532. /**
  17533. * Sets the passed Effect "effect" with the Light textures.
  17534. * @param effect The effect to update
  17535. * @param lightIndex The index of the light in the effect to update
  17536. * @returns The light
  17537. */
  17538. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17539. /**
  17540. * Binds the lights information from the scene to the effect for the given mesh.
  17541. * @param lightIndex Light index
  17542. * @param scene The scene where the light belongs to
  17543. * @param effect The effect we are binding the data to
  17544. * @param useSpecular Defines if specular is supported
  17545. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17546. */
  17547. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17548. /**
  17549. * Sets the passed Effect "effect" with the Light information.
  17550. * @param effect The effect to update
  17551. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17552. * @returns The light
  17553. */
  17554. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17555. /**
  17556. * Returns the string "Light".
  17557. * @returns the class name
  17558. */
  17559. getClassName(): string;
  17560. /** @hidden */
  17561. readonly _isLight: boolean;
  17562. /**
  17563. * Converts the light information to a readable string for debug purpose.
  17564. * @param fullDetails Supports for multiple levels of logging within scene loading
  17565. * @returns the human readable light info
  17566. */
  17567. toString(fullDetails?: boolean): string;
  17568. /** @hidden */
  17569. protected _syncParentEnabledState(): void;
  17570. /**
  17571. * Set the enabled state of this node.
  17572. * @param value - the new enabled state
  17573. */
  17574. setEnabled(value: boolean): void;
  17575. /**
  17576. * Returns the Light associated shadow generator if any.
  17577. * @return the associated shadow generator.
  17578. */
  17579. getShadowGenerator(): Nullable<IShadowGenerator>;
  17580. /**
  17581. * Returns a Vector3, the absolute light position in the World.
  17582. * @returns the world space position of the light
  17583. */
  17584. getAbsolutePosition(): Vector3;
  17585. /**
  17586. * Specifies if the light will affect the passed mesh.
  17587. * @param mesh The mesh to test against the light
  17588. * @return true the mesh is affected otherwise, false.
  17589. */
  17590. canAffectMesh(mesh: AbstractMesh): boolean;
  17591. /**
  17592. * Sort function to order lights for rendering.
  17593. * @param a First Light object to compare to second.
  17594. * @param b Second Light object to compare first.
  17595. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17596. */
  17597. static CompareLightsPriority(a: Light, b: Light): number;
  17598. /**
  17599. * Releases resources associated with this node.
  17600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17602. */
  17603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17604. /**
  17605. * Returns the light type ID (integer).
  17606. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17607. */
  17608. getTypeID(): number;
  17609. /**
  17610. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17611. * @returns the scaled intensity in intensity mode unit
  17612. */
  17613. getScaledIntensity(): number;
  17614. /**
  17615. * Returns a new Light object, named "name", from the current one.
  17616. * @param name The name of the cloned light
  17617. * @returns the new created light
  17618. */
  17619. clone(name: string): Nullable<Light>;
  17620. /**
  17621. * Serializes the current light into a Serialization object.
  17622. * @returns the serialized object.
  17623. */
  17624. serialize(): any;
  17625. /**
  17626. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17627. * This new light is named "name" and added to the passed scene.
  17628. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17629. * @param name The friendly name of the light
  17630. * @param scene The scene the new light will belong to
  17631. * @returns the constructor function
  17632. */
  17633. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17634. /**
  17635. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17636. * @param parsedLight The JSON representation of the light
  17637. * @param scene The scene to create the parsed light in
  17638. * @returns the created light after parsing
  17639. */
  17640. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17641. private _hookArrayForExcluded;
  17642. private _hookArrayForIncludedOnly;
  17643. private _resyncMeshes;
  17644. /**
  17645. * Forces the meshes to update their light related information in their rendering used effects
  17646. * @hidden Internal Use Only
  17647. */
  17648. _markMeshesAsLightDirty(): void;
  17649. /**
  17650. * Recomputes the cached photometric scale if needed.
  17651. */
  17652. private _computePhotometricScale;
  17653. /**
  17654. * Returns the Photometric Scale according to the light type and intensity mode.
  17655. */
  17656. private _getPhotometricScale;
  17657. /**
  17658. * Reorder the light in the scene according to their defined priority.
  17659. * @hidden Internal Use Only
  17660. */
  17661. _reorderLightsInScene(): void;
  17662. /**
  17663. * Prepares the list of defines specific to the light type.
  17664. * @param defines the list of defines
  17665. * @param lightIndex defines the index of the light for the effect
  17666. */
  17667. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17668. }
  17669. }
  17670. declare module "babylonjs/Actions/action" {
  17671. import { Observable } from "babylonjs/Misc/observable";
  17672. import { Condition } from "babylonjs/Actions/condition";
  17673. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17674. import { ActionManager } from "babylonjs/Actions/actionManager";
  17675. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17676. /**
  17677. * Interface used to define Action
  17678. */
  17679. export interface IAction {
  17680. /**
  17681. * Trigger for the action
  17682. */
  17683. trigger: number;
  17684. /** Options of the trigger */
  17685. triggerOptions: any;
  17686. /**
  17687. * Gets the trigger parameters
  17688. * @returns the trigger parameters
  17689. */
  17690. getTriggerParameter(): any;
  17691. /**
  17692. * Internal only - executes current action event
  17693. * @hidden
  17694. */
  17695. _executeCurrent(evt?: ActionEvent): void;
  17696. /**
  17697. * Serialize placeholder for child classes
  17698. * @param parent of child
  17699. * @returns the serialized object
  17700. */
  17701. serialize(parent: any): any;
  17702. /**
  17703. * Internal only
  17704. * @hidden
  17705. */
  17706. _prepare(): void;
  17707. /**
  17708. * Internal only - manager for action
  17709. * @hidden
  17710. */
  17711. _actionManager: AbstractActionManager;
  17712. /**
  17713. * Adds action to chain of actions, may be a DoNothingAction
  17714. * @param action defines the next action to execute
  17715. * @returns The action passed in
  17716. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17717. */
  17718. then(action: IAction): IAction;
  17719. }
  17720. /**
  17721. * The action to be carried out following a trigger
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17723. */
  17724. export class Action implements IAction {
  17725. /** the trigger, with or without parameters, for the action */
  17726. triggerOptions: any;
  17727. /**
  17728. * Trigger for the action
  17729. */
  17730. trigger: number;
  17731. /**
  17732. * Internal only - manager for action
  17733. * @hidden
  17734. */
  17735. _actionManager: ActionManager;
  17736. private _nextActiveAction;
  17737. private _child;
  17738. private _condition?;
  17739. private _triggerParameter;
  17740. /**
  17741. * An event triggered prior to action being executed.
  17742. */
  17743. onBeforeExecuteObservable: Observable<Action>;
  17744. /**
  17745. * Creates a new Action
  17746. * @param triggerOptions the trigger, with or without parameters, for the action
  17747. * @param condition an optional determinant of action
  17748. */
  17749. constructor(
  17750. /** the trigger, with or without parameters, for the action */
  17751. triggerOptions: any, condition?: Condition);
  17752. /**
  17753. * Internal only
  17754. * @hidden
  17755. */
  17756. _prepare(): void;
  17757. /**
  17758. * Gets the trigger parameters
  17759. * @returns the trigger parameters
  17760. */
  17761. getTriggerParameter(): any;
  17762. /**
  17763. * Internal only - executes current action event
  17764. * @hidden
  17765. */
  17766. _executeCurrent(evt?: ActionEvent): void;
  17767. /**
  17768. * Execute placeholder for child classes
  17769. * @param evt optional action event
  17770. */
  17771. execute(evt?: ActionEvent): void;
  17772. /**
  17773. * Skips to next active action
  17774. */
  17775. skipToNextActiveAction(): void;
  17776. /**
  17777. * Adds action to chain of actions, may be a DoNothingAction
  17778. * @param action defines the next action to execute
  17779. * @returns The action passed in
  17780. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17781. */
  17782. then(action: Action): Action;
  17783. /**
  17784. * Internal only
  17785. * @hidden
  17786. */
  17787. _getProperty(propertyPath: string): string;
  17788. /**
  17789. * Internal only
  17790. * @hidden
  17791. */
  17792. _getEffectiveTarget(target: any, propertyPath: string): any;
  17793. /**
  17794. * Serialize placeholder for child classes
  17795. * @param parent of child
  17796. * @returns the serialized object
  17797. */
  17798. serialize(parent: any): any;
  17799. /**
  17800. * Internal only called by serialize
  17801. * @hidden
  17802. */
  17803. protected _serialize(serializedAction: any, parent?: any): any;
  17804. /**
  17805. * Internal only
  17806. * @hidden
  17807. */
  17808. static _SerializeValueAsString: (value: any) => string;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17814. name: string;
  17815. targetType: string;
  17816. value: string;
  17817. };
  17818. }
  17819. }
  17820. declare module "babylonjs/Actions/condition" {
  17821. import { ActionManager } from "babylonjs/Actions/actionManager";
  17822. /**
  17823. * A Condition applied to an Action
  17824. */
  17825. export class Condition {
  17826. /**
  17827. * Internal only - manager for action
  17828. * @hidden
  17829. */
  17830. _actionManager: ActionManager;
  17831. /**
  17832. * Internal only
  17833. * @hidden
  17834. */
  17835. _evaluationId: number;
  17836. /**
  17837. * Internal only
  17838. * @hidden
  17839. */
  17840. _currentResult: boolean;
  17841. /**
  17842. * Creates a new Condition
  17843. * @param actionManager the manager of the action the condition is applied to
  17844. */
  17845. constructor(actionManager: ActionManager);
  17846. /**
  17847. * Check if the current condition is valid
  17848. * @returns a boolean
  17849. */
  17850. isValid(): boolean;
  17851. /**
  17852. * Internal only
  17853. * @hidden
  17854. */
  17855. _getProperty(propertyPath: string): string;
  17856. /**
  17857. * Internal only
  17858. * @hidden
  17859. */
  17860. _getEffectiveTarget(target: any, propertyPath: string): any;
  17861. /**
  17862. * Serialize placeholder for child classes
  17863. * @returns the serialized object
  17864. */
  17865. serialize(): any;
  17866. /**
  17867. * Internal only
  17868. * @hidden
  17869. */
  17870. protected _serialize(serializedCondition: any): any;
  17871. }
  17872. /**
  17873. * Defines specific conditional operators as extensions of Condition
  17874. */
  17875. export class ValueCondition extends Condition {
  17876. /** path to specify the property of the target the conditional operator uses */
  17877. propertyPath: string;
  17878. /** the value compared by the conditional operator against the current value of the property */
  17879. value: any;
  17880. /** the conditional operator, default ValueCondition.IsEqual */
  17881. operator: number;
  17882. /**
  17883. * Internal only
  17884. * @hidden
  17885. */
  17886. private static _IsEqual;
  17887. /**
  17888. * Internal only
  17889. * @hidden
  17890. */
  17891. private static _IsDifferent;
  17892. /**
  17893. * Internal only
  17894. * @hidden
  17895. */
  17896. private static _IsGreater;
  17897. /**
  17898. * Internal only
  17899. * @hidden
  17900. */
  17901. private static _IsLesser;
  17902. /**
  17903. * returns the number for IsEqual
  17904. */
  17905. static get IsEqual(): number;
  17906. /**
  17907. * Returns the number for IsDifferent
  17908. */
  17909. static get IsDifferent(): number;
  17910. /**
  17911. * Returns the number for IsGreater
  17912. */
  17913. static get IsGreater(): number;
  17914. /**
  17915. * Returns the number for IsLesser
  17916. */
  17917. static get IsLesser(): number;
  17918. /**
  17919. * Internal only The action manager for the condition
  17920. * @hidden
  17921. */
  17922. _actionManager: ActionManager;
  17923. /**
  17924. * Internal only
  17925. * @hidden
  17926. */
  17927. private _target;
  17928. /**
  17929. * Internal only
  17930. * @hidden
  17931. */
  17932. private _effectiveTarget;
  17933. /**
  17934. * Internal only
  17935. * @hidden
  17936. */
  17937. private _property;
  17938. /**
  17939. * Creates a new ValueCondition
  17940. * @param actionManager manager for the action the condition applies to
  17941. * @param target for the action
  17942. * @param propertyPath path to specify the property of the target the conditional operator uses
  17943. * @param value the value compared by the conditional operator against the current value of the property
  17944. * @param operator the conditional operator, default ValueCondition.IsEqual
  17945. */
  17946. constructor(actionManager: ActionManager, target: any,
  17947. /** path to specify the property of the target the conditional operator uses */
  17948. propertyPath: string,
  17949. /** the value compared by the conditional operator against the current value of the property */
  17950. value: any,
  17951. /** the conditional operator, default ValueCondition.IsEqual */
  17952. operator?: number);
  17953. /**
  17954. * Compares the given value with the property value for the specified conditional operator
  17955. * @returns the result of the comparison
  17956. */
  17957. isValid(): boolean;
  17958. /**
  17959. * Serialize the ValueCondition into a JSON compatible object
  17960. * @returns serialization object
  17961. */
  17962. serialize(): any;
  17963. /**
  17964. * Gets the name of the conditional operator for the ValueCondition
  17965. * @param operator the conditional operator
  17966. * @returns the name
  17967. */
  17968. static GetOperatorName(operator: number): string;
  17969. }
  17970. /**
  17971. * Defines a predicate condition as an extension of Condition
  17972. */
  17973. export class PredicateCondition extends Condition {
  17974. /** defines the predicate function used to validate the condition */
  17975. predicate: () => boolean;
  17976. /**
  17977. * Internal only - manager for action
  17978. * @hidden
  17979. */
  17980. _actionManager: ActionManager;
  17981. /**
  17982. * Creates a new PredicateCondition
  17983. * @param actionManager manager for the action the condition applies to
  17984. * @param predicate defines the predicate function used to validate the condition
  17985. */
  17986. constructor(actionManager: ActionManager,
  17987. /** defines the predicate function used to validate the condition */
  17988. predicate: () => boolean);
  17989. /**
  17990. * @returns the validity of the predicate condition
  17991. */
  17992. isValid(): boolean;
  17993. }
  17994. /**
  17995. * Defines a state condition as an extension of Condition
  17996. */
  17997. export class StateCondition extends Condition {
  17998. /** Value to compare with target state */
  17999. value: string;
  18000. /**
  18001. * Internal only - manager for action
  18002. * @hidden
  18003. */
  18004. _actionManager: ActionManager;
  18005. /**
  18006. * Internal only
  18007. * @hidden
  18008. */
  18009. private _target;
  18010. /**
  18011. * Creates a new StateCondition
  18012. * @param actionManager manager for the action the condition applies to
  18013. * @param target of the condition
  18014. * @param value to compare with target state
  18015. */
  18016. constructor(actionManager: ActionManager, target: any,
  18017. /** Value to compare with target state */
  18018. value: string);
  18019. /**
  18020. * Gets a boolean indicating if the current condition is met
  18021. * @returns the validity of the state
  18022. */
  18023. isValid(): boolean;
  18024. /**
  18025. * Serialize the StateCondition into a JSON compatible object
  18026. * @returns serialization object
  18027. */
  18028. serialize(): any;
  18029. }
  18030. }
  18031. declare module "babylonjs/Actions/directActions" {
  18032. import { Action } from "babylonjs/Actions/action";
  18033. import { Condition } from "babylonjs/Actions/condition";
  18034. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18035. /**
  18036. * This defines an action responsible to toggle a boolean once triggered.
  18037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18038. */
  18039. export class SwitchBooleanAction extends Action {
  18040. /**
  18041. * The path to the boolean property in the target object
  18042. */
  18043. propertyPath: string;
  18044. private _target;
  18045. private _effectiveTarget;
  18046. private _property;
  18047. /**
  18048. * Instantiate the action
  18049. * @param triggerOptions defines the trigger options
  18050. * @param target defines the object containing the boolean
  18051. * @param propertyPath defines the path to the boolean property in the target object
  18052. * @param condition defines the trigger related conditions
  18053. */
  18054. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18055. /** @hidden */
  18056. _prepare(): void;
  18057. /**
  18058. * Execute the action toggle the boolean value.
  18059. */
  18060. execute(): void;
  18061. /**
  18062. * Serializes the actions and its related information.
  18063. * @param parent defines the object to serialize in
  18064. * @returns the serialized object
  18065. */
  18066. serialize(parent: any): any;
  18067. }
  18068. /**
  18069. * This defines an action responsible to set a the state field of the target
  18070. * to a desired value once triggered.
  18071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18072. */
  18073. export class SetStateAction extends Action {
  18074. /**
  18075. * The value to store in the state field.
  18076. */
  18077. value: string;
  18078. private _target;
  18079. /**
  18080. * Instantiate the action
  18081. * @param triggerOptions defines the trigger options
  18082. * @param target defines the object containing the state property
  18083. * @param value defines the value to store in the state field
  18084. * @param condition defines the trigger related conditions
  18085. */
  18086. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18087. /**
  18088. * Execute the action and store the value on the target state property.
  18089. */
  18090. execute(): void;
  18091. /**
  18092. * Serializes the actions and its related information.
  18093. * @param parent defines the object to serialize in
  18094. * @returns the serialized object
  18095. */
  18096. serialize(parent: any): any;
  18097. }
  18098. /**
  18099. * This defines an action responsible to set a property of the target
  18100. * to a desired value once triggered.
  18101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18102. */
  18103. export class SetValueAction extends Action {
  18104. /**
  18105. * The path of the property to set in the target.
  18106. */
  18107. propertyPath: string;
  18108. /**
  18109. * The value to set in the property
  18110. */
  18111. value: any;
  18112. private _target;
  18113. private _effectiveTarget;
  18114. private _property;
  18115. /**
  18116. * Instantiate the action
  18117. * @param triggerOptions defines the trigger options
  18118. * @param target defines the object containing the property
  18119. * @param propertyPath defines the path of the property to set in the target
  18120. * @param value defines the value to set in the property
  18121. * @param condition defines the trigger related conditions
  18122. */
  18123. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18124. /** @hidden */
  18125. _prepare(): void;
  18126. /**
  18127. * Execute the action and set the targetted property to the desired value.
  18128. */
  18129. execute(): void;
  18130. /**
  18131. * Serializes the actions and its related information.
  18132. * @param parent defines the object to serialize in
  18133. * @returns the serialized object
  18134. */
  18135. serialize(parent: any): any;
  18136. }
  18137. /**
  18138. * This defines an action responsible to increment the target value
  18139. * to a desired value once triggered.
  18140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18141. */
  18142. export class IncrementValueAction extends Action {
  18143. /**
  18144. * The path of the property to increment in the target.
  18145. */
  18146. propertyPath: string;
  18147. /**
  18148. * The value we should increment the property by.
  18149. */
  18150. value: any;
  18151. private _target;
  18152. private _effectiveTarget;
  18153. private _property;
  18154. /**
  18155. * Instantiate the action
  18156. * @param triggerOptions defines the trigger options
  18157. * @param target defines the object containing the property
  18158. * @param propertyPath defines the path of the property to increment in the target
  18159. * @param value defines the value value we should increment the property by
  18160. * @param condition defines the trigger related conditions
  18161. */
  18162. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18163. /** @hidden */
  18164. _prepare(): void;
  18165. /**
  18166. * Execute the action and increment the target of the value amount.
  18167. */
  18168. execute(): void;
  18169. /**
  18170. * Serializes the actions and its related information.
  18171. * @param parent defines the object to serialize in
  18172. * @returns the serialized object
  18173. */
  18174. serialize(parent: any): any;
  18175. }
  18176. /**
  18177. * This defines an action responsible to start an animation once triggered.
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18179. */
  18180. export class PlayAnimationAction extends Action {
  18181. /**
  18182. * Where the animation should start (animation frame)
  18183. */
  18184. from: number;
  18185. /**
  18186. * Where the animation should stop (animation frame)
  18187. */
  18188. to: number;
  18189. /**
  18190. * Define if the animation should loop or stop after the first play.
  18191. */
  18192. loop?: boolean;
  18193. private _target;
  18194. /**
  18195. * Instantiate the action
  18196. * @param triggerOptions defines the trigger options
  18197. * @param target defines the target animation or animation name
  18198. * @param from defines from where the animation should start (animation frame)
  18199. * @param end defines where the animation should stop (animation frame)
  18200. * @param loop defines if the animation should loop or stop after the first play
  18201. * @param condition defines the trigger related conditions
  18202. */
  18203. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18204. /** @hidden */
  18205. _prepare(): void;
  18206. /**
  18207. * Execute the action and play the animation.
  18208. */
  18209. execute(): void;
  18210. /**
  18211. * Serializes the actions and its related information.
  18212. * @param parent defines the object to serialize in
  18213. * @returns the serialized object
  18214. */
  18215. serialize(parent: any): any;
  18216. }
  18217. /**
  18218. * This defines an action responsible to stop an animation once triggered.
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18220. */
  18221. export class StopAnimationAction extends Action {
  18222. private _target;
  18223. /**
  18224. * Instantiate the action
  18225. * @param triggerOptions defines the trigger options
  18226. * @param target defines the target animation or animation name
  18227. * @param condition defines the trigger related conditions
  18228. */
  18229. constructor(triggerOptions: any, target: any, condition?: Condition);
  18230. /** @hidden */
  18231. _prepare(): void;
  18232. /**
  18233. * Execute the action and stop the animation.
  18234. */
  18235. execute(): void;
  18236. /**
  18237. * Serializes the actions and its related information.
  18238. * @param parent defines the object to serialize in
  18239. * @returns the serialized object
  18240. */
  18241. serialize(parent: any): any;
  18242. }
  18243. /**
  18244. * This defines an action responsible that does nothing once triggered.
  18245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18246. */
  18247. export class DoNothingAction extends Action {
  18248. /**
  18249. * Instantiate the action
  18250. * @param triggerOptions defines the trigger options
  18251. * @param condition defines the trigger related conditions
  18252. */
  18253. constructor(triggerOptions?: any, condition?: Condition);
  18254. /**
  18255. * Execute the action and do nothing.
  18256. */
  18257. execute(): void;
  18258. /**
  18259. * Serializes the actions and its related information.
  18260. * @param parent defines the object to serialize in
  18261. * @returns the serialized object
  18262. */
  18263. serialize(parent: any): any;
  18264. }
  18265. /**
  18266. * This defines an action responsible to trigger several actions once triggered.
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18268. */
  18269. export class CombineAction extends Action {
  18270. /**
  18271. * The list of aggregated animations to run.
  18272. */
  18273. children: Action[];
  18274. /**
  18275. * Instantiate the action
  18276. * @param triggerOptions defines the trigger options
  18277. * @param children defines the list of aggregated animations to run
  18278. * @param condition defines the trigger related conditions
  18279. */
  18280. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18281. /** @hidden */
  18282. _prepare(): void;
  18283. /**
  18284. * Execute the action and executes all the aggregated actions.
  18285. */
  18286. execute(evt: ActionEvent): void;
  18287. /**
  18288. * Serializes the actions and its related information.
  18289. * @param parent defines the object to serialize in
  18290. * @returns the serialized object
  18291. */
  18292. serialize(parent: any): any;
  18293. }
  18294. /**
  18295. * This defines an action responsible to run code (external event) once triggered.
  18296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18297. */
  18298. export class ExecuteCodeAction extends Action {
  18299. /**
  18300. * The callback function to run.
  18301. */
  18302. func: (evt: ActionEvent) => void;
  18303. /**
  18304. * Instantiate the action
  18305. * @param triggerOptions defines the trigger options
  18306. * @param func defines the callback function to run
  18307. * @param condition defines the trigger related conditions
  18308. */
  18309. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18310. /**
  18311. * Execute the action and run the attached code.
  18312. */
  18313. execute(evt: ActionEvent): void;
  18314. }
  18315. /**
  18316. * This defines an action responsible to set the parent property of the target once triggered.
  18317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18318. */
  18319. export class SetParentAction extends Action {
  18320. private _parent;
  18321. private _target;
  18322. /**
  18323. * Instantiate the action
  18324. * @param triggerOptions defines the trigger options
  18325. * @param target defines the target containing the parent property
  18326. * @param parent defines from where the animation should start (animation frame)
  18327. * @param condition defines the trigger related conditions
  18328. */
  18329. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18330. /** @hidden */
  18331. _prepare(): void;
  18332. /**
  18333. * Execute the action and set the parent property.
  18334. */
  18335. execute(): void;
  18336. /**
  18337. * Serializes the actions and its related information.
  18338. * @param parent defines the object to serialize in
  18339. * @returns the serialized object
  18340. */
  18341. serialize(parent: any): any;
  18342. }
  18343. }
  18344. declare module "babylonjs/Actions/actionManager" {
  18345. import { Nullable } from "babylonjs/types";
  18346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18347. import { Scene } from "babylonjs/scene";
  18348. import { IAction } from "babylonjs/Actions/action";
  18349. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18351. /**
  18352. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18353. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18355. */
  18356. export class ActionManager extends AbstractActionManager {
  18357. /**
  18358. * Nothing
  18359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18360. */
  18361. static readonly NothingTrigger: number;
  18362. /**
  18363. * On pick
  18364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18365. */
  18366. static readonly OnPickTrigger: number;
  18367. /**
  18368. * On left pick
  18369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18370. */
  18371. static readonly OnLeftPickTrigger: number;
  18372. /**
  18373. * On right pick
  18374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18375. */
  18376. static readonly OnRightPickTrigger: number;
  18377. /**
  18378. * On center pick
  18379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18380. */
  18381. static readonly OnCenterPickTrigger: number;
  18382. /**
  18383. * On pick down
  18384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18385. */
  18386. static readonly OnPickDownTrigger: number;
  18387. /**
  18388. * On double pick
  18389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18390. */
  18391. static readonly OnDoublePickTrigger: number;
  18392. /**
  18393. * On pick up
  18394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18395. */
  18396. static readonly OnPickUpTrigger: number;
  18397. /**
  18398. * On pick out.
  18399. * This trigger will only be raised if you also declared a OnPickDown
  18400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18401. */
  18402. static readonly OnPickOutTrigger: number;
  18403. /**
  18404. * On long press
  18405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18406. */
  18407. static readonly OnLongPressTrigger: number;
  18408. /**
  18409. * On pointer over
  18410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18411. */
  18412. static readonly OnPointerOverTrigger: number;
  18413. /**
  18414. * On pointer out
  18415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18416. */
  18417. static readonly OnPointerOutTrigger: number;
  18418. /**
  18419. * On every frame
  18420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18421. */
  18422. static readonly OnEveryFrameTrigger: number;
  18423. /**
  18424. * On intersection enter
  18425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18426. */
  18427. static readonly OnIntersectionEnterTrigger: number;
  18428. /**
  18429. * On intersection exit
  18430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18431. */
  18432. static readonly OnIntersectionExitTrigger: number;
  18433. /**
  18434. * On key down
  18435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18436. */
  18437. static readonly OnKeyDownTrigger: number;
  18438. /**
  18439. * On key up
  18440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18441. */
  18442. static readonly OnKeyUpTrigger: number;
  18443. private _scene;
  18444. /**
  18445. * Creates a new action manager
  18446. * @param scene defines the hosting scene
  18447. */
  18448. constructor(scene: Scene);
  18449. /**
  18450. * Releases all associated resources
  18451. */
  18452. dispose(): void;
  18453. /**
  18454. * Gets hosting scene
  18455. * @returns the hosting scene
  18456. */
  18457. getScene(): Scene;
  18458. /**
  18459. * Does this action manager handles actions of any of the given triggers
  18460. * @param triggers defines the triggers to be tested
  18461. * @return a boolean indicating whether one (or more) of the triggers is handled
  18462. */
  18463. hasSpecificTriggers(triggers: number[]): boolean;
  18464. /**
  18465. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18466. * speed.
  18467. * @param triggerA defines the trigger to be tested
  18468. * @param triggerB defines the trigger to be tested
  18469. * @return a boolean indicating whether one (or more) of the triggers is handled
  18470. */
  18471. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18472. /**
  18473. * Does this action manager handles actions of a given trigger
  18474. * @param trigger defines the trigger to be tested
  18475. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18476. * @return whether the trigger is handled
  18477. */
  18478. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18479. /**
  18480. * Does this action manager has pointer triggers
  18481. */
  18482. get hasPointerTriggers(): boolean;
  18483. /**
  18484. * Does this action manager has pick triggers
  18485. */
  18486. get hasPickTriggers(): boolean;
  18487. /**
  18488. * Registers an action to this action manager
  18489. * @param action defines the action to be registered
  18490. * @return the action amended (prepared) after registration
  18491. */
  18492. registerAction(action: IAction): Nullable<IAction>;
  18493. /**
  18494. * Unregisters an action to this action manager
  18495. * @param action defines the action to be unregistered
  18496. * @return a boolean indicating whether the action has been unregistered
  18497. */
  18498. unregisterAction(action: IAction): Boolean;
  18499. /**
  18500. * Process a specific trigger
  18501. * @param trigger defines the trigger to process
  18502. * @param evt defines the event details to be processed
  18503. */
  18504. processTrigger(trigger: number, evt?: IActionEvent): void;
  18505. /** @hidden */
  18506. _getEffectiveTarget(target: any, propertyPath: string): any;
  18507. /** @hidden */
  18508. _getProperty(propertyPath: string): string;
  18509. /**
  18510. * Serialize this manager to a JSON object
  18511. * @param name defines the property name to store this manager
  18512. * @returns a JSON representation of this manager
  18513. */
  18514. serialize(name: string): any;
  18515. /**
  18516. * Creates a new ActionManager from a JSON data
  18517. * @param parsedActions defines the JSON data to read from
  18518. * @param object defines the hosting mesh
  18519. * @param scene defines the hosting scene
  18520. */
  18521. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18522. /**
  18523. * Get a trigger name by index
  18524. * @param trigger defines the trigger index
  18525. * @returns a trigger name
  18526. */
  18527. static GetTriggerName(trigger: number): string;
  18528. }
  18529. }
  18530. declare module "babylonjs/Sprites/sprite" {
  18531. import { Vector3 } from "babylonjs/Maths/math.vector";
  18532. import { Nullable } from "babylonjs/types";
  18533. import { ActionManager } from "babylonjs/Actions/actionManager";
  18534. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18535. import { Color4 } from "babylonjs/Maths/math.color";
  18536. /**
  18537. * Class used to represent a sprite
  18538. * @see http://doc.babylonjs.com/babylon101/sprites
  18539. */
  18540. export class Sprite {
  18541. /** defines the name */
  18542. name: string;
  18543. /** Gets or sets the current world position */
  18544. position: Vector3;
  18545. /** Gets or sets the main color */
  18546. color: Color4;
  18547. /** Gets or sets the width */
  18548. width: number;
  18549. /** Gets or sets the height */
  18550. height: number;
  18551. /** Gets or sets rotation angle */
  18552. angle: number;
  18553. /** Gets or sets the cell index in the sprite sheet */
  18554. cellIndex: number;
  18555. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18556. cellRef: string;
  18557. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18558. invertU: number;
  18559. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18560. invertV: number;
  18561. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18562. disposeWhenFinishedAnimating: boolean;
  18563. /** Gets the list of attached animations */
  18564. animations: Animation[];
  18565. /** Gets or sets a boolean indicating if the sprite can be picked */
  18566. isPickable: boolean;
  18567. /**
  18568. * Gets or sets the associated action manager
  18569. */
  18570. actionManager: Nullable<ActionManager>;
  18571. private _animationStarted;
  18572. private _loopAnimation;
  18573. private _fromIndex;
  18574. private _toIndex;
  18575. private _delay;
  18576. private _direction;
  18577. private _manager;
  18578. private _time;
  18579. private _onAnimationEnd;
  18580. /**
  18581. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18582. */
  18583. isVisible: boolean;
  18584. /**
  18585. * Gets or sets the sprite size
  18586. */
  18587. get size(): number;
  18588. set size(value: number);
  18589. /**
  18590. * Creates a new Sprite
  18591. * @param name defines the name
  18592. * @param manager defines the manager
  18593. */
  18594. constructor(
  18595. /** defines the name */
  18596. name: string, manager: ISpriteManager);
  18597. /**
  18598. * Starts an animation
  18599. * @param from defines the initial key
  18600. * @param to defines the end key
  18601. * @param loop defines if the animation must loop
  18602. * @param delay defines the start delay (in ms)
  18603. * @param onAnimationEnd defines a callback to call when animation ends
  18604. */
  18605. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18606. /** Stops current animation (if any) */
  18607. stopAnimation(): void;
  18608. /** @hidden */
  18609. _animate(deltaTime: number): void;
  18610. /** Release associated resources */
  18611. dispose(): void;
  18612. }
  18613. }
  18614. declare module "babylonjs/Collisions/pickingInfo" {
  18615. import { Nullable } from "babylonjs/types";
  18616. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18618. import { Sprite } from "babylonjs/Sprites/sprite";
  18619. import { Ray } from "babylonjs/Culling/ray";
  18620. /**
  18621. * Information about the result of picking within a scene
  18622. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18623. */
  18624. export class PickingInfo {
  18625. /** @hidden */
  18626. _pickingUnavailable: boolean;
  18627. /**
  18628. * If the pick collided with an object
  18629. */
  18630. hit: boolean;
  18631. /**
  18632. * Distance away where the pick collided
  18633. */
  18634. distance: number;
  18635. /**
  18636. * The location of pick collision
  18637. */
  18638. pickedPoint: Nullable<Vector3>;
  18639. /**
  18640. * The mesh corresponding the the pick collision
  18641. */
  18642. pickedMesh: Nullable<AbstractMesh>;
  18643. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18644. bu: number;
  18645. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18646. bv: number;
  18647. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18648. faceId: number;
  18649. /** Id of the the submesh that was picked */
  18650. subMeshId: number;
  18651. /** If a sprite was picked, this will be the sprite the pick collided with */
  18652. pickedSprite: Nullable<Sprite>;
  18653. /**
  18654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18655. */
  18656. originMesh: Nullable<AbstractMesh>;
  18657. /**
  18658. * The ray that was used to perform the picking.
  18659. */
  18660. ray: Nullable<Ray>;
  18661. /**
  18662. * Gets the normal correspodning to the face the pick collided with
  18663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18665. * @returns The normal correspodning to the face the pick collided with
  18666. */
  18667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18668. /**
  18669. * Gets the texture coordinates of where the pick occured
  18670. * @returns the vector containing the coordnates of the texture
  18671. */
  18672. getTextureCoordinates(): Nullable<Vector2>;
  18673. }
  18674. }
  18675. declare module "babylonjs/Events/pointerEvents" {
  18676. import { Nullable } from "babylonjs/types";
  18677. import { Vector2 } from "babylonjs/Maths/math.vector";
  18678. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18679. import { Ray } from "babylonjs/Culling/ray";
  18680. /**
  18681. * Gather the list of pointer event types as constants.
  18682. */
  18683. export class PointerEventTypes {
  18684. /**
  18685. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18686. */
  18687. static readonly POINTERDOWN: number;
  18688. /**
  18689. * The pointerup event is fired when a pointer is no longer active.
  18690. */
  18691. static readonly POINTERUP: number;
  18692. /**
  18693. * The pointermove event is fired when a pointer changes coordinates.
  18694. */
  18695. static readonly POINTERMOVE: number;
  18696. /**
  18697. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18698. */
  18699. static readonly POINTERWHEEL: number;
  18700. /**
  18701. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18702. */
  18703. static readonly POINTERPICK: number;
  18704. /**
  18705. * The pointertap event is fired when a the object has been touched and released without drag.
  18706. */
  18707. static readonly POINTERTAP: number;
  18708. /**
  18709. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18710. */
  18711. static readonly POINTERDOUBLETAP: number;
  18712. }
  18713. /**
  18714. * Base class of pointer info types.
  18715. */
  18716. export class PointerInfoBase {
  18717. /**
  18718. * Defines the type of event (PointerEventTypes)
  18719. */
  18720. type: number;
  18721. /**
  18722. * Defines the related dom event
  18723. */
  18724. event: PointerEvent | MouseWheelEvent;
  18725. /**
  18726. * Instantiates the base class of pointers info.
  18727. * @param type Defines the type of event (PointerEventTypes)
  18728. * @param event Defines the related dom event
  18729. */
  18730. constructor(
  18731. /**
  18732. * Defines the type of event (PointerEventTypes)
  18733. */
  18734. type: number,
  18735. /**
  18736. * Defines the related dom event
  18737. */
  18738. event: PointerEvent | MouseWheelEvent);
  18739. }
  18740. /**
  18741. * This class is used to store pointer related info for the onPrePointerObservable event.
  18742. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18743. */
  18744. export class PointerInfoPre extends PointerInfoBase {
  18745. /**
  18746. * Ray from a pointer if availible (eg. 6dof controller)
  18747. */
  18748. ray: Nullable<Ray>;
  18749. /**
  18750. * Defines the local position of the pointer on the canvas.
  18751. */
  18752. localPosition: Vector2;
  18753. /**
  18754. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18755. */
  18756. skipOnPointerObservable: boolean;
  18757. /**
  18758. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18759. * @param type Defines the type of event (PointerEventTypes)
  18760. * @param event Defines the related dom event
  18761. * @param localX Defines the local x coordinates of the pointer when the event occured
  18762. * @param localY Defines the local y coordinates of the pointer when the event occured
  18763. */
  18764. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18765. }
  18766. /**
  18767. * This type contains all the data related to a pointer event in Babylon.js.
  18768. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18769. */
  18770. export class PointerInfo extends PointerInfoBase {
  18771. /**
  18772. * Defines the picking info associated to the info (if any)\
  18773. */
  18774. pickInfo: Nullable<PickingInfo>;
  18775. /**
  18776. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18777. * @param type Defines the type of event (PointerEventTypes)
  18778. * @param event Defines the related dom event
  18779. * @param pickInfo Defines the picking info associated to the info (if any)\
  18780. */
  18781. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18782. /**
  18783. * Defines the picking info associated to the info (if any)\
  18784. */
  18785. pickInfo: Nullable<PickingInfo>);
  18786. }
  18787. /**
  18788. * Data relating to a touch event on the screen.
  18789. */
  18790. export interface PointerTouch {
  18791. /**
  18792. * X coordinate of touch.
  18793. */
  18794. x: number;
  18795. /**
  18796. * Y coordinate of touch.
  18797. */
  18798. y: number;
  18799. /**
  18800. * Id of touch. Unique for each finger.
  18801. */
  18802. pointerId: number;
  18803. /**
  18804. * Event type passed from DOM.
  18805. */
  18806. type: any;
  18807. }
  18808. }
  18809. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18810. import { Observable } from "babylonjs/Misc/observable";
  18811. import { Nullable } from "babylonjs/types";
  18812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18814. /**
  18815. * Manage the mouse inputs to control the movement of a free camera.
  18816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18817. */
  18818. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18819. /**
  18820. * Define if touch is enabled in the mouse input
  18821. */
  18822. touchEnabled: boolean;
  18823. /**
  18824. * Defines the camera the input is attached to.
  18825. */
  18826. camera: FreeCamera;
  18827. /**
  18828. * Defines the buttons associated with the input to handle camera move.
  18829. */
  18830. buttons: number[];
  18831. /**
  18832. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18833. */
  18834. angularSensibility: number;
  18835. private _pointerInput;
  18836. private _onMouseMove;
  18837. private _observer;
  18838. private previousPosition;
  18839. /**
  18840. * Observable for when a pointer move event occurs containing the move offset
  18841. */
  18842. onPointerMovedObservable: Observable<{
  18843. offsetX: number;
  18844. offsetY: number;
  18845. }>;
  18846. /**
  18847. * @hidden
  18848. * If the camera should be rotated automatically based on pointer movement
  18849. */
  18850. _allowCameraRotation: boolean;
  18851. /**
  18852. * Manage the mouse inputs to control the movement of a free camera.
  18853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18854. * @param touchEnabled Defines if touch is enabled or not
  18855. */
  18856. constructor(
  18857. /**
  18858. * Define if touch is enabled in the mouse input
  18859. */
  18860. touchEnabled?: boolean);
  18861. /**
  18862. * Attach the input controls to a specific dom element to get the input from.
  18863. * @param element Defines the element the controls should be listened from
  18864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18865. */
  18866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18867. /**
  18868. * Called on JS contextmenu event.
  18869. * Override this method to provide functionality.
  18870. */
  18871. protected onContextMenu(evt: PointerEvent): void;
  18872. /**
  18873. * Detach the current controls from the specified dom element.
  18874. * @param element Defines the element to stop listening the inputs from
  18875. */
  18876. detachControl(element: Nullable<HTMLElement>): void;
  18877. /**
  18878. * Gets the class name of the current intput.
  18879. * @returns the class name
  18880. */
  18881. getClassName(): string;
  18882. /**
  18883. * Get the friendly name associated with the input class.
  18884. * @returns the input friendly name
  18885. */
  18886. getSimpleName(): string;
  18887. }
  18888. }
  18889. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18890. import { Nullable } from "babylonjs/types";
  18891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18892. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18893. /**
  18894. * Manage the touch inputs to control the movement of a free camera.
  18895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18896. */
  18897. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18898. /**
  18899. * Defines the camera the input is attached to.
  18900. */
  18901. camera: FreeCamera;
  18902. /**
  18903. * Defines the touch sensibility for rotation.
  18904. * The higher the faster.
  18905. */
  18906. touchAngularSensibility: number;
  18907. /**
  18908. * Defines the touch sensibility for move.
  18909. * The higher the faster.
  18910. */
  18911. touchMoveSensibility: number;
  18912. private _offsetX;
  18913. private _offsetY;
  18914. private _pointerPressed;
  18915. private _pointerInput;
  18916. private _observer;
  18917. private _onLostFocus;
  18918. /**
  18919. * Attach the input controls to a specific dom element to get the input from.
  18920. * @param element Defines the element the controls should be listened from
  18921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18922. */
  18923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18924. /**
  18925. * Detach the current controls from the specified dom element.
  18926. * @param element Defines the element to stop listening the inputs from
  18927. */
  18928. detachControl(element: Nullable<HTMLElement>): void;
  18929. /**
  18930. * Update the current camera state depending on the inputs that have been used this frame.
  18931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18932. */
  18933. checkInputs(): void;
  18934. /**
  18935. * Gets the class name of the current intput.
  18936. * @returns the class name
  18937. */
  18938. getClassName(): string;
  18939. /**
  18940. * Get the friendly name associated with the input class.
  18941. * @returns the input friendly name
  18942. */
  18943. getSimpleName(): string;
  18944. }
  18945. }
  18946. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18948. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18949. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18950. import { Nullable } from "babylonjs/types";
  18951. /**
  18952. * Default Inputs manager for the FreeCamera.
  18953. * It groups all the default supported inputs for ease of use.
  18954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18955. */
  18956. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18957. /**
  18958. * @hidden
  18959. */
  18960. _mouseInput: Nullable<FreeCameraMouseInput>;
  18961. /**
  18962. * Instantiates a new FreeCameraInputsManager.
  18963. * @param camera Defines the camera the inputs belong to
  18964. */
  18965. constructor(camera: FreeCamera);
  18966. /**
  18967. * Add keyboard input support to the input manager.
  18968. * @returns the current input manager
  18969. */
  18970. addKeyboard(): FreeCameraInputsManager;
  18971. /**
  18972. * Add mouse input support to the input manager.
  18973. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18974. * @returns the current input manager
  18975. */
  18976. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18977. /**
  18978. * Removes the mouse input support from the manager
  18979. * @returns the current input manager
  18980. */
  18981. removeMouse(): FreeCameraInputsManager;
  18982. /**
  18983. * Add touch input support to the input manager.
  18984. * @returns the current input manager
  18985. */
  18986. addTouch(): FreeCameraInputsManager;
  18987. /**
  18988. * Remove all attached input methods from a camera
  18989. */
  18990. clear(): void;
  18991. }
  18992. }
  18993. declare module "babylonjs/Cameras/freeCamera" {
  18994. import { Vector3 } from "babylonjs/Maths/math.vector";
  18995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18996. import { Scene } from "babylonjs/scene";
  18997. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18998. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18999. /**
  19000. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19001. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19002. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19003. */
  19004. export class FreeCamera extends TargetCamera {
  19005. /**
  19006. * Define the collision ellipsoid of the camera.
  19007. * This is helpful to simulate a camera body like the player body around the camera
  19008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19009. */
  19010. ellipsoid: Vector3;
  19011. /**
  19012. * Define an offset for the position of the ellipsoid around the camera.
  19013. * This can be helpful to determine the center of the body near the gravity center of the body
  19014. * instead of its head.
  19015. */
  19016. ellipsoidOffset: Vector3;
  19017. /**
  19018. * Enable or disable collisions of the camera with the rest of the scene objects.
  19019. */
  19020. checkCollisions: boolean;
  19021. /**
  19022. * Enable or disable gravity on the camera.
  19023. */
  19024. applyGravity: boolean;
  19025. /**
  19026. * Define the input manager associated to the camera.
  19027. */
  19028. inputs: FreeCameraInputsManager;
  19029. /**
  19030. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19031. * Higher values reduce sensitivity.
  19032. */
  19033. get angularSensibility(): number;
  19034. /**
  19035. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19036. * Higher values reduce sensitivity.
  19037. */
  19038. set angularSensibility(value: number);
  19039. /**
  19040. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19041. */
  19042. get keysUp(): number[];
  19043. set keysUp(value: number[]);
  19044. /**
  19045. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19046. */
  19047. get keysUpward(): number[];
  19048. set keysUpward(value: number[]);
  19049. /**
  19050. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19051. */
  19052. get keysDown(): number[];
  19053. set keysDown(value: number[]);
  19054. /**
  19055. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19056. */
  19057. get keysDownward(): number[];
  19058. set keysDownward(value: number[]);
  19059. /**
  19060. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19061. */
  19062. get keysLeft(): number[];
  19063. set keysLeft(value: number[]);
  19064. /**
  19065. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19066. */
  19067. get keysRight(): number[];
  19068. set keysRight(value: number[]);
  19069. /**
  19070. * Event raised when the camera collide with a mesh in the scene.
  19071. */
  19072. onCollide: (collidedMesh: AbstractMesh) => void;
  19073. private _collider;
  19074. private _needMoveForGravity;
  19075. private _oldPosition;
  19076. private _diffPosition;
  19077. private _newPosition;
  19078. /** @hidden */
  19079. _localDirection: Vector3;
  19080. /** @hidden */
  19081. _transformedDirection: Vector3;
  19082. /**
  19083. * Instantiates a Free Camera.
  19084. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19085. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19086. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19087. * @param name Define the name of the camera in the scene
  19088. * @param position Define the start position of the camera in the scene
  19089. * @param scene Define the scene the camera belongs to
  19090. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19091. */
  19092. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19093. /**
  19094. * Attached controls to the current camera.
  19095. * @param element Defines the element the controls should be listened from
  19096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19097. */
  19098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19099. /**
  19100. * Detach the current controls from the camera.
  19101. * The camera will stop reacting to inputs.
  19102. * @param element Defines the element to stop listening the inputs from
  19103. */
  19104. detachControl(element: HTMLElement): void;
  19105. private _collisionMask;
  19106. /**
  19107. * Define a collision mask to limit the list of object the camera can collide with
  19108. */
  19109. get collisionMask(): number;
  19110. set collisionMask(mask: number);
  19111. /** @hidden */
  19112. _collideWithWorld(displacement: Vector3): void;
  19113. private _onCollisionPositionChange;
  19114. /** @hidden */
  19115. _checkInputs(): void;
  19116. /** @hidden */
  19117. _decideIfNeedsToMove(): boolean;
  19118. /** @hidden */
  19119. _updatePosition(): void;
  19120. /**
  19121. * Destroy the camera and release the current resources hold by it.
  19122. */
  19123. dispose(): void;
  19124. /**
  19125. * Gets the current object class name.
  19126. * @return the class name
  19127. */
  19128. getClassName(): string;
  19129. }
  19130. }
  19131. declare module "babylonjs/Gamepads/gamepad" {
  19132. import { Observable } from "babylonjs/Misc/observable";
  19133. /**
  19134. * Represents a gamepad control stick position
  19135. */
  19136. export class StickValues {
  19137. /**
  19138. * The x component of the control stick
  19139. */
  19140. x: number;
  19141. /**
  19142. * The y component of the control stick
  19143. */
  19144. y: number;
  19145. /**
  19146. * Initializes the gamepad x and y control stick values
  19147. * @param x The x component of the gamepad control stick value
  19148. * @param y The y component of the gamepad control stick value
  19149. */
  19150. constructor(
  19151. /**
  19152. * The x component of the control stick
  19153. */
  19154. x: number,
  19155. /**
  19156. * The y component of the control stick
  19157. */
  19158. y: number);
  19159. }
  19160. /**
  19161. * An interface which manages callbacks for gamepad button changes
  19162. */
  19163. export interface GamepadButtonChanges {
  19164. /**
  19165. * Called when a gamepad has been changed
  19166. */
  19167. changed: boolean;
  19168. /**
  19169. * Called when a gamepad press event has been triggered
  19170. */
  19171. pressChanged: boolean;
  19172. /**
  19173. * Called when a touch event has been triggered
  19174. */
  19175. touchChanged: boolean;
  19176. /**
  19177. * Called when a value has changed
  19178. */
  19179. valueChanged: boolean;
  19180. }
  19181. /**
  19182. * Represents a gamepad
  19183. */
  19184. export class Gamepad {
  19185. /**
  19186. * The id of the gamepad
  19187. */
  19188. id: string;
  19189. /**
  19190. * The index of the gamepad
  19191. */
  19192. index: number;
  19193. /**
  19194. * The browser gamepad
  19195. */
  19196. browserGamepad: any;
  19197. /**
  19198. * Specifies what type of gamepad this represents
  19199. */
  19200. type: number;
  19201. private _leftStick;
  19202. private _rightStick;
  19203. /** @hidden */
  19204. _isConnected: boolean;
  19205. private _leftStickAxisX;
  19206. private _leftStickAxisY;
  19207. private _rightStickAxisX;
  19208. private _rightStickAxisY;
  19209. /**
  19210. * Triggered when the left control stick has been changed
  19211. */
  19212. private _onleftstickchanged;
  19213. /**
  19214. * Triggered when the right control stick has been changed
  19215. */
  19216. private _onrightstickchanged;
  19217. /**
  19218. * Represents a gamepad controller
  19219. */
  19220. static GAMEPAD: number;
  19221. /**
  19222. * Represents a generic controller
  19223. */
  19224. static GENERIC: number;
  19225. /**
  19226. * Represents an XBox controller
  19227. */
  19228. static XBOX: number;
  19229. /**
  19230. * Represents a pose-enabled controller
  19231. */
  19232. static POSE_ENABLED: number;
  19233. /**
  19234. * Represents an Dual Shock controller
  19235. */
  19236. static DUALSHOCK: number;
  19237. /**
  19238. * Specifies whether the left control stick should be Y-inverted
  19239. */
  19240. protected _invertLeftStickY: boolean;
  19241. /**
  19242. * Specifies if the gamepad has been connected
  19243. */
  19244. get isConnected(): boolean;
  19245. /**
  19246. * Initializes the gamepad
  19247. * @param id The id of the gamepad
  19248. * @param index The index of the gamepad
  19249. * @param browserGamepad The browser gamepad
  19250. * @param leftStickX The x component of the left joystick
  19251. * @param leftStickY The y component of the left joystick
  19252. * @param rightStickX The x component of the right joystick
  19253. * @param rightStickY The y component of the right joystick
  19254. */
  19255. constructor(
  19256. /**
  19257. * The id of the gamepad
  19258. */
  19259. id: string,
  19260. /**
  19261. * The index of the gamepad
  19262. */
  19263. index: number,
  19264. /**
  19265. * The browser gamepad
  19266. */
  19267. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19268. /**
  19269. * Callback triggered when the left joystick has changed
  19270. * @param callback
  19271. */
  19272. onleftstickchanged(callback: (values: StickValues) => void): void;
  19273. /**
  19274. * Callback triggered when the right joystick has changed
  19275. * @param callback
  19276. */
  19277. onrightstickchanged(callback: (values: StickValues) => void): void;
  19278. /**
  19279. * Gets the left joystick
  19280. */
  19281. get leftStick(): StickValues;
  19282. /**
  19283. * Sets the left joystick values
  19284. */
  19285. set leftStick(newValues: StickValues);
  19286. /**
  19287. * Gets the right joystick
  19288. */
  19289. get rightStick(): StickValues;
  19290. /**
  19291. * Sets the right joystick value
  19292. */
  19293. set rightStick(newValues: StickValues);
  19294. /**
  19295. * Updates the gamepad joystick positions
  19296. */
  19297. update(): void;
  19298. /**
  19299. * Disposes the gamepad
  19300. */
  19301. dispose(): void;
  19302. }
  19303. /**
  19304. * Represents a generic gamepad
  19305. */
  19306. export class GenericPad extends Gamepad {
  19307. private _buttons;
  19308. private _onbuttondown;
  19309. private _onbuttonup;
  19310. /**
  19311. * Observable triggered when a button has been pressed
  19312. */
  19313. onButtonDownObservable: Observable<number>;
  19314. /**
  19315. * Observable triggered when a button has been released
  19316. */
  19317. onButtonUpObservable: Observable<number>;
  19318. /**
  19319. * Callback triggered when a button has been pressed
  19320. * @param callback Called when a button has been pressed
  19321. */
  19322. onbuttondown(callback: (buttonPressed: number) => void): void;
  19323. /**
  19324. * Callback triggered when a button has been released
  19325. * @param callback Called when a button has been released
  19326. */
  19327. onbuttonup(callback: (buttonReleased: number) => void): void;
  19328. /**
  19329. * Initializes the generic gamepad
  19330. * @param id The id of the generic gamepad
  19331. * @param index The index of the generic gamepad
  19332. * @param browserGamepad The browser gamepad
  19333. */
  19334. constructor(id: string, index: number, browserGamepad: any);
  19335. private _setButtonValue;
  19336. /**
  19337. * Updates the generic gamepad
  19338. */
  19339. update(): void;
  19340. /**
  19341. * Disposes the generic gamepad
  19342. */
  19343. dispose(): void;
  19344. }
  19345. }
  19346. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19347. import { Observable } from "babylonjs/Misc/observable";
  19348. import { Nullable } from "babylonjs/types";
  19349. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19352. import { Ray } from "babylonjs/Culling/ray";
  19353. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19354. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19355. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19356. /**
  19357. * Defines the types of pose enabled controllers that are supported
  19358. */
  19359. export enum PoseEnabledControllerType {
  19360. /**
  19361. * HTC Vive
  19362. */
  19363. VIVE = 0,
  19364. /**
  19365. * Oculus Rift
  19366. */
  19367. OCULUS = 1,
  19368. /**
  19369. * Windows mixed reality
  19370. */
  19371. WINDOWS = 2,
  19372. /**
  19373. * Samsung gear VR
  19374. */
  19375. GEAR_VR = 3,
  19376. /**
  19377. * Google Daydream
  19378. */
  19379. DAYDREAM = 4,
  19380. /**
  19381. * Generic
  19382. */
  19383. GENERIC = 5
  19384. }
  19385. /**
  19386. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19387. */
  19388. export interface MutableGamepadButton {
  19389. /**
  19390. * Value of the button/trigger
  19391. */
  19392. value: number;
  19393. /**
  19394. * If the button/trigger is currently touched
  19395. */
  19396. touched: boolean;
  19397. /**
  19398. * If the button/trigger is currently pressed
  19399. */
  19400. pressed: boolean;
  19401. }
  19402. /**
  19403. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19404. * @hidden
  19405. */
  19406. export interface ExtendedGamepadButton extends GamepadButton {
  19407. /**
  19408. * If the button/trigger is currently pressed
  19409. */
  19410. readonly pressed: boolean;
  19411. /**
  19412. * If the button/trigger is currently touched
  19413. */
  19414. readonly touched: boolean;
  19415. /**
  19416. * Value of the button/trigger
  19417. */
  19418. readonly value: number;
  19419. }
  19420. /** @hidden */
  19421. export interface _GamePadFactory {
  19422. /**
  19423. * Returns whether or not the current gamepad can be created for this type of controller.
  19424. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19425. * @returns true if it can be created, otherwise false
  19426. */
  19427. canCreate(gamepadInfo: any): boolean;
  19428. /**
  19429. * Creates a new instance of the Gamepad.
  19430. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19431. * @returns the new gamepad instance
  19432. */
  19433. create(gamepadInfo: any): Gamepad;
  19434. }
  19435. /**
  19436. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19437. */
  19438. export class PoseEnabledControllerHelper {
  19439. /** @hidden */
  19440. static _ControllerFactories: _GamePadFactory[];
  19441. /** @hidden */
  19442. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19443. /**
  19444. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19445. * @param vrGamepad the gamepad to initialized
  19446. * @returns a vr controller of the type the gamepad identified as
  19447. */
  19448. static InitiateController(vrGamepad: any): Gamepad;
  19449. }
  19450. /**
  19451. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19452. */
  19453. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19454. /**
  19455. * If the controller is used in a webXR session
  19456. */
  19457. isXR: boolean;
  19458. private _deviceRoomPosition;
  19459. private _deviceRoomRotationQuaternion;
  19460. /**
  19461. * The device position in babylon space
  19462. */
  19463. devicePosition: Vector3;
  19464. /**
  19465. * The device rotation in babylon space
  19466. */
  19467. deviceRotationQuaternion: Quaternion;
  19468. /**
  19469. * The scale factor of the device in babylon space
  19470. */
  19471. deviceScaleFactor: number;
  19472. /**
  19473. * (Likely devicePosition should be used instead) The device position in its room space
  19474. */
  19475. position: Vector3;
  19476. /**
  19477. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19478. */
  19479. rotationQuaternion: Quaternion;
  19480. /**
  19481. * The type of controller (Eg. Windows mixed reality)
  19482. */
  19483. controllerType: PoseEnabledControllerType;
  19484. protected _calculatedPosition: Vector3;
  19485. private _calculatedRotation;
  19486. /**
  19487. * The raw pose from the device
  19488. */
  19489. rawPose: DevicePose;
  19490. private _trackPosition;
  19491. private _maxRotationDistFromHeadset;
  19492. private _draggedRoomRotation;
  19493. /**
  19494. * @hidden
  19495. */
  19496. _disableTrackPosition(fixedPosition: Vector3): void;
  19497. /**
  19498. * Internal, the mesh attached to the controller
  19499. * @hidden
  19500. */
  19501. _mesh: Nullable<AbstractMesh>;
  19502. private _poseControlledCamera;
  19503. private _leftHandSystemQuaternion;
  19504. /**
  19505. * Internal, matrix used to convert room space to babylon space
  19506. * @hidden
  19507. */
  19508. _deviceToWorld: Matrix;
  19509. /**
  19510. * Node to be used when casting a ray from the controller
  19511. * @hidden
  19512. */
  19513. _pointingPoseNode: Nullable<TransformNode>;
  19514. /**
  19515. * Name of the child mesh that can be used to cast a ray from the controller
  19516. */
  19517. static readonly POINTING_POSE: string;
  19518. /**
  19519. * Creates a new PoseEnabledController from a gamepad
  19520. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19521. */
  19522. constructor(browserGamepad: any);
  19523. private _workingMatrix;
  19524. /**
  19525. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19526. */
  19527. update(): void;
  19528. /**
  19529. * Updates only the pose device and mesh without doing any button event checking
  19530. */
  19531. protected _updatePoseAndMesh(): void;
  19532. /**
  19533. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19534. * @param poseData raw pose fromthe device
  19535. */
  19536. updateFromDevice(poseData: DevicePose): void;
  19537. /**
  19538. * @hidden
  19539. */
  19540. _meshAttachedObservable: Observable<AbstractMesh>;
  19541. /**
  19542. * Attaches a mesh to the controller
  19543. * @param mesh the mesh to be attached
  19544. */
  19545. attachToMesh(mesh: AbstractMesh): void;
  19546. /**
  19547. * Attaches the controllers mesh to a camera
  19548. * @param camera the camera the mesh should be attached to
  19549. */
  19550. attachToPoseControlledCamera(camera: TargetCamera): void;
  19551. /**
  19552. * Disposes of the controller
  19553. */
  19554. dispose(): void;
  19555. /**
  19556. * The mesh that is attached to the controller
  19557. */
  19558. get mesh(): Nullable<AbstractMesh>;
  19559. /**
  19560. * Gets the ray of the controller in the direction the controller is pointing
  19561. * @param length the length the resulting ray should be
  19562. * @returns a ray in the direction the controller is pointing
  19563. */
  19564. getForwardRay(length?: number): Ray;
  19565. }
  19566. }
  19567. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19568. import { Observable } from "babylonjs/Misc/observable";
  19569. import { Scene } from "babylonjs/scene";
  19570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19571. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19572. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19573. import { Nullable } from "babylonjs/types";
  19574. /**
  19575. * Defines the WebVRController object that represents controllers tracked in 3D space
  19576. */
  19577. export abstract class WebVRController extends PoseEnabledController {
  19578. /**
  19579. * Internal, the default controller model for the controller
  19580. */
  19581. protected _defaultModel: Nullable<AbstractMesh>;
  19582. /**
  19583. * Fired when the trigger state has changed
  19584. */
  19585. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19586. /**
  19587. * Fired when the main button state has changed
  19588. */
  19589. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19590. /**
  19591. * Fired when the secondary button state has changed
  19592. */
  19593. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19594. /**
  19595. * Fired when the pad state has changed
  19596. */
  19597. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19598. /**
  19599. * Fired when controllers stick values have changed
  19600. */
  19601. onPadValuesChangedObservable: Observable<StickValues>;
  19602. /**
  19603. * Array of button availible on the controller
  19604. */
  19605. protected _buttons: Array<MutableGamepadButton>;
  19606. private _onButtonStateChange;
  19607. /**
  19608. * Fired when a controller button's state has changed
  19609. * @param callback the callback containing the button that was modified
  19610. */
  19611. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19612. /**
  19613. * X and Y axis corresponding to the controllers joystick
  19614. */
  19615. pad: StickValues;
  19616. /**
  19617. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19618. */
  19619. hand: string;
  19620. /**
  19621. * The default controller model for the controller
  19622. */
  19623. get defaultModel(): Nullable<AbstractMesh>;
  19624. /**
  19625. * Creates a new WebVRController from a gamepad
  19626. * @param vrGamepad the gamepad that the WebVRController should be created from
  19627. */
  19628. constructor(vrGamepad: any);
  19629. /**
  19630. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19631. */
  19632. update(): void;
  19633. /**
  19634. * Function to be called when a button is modified
  19635. */
  19636. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19637. /**
  19638. * Loads a mesh and attaches it to the controller
  19639. * @param scene the scene the mesh should be added to
  19640. * @param meshLoaded callback for when the mesh has been loaded
  19641. */
  19642. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19643. private _setButtonValue;
  19644. private _changes;
  19645. private _checkChanges;
  19646. /**
  19647. * Disposes of th webVRCOntroller
  19648. */
  19649. dispose(): void;
  19650. }
  19651. }
  19652. declare module "babylonjs/Lights/hemisphericLight" {
  19653. import { Nullable } from "babylonjs/types";
  19654. import { Scene } from "babylonjs/scene";
  19655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19656. import { Color3 } from "babylonjs/Maths/math.color";
  19657. import { Effect } from "babylonjs/Materials/effect";
  19658. import { Light } from "babylonjs/Lights/light";
  19659. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19660. /**
  19661. * The HemisphericLight simulates the ambient environment light,
  19662. * so the passed direction is the light reflection direction, not the incoming direction.
  19663. */
  19664. export class HemisphericLight extends Light {
  19665. /**
  19666. * The groundColor is the light in the opposite direction to the one specified during creation.
  19667. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19668. */
  19669. groundColor: Color3;
  19670. /**
  19671. * The light reflection direction, not the incoming direction.
  19672. */
  19673. direction: Vector3;
  19674. /**
  19675. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19676. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19677. * The HemisphericLight can't cast shadows.
  19678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19679. * @param name The friendly name of the light
  19680. * @param direction The direction of the light reflection
  19681. * @param scene The scene the light belongs to
  19682. */
  19683. constructor(name: string, direction: Vector3, scene: Scene);
  19684. protected _buildUniformLayout(): void;
  19685. /**
  19686. * Returns the string "HemisphericLight".
  19687. * @return The class name
  19688. */
  19689. getClassName(): string;
  19690. /**
  19691. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19692. * Returns the updated direction.
  19693. * @param target The target the direction should point to
  19694. * @return The computed direction
  19695. */
  19696. setDirectionToTarget(target: Vector3): Vector3;
  19697. /**
  19698. * Returns the shadow generator associated to the light.
  19699. * @returns Always null for hemispheric lights because it does not support shadows.
  19700. */
  19701. getShadowGenerator(): Nullable<IShadowGenerator>;
  19702. /**
  19703. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19704. * @param effect The effect to update
  19705. * @param lightIndex The index of the light in the effect to update
  19706. * @returns The hemispheric light
  19707. */
  19708. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19709. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19710. /**
  19711. * Computes the world matrix of the node
  19712. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19713. * @param useWasUpdatedFlag defines a reserved property
  19714. * @returns the world matrix
  19715. */
  19716. computeWorldMatrix(): Matrix;
  19717. /**
  19718. * Returns the integer 3.
  19719. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19720. */
  19721. getTypeID(): number;
  19722. /**
  19723. * Prepares the list of defines specific to the light type.
  19724. * @param defines the list of defines
  19725. * @param lightIndex defines the index of the light for the effect
  19726. */
  19727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19728. }
  19729. }
  19730. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19731. /** @hidden */
  19732. export var vrMultiviewToSingleviewPixelShader: {
  19733. name: string;
  19734. shader: string;
  19735. };
  19736. }
  19737. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19739. import { Scene } from "babylonjs/scene";
  19740. /**
  19741. * Renders to multiple views with a single draw call
  19742. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19743. */
  19744. export class MultiviewRenderTarget extends RenderTargetTexture {
  19745. /**
  19746. * Creates a multiview render target
  19747. * @param scene scene used with the render target
  19748. * @param size the size of the render target (used for each view)
  19749. */
  19750. constructor(scene: Scene, size?: number | {
  19751. width: number;
  19752. height: number;
  19753. } | {
  19754. ratio: number;
  19755. });
  19756. /**
  19757. * @hidden
  19758. * @param faceIndex the face index, if its a cube texture
  19759. */
  19760. _bindFrameBuffer(faceIndex?: number): void;
  19761. /**
  19762. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19763. * @returns the view count
  19764. */
  19765. getViewCount(): number;
  19766. }
  19767. }
  19768. declare module "babylonjs/Maths/math.frustum" {
  19769. import { Matrix } from "babylonjs/Maths/math.vector";
  19770. import { DeepImmutable } from "babylonjs/types";
  19771. import { Plane } from "babylonjs/Maths/math.plane";
  19772. /**
  19773. * Represents a camera frustum
  19774. */
  19775. export class Frustum {
  19776. /**
  19777. * Gets the planes representing the frustum
  19778. * @param transform matrix to be applied to the returned planes
  19779. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19780. */
  19781. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19782. /**
  19783. * Gets the near frustum plane transformed by the transform matrix
  19784. * @param transform transformation matrix to be applied to the resulting frustum plane
  19785. * @param frustumPlane the resuling frustum plane
  19786. */
  19787. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19788. /**
  19789. * Gets the far frustum plane transformed by the transform matrix
  19790. * @param transform transformation matrix to be applied to the resulting frustum plane
  19791. * @param frustumPlane the resuling frustum plane
  19792. */
  19793. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19794. /**
  19795. * Gets the left frustum plane transformed by the transform matrix
  19796. * @param transform transformation matrix to be applied to the resulting frustum plane
  19797. * @param frustumPlane the resuling frustum plane
  19798. */
  19799. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19800. /**
  19801. * Gets the right frustum plane transformed by the transform matrix
  19802. * @param transform transformation matrix to be applied to the resulting frustum plane
  19803. * @param frustumPlane the resuling frustum plane
  19804. */
  19805. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19806. /**
  19807. * Gets the top frustum plane transformed by the transform matrix
  19808. * @param transform transformation matrix to be applied to the resulting frustum plane
  19809. * @param frustumPlane the resuling frustum plane
  19810. */
  19811. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19812. /**
  19813. * Gets the bottom frustum plane transformed by the transform matrix
  19814. * @param transform transformation matrix to be applied to the resulting frustum plane
  19815. * @param frustumPlane the resuling frustum plane
  19816. */
  19817. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19818. /**
  19819. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19820. * @param transform transformation matrix to be applied to the resulting frustum planes
  19821. * @param frustumPlanes the resuling frustum planes
  19822. */
  19823. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19824. }
  19825. }
  19826. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19827. import { Camera } from "babylonjs/Cameras/camera";
  19828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19829. import { Nullable } from "babylonjs/types";
  19830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19831. import { Matrix } from "babylonjs/Maths/math.vector";
  19832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19833. module "babylonjs/Engines/engine" {
  19834. interface Engine {
  19835. /**
  19836. * Creates a new multiview render target
  19837. * @param width defines the width of the texture
  19838. * @param height defines the height of the texture
  19839. * @returns the created multiview texture
  19840. */
  19841. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19842. /**
  19843. * Binds a multiview framebuffer to be drawn to
  19844. * @param multiviewTexture texture to bind
  19845. */
  19846. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19847. }
  19848. }
  19849. module "babylonjs/Cameras/camera" {
  19850. interface Camera {
  19851. /**
  19852. * @hidden
  19853. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19854. */
  19855. _useMultiviewToSingleView: boolean;
  19856. /**
  19857. * @hidden
  19858. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19859. */
  19860. _multiviewTexture: Nullable<RenderTargetTexture>;
  19861. /**
  19862. * @hidden
  19863. * ensures the multiview texture of the camera exists and has the specified width/height
  19864. * @param width height to set on the multiview texture
  19865. * @param height width to set on the multiview texture
  19866. */
  19867. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19868. }
  19869. }
  19870. module "babylonjs/scene" {
  19871. interface Scene {
  19872. /** @hidden */
  19873. _transformMatrixR: Matrix;
  19874. /** @hidden */
  19875. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19876. /** @hidden */
  19877. _createMultiviewUbo(): void;
  19878. /** @hidden */
  19879. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19880. /** @hidden */
  19881. _renderMultiviewToSingleView(camera: Camera): void;
  19882. }
  19883. }
  19884. }
  19885. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19886. import { Camera } from "babylonjs/Cameras/camera";
  19887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19888. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19889. import "babylonjs/Engines/Extensions/engine.multiview";
  19890. /**
  19891. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19892. * This will not be used for webXR as it supports displaying texture arrays directly
  19893. */
  19894. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19895. /**
  19896. * Initializes a VRMultiviewToSingleview
  19897. * @param name name of the post process
  19898. * @param camera camera to be applied to
  19899. * @param scaleFactor scaling factor to the size of the output texture
  19900. */
  19901. constructor(name: string, camera: Camera, scaleFactor: number);
  19902. }
  19903. }
  19904. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19905. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19906. import { Nullable } from "babylonjs/types";
  19907. import { Size } from "babylonjs/Maths/math.size";
  19908. import { Observable } from "babylonjs/Misc/observable";
  19909. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19910. /**
  19911. * Interface used to define additional presentation attributes
  19912. */
  19913. export interface IVRPresentationAttributes {
  19914. /**
  19915. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19916. */
  19917. highRefreshRate: boolean;
  19918. /**
  19919. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19920. */
  19921. foveationLevel: number;
  19922. }
  19923. module "babylonjs/Engines/engine" {
  19924. interface Engine {
  19925. /** @hidden */
  19926. _vrDisplay: any;
  19927. /** @hidden */
  19928. _vrSupported: boolean;
  19929. /** @hidden */
  19930. _oldSize: Size;
  19931. /** @hidden */
  19932. _oldHardwareScaleFactor: number;
  19933. /** @hidden */
  19934. _vrExclusivePointerMode: boolean;
  19935. /** @hidden */
  19936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19937. /** @hidden */
  19938. _onVRDisplayPointerRestricted: () => void;
  19939. /** @hidden */
  19940. _onVRDisplayPointerUnrestricted: () => void;
  19941. /** @hidden */
  19942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19943. /** @hidden */
  19944. _onVrDisplayDisconnect: Nullable<() => void>;
  19945. /** @hidden */
  19946. _onVrDisplayPresentChange: Nullable<() => void>;
  19947. /**
  19948. * Observable signaled when VR display mode changes
  19949. */
  19950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19951. /**
  19952. * Observable signaled when VR request present is complete
  19953. */
  19954. onVRRequestPresentComplete: Observable<boolean>;
  19955. /**
  19956. * Observable signaled when VR request present starts
  19957. */
  19958. onVRRequestPresentStart: Observable<Engine>;
  19959. /**
  19960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19962. */
  19963. isInVRExclusivePointerMode: boolean;
  19964. /**
  19965. * Gets a boolean indicating if a webVR device was detected
  19966. * @returns true if a webVR device was detected
  19967. */
  19968. isVRDevicePresent(): boolean;
  19969. /**
  19970. * Gets the current webVR device
  19971. * @returns the current webVR device (or null)
  19972. */
  19973. getVRDevice(): any;
  19974. /**
  19975. * Initializes a webVR display and starts listening to display change events
  19976. * The onVRDisplayChangedObservable will be notified upon these changes
  19977. * @returns A promise containing a VRDisplay and if vr is supported
  19978. */
  19979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19980. /** @hidden */
  19981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19982. /**
  19983. * Gets or sets the presentation attributes used to configure VR rendering
  19984. */
  19985. vrPresentationAttributes?: IVRPresentationAttributes;
  19986. /**
  19987. * Call this function to switch to webVR mode
  19988. * Will do nothing if webVR is not supported or if there is no webVR device
  19989. * @param options the webvr options provided to the camera. mainly used for multiview
  19990. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19991. */
  19992. enableVR(options: WebVROptions): void;
  19993. /** @hidden */
  19994. _onVRFullScreenTriggered(): void;
  19995. }
  19996. }
  19997. }
  19998. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19999. import { Nullable } from "babylonjs/types";
  20000. import { Observable } from "babylonjs/Misc/observable";
  20001. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20002. import { Scene } from "babylonjs/scene";
  20003. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20004. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20005. import { Node } from "babylonjs/node";
  20006. import { Ray } from "babylonjs/Culling/ray";
  20007. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20008. import "babylonjs/Engines/Extensions/engine.webVR";
  20009. /**
  20010. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20011. * IMPORTANT!! The data is right-hand data.
  20012. * @export
  20013. * @interface DevicePose
  20014. */
  20015. export interface DevicePose {
  20016. /**
  20017. * The position of the device, values in array are [x,y,z].
  20018. */
  20019. readonly position: Nullable<Float32Array>;
  20020. /**
  20021. * The linearVelocity of the device, values in array are [x,y,z].
  20022. */
  20023. readonly linearVelocity: Nullable<Float32Array>;
  20024. /**
  20025. * The linearAcceleration of the device, values in array are [x,y,z].
  20026. */
  20027. readonly linearAcceleration: Nullable<Float32Array>;
  20028. /**
  20029. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20030. */
  20031. readonly orientation: Nullable<Float32Array>;
  20032. /**
  20033. * The angularVelocity of the device, values in array are [x,y,z].
  20034. */
  20035. readonly angularVelocity: Nullable<Float32Array>;
  20036. /**
  20037. * The angularAcceleration of the device, values in array are [x,y,z].
  20038. */
  20039. readonly angularAcceleration: Nullable<Float32Array>;
  20040. }
  20041. /**
  20042. * Interface representing a pose controlled object in Babylon.
  20043. * A pose controlled object has both regular pose values as well as pose values
  20044. * from an external device such as a VR head mounted display
  20045. */
  20046. export interface PoseControlled {
  20047. /**
  20048. * The position of the object in babylon space.
  20049. */
  20050. position: Vector3;
  20051. /**
  20052. * The rotation quaternion of the object in babylon space.
  20053. */
  20054. rotationQuaternion: Quaternion;
  20055. /**
  20056. * The position of the device in babylon space.
  20057. */
  20058. devicePosition?: Vector3;
  20059. /**
  20060. * The rotation quaternion of the device in babylon space.
  20061. */
  20062. deviceRotationQuaternion: Quaternion;
  20063. /**
  20064. * The raw pose coming from the device.
  20065. */
  20066. rawPose: Nullable<DevicePose>;
  20067. /**
  20068. * The scale of the device to be used when translating from device space to babylon space.
  20069. */
  20070. deviceScaleFactor: number;
  20071. /**
  20072. * Updates the poseControlled values based on the input device pose.
  20073. * @param poseData the pose data to update the object with
  20074. */
  20075. updateFromDevice(poseData: DevicePose): void;
  20076. }
  20077. /**
  20078. * Set of options to customize the webVRCamera
  20079. */
  20080. export interface WebVROptions {
  20081. /**
  20082. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20083. */
  20084. trackPosition?: boolean;
  20085. /**
  20086. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20087. */
  20088. positionScale?: number;
  20089. /**
  20090. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20091. */
  20092. displayName?: string;
  20093. /**
  20094. * Should the native controller meshes be initialized. (default: true)
  20095. */
  20096. controllerMeshes?: boolean;
  20097. /**
  20098. * Creating a default HemiLight only on controllers. (default: true)
  20099. */
  20100. defaultLightingOnControllers?: boolean;
  20101. /**
  20102. * If you don't want to use the default VR button of the helper. (default: false)
  20103. */
  20104. useCustomVRButton?: boolean;
  20105. /**
  20106. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20107. */
  20108. customVRButton?: HTMLButtonElement;
  20109. /**
  20110. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20111. */
  20112. rayLength?: number;
  20113. /**
  20114. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20115. */
  20116. defaultHeight?: number;
  20117. /**
  20118. * If multiview should be used if availible (default: false)
  20119. */
  20120. useMultiview?: boolean;
  20121. }
  20122. /**
  20123. * This represents a WebVR camera.
  20124. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20125. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20126. */
  20127. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20128. private webVROptions;
  20129. /**
  20130. * @hidden
  20131. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20132. */
  20133. _vrDevice: any;
  20134. /**
  20135. * The rawPose of the vrDevice.
  20136. */
  20137. rawPose: Nullable<DevicePose>;
  20138. private _onVREnabled;
  20139. private _specsVersion;
  20140. private _attached;
  20141. private _frameData;
  20142. protected _descendants: Array<Node>;
  20143. private _deviceRoomPosition;
  20144. /** @hidden */
  20145. _deviceRoomRotationQuaternion: Quaternion;
  20146. private _standingMatrix;
  20147. /**
  20148. * Represents device position in babylon space.
  20149. */
  20150. devicePosition: Vector3;
  20151. /**
  20152. * Represents device rotation in babylon space.
  20153. */
  20154. deviceRotationQuaternion: Quaternion;
  20155. /**
  20156. * The scale of the device to be used when translating from device space to babylon space.
  20157. */
  20158. deviceScaleFactor: number;
  20159. private _deviceToWorld;
  20160. private _worldToDevice;
  20161. /**
  20162. * References to the webVR controllers for the vrDevice.
  20163. */
  20164. controllers: Array<WebVRController>;
  20165. /**
  20166. * Emits an event when a controller is attached.
  20167. */
  20168. onControllersAttachedObservable: Observable<WebVRController[]>;
  20169. /**
  20170. * Emits an event when a controller's mesh has been loaded;
  20171. */
  20172. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20173. /**
  20174. * Emits an event when the HMD's pose has been updated.
  20175. */
  20176. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20177. private _poseSet;
  20178. /**
  20179. * If the rig cameras be used as parent instead of this camera.
  20180. */
  20181. rigParenting: boolean;
  20182. private _lightOnControllers;
  20183. private _defaultHeight?;
  20184. /**
  20185. * Instantiates a WebVRFreeCamera.
  20186. * @param name The name of the WebVRFreeCamera
  20187. * @param position The starting anchor position for the camera
  20188. * @param scene The scene the camera belongs to
  20189. * @param webVROptions a set of customizable options for the webVRCamera
  20190. */
  20191. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20192. /**
  20193. * Gets the device distance from the ground in meters.
  20194. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20195. */
  20196. deviceDistanceToRoomGround(): number;
  20197. /**
  20198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20199. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20200. */
  20201. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20202. /**
  20203. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20204. * @returns A promise with a boolean set to if the standing matrix is supported.
  20205. */
  20206. useStandingMatrixAsync(): Promise<boolean>;
  20207. /**
  20208. * Disposes the camera
  20209. */
  20210. dispose(): void;
  20211. /**
  20212. * Gets a vrController by name.
  20213. * @param name The name of the controller to retreive
  20214. * @returns the controller matching the name specified or null if not found
  20215. */
  20216. getControllerByName(name: string): Nullable<WebVRController>;
  20217. private _leftController;
  20218. /**
  20219. * The controller corresponding to the users left hand.
  20220. */
  20221. get leftController(): Nullable<WebVRController>;
  20222. private _rightController;
  20223. /**
  20224. * The controller corresponding to the users right hand.
  20225. */
  20226. get rightController(): Nullable<WebVRController>;
  20227. /**
  20228. * Casts a ray forward from the vrCamera's gaze.
  20229. * @param length Length of the ray (default: 100)
  20230. * @returns the ray corresponding to the gaze
  20231. */
  20232. getForwardRay(length?: number): Ray;
  20233. /**
  20234. * @hidden
  20235. * Updates the camera based on device's frame data
  20236. */
  20237. _checkInputs(): void;
  20238. /**
  20239. * Updates the poseControlled values based on the input device pose.
  20240. * @param poseData Pose coming from the device
  20241. */
  20242. updateFromDevice(poseData: DevicePose): void;
  20243. private _htmlElementAttached;
  20244. private _detachIfAttached;
  20245. /**
  20246. * WebVR's attach control will start broadcasting frames to the device.
  20247. * Note that in certain browsers (chrome for example) this function must be called
  20248. * within a user-interaction callback. Example:
  20249. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20250. *
  20251. * @param element html element to attach the vrDevice to
  20252. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20253. */
  20254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20255. /**
  20256. * Detaches the camera from the html element and disables VR
  20257. *
  20258. * @param element html element to detach from
  20259. */
  20260. detachControl(element: HTMLElement): void;
  20261. /**
  20262. * @returns the name of this class
  20263. */
  20264. getClassName(): string;
  20265. /**
  20266. * Calls resetPose on the vrDisplay
  20267. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20268. */
  20269. resetToCurrentRotation(): void;
  20270. /**
  20271. * @hidden
  20272. * Updates the rig cameras (left and right eye)
  20273. */
  20274. _updateRigCameras(): void;
  20275. private _workingVector;
  20276. private _oneVector;
  20277. private _workingMatrix;
  20278. private updateCacheCalled;
  20279. private _correctPositionIfNotTrackPosition;
  20280. /**
  20281. * @hidden
  20282. * Updates the cached values of the camera
  20283. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20284. */
  20285. _updateCache(ignoreParentClass?: boolean): void;
  20286. /**
  20287. * @hidden
  20288. * Get current device position in babylon world
  20289. */
  20290. _computeDevicePosition(): void;
  20291. /**
  20292. * Updates the current device position and rotation in the babylon world
  20293. */
  20294. update(): void;
  20295. /**
  20296. * @hidden
  20297. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20298. * @returns an identity matrix
  20299. */
  20300. _getViewMatrix(): Matrix;
  20301. private _tmpMatrix;
  20302. /**
  20303. * This function is called by the two RIG cameras.
  20304. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20305. * @hidden
  20306. */
  20307. _getWebVRViewMatrix(): Matrix;
  20308. /** @hidden */
  20309. _getWebVRProjectionMatrix(): Matrix;
  20310. private _onGamepadConnectedObserver;
  20311. private _onGamepadDisconnectedObserver;
  20312. private _updateCacheWhenTrackingDisabledObserver;
  20313. /**
  20314. * Initializes the controllers and their meshes
  20315. */
  20316. initControllers(): void;
  20317. }
  20318. }
  20319. declare module "babylonjs/PostProcesses/postProcess" {
  20320. import { Nullable } from "babylonjs/types";
  20321. import { SmartArray } from "babylonjs/Misc/smartArray";
  20322. import { Observable } from "babylonjs/Misc/observable";
  20323. import { Vector2 } from "babylonjs/Maths/math.vector";
  20324. import { Camera } from "babylonjs/Cameras/camera";
  20325. import { Effect } from "babylonjs/Materials/effect";
  20326. import "babylonjs/Shaders/postprocess.vertex";
  20327. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20328. import { Engine } from "babylonjs/Engines/engine";
  20329. import { Color4 } from "babylonjs/Maths/math.color";
  20330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20332. /**
  20333. * Size options for a post process
  20334. */
  20335. export type PostProcessOptions = {
  20336. width: number;
  20337. height: number;
  20338. };
  20339. /**
  20340. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20341. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20342. */
  20343. export class PostProcess {
  20344. /** Name of the PostProcess. */
  20345. name: string;
  20346. /**
  20347. * Gets or sets the unique id of the post process
  20348. */
  20349. uniqueId: number;
  20350. /**
  20351. * Width of the texture to apply the post process on
  20352. */
  20353. width: number;
  20354. /**
  20355. * Height of the texture to apply the post process on
  20356. */
  20357. height: number;
  20358. /**
  20359. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20360. * @hidden
  20361. */
  20362. _outputTexture: Nullable<InternalTexture>;
  20363. /**
  20364. * Sampling mode used by the shader
  20365. * See https://doc.babylonjs.com/classes/3.1/texture
  20366. */
  20367. renderTargetSamplingMode: number;
  20368. /**
  20369. * Clear color to use when screen clearing
  20370. */
  20371. clearColor: Color4;
  20372. /**
  20373. * If the buffer needs to be cleared before applying the post process. (default: true)
  20374. * Should be set to false if shader will overwrite all previous pixels.
  20375. */
  20376. autoClear: boolean;
  20377. /**
  20378. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20379. */
  20380. alphaMode: number;
  20381. /**
  20382. * Sets the setAlphaBlendConstants of the babylon engine
  20383. */
  20384. alphaConstants: Color4;
  20385. /**
  20386. * Animations to be used for the post processing
  20387. */
  20388. animations: import("babylonjs/Animations/animation").Animation[];
  20389. /**
  20390. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20391. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20392. */
  20393. enablePixelPerfectMode: boolean;
  20394. /**
  20395. * Force the postprocess to be applied without taking in account viewport
  20396. */
  20397. forceFullscreenViewport: boolean;
  20398. /**
  20399. * List of inspectable custom properties (used by the Inspector)
  20400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20401. */
  20402. inspectableCustomProperties: IInspectable[];
  20403. /**
  20404. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20405. *
  20406. * | Value | Type | Description |
  20407. * | ----- | ----------------------------------- | ----------- |
  20408. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20409. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20410. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20411. *
  20412. */
  20413. scaleMode: number;
  20414. /**
  20415. * Force textures to be a power of two (default: false)
  20416. */
  20417. alwaysForcePOT: boolean;
  20418. private _samples;
  20419. /**
  20420. * Number of sample textures (default: 1)
  20421. */
  20422. get samples(): number;
  20423. set samples(n: number);
  20424. /**
  20425. * Modify the scale of the post process to be the same as the viewport (default: false)
  20426. */
  20427. adaptScaleToCurrentViewport: boolean;
  20428. private _camera;
  20429. private _scene;
  20430. private _engine;
  20431. private _options;
  20432. private _reusable;
  20433. private _textureType;
  20434. private _textureFormat;
  20435. /**
  20436. * Smart array of input and output textures for the post process.
  20437. * @hidden
  20438. */
  20439. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20440. /**
  20441. * The index in _textures that corresponds to the output texture.
  20442. * @hidden
  20443. */
  20444. _currentRenderTextureInd: number;
  20445. private _effect;
  20446. private _samplers;
  20447. private _fragmentUrl;
  20448. private _vertexUrl;
  20449. private _parameters;
  20450. private _scaleRatio;
  20451. protected _indexParameters: any;
  20452. private _shareOutputWithPostProcess;
  20453. private _texelSize;
  20454. private _forcedOutputTexture;
  20455. /**
  20456. * Returns the fragment url or shader name used in the post process.
  20457. * @returns the fragment url or name in the shader store.
  20458. */
  20459. getEffectName(): string;
  20460. /**
  20461. * An event triggered when the postprocess is activated.
  20462. */
  20463. onActivateObservable: Observable<Camera>;
  20464. private _onActivateObserver;
  20465. /**
  20466. * A function that is added to the onActivateObservable
  20467. */
  20468. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20469. /**
  20470. * An event triggered when the postprocess changes its size.
  20471. */
  20472. onSizeChangedObservable: Observable<PostProcess>;
  20473. private _onSizeChangedObserver;
  20474. /**
  20475. * A function that is added to the onSizeChangedObservable
  20476. */
  20477. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20478. /**
  20479. * An event triggered when the postprocess applies its effect.
  20480. */
  20481. onApplyObservable: Observable<Effect>;
  20482. private _onApplyObserver;
  20483. /**
  20484. * A function that is added to the onApplyObservable
  20485. */
  20486. set onApply(callback: (effect: Effect) => void);
  20487. /**
  20488. * An event triggered before rendering the postprocess
  20489. */
  20490. onBeforeRenderObservable: Observable<Effect>;
  20491. private _onBeforeRenderObserver;
  20492. /**
  20493. * A function that is added to the onBeforeRenderObservable
  20494. */
  20495. set onBeforeRender(callback: (effect: Effect) => void);
  20496. /**
  20497. * An event triggered after rendering the postprocess
  20498. */
  20499. onAfterRenderObservable: Observable<Effect>;
  20500. private _onAfterRenderObserver;
  20501. /**
  20502. * A function that is added to the onAfterRenderObservable
  20503. */
  20504. set onAfterRender(callback: (efect: Effect) => void);
  20505. /**
  20506. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  20507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20508. */
  20509. get inputTexture(): InternalTexture;
  20510. set inputTexture(value: InternalTexture);
  20511. /**
  20512. * Gets the camera which post process is applied to.
  20513. * @returns The camera the post process is applied to.
  20514. */
  20515. getCamera(): Camera;
  20516. /**
  20517. * Gets the texel size of the postprocess.
  20518. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20519. */
  20520. get texelSize(): Vector2;
  20521. /**
  20522. * Creates a new instance PostProcess
  20523. * @param name The name of the PostProcess.
  20524. * @param fragmentUrl The url of the fragment shader to be used.
  20525. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20526. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20527. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20528. * @param camera The camera to apply the render pass to.
  20529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20530. * @param engine The engine which the post process will be applied. (default: current engine)
  20531. * @param reusable If the post process can be reused on the same frame. (default: false)
  20532. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20533. * @param textureType Type of textures used when performing the post process. (default: 0)
  20534. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20535. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20536. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20537. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20538. */
  20539. constructor(
  20540. /** Name of the PostProcess. */
  20541. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20542. /**
  20543. * Gets a string idenfifying the name of the class
  20544. * @returns "PostProcess" string
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Gets the engine which this post process belongs to.
  20549. * @returns The engine the post process was enabled with.
  20550. */
  20551. getEngine(): Engine;
  20552. /**
  20553. * The effect that is created when initializing the post process.
  20554. * @returns The created effect corresponding the the postprocess.
  20555. */
  20556. getEffect(): Effect;
  20557. /**
  20558. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20559. * @param postProcess The post process to share the output with.
  20560. * @returns This post process.
  20561. */
  20562. shareOutputWith(postProcess: PostProcess): PostProcess;
  20563. /**
  20564. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20565. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20566. */
  20567. useOwnOutput(): void;
  20568. /**
  20569. * Updates the effect with the current post process compile time values and recompiles the shader.
  20570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20573. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20574. * @param onCompiled Called when the shader has been compiled.
  20575. * @param onError Called if there is an error when compiling a shader.
  20576. */
  20577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20578. /**
  20579. * The post process is reusable if it can be used multiple times within one frame.
  20580. * @returns If the post process is reusable
  20581. */
  20582. isReusable(): boolean;
  20583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20584. markTextureDirty(): void;
  20585. /**
  20586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20587. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20591. * @returns The target texture that was bound to be written to.
  20592. */
  20593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20594. /**
  20595. * If the post process is supported.
  20596. */
  20597. get isSupported(): boolean;
  20598. /**
  20599. * The aspect ratio of the output texture.
  20600. */
  20601. get aspectRatio(): number;
  20602. /**
  20603. * Get a value indicating if the post-process is ready to be used
  20604. * @returns true if the post-process is ready (shader is compiled)
  20605. */
  20606. isReady(): boolean;
  20607. /**
  20608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20610. */
  20611. apply(): Nullable<Effect>;
  20612. private _disposeTextures;
  20613. /**
  20614. * Disposes the post process.
  20615. * @param camera The camera to dispose the post process on.
  20616. */
  20617. dispose(camera?: Camera): void;
  20618. }
  20619. }
  20620. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20621. /** @hidden */
  20622. export var kernelBlurVaryingDeclaration: {
  20623. name: string;
  20624. shader: string;
  20625. };
  20626. }
  20627. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20628. /** @hidden */
  20629. export var kernelBlurFragment: {
  20630. name: string;
  20631. shader: string;
  20632. };
  20633. }
  20634. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20635. /** @hidden */
  20636. export var kernelBlurFragment2: {
  20637. name: string;
  20638. shader: string;
  20639. };
  20640. }
  20641. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20642. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20643. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20644. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20645. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20646. /** @hidden */
  20647. export var kernelBlurPixelShader: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20653. /** @hidden */
  20654. export var kernelBlurVertex: {
  20655. name: string;
  20656. shader: string;
  20657. };
  20658. }
  20659. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20660. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20661. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20662. /** @hidden */
  20663. export var kernelBlurVertexShader: {
  20664. name: string;
  20665. shader: string;
  20666. };
  20667. }
  20668. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20669. import { Vector2 } from "babylonjs/Maths/math.vector";
  20670. import { Nullable } from "babylonjs/types";
  20671. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20672. import { Camera } from "babylonjs/Cameras/camera";
  20673. import { Effect } from "babylonjs/Materials/effect";
  20674. import { Engine } from "babylonjs/Engines/engine";
  20675. import "babylonjs/Shaders/kernelBlur.fragment";
  20676. import "babylonjs/Shaders/kernelBlur.vertex";
  20677. /**
  20678. * The Blur Post Process which blurs an image based on a kernel and direction.
  20679. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20680. */
  20681. export class BlurPostProcess extends PostProcess {
  20682. /** The direction in which to blur the image. */
  20683. direction: Vector2;
  20684. private blockCompilation;
  20685. protected _kernel: number;
  20686. protected _idealKernel: number;
  20687. protected _packedFloat: boolean;
  20688. private _staticDefines;
  20689. /**
  20690. * Sets the length in pixels of the blur sample region
  20691. */
  20692. set kernel(v: number);
  20693. /**
  20694. * Gets the length in pixels of the blur sample region
  20695. */
  20696. get kernel(): number;
  20697. /**
  20698. * Sets wether or not the blur needs to unpack/repack floats
  20699. */
  20700. set packedFloat(v: boolean);
  20701. /**
  20702. * Gets wether or not the blur is unpacking/repacking floats
  20703. */
  20704. get packedFloat(): boolean;
  20705. /**
  20706. * Creates a new instance BlurPostProcess
  20707. * @param name The name of the effect.
  20708. * @param direction The direction in which to blur the image.
  20709. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20710. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20711. * @param camera The camera to apply the render pass to.
  20712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20713. * @param engine The engine which the post process will be applied. (default: current engine)
  20714. * @param reusable If the post process can be reused on the same frame. (default: false)
  20715. * @param textureType Type of textures used when performing the post process. (default: 0)
  20716. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20717. */
  20718. constructor(name: string,
  20719. /** The direction in which to blur the image. */
  20720. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20721. /**
  20722. * Updates the effect with the current post process compile time values and recompiles the shader.
  20723. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20724. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20725. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20726. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20727. * @param onCompiled Called when the shader has been compiled.
  20728. * @param onError Called if there is an error when compiling a shader.
  20729. */
  20730. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20731. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20732. /**
  20733. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20734. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20735. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20736. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20737. * The gaps between physical kernels are compensated for in the weighting of the samples
  20738. * @param idealKernel Ideal blur kernel.
  20739. * @return Nearest best kernel.
  20740. */
  20741. protected _nearestBestKernel(idealKernel: number): number;
  20742. /**
  20743. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20744. * @param x The point on the Gaussian distribution to sample.
  20745. * @return the value of the Gaussian function at x.
  20746. */
  20747. protected _gaussianWeight(x: number): number;
  20748. /**
  20749. * Generates a string that can be used as a floating point number in GLSL.
  20750. * @param x Value to print.
  20751. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20752. * @return GLSL float string.
  20753. */
  20754. protected _glslFloat(x: number, decimalFigures?: number): string;
  20755. }
  20756. }
  20757. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20758. import { Scene } from "babylonjs/scene";
  20759. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20760. import { Plane } from "babylonjs/Maths/math.plane";
  20761. /**
  20762. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20763. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20764. * You can then easily use it as a reflectionTexture on a flat surface.
  20765. * In case the surface is not a plane, please consider relying on reflection probes.
  20766. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20767. */
  20768. export class MirrorTexture extends RenderTargetTexture {
  20769. private scene;
  20770. /**
  20771. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20772. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20773. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20774. */
  20775. mirrorPlane: Plane;
  20776. /**
  20777. * Define the blur ratio used to blur the reflection if needed.
  20778. */
  20779. set blurRatio(value: number);
  20780. get blurRatio(): number;
  20781. /**
  20782. * Define the adaptive blur kernel used to blur the reflection if needed.
  20783. * This will autocompute the closest best match for the `blurKernel`
  20784. */
  20785. set adaptiveBlurKernel(value: number);
  20786. /**
  20787. * Define the blur kernel used to blur the reflection if needed.
  20788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20789. */
  20790. set blurKernel(value: number);
  20791. /**
  20792. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20794. */
  20795. set blurKernelX(value: number);
  20796. get blurKernelX(): number;
  20797. /**
  20798. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20800. */
  20801. set blurKernelY(value: number);
  20802. get blurKernelY(): number;
  20803. private _autoComputeBlurKernel;
  20804. protected _onRatioRescale(): void;
  20805. private _updateGammaSpace;
  20806. private _imageProcessingConfigChangeObserver;
  20807. private _transformMatrix;
  20808. private _mirrorMatrix;
  20809. private _savedViewMatrix;
  20810. private _blurX;
  20811. private _blurY;
  20812. private _adaptiveBlurKernel;
  20813. private _blurKernelX;
  20814. private _blurKernelY;
  20815. private _blurRatio;
  20816. /**
  20817. * Instantiates a Mirror Texture.
  20818. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20819. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20820. * You can then easily use it as a reflectionTexture on a flat surface.
  20821. * In case the surface is not a plane, please consider relying on reflection probes.
  20822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20823. * @param name
  20824. * @param size
  20825. * @param scene
  20826. * @param generateMipMaps
  20827. * @param type
  20828. * @param samplingMode
  20829. * @param generateDepthBuffer
  20830. */
  20831. constructor(name: string, size: number | {
  20832. width: number;
  20833. height: number;
  20834. } | {
  20835. ratio: number;
  20836. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20837. private _preparePostProcesses;
  20838. /**
  20839. * Clone the mirror texture.
  20840. * @returns the cloned texture
  20841. */
  20842. clone(): MirrorTexture;
  20843. /**
  20844. * Serialize the texture to a JSON representation you could use in Parse later on
  20845. * @returns the serialized JSON representation
  20846. */
  20847. serialize(): any;
  20848. /**
  20849. * Dispose the texture and release its associated resources.
  20850. */
  20851. dispose(): void;
  20852. }
  20853. }
  20854. declare module "babylonjs/Materials/Textures/texture" {
  20855. import { Observable } from "babylonjs/Misc/observable";
  20856. import { Nullable } from "babylonjs/types";
  20857. import { Matrix } from "babylonjs/Maths/math.vector";
  20858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20859. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20860. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20861. import { Scene } from "babylonjs/scene";
  20862. /**
  20863. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20864. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20865. */
  20866. export class Texture extends BaseTexture {
  20867. /**
  20868. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20869. */
  20870. static SerializeBuffers: boolean;
  20871. /** @hidden */
  20872. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20873. /** @hidden */
  20874. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20875. /** @hidden */
  20876. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20877. /** nearest is mag = nearest and min = nearest and mip = linear */
  20878. static readonly NEAREST_SAMPLINGMODE: number;
  20879. /** nearest is mag = nearest and min = nearest and mip = linear */
  20880. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20881. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20882. static readonly BILINEAR_SAMPLINGMODE: number;
  20883. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20884. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20885. /** Trilinear is mag = linear and min = linear and mip = linear */
  20886. static readonly TRILINEAR_SAMPLINGMODE: number;
  20887. /** Trilinear is mag = linear and min = linear and mip = linear */
  20888. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20889. /** mag = nearest and min = nearest and mip = nearest */
  20890. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20891. /** mag = nearest and min = linear and mip = nearest */
  20892. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20893. /** mag = nearest and min = linear and mip = linear */
  20894. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20895. /** mag = nearest and min = linear and mip = none */
  20896. static readonly NEAREST_LINEAR: number;
  20897. /** mag = nearest and min = nearest and mip = none */
  20898. static readonly NEAREST_NEAREST: number;
  20899. /** mag = linear and min = nearest and mip = nearest */
  20900. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20901. /** mag = linear and min = nearest and mip = linear */
  20902. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20903. /** mag = linear and min = linear and mip = none */
  20904. static readonly LINEAR_LINEAR: number;
  20905. /** mag = linear and min = nearest and mip = none */
  20906. static readonly LINEAR_NEAREST: number;
  20907. /** Explicit coordinates mode */
  20908. static readonly EXPLICIT_MODE: number;
  20909. /** Spherical coordinates mode */
  20910. static readonly SPHERICAL_MODE: number;
  20911. /** Planar coordinates mode */
  20912. static readonly PLANAR_MODE: number;
  20913. /** Cubic coordinates mode */
  20914. static readonly CUBIC_MODE: number;
  20915. /** Projection coordinates mode */
  20916. static readonly PROJECTION_MODE: number;
  20917. /** Inverse Cubic coordinates mode */
  20918. static readonly SKYBOX_MODE: number;
  20919. /** Inverse Cubic coordinates mode */
  20920. static readonly INVCUBIC_MODE: number;
  20921. /** Equirectangular coordinates mode */
  20922. static readonly EQUIRECTANGULAR_MODE: number;
  20923. /** Equirectangular Fixed coordinates mode */
  20924. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20925. /** Equirectangular Fixed Mirrored coordinates mode */
  20926. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20927. /** Texture is not repeating outside of 0..1 UVs */
  20928. static readonly CLAMP_ADDRESSMODE: number;
  20929. /** Texture is repeating outside of 0..1 UVs */
  20930. static readonly WRAP_ADDRESSMODE: number;
  20931. /** Texture is repeating and mirrored */
  20932. static readonly MIRROR_ADDRESSMODE: number;
  20933. /**
  20934. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20935. */
  20936. static UseSerializedUrlIfAny: boolean;
  20937. /**
  20938. * Define the url of the texture.
  20939. */
  20940. url: Nullable<string>;
  20941. /**
  20942. * Define an offset on the texture to offset the u coordinates of the UVs
  20943. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20944. */
  20945. uOffset: number;
  20946. /**
  20947. * Define an offset on the texture to offset the v coordinates of the UVs
  20948. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20949. */
  20950. vOffset: number;
  20951. /**
  20952. * Define an offset on the texture to scale the u coordinates of the UVs
  20953. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20954. */
  20955. uScale: number;
  20956. /**
  20957. * Define an offset on the texture to scale the v coordinates of the UVs
  20958. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20959. */
  20960. vScale: number;
  20961. /**
  20962. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20963. * @see http://doc.babylonjs.com/how_to/more_materials
  20964. */
  20965. uAng: number;
  20966. /**
  20967. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20968. * @see http://doc.babylonjs.com/how_to/more_materials
  20969. */
  20970. vAng: number;
  20971. /**
  20972. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20973. * @see http://doc.babylonjs.com/how_to/more_materials
  20974. */
  20975. wAng: number;
  20976. /**
  20977. * Defines the center of rotation (U)
  20978. */
  20979. uRotationCenter: number;
  20980. /**
  20981. * Defines the center of rotation (V)
  20982. */
  20983. vRotationCenter: number;
  20984. /**
  20985. * Defines the center of rotation (W)
  20986. */
  20987. wRotationCenter: number;
  20988. /**
  20989. * Are mip maps generated for this texture or not.
  20990. */
  20991. get noMipmap(): boolean;
  20992. /**
  20993. * List of inspectable custom properties (used by the Inspector)
  20994. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20995. */
  20996. inspectableCustomProperties: Nullable<IInspectable[]>;
  20997. private _noMipmap;
  20998. /** @hidden */
  20999. _invertY: boolean;
  21000. private _rowGenerationMatrix;
  21001. private _cachedTextureMatrix;
  21002. private _projectionModeMatrix;
  21003. private _t0;
  21004. private _t1;
  21005. private _t2;
  21006. private _cachedUOffset;
  21007. private _cachedVOffset;
  21008. private _cachedUScale;
  21009. private _cachedVScale;
  21010. private _cachedUAng;
  21011. private _cachedVAng;
  21012. private _cachedWAng;
  21013. private _cachedProjectionMatrixId;
  21014. private _cachedCoordinatesMode;
  21015. /** @hidden */
  21016. protected _initialSamplingMode: number;
  21017. /** @hidden */
  21018. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21019. private _deleteBuffer;
  21020. protected _format: Nullable<number>;
  21021. private _delayedOnLoad;
  21022. private _delayedOnError;
  21023. private _mimeType?;
  21024. /**
  21025. * Observable triggered once the texture has been loaded.
  21026. */
  21027. onLoadObservable: Observable<Texture>;
  21028. protected _isBlocking: boolean;
  21029. /**
  21030. * Is the texture preventing material to render while loading.
  21031. * If false, a default texture will be used instead of the loading one during the preparation step.
  21032. */
  21033. set isBlocking(value: boolean);
  21034. get isBlocking(): boolean;
  21035. /**
  21036. * Get the current sampling mode associated with the texture.
  21037. */
  21038. get samplingMode(): number;
  21039. /**
  21040. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21041. */
  21042. get invertY(): boolean;
  21043. /**
  21044. * Instantiates a new texture.
  21045. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21046. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21047. * @param url defines the url of the picture to load as a texture
  21048. * @param scene defines the scene or engine the texture will belong to
  21049. * @param noMipmap defines if the texture will require mip maps or not
  21050. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21051. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21052. * @param onLoad defines a callback triggered when the texture has been loaded
  21053. * @param onError defines a callback triggered when an error occurred during the loading session
  21054. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21055. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21056. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21057. * @param mimeType defines an optional mime type information
  21058. */
  21059. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  21060. /**
  21061. * Update the url (and optional buffer) of this texture if url was null during construction.
  21062. * @param url the url of the texture
  21063. * @param buffer the buffer of the texture (defaults to null)
  21064. * @param onLoad callback called when the texture is loaded (defaults to null)
  21065. */
  21066. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21067. /**
  21068. * Finish the loading sequence of a texture flagged as delayed load.
  21069. * @hidden
  21070. */
  21071. delayLoad(): void;
  21072. private _prepareRowForTextureGeneration;
  21073. /**
  21074. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21075. * @returns the transform matrix of the texture.
  21076. */
  21077. getTextureMatrix(uBase?: number): Matrix;
  21078. /**
  21079. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21080. * @returns The reflection texture transform
  21081. */
  21082. getReflectionTextureMatrix(): Matrix;
  21083. /**
  21084. * Clones the texture.
  21085. * @returns the cloned texture
  21086. */
  21087. clone(): Texture;
  21088. /**
  21089. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21090. * @returns The JSON representation of the texture
  21091. */
  21092. serialize(): any;
  21093. /**
  21094. * Get the current class name of the texture useful for serialization or dynamic coding.
  21095. * @returns "Texture"
  21096. */
  21097. getClassName(): string;
  21098. /**
  21099. * Dispose the texture and release its associated resources.
  21100. */
  21101. dispose(): void;
  21102. /**
  21103. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21104. * @param parsedTexture Define the JSON representation of the texture
  21105. * @param scene Define the scene the parsed texture should be instantiated in
  21106. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21107. * @returns The parsed texture if successful
  21108. */
  21109. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21110. /**
  21111. * Creates a texture from its base 64 representation.
  21112. * @param data Define the base64 payload without the data: prefix
  21113. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21114. * @param scene Define the scene the texture should belong to
  21115. * @param noMipmap Forces the texture to not create mip map information if true
  21116. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21117. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21118. * @param onLoad define a callback triggered when the texture has been loaded
  21119. * @param onError define a callback triggered when an error occurred during the loading session
  21120. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21121. * @returns the created texture
  21122. */
  21123. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21124. /**
  21125. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21126. * @param data Define the base64 payload without the data: prefix
  21127. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21128. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21129. * @param scene Define the scene the texture should belong to
  21130. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21131. * @param noMipmap Forces the texture to not create mip map information if true
  21132. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21133. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21134. * @param onLoad define a callback triggered when the texture has been loaded
  21135. * @param onError define a callback triggered when an error occurred during the loading session
  21136. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21137. * @returns the created texture
  21138. */
  21139. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  21140. }
  21141. }
  21142. declare module "babylonjs/PostProcesses/postProcessManager" {
  21143. import { Nullable } from "babylonjs/types";
  21144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21146. import { Scene } from "babylonjs/scene";
  21147. /**
  21148. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21149. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21150. */
  21151. export class PostProcessManager {
  21152. private _scene;
  21153. private _indexBuffer;
  21154. private _vertexBuffers;
  21155. /**
  21156. * Creates a new instance PostProcess
  21157. * @param scene The scene that the post process is associated with.
  21158. */
  21159. constructor(scene: Scene);
  21160. private _prepareBuffers;
  21161. private _buildIndexBuffer;
  21162. /**
  21163. * Rebuilds the vertex buffers of the manager.
  21164. * @hidden
  21165. */
  21166. _rebuild(): void;
  21167. /**
  21168. * Prepares a frame to be run through a post process.
  21169. * @param sourceTexture The input texture to the post procesess. (default: null)
  21170. * @param postProcesses An array of post processes to be run. (default: null)
  21171. * @returns True if the post processes were able to be run.
  21172. * @hidden
  21173. */
  21174. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21175. /**
  21176. * Manually render a set of post processes to a texture.
  21177. * @param postProcesses An array of post processes to be run.
  21178. * @param targetTexture The target texture to render to.
  21179. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21180. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21181. * @param lodLevel defines which lod of the texture to render to
  21182. */
  21183. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21184. /**
  21185. * Finalize the result of the output of the postprocesses.
  21186. * @param doNotPresent If true the result will not be displayed to the screen.
  21187. * @param targetTexture The target texture to render to.
  21188. * @param faceIndex The index of the face to bind the target texture to.
  21189. * @param postProcesses The array of post processes to render.
  21190. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21191. * @hidden
  21192. */
  21193. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21194. /**
  21195. * Disposes of the post process manager.
  21196. */
  21197. dispose(): void;
  21198. }
  21199. }
  21200. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21201. import { Observable } from "babylonjs/Misc/observable";
  21202. import { SmartArray } from "babylonjs/Misc/smartArray";
  21203. import { Nullable, Immutable } from "babylonjs/types";
  21204. import { Camera } from "babylonjs/Cameras/camera";
  21205. import { Scene } from "babylonjs/scene";
  21206. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21207. import { Color4 } from "babylonjs/Maths/math.color";
  21208. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21212. import { Texture } from "babylonjs/Materials/Textures/texture";
  21213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21214. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21215. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21216. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21217. import { Engine } from "babylonjs/Engines/engine";
  21218. /**
  21219. * This Helps creating a texture that will be created from a camera in your scene.
  21220. * It is basically a dynamic texture that could be used to create special effects for instance.
  21221. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21222. */
  21223. export class RenderTargetTexture extends Texture {
  21224. isCube: boolean;
  21225. /**
  21226. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21227. */
  21228. static readonly REFRESHRATE_RENDER_ONCE: number;
  21229. /**
  21230. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21231. */
  21232. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21233. /**
  21234. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21235. * the central point of your effect and can save a lot of performances.
  21236. */
  21237. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21238. /**
  21239. * Use this predicate to dynamically define the list of mesh you want to render.
  21240. * If set, the renderList property will be overwritten.
  21241. */
  21242. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21243. private _renderList;
  21244. /**
  21245. * Use this list to define the list of mesh you want to render.
  21246. */
  21247. get renderList(): Nullable<Array<AbstractMesh>>;
  21248. set renderList(value: Nullable<Array<AbstractMesh>>);
  21249. /**
  21250. * Use this function to overload the renderList array at rendering time.
  21251. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21252. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21253. * the cube (if the RTT is a cube, else layerOrFace=0).
  21254. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21255. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21256. * hold dummy elements!
  21257. */
  21258. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21259. private _hookArray;
  21260. /**
  21261. * Define if particles should be rendered in your texture.
  21262. */
  21263. renderParticles: boolean;
  21264. /**
  21265. * Define if sprites should be rendered in your texture.
  21266. */
  21267. renderSprites: boolean;
  21268. /**
  21269. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21270. */
  21271. coordinatesMode: number;
  21272. /**
  21273. * Define the camera used to render the texture.
  21274. */
  21275. activeCamera: Nullable<Camera>;
  21276. /**
  21277. * Override the mesh isReady function with your own one.
  21278. */
  21279. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21280. /**
  21281. * Override the render function of the texture with your own one.
  21282. */
  21283. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21284. /**
  21285. * Define if camera post processes should be use while rendering the texture.
  21286. */
  21287. useCameraPostProcesses: boolean;
  21288. /**
  21289. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21290. */
  21291. ignoreCameraViewport: boolean;
  21292. private _postProcessManager;
  21293. private _postProcesses;
  21294. private _resizeObserver;
  21295. /**
  21296. * An event triggered when the texture is unbind.
  21297. */
  21298. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21299. /**
  21300. * An event triggered when the texture is unbind.
  21301. */
  21302. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21303. private _onAfterUnbindObserver;
  21304. /**
  21305. * Set a after unbind callback in the texture.
  21306. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21307. */
  21308. set onAfterUnbind(callback: () => void);
  21309. /**
  21310. * An event triggered before rendering the texture
  21311. */
  21312. onBeforeRenderObservable: Observable<number>;
  21313. private _onBeforeRenderObserver;
  21314. /**
  21315. * Set a before render callback in the texture.
  21316. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21317. */
  21318. set onBeforeRender(callback: (faceIndex: number) => void);
  21319. /**
  21320. * An event triggered after rendering the texture
  21321. */
  21322. onAfterRenderObservable: Observable<number>;
  21323. private _onAfterRenderObserver;
  21324. /**
  21325. * Set a after render callback in the texture.
  21326. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21327. */
  21328. set onAfterRender(callback: (faceIndex: number) => void);
  21329. /**
  21330. * An event triggered after the texture clear
  21331. */
  21332. onClearObservable: Observable<Engine>;
  21333. private _onClearObserver;
  21334. /**
  21335. * Set a clear callback in the texture.
  21336. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21337. */
  21338. set onClear(callback: (Engine: Engine) => void);
  21339. /**
  21340. * An event triggered when the texture is resized.
  21341. */
  21342. onResizeObservable: Observable<RenderTargetTexture>;
  21343. /**
  21344. * Define the clear color of the Render Target if it should be different from the scene.
  21345. */
  21346. clearColor: Color4;
  21347. protected _size: number | {
  21348. width: number;
  21349. height: number;
  21350. layers?: number;
  21351. };
  21352. protected _initialSizeParameter: number | {
  21353. width: number;
  21354. height: number;
  21355. } | {
  21356. ratio: number;
  21357. };
  21358. protected _sizeRatio: Nullable<number>;
  21359. /** @hidden */
  21360. _generateMipMaps: boolean;
  21361. protected _renderingManager: RenderingManager;
  21362. /** @hidden */
  21363. _waitingRenderList: string[];
  21364. protected _doNotChangeAspectRatio: boolean;
  21365. protected _currentRefreshId: number;
  21366. protected _refreshRate: number;
  21367. protected _textureMatrix: Matrix;
  21368. protected _samples: number;
  21369. protected _renderTargetOptions: RenderTargetCreationOptions;
  21370. /**
  21371. * Gets render target creation options that were used.
  21372. */
  21373. get renderTargetOptions(): RenderTargetCreationOptions;
  21374. protected _engine: Engine;
  21375. protected _onRatioRescale(): void;
  21376. /**
  21377. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21378. * It must define where the camera used to render the texture is set
  21379. */
  21380. boundingBoxPosition: Vector3;
  21381. private _boundingBoxSize;
  21382. /**
  21383. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21384. * When defined, the cubemap will switch to local mode
  21385. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21386. * @example https://www.babylonjs-playground.com/#RNASML
  21387. */
  21388. set boundingBoxSize(value: Vector3);
  21389. get boundingBoxSize(): Vector3;
  21390. /**
  21391. * In case the RTT has been created with a depth texture, get the associated
  21392. * depth texture.
  21393. * Otherwise, return null.
  21394. */
  21395. get depthStencilTexture(): Nullable<InternalTexture>;
  21396. /**
  21397. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21398. * or used a shadow, depth texture...
  21399. * @param name The friendly name of the texture
  21400. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  21401. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21402. * @param generateMipMaps True if mip maps need to be generated after render.
  21403. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21404. * @param type The type of the buffer in the RTT (int, half float, float...)
  21405. * @param isCube True if a cube texture needs to be created
  21406. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21407. * @param generateDepthBuffer True to generate a depth buffer
  21408. * @param generateStencilBuffer True to generate a stencil buffer
  21409. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21410. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21411. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21412. */
  21413. constructor(name: string, size: number | {
  21414. width: number;
  21415. height: number;
  21416. layers?: number;
  21417. } | {
  21418. ratio: number;
  21419. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21420. /**
  21421. * Creates a depth stencil texture.
  21422. * This is only available in WebGL 2 or with the depth texture extension available.
  21423. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21424. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21425. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21426. */
  21427. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21428. private _processSizeParameter;
  21429. /**
  21430. * Define the number of samples to use in case of MSAA.
  21431. * It defaults to one meaning no MSAA has been enabled.
  21432. */
  21433. get samples(): number;
  21434. set samples(value: number);
  21435. /**
  21436. * Resets the refresh counter of the texture and start bak from scratch.
  21437. * Could be useful to regenerate the texture if it is setup to render only once.
  21438. */
  21439. resetRefreshCounter(): void;
  21440. /**
  21441. * Define the refresh rate of the texture or the rendering frequency.
  21442. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21443. */
  21444. get refreshRate(): number;
  21445. set refreshRate(value: number);
  21446. /**
  21447. * Adds a post process to the render target rendering passes.
  21448. * @param postProcess define the post process to add
  21449. */
  21450. addPostProcess(postProcess: PostProcess): void;
  21451. /**
  21452. * Clear all the post processes attached to the render target
  21453. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21454. */
  21455. clearPostProcesses(dispose?: boolean): void;
  21456. /**
  21457. * Remove one of the post process from the list of attached post processes to the texture
  21458. * @param postProcess define the post process to remove from the list
  21459. */
  21460. removePostProcess(postProcess: PostProcess): void;
  21461. /** @hidden */
  21462. _shouldRender(): boolean;
  21463. /**
  21464. * Gets the actual render size of the texture.
  21465. * @returns the width of the render size
  21466. */
  21467. getRenderSize(): number;
  21468. /**
  21469. * Gets the actual render width of the texture.
  21470. * @returns the width of the render size
  21471. */
  21472. getRenderWidth(): number;
  21473. /**
  21474. * Gets the actual render height of the texture.
  21475. * @returns the height of the render size
  21476. */
  21477. getRenderHeight(): number;
  21478. /**
  21479. * Gets the actual number of layers of the texture.
  21480. * @returns the number of layers
  21481. */
  21482. getRenderLayers(): number;
  21483. /**
  21484. * Get if the texture can be rescaled or not.
  21485. */
  21486. get canRescale(): boolean;
  21487. /**
  21488. * Resize the texture using a ratio.
  21489. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21490. */
  21491. scale(ratio: number): void;
  21492. /**
  21493. * Get the texture reflection matrix used to rotate/transform the reflection.
  21494. * @returns the reflection matrix
  21495. */
  21496. getReflectionTextureMatrix(): Matrix;
  21497. /**
  21498. * Resize the texture to a new desired size.
  21499. * Be carrefull as it will recreate all the data in the new texture.
  21500. * @param size Define the new size. It can be:
  21501. * - a number for squared texture,
  21502. * - an object containing { width: number, height: number }
  21503. * - or an object containing a ratio { ratio: number }
  21504. */
  21505. resize(size: number | {
  21506. width: number;
  21507. height: number;
  21508. } | {
  21509. ratio: number;
  21510. }): void;
  21511. private _defaultRenderListPrepared;
  21512. /**
  21513. * Renders all the objects from the render list into the texture.
  21514. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21515. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21516. */
  21517. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21518. private _bestReflectionRenderTargetDimension;
  21519. private _prepareRenderingManager;
  21520. /**
  21521. * @hidden
  21522. * @param faceIndex face index to bind to if this is a cubetexture
  21523. * @param layer defines the index of the texture to bind in the array
  21524. */
  21525. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21526. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21527. private renderToTarget;
  21528. /**
  21529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21530. * This allowed control for front to back rendering or reversly depending of the special needs.
  21531. *
  21532. * @param renderingGroupId The rendering group id corresponding to its index
  21533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21536. */
  21537. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  21538. /**
  21539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21540. *
  21541. * @param renderingGroupId The rendering group id corresponding to its index
  21542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21543. */
  21544. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21545. /**
  21546. * Clones the texture.
  21547. * @returns the cloned texture
  21548. */
  21549. clone(): RenderTargetTexture;
  21550. /**
  21551. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21552. * @returns The JSON representation of the texture
  21553. */
  21554. serialize(): any;
  21555. /**
  21556. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21557. */
  21558. disposeFramebufferObjects(): void;
  21559. /**
  21560. * Dispose the texture and release its associated resources.
  21561. */
  21562. dispose(): void;
  21563. /** @hidden */
  21564. _rebuild(): void;
  21565. /**
  21566. * Clear the info related to rendering groups preventing retention point in material dispose.
  21567. */
  21568. freeRenderingGroups(): void;
  21569. /**
  21570. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21571. * @returns the view count
  21572. */
  21573. getViewCount(): number;
  21574. }
  21575. }
  21576. declare module "babylonjs/Materials/material" {
  21577. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21578. import { SmartArray } from "babylonjs/Misc/smartArray";
  21579. import { Observable } from "babylonjs/Misc/observable";
  21580. import { Nullable } from "babylonjs/types";
  21581. import { Scene } from "babylonjs/scene";
  21582. import { Matrix } from "babylonjs/Maths/math.vector";
  21583. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21585. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21586. import { Effect } from "babylonjs/Materials/effect";
  21587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21589. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21590. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21591. import { Mesh } from "babylonjs/Meshes/mesh";
  21592. import { Animation } from "babylonjs/Animations/animation";
  21593. /**
  21594. * Options for compiling materials.
  21595. */
  21596. export interface IMaterialCompilationOptions {
  21597. /**
  21598. * Defines whether clip planes are enabled.
  21599. */
  21600. clipPlane: boolean;
  21601. /**
  21602. * Defines whether instances are enabled.
  21603. */
  21604. useInstances: boolean;
  21605. }
  21606. /**
  21607. * Base class for the main features of a material in Babylon.js
  21608. */
  21609. export class Material implements IAnimatable {
  21610. /**
  21611. * Returns the triangle fill mode
  21612. */
  21613. static readonly TriangleFillMode: number;
  21614. /**
  21615. * Returns the wireframe mode
  21616. */
  21617. static readonly WireFrameFillMode: number;
  21618. /**
  21619. * Returns the point fill mode
  21620. */
  21621. static readonly PointFillMode: number;
  21622. /**
  21623. * Returns the point list draw mode
  21624. */
  21625. static readonly PointListDrawMode: number;
  21626. /**
  21627. * Returns the line list draw mode
  21628. */
  21629. static readonly LineListDrawMode: number;
  21630. /**
  21631. * Returns the line loop draw mode
  21632. */
  21633. static readonly LineLoopDrawMode: number;
  21634. /**
  21635. * Returns the line strip draw mode
  21636. */
  21637. static readonly LineStripDrawMode: number;
  21638. /**
  21639. * Returns the triangle strip draw mode
  21640. */
  21641. static readonly TriangleStripDrawMode: number;
  21642. /**
  21643. * Returns the triangle fan draw mode
  21644. */
  21645. static readonly TriangleFanDrawMode: number;
  21646. /**
  21647. * Stores the clock-wise side orientation
  21648. */
  21649. static readonly ClockWiseSideOrientation: number;
  21650. /**
  21651. * Stores the counter clock-wise side orientation
  21652. */
  21653. static readonly CounterClockWiseSideOrientation: number;
  21654. /**
  21655. * The dirty texture flag value
  21656. */
  21657. static readonly TextureDirtyFlag: number;
  21658. /**
  21659. * The dirty light flag value
  21660. */
  21661. static readonly LightDirtyFlag: number;
  21662. /**
  21663. * The dirty fresnel flag value
  21664. */
  21665. static readonly FresnelDirtyFlag: number;
  21666. /**
  21667. * The dirty attribute flag value
  21668. */
  21669. static readonly AttributesDirtyFlag: number;
  21670. /**
  21671. * The dirty misc flag value
  21672. */
  21673. static readonly MiscDirtyFlag: number;
  21674. /**
  21675. * The all dirty flag value
  21676. */
  21677. static readonly AllDirtyFlag: number;
  21678. /**
  21679. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21680. */
  21681. static readonly MATERIAL_OPAQUE: number;
  21682. /**
  21683. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21684. */
  21685. static readonly MATERIAL_ALPHATEST: number;
  21686. /**
  21687. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21688. */
  21689. static readonly MATERIAL_ALPHABLEND: number;
  21690. /**
  21691. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21692. * They are also discarded below the alpha cutoff threshold to improve performances.
  21693. */
  21694. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21695. /**
  21696. * The ID of the material
  21697. */
  21698. id: string;
  21699. /**
  21700. * Gets or sets the unique id of the material
  21701. */
  21702. uniqueId: number;
  21703. /**
  21704. * The name of the material
  21705. */
  21706. name: string;
  21707. /**
  21708. * Gets or sets user defined metadata
  21709. */
  21710. metadata: any;
  21711. /**
  21712. * For internal use only. Please do not use.
  21713. */
  21714. reservedDataStore: any;
  21715. /**
  21716. * Specifies if the ready state should be checked on each call
  21717. */
  21718. checkReadyOnEveryCall: boolean;
  21719. /**
  21720. * Specifies if the ready state should be checked once
  21721. */
  21722. checkReadyOnlyOnce: boolean;
  21723. /**
  21724. * The state of the material
  21725. */
  21726. state: string;
  21727. /**
  21728. * The alpha value of the material
  21729. */
  21730. protected _alpha: number;
  21731. /**
  21732. * List of inspectable custom properties (used by the Inspector)
  21733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21734. */
  21735. inspectableCustomProperties: IInspectable[];
  21736. /**
  21737. * Sets the alpha value of the material
  21738. */
  21739. set alpha(value: number);
  21740. /**
  21741. * Gets the alpha value of the material
  21742. */
  21743. get alpha(): number;
  21744. /**
  21745. * Specifies if back face culling is enabled
  21746. */
  21747. protected _backFaceCulling: boolean;
  21748. /**
  21749. * Sets the back-face culling state
  21750. */
  21751. set backFaceCulling(value: boolean);
  21752. /**
  21753. * Gets the back-face culling state
  21754. */
  21755. get backFaceCulling(): boolean;
  21756. /**
  21757. * Stores the value for side orientation
  21758. */
  21759. sideOrientation: number;
  21760. /**
  21761. * Callback triggered when the material is compiled
  21762. */
  21763. onCompiled: Nullable<(effect: Effect) => void>;
  21764. /**
  21765. * Callback triggered when an error occurs
  21766. */
  21767. onError: Nullable<(effect: Effect, errors: string) => void>;
  21768. /**
  21769. * Callback triggered to get the render target textures
  21770. */
  21771. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21772. /**
  21773. * Gets a boolean indicating that current material needs to register RTT
  21774. */
  21775. get hasRenderTargetTextures(): boolean;
  21776. /**
  21777. * Specifies if the material should be serialized
  21778. */
  21779. doNotSerialize: boolean;
  21780. /**
  21781. * @hidden
  21782. */
  21783. _storeEffectOnSubMeshes: boolean;
  21784. /**
  21785. * Stores the animations for the material
  21786. */
  21787. animations: Nullable<Array<Animation>>;
  21788. /**
  21789. * An event triggered when the material is disposed
  21790. */
  21791. onDisposeObservable: Observable<Material>;
  21792. /**
  21793. * An observer which watches for dispose events
  21794. */
  21795. private _onDisposeObserver;
  21796. private _onUnBindObservable;
  21797. /**
  21798. * Called during a dispose event
  21799. */
  21800. set onDispose(callback: () => void);
  21801. private _onBindObservable;
  21802. /**
  21803. * An event triggered when the material is bound
  21804. */
  21805. get onBindObservable(): Observable<AbstractMesh>;
  21806. /**
  21807. * An observer which watches for bind events
  21808. */
  21809. private _onBindObserver;
  21810. /**
  21811. * Called during a bind event
  21812. */
  21813. set onBind(callback: (Mesh: AbstractMesh) => void);
  21814. /**
  21815. * An event triggered when the material is unbound
  21816. */
  21817. get onUnBindObservable(): Observable<Material>;
  21818. /**
  21819. * Stores the value of the alpha mode
  21820. */
  21821. private _alphaMode;
  21822. /**
  21823. * Sets the value of the alpha mode.
  21824. *
  21825. * | Value | Type | Description |
  21826. * | --- | --- | --- |
  21827. * | 0 | ALPHA_DISABLE | |
  21828. * | 1 | ALPHA_ADD | |
  21829. * | 2 | ALPHA_COMBINE | |
  21830. * | 3 | ALPHA_SUBTRACT | |
  21831. * | 4 | ALPHA_MULTIPLY | |
  21832. * | 5 | ALPHA_MAXIMIZED | |
  21833. * | 6 | ALPHA_ONEONE | |
  21834. * | 7 | ALPHA_PREMULTIPLIED | |
  21835. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21836. * | 9 | ALPHA_INTERPOLATE | |
  21837. * | 10 | ALPHA_SCREENMODE | |
  21838. *
  21839. */
  21840. set alphaMode(value: number);
  21841. /**
  21842. * Gets the value of the alpha mode
  21843. */
  21844. get alphaMode(): number;
  21845. /**
  21846. * Stores the state of the need depth pre-pass value
  21847. */
  21848. private _needDepthPrePass;
  21849. /**
  21850. * Sets the need depth pre-pass value
  21851. */
  21852. set needDepthPrePass(value: boolean);
  21853. /**
  21854. * Gets the depth pre-pass value
  21855. */
  21856. get needDepthPrePass(): boolean;
  21857. /**
  21858. * Specifies if depth writing should be disabled
  21859. */
  21860. disableDepthWrite: boolean;
  21861. /**
  21862. * Specifies if depth writing should be forced
  21863. */
  21864. forceDepthWrite: boolean;
  21865. /**
  21866. * Specifies the depth function that should be used. 0 means the default engine function
  21867. */
  21868. depthFunction: number;
  21869. /**
  21870. * Specifies if there should be a separate pass for culling
  21871. */
  21872. separateCullingPass: boolean;
  21873. /**
  21874. * Stores the state specifing if fog should be enabled
  21875. */
  21876. private _fogEnabled;
  21877. /**
  21878. * Sets the state for enabling fog
  21879. */
  21880. set fogEnabled(value: boolean);
  21881. /**
  21882. * Gets the value of the fog enabled state
  21883. */
  21884. get fogEnabled(): boolean;
  21885. /**
  21886. * Stores the size of points
  21887. */
  21888. pointSize: number;
  21889. /**
  21890. * Stores the z offset value
  21891. */
  21892. zOffset: number;
  21893. /**
  21894. * Gets a value specifying if wireframe mode is enabled
  21895. */
  21896. get wireframe(): boolean;
  21897. /**
  21898. * Sets the state of wireframe mode
  21899. */
  21900. set wireframe(value: boolean);
  21901. /**
  21902. * Gets the value specifying if point clouds are enabled
  21903. */
  21904. get pointsCloud(): boolean;
  21905. /**
  21906. * Sets the state of point cloud mode
  21907. */
  21908. set pointsCloud(value: boolean);
  21909. /**
  21910. * Gets the material fill mode
  21911. */
  21912. get fillMode(): number;
  21913. /**
  21914. * Sets the material fill mode
  21915. */
  21916. set fillMode(value: number);
  21917. /**
  21918. * @hidden
  21919. * Stores the effects for the material
  21920. */
  21921. _effect: Nullable<Effect>;
  21922. /**
  21923. * Specifies if uniform buffers should be used
  21924. */
  21925. private _useUBO;
  21926. /**
  21927. * Stores a reference to the scene
  21928. */
  21929. private _scene;
  21930. /**
  21931. * Stores the fill mode state
  21932. */
  21933. private _fillMode;
  21934. /**
  21935. * Specifies if the depth write state should be cached
  21936. */
  21937. private _cachedDepthWriteState;
  21938. /**
  21939. * Specifies if the depth function state should be cached
  21940. */
  21941. private _cachedDepthFunctionState;
  21942. /**
  21943. * Stores the uniform buffer
  21944. */
  21945. protected _uniformBuffer: UniformBuffer;
  21946. /** @hidden */
  21947. _indexInSceneMaterialArray: number;
  21948. /** @hidden */
  21949. meshMap: Nullable<{
  21950. [id: string]: AbstractMesh | undefined;
  21951. }>;
  21952. /**
  21953. * Creates a material instance
  21954. * @param name defines the name of the material
  21955. * @param scene defines the scene to reference
  21956. * @param doNotAdd specifies if the material should be added to the scene
  21957. */
  21958. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21959. /**
  21960. * Returns a string representation of the current material
  21961. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21962. * @returns a string with material information
  21963. */
  21964. toString(fullDetails?: boolean): string;
  21965. /**
  21966. * Gets the class name of the material
  21967. * @returns a string with the class name of the material
  21968. */
  21969. getClassName(): string;
  21970. /**
  21971. * Specifies if updates for the material been locked
  21972. */
  21973. get isFrozen(): boolean;
  21974. /**
  21975. * Locks updates for the material
  21976. */
  21977. freeze(): void;
  21978. /**
  21979. * Unlocks updates for the material
  21980. */
  21981. unfreeze(): void;
  21982. /**
  21983. * Specifies if the material is ready to be used
  21984. * @param mesh defines the mesh to check
  21985. * @param useInstances specifies if instances should be used
  21986. * @returns a boolean indicating if the material is ready to be used
  21987. */
  21988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21989. /**
  21990. * Specifies that the submesh is ready to be used
  21991. * @param mesh defines the mesh to check
  21992. * @param subMesh defines which submesh to check
  21993. * @param useInstances specifies that instances should be used
  21994. * @returns a boolean indicating that the submesh is ready or not
  21995. */
  21996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21997. /**
  21998. * Returns the material effect
  21999. * @returns the effect associated with the material
  22000. */
  22001. getEffect(): Nullable<Effect>;
  22002. /**
  22003. * Returns the current scene
  22004. * @returns a Scene
  22005. */
  22006. getScene(): Scene;
  22007. /**
  22008. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22009. */
  22010. protected _forceAlphaTest: boolean;
  22011. /**
  22012. * The transparency mode of the material.
  22013. */
  22014. protected _transparencyMode: Nullable<number>;
  22015. /**
  22016. * Gets the current transparency mode.
  22017. */
  22018. get transparencyMode(): Nullable<number>;
  22019. /**
  22020. * Sets the transparency mode of the material.
  22021. *
  22022. * | Value | Type | Description |
  22023. * | ----- | ----------------------------------- | ----------- |
  22024. * | 0 | OPAQUE | |
  22025. * | 1 | ALPHATEST | |
  22026. * | 2 | ALPHABLEND | |
  22027. * | 3 | ALPHATESTANDBLEND | |
  22028. *
  22029. */
  22030. set transparencyMode(value: Nullable<number>);
  22031. /**
  22032. * Returns true if alpha blending should be disabled.
  22033. */
  22034. protected get _disableAlphaBlending(): boolean;
  22035. /**
  22036. * Specifies whether or not this material should be rendered in alpha blend mode.
  22037. * @returns a boolean specifying if alpha blending is needed
  22038. */
  22039. needAlphaBlending(): boolean;
  22040. /**
  22041. * Specifies if the mesh will require alpha blending
  22042. * @param mesh defines the mesh to check
  22043. * @returns a boolean specifying if alpha blending is needed for the mesh
  22044. */
  22045. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22046. /**
  22047. * Specifies whether or not this material should be rendered in alpha test mode.
  22048. * @returns a boolean specifying if an alpha test is needed.
  22049. */
  22050. needAlphaTesting(): boolean;
  22051. /**
  22052. * Specifies if material alpha testing should be turned on for the mesh
  22053. * @param mesh defines the mesh to check
  22054. */
  22055. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22056. /**
  22057. * Gets the texture used for the alpha test
  22058. * @returns the texture to use for alpha testing
  22059. */
  22060. getAlphaTestTexture(): Nullable<BaseTexture>;
  22061. /**
  22062. * Marks the material to indicate that it needs to be re-calculated
  22063. */
  22064. markDirty(): void;
  22065. /** @hidden */
  22066. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22067. /**
  22068. * Binds the material to the mesh
  22069. * @param world defines the world transformation matrix
  22070. * @param mesh defines the mesh to bind the material to
  22071. */
  22072. bind(world: Matrix, mesh?: Mesh): void;
  22073. /**
  22074. * Binds the submesh to the material
  22075. * @param world defines the world transformation matrix
  22076. * @param mesh defines the mesh containing the submesh
  22077. * @param subMesh defines the submesh to bind the material to
  22078. */
  22079. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22080. /**
  22081. * Binds the world matrix to the material
  22082. * @param world defines the world transformation matrix
  22083. */
  22084. bindOnlyWorldMatrix(world: Matrix): void;
  22085. /**
  22086. * Binds the scene's uniform buffer to the effect.
  22087. * @param effect defines the effect to bind to the scene uniform buffer
  22088. * @param sceneUbo defines the uniform buffer storing scene data
  22089. */
  22090. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22091. /**
  22092. * Binds the view matrix to the effect
  22093. * @param effect defines the effect to bind the view matrix to
  22094. */
  22095. bindView(effect: Effect): void;
  22096. /**
  22097. * Binds the view projection matrix to the effect
  22098. * @param effect defines the effect to bind the view projection matrix to
  22099. */
  22100. bindViewProjection(effect: Effect): void;
  22101. /**
  22102. * Processes to execute after binding the material to a mesh
  22103. * @param mesh defines the rendered mesh
  22104. */
  22105. protected _afterBind(mesh?: Mesh): void;
  22106. /**
  22107. * Unbinds the material from the mesh
  22108. */
  22109. unbind(): void;
  22110. /**
  22111. * Gets the active textures from the material
  22112. * @returns an array of textures
  22113. */
  22114. getActiveTextures(): BaseTexture[];
  22115. /**
  22116. * Specifies if the material uses a texture
  22117. * @param texture defines the texture to check against the material
  22118. * @returns a boolean specifying if the material uses the texture
  22119. */
  22120. hasTexture(texture: BaseTexture): boolean;
  22121. /**
  22122. * Makes a duplicate of the material, and gives it a new name
  22123. * @param name defines the new name for the duplicated material
  22124. * @returns the cloned material
  22125. */
  22126. clone(name: string): Nullable<Material>;
  22127. /**
  22128. * Gets the meshes bound to the material
  22129. * @returns an array of meshes bound to the material
  22130. */
  22131. getBindedMeshes(): AbstractMesh[];
  22132. /**
  22133. * Force shader compilation
  22134. * @param mesh defines the mesh associated with this material
  22135. * @param onCompiled defines a function to execute once the material is compiled
  22136. * @param options defines the options to configure the compilation
  22137. * @param onError defines a function to execute if the material fails compiling
  22138. */
  22139. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22140. /**
  22141. * Force shader compilation
  22142. * @param mesh defines the mesh that will use this material
  22143. * @param options defines additional options for compiling the shaders
  22144. * @returns a promise that resolves when the compilation completes
  22145. */
  22146. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22147. private static readonly _AllDirtyCallBack;
  22148. private static readonly _ImageProcessingDirtyCallBack;
  22149. private static readonly _TextureDirtyCallBack;
  22150. private static readonly _FresnelDirtyCallBack;
  22151. private static readonly _MiscDirtyCallBack;
  22152. private static readonly _LightsDirtyCallBack;
  22153. private static readonly _AttributeDirtyCallBack;
  22154. private static _FresnelAndMiscDirtyCallBack;
  22155. private static _TextureAndMiscDirtyCallBack;
  22156. private static readonly _DirtyCallbackArray;
  22157. private static readonly _RunDirtyCallBacks;
  22158. /**
  22159. * Marks a define in the material to indicate that it needs to be re-computed
  22160. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22161. */
  22162. markAsDirty(flag: number): void;
  22163. /**
  22164. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22165. * @param func defines a function which checks material defines against the submeshes
  22166. */
  22167. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22168. /**
  22169. * Indicates that we need to re-calculated for all submeshes
  22170. */
  22171. protected _markAllSubMeshesAsAllDirty(): void;
  22172. /**
  22173. * Indicates that image processing needs to be re-calculated for all submeshes
  22174. */
  22175. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22176. /**
  22177. * Indicates that textures need to be re-calculated for all submeshes
  22178. */
  22179. protected _markAllSubMeshesAsTexturesDirty(): void;
  22180. /**
  22181. * Indicates that fresnel needs to be re-calculated for all submeshes
  22182. */
  22183. protected _markAllSubMeshesAsFresnelDirty(): void;
  22184. /**
  22185. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22186. */
  22187. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22188. /**
  22189. * Indicates that lights need to be re-calculated for all submeshes
  22190. */
  22191. protected _markAllSubMeshesAsLightsDirty(): void;
  22192. /**
  22193. * Indicates that attributes need to be re-calculated for all submeshes
  22194. */
  22195. protected _markAllSubMeshesAsAttributesDirty(): void;
  22196. /**
  22197. * Indicates that misc needs to be re-calculated for all submeshes
  22198. */
  22199. protected _markAllSubMeshesAsMiscDirty(): void;
  22200. /**
  22201. * Indicates that textures and misc need to be re-calculated for all submeshes
  22202. */
  22203. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22204. /**
  22205. * Disposes the material
  22206. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22207. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22208. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22209. */
  22210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22211. /** @hidden */
  22212. private releaseVertexArrayObject;
  22213. /**
  22214. * Serializes this material
  22215. * @returns the serialized material object
  22216. */
  22217. serialize(): any;
  22218. /**
  22219. * Creates a material from parsed material data
  22220. * @param parsedMaterial defines parsed material data
  22221. * @param scene defines the hosting scene
  22222. * @param rootUrl defines the root URL to use to load textures
  22223. * @returns a new material
  22224. */
  22225. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22226. }
  22227. }
  22228. declare module "babylonjs/Materials/multiMaterial" {
  22229. import { Nullable } from "babylonjs/types";
  22230. import { Scene } from "babylonjs/scene";
  22231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22232. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22234. import { Material } from "babylonjs/Materials/material";
  22235. /**
  22236. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22237. * separate meshes. This can be use to improve performances.
  22238. * @see http://doc.babylonjs.com/how_to/multi_materials
  22239. */
  22240. export class MultiMaterial extends Material {
  22241. private _subMaterials;
  22242. /**
  22243. * Gets or Sets the list of Materials used within the multi material.
  22244. * They need to be ordered according to the submeshes order in the associated mesh
  22245. */
  22246. get subMaterials(): Nullable<Material>[];
  22247. set subMaterials(value: Nullable<Material>[]);
  22248. /**
  22249. * Function used to align with Node.getChildren()
  22250. * @returns the list of Materials used within the multi material
  22251. */
  22252. getChildren(): Nullable<Material>[];
  22253. /**
  22254. * Instantiates a new Multi Material
  22255. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22256. * separate meshes. This can be use to improve performances.
  22257. * @see http://doc.babylonjs.com/how_to/multi_materials
  22258. * @param name Define the name in the scene
  22259. * @param scene Define the scene the material belongs to
  22260. */
  22261. constructor(name: string, scene: Scene);
  22262. private _hookArray;
  22263. /**
  22264. * Get one of the submaterial by its index in the submaterials array
  22265. * @param index The index to look the sub material at
  22266. * @returns The Material if the index has been defined
  22267. */
  22268. getSubMaterial(index: number): Nullable<Material>;
  22269. /**
  22270. * Get the list of active textures for the whole sub materials list.
  22271. * @returns All the textures that will be used during the rendering
  22272. */
  22273. getActiveTextures(): BaseTexture[];
  22274. /**
  22275. * Gets the current class name of the material e.g. "MultiMaterial"
  22276. * Mainly use in serialization.
  22277. * @returns the class name
  22278. */
  22279. getClassName(): string;
  22280. /**
  22281. * Checks if the material is ready to render the requested sub mesh
  22282. * @param mesh Define the mesh the submesh belongs to
  22283. * @param subMesh Define the sub mesh to look readyness for
  22284. * @param useInstances Define whether or not the material is used with instances
  22285. * @returns true if ready, otherwise false
  22286. */
  22287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22288. /**
  22289. * Clones the current material and its related sub materials
  22290. * @param name Define the name of the newly cloned material
  22291. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22292. * @returns the cloned material
  22293. */
  22294. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22295. /**
  22296. * Serializes the materials into a JSON representation.
  22297. * @returns the JSON representation
  22298. */
  22299. serialize(): any;
  22300. /**
  22301. * Dispose the material and release its associated resources
  22302. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  22303. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  22304. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  22305. */
  22306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22307. /**
  22308. * Creates a MultiMaterial from parsed MultiMaterial data.
  22309. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22310. * @param scene defines the hosting scene
  22311. * @returns a new MultiMaterial
  22312. */
  22313. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22314. }
  22315. }
  22316. declare module "babylonjs/Meshes/subMesh" {
  22317. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22319. import { Engine } from "babylonjs/Engines/engine";
  22320. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22321. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22322. import { Effect } from "babylonjs/Materials/effect";
  22323. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22324. import { Plane } from "babylonjs/Maths/math.plane";
  22325. import { Collider } from "babylonjs/Collisions/collider";
  22326. import { Material } from "babylonjs/Materials/material";
  22327. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22329. import { Mesh } from "babylonjs/Meshes/mesh";
  22330. import { Ray } from "babylonjs/Culling/ray";
  22331. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22332. /**
  22333. * Base class for submeshes
  22334. */
  22335. export class BaseSubMesh {
  22336. /** @hidden */
  22337. _materialDefines: Nullable<MaterialDefines>;
  22338. /** @hidden */
  22339. _materialEffect: Nullable<Effect>;
  22340. /**
  22341. * Gets material defines used by the effect associated to the sub mesh
  22342. */
  22343. get materialDefines(): Nullable<MaterialDefines>;
  22344. /**
  22345. * Sets material defines used by the effect associated to the sub mesh
  22346. */
  22347. set materialDefines(defines: Nullable<MaterialDefines>);
  22348. /**
  22349. * Gets associated effect
  22350. */
  22351. get effect(): Nullable<Effect>;
  22352. /**
  22353. * Sets associated effect (effect used to render this submesh)
  22354. * @param effect defines the effect to associate with
  22355. * @param defines defines the set of defines used to compile this effect
  22356. */
  22357. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22358. }
  22359. /**
  22360. * Defines a subdivision inside a mesh
  22361. */
  22362. export class SubMesh extends BaseSubMesh implements ICullable {
  22363. /** the material index to use */
  22364. materialIndex: number;
  22365. /** vertex index start */
  22366. verticesStart: number;
  22367. /** vertices count */
  22368. verticesCount: number;
  22369. /** index start */
  22370. indexStart: number;
  22371. /** indices count */
  22372. indexCount: number;
  22373. /** @hidden */
  22374. _linesIndexCount: number;
  22375. private _mesh;
  22376. private _renderingMesh;
  22377. private _boundingInfo;
  22378. private _linesIndexBuffer;
  22379. /** @hidden */
  22380. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22381. /** @hidden */
  22382. _trianglePlanes: Plane[];
  22383. /** @hidden */
  22384. _lastColliderTransformMatrix: Nullable<Matrix>;
  22385. /** @hidden */
  22386. _renderId: number;
  22387. /** @hidden */
  22388. _alphaIndex: number;
  22389. /** @hidden */
  22390. _distanceToCamera: number;
  22391. /** @hidden */
  22392. _id: number;
  22393. private _currentMaterial;
  22394. /**
  22395. * Add a new submesh to a mesh
  22396. * @param materialIndex defines the material index to use
  22397. * @param verticesStart defines vertex index start
  22398. * @param verticesCount defines vertices count
  22399. * @param indexStart defines index start
  22400. * @param indexCount defines indices count
  22401. * @param mesh defines the parent mesh
  22402. * @param renderingMesh defines an optional rendering mesh
  22403. * @param createBoundingBox defines if bounding box should be created for this submesh
  22404. * @returns the new submesh
  22405. */
  22406. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22407. /**
  22408. * Creates a new submesh
  22409. * @param materialIndex defines the material index to use
  22410. * @param verticesStart defines vertex index start
  22411. * @param verticesCount defines vertices count
  22412. * @param indexStart defines index start
  22413. * @param indexCount defines indices count
  22414. * @param mesh defines the parent mesh
  22415. * @param renderingMesh defines an optional rendering mesh
  22416. * @param createBoundingBox defines if bounding box should be created for this submesh
  22417. */
  22418. constructor(
  22419. /** the material index to use */
  22420. materialIndex: number,
  22421. /** vertex index start */
  22422. verticesStart: number,
  22423. /** vertices count */
  22424. verticesCount: number,
  22425. /** index start */
  22426. indexStart: number,
  22427. /** indices count */
  22428. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22429. /**
  22430. * Returns true if this submesh covers the entire parent mesh
  22431. * @ignorenaming
  22432. */
  22433. get IsGlobal(): boolean;
  22434. /**
  22435. * Returns the submesh BoudingInfo object
  22436. * @returns current bounding info (or mesh's one if the submesh is global)
  22437. */
  22438. getBoundingInfo(): BoundingInfo;
  22439. /**
  22440. * Sets the submesh BoundingInfo
  22441. * @param boundingInfo defines the new bounding info to use
  22442. * @returns the SubMesh
  22443. */
  22444. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22445. /**
  22446. * Returns the mesh of the current submesh
  22447. * @return the parent mesh
  22448. */
  22449. getMesh(): AbstractMesh;
  22450. /**
  22451. * Returns the rendering mesh of the submesh
  22452. * @returns the rendering mesh (could be different from parent mesh)
  22453. */
  22454. getRenderingMesh(): Mesh;
  22455. /**
  22456. * Returns the submesh material
  22457. * @returns null or the current material
  22458. */
  22459. getMaterial(): Nullable<Material>;
  22460. /**
  22461. * Sets a new updated BoundingInfo object to the submesh
  22462. * @param data defines an optional position array to use to determine the bounding info
  22463. * @returns the SubMesh
  22464. */
  22465. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22466. /** @hidden */
  22467. _checkCollision(collider: Collider): boolean;
  22468. /**
  22469. * Updates the submesh BoundingInfo
  22470. * @param world defines the world matrix to use to update the bounding info
  22471. * @returns the submesh
  22472. */
  22473. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22474. /**
  22475. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22476. * @param frustumPlanes defines the frustum planes
  22477. * @returns true if the submesh is intersecting with the frustum
  22478. */
  22479. isInFrustum(frustumPlanes: Plane[]): boolean;
  22480. /**
  22481. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22482. * @param frustumPlanes defines the frustum planes
  22483. * @returns true if the submesh is inside the frustum
  22484. */
  22485. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22486. /**
  22487. * Renders the submesh
  22488. * @param enableAlphaMode defines if alpha needs to be used
  22489. * @returns the submesh
  22490. */
  22491. render(enableAlphaMode: boolean): SubMesh;
  22492. /**
  22493. * @hidden
  22494. */
  22495. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22496. /**
  22497. * Checks if the submesh intersects with a ray
  22498. * @param ray defines the ray to test
  22499. * @returns true is the passed ray intersects the submesh bounding box
  22500. */
  22501. canIntersects(ray: Ray): boolean;
  22502. /**
  22503. * Intersects current submesh with a ray
  22504. * @param ray defines the ray to test
  22505. * @param positions defines mesh's positions array
  22506. * @param indices defines mesh's indices array
  22507. * @param fastCheck defines if only bounding info should be used
  22508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22509. * @returns intersection info or null if no intersection
  22510. */
  22511. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22512. /** @hidden */
  22513. private _intersectLines;
  22514. /** @hidden */
  22515. private _intersectUnIndexedLines;
  22516. /** @hidden */
  22517. private _intersectTriangles;
  22518. /** @hidden */
  22519. private _intersectUnIndexedTriangles;
  22520. /** @hidden */
  22521. _rebuild(): void;
  22522. /**
  22523. * Creates a new submesh from the passed mesh
  22524. * @param newMesh defines the new hosting mesh
  22525. * @param newRenderingMesh defines an optional rendering mesh
  22526. * @returns the new submesh
  22527. */
  22528. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22529. /**
  22530. * Release associated resources
  22531. */
  22532. dispose(): void;
  22533. /**
  22534. * Gets the class name
  22535. * @returns the string "SubMesh".
  22536. */
  22537. getClassName(): string;
  22538. /**
  22539. * Creates a new submesh from indices data
  22540. * @param materialIndex the index of the main mesh material
  22541. * @param startIndex the index where to start the copy in the mesh indices array
  22542. * @param indexCount the number of indices to copy then from the startIndex
  22543. * @param mesh the main mesh to create the submesh from
  22544. * @param renderingMesh the optional rendering mesh
  22545. * @returns a new submesh
  22546. */
  22547. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22548. }
  22549. }
  22550. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22551. /**
  22552. * Class used to represent data loading progression
  22553. */
  22554. export class SceneLoaderFlags {
  22555. private static _ForceFullSceneLoadingForIncremental;
  22556. private static _ShowLoadingScreen;
  22557. private static _CleanBoneMatrixWeights;
  22558. private static _loggingLevel;
  22559. /**
  22560. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22561. */
  22562. static get ForceFullSceneLoadingForIncremental(): boolean;
  22563. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22564. /**
  22565. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22566. */
  22567. static get ShowLoadingScreen(): boolean;
  22568. static set ShowLoadingScreen(value: boolean);
  22569. /**
  22570. * Defines the current logging level (while loading the scene)
  22571. * @ignorenaming
  22572. */
  22573. static get loggingLevel(): number;
  22574. static set loggingLevel(value: number);
  22575. /**
  22576. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22577. */
  22578. static get CleanBoneMatrixWeights(): boolean;
  22579. static set CleanBoneMatrixWeights(value: boolean);
  22580. }
  22581. }
  22582. declare module "babylonjs/Meshes/geometry" {
  22583. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22584. import { Scene } from "babylonjs/scene";
  22585. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22586. import { Engine } from "babylonjs/Engines/engine";
  22587. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22588. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22589. import { Effect } from "babylonjs/Materials/effect";
  22590. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22591. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22592. import { Mesh } from "babylonjs/Meshes/mesh";
  22593. /**
  22594. * Class used to store geometry data (vertex buffers + index buffer)
  22595. */
  22596. export class Geometry implements IGetSetVerticesData {
  22597. /**
  22598. * Gets or sets the ID of the geometry
  22599. */
  22600. id: string;
  22601. /**
  22602. * Gets or sets the unique ID of the geometry
  22603. */
  22604. uniqueId: number;
  22605. /**
  22606. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22607. */
  22608. delayLoadState: number;
  22609. /**
  22610. * Gets the file containing the data to load when running in delay load state
  22611. */
  22612. delayLoadingFile: Nullable<string>;
  22613. /**
  22614. * Callback called when the geometry is updated
  22615. */
  22616. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22617. private _scene;
  22618. private _engine;
  22619. private _meshes;
  22620. private _totalVertices;
  22621. /** @hidden */
  22622. _indices: IndicesArray;
  22623. /** @hidden */
  22624. _vertexBuffers: {
  22625. [key: string]: VertexBuffer;
  22626. };
  22627. private _isDisposed;
  22628. private _extend;
  22629. private _boundingBias;
  22630. /** @hidden */
  22631. _delayInfo: Array<string>;
  22632. private _indexBuffer;
  22633. private _indexBufferIsUpdatable;
  22634. /** @hidden */
  22635. _boundingInfo: Nullable<BoundingInfo>;
  22636. /** @hidden */
  22637. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22638. /** @hidden */
  22639. _softwareSkinningFrameId: number;
  22640. private _vertexArrayObjects;
  22641. private _updatable;
  22642. /** @hidden */
  22643. _positions: Nullable<Vector3[]>;
  22644. /**
  22645. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22646. */
  22647. get boundingBias(): Vector2;
  22648. /**
  22649. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22650. */
  22651. set boundingBias(value: Vector2);
  22652. /**
  22653. * Static function used to attach a new empty geometry to a mesh
  22654. * @param mesh defines the mesh to attach the geometry to
  22655. * @returns the new Geometry
  22656. */
  22657. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22658. /** Get the list of meshes using this geometry */
  22659. get meshes(): Mesh[];
  22660. /**
  22661. * Creates a new geometry
  22662. * @param id defines the unique ID
  22663. * @param scene defines the hosting scene
  22664. * @param vertexData defines the VertexData used to get geometry data
  22665. * @param updatable defines if geometry must be updatable (false by default)
  22666. * @param mesh defines the mesh that will be associated with the geometry
  22667. */
  22668. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22669. /**
  22670. * Gets the current extend of the geometry
  22671. */
  22672. get extend(): {
  22673. minimum: Vector3;
  22674. maximum: Vector3;
  22675. };
  22676. /**
  22677. * Gets the hosting scene
  22678. * @returns the hosting Scene
  22679. */
  22680. getScene(): Scene;
  22681. /**
  22682. * Gets the hosting engine
  22683. * @returns the hosting Engine
  22684. */
  22685. getEngine(): Engine;
  22686. /**
  22687. * Defines if the geometry is ready to use
  22688. * @returns true if the geometry is ready to be used
  22689. */
  22690. isReady(): boolean;
  22691. /**
  22692. * Gets a value indicating that the geometry should not be serialized
  22693. */
  22694. get doNotSerialize(): boolean;
  22695. /** @hidden */
  22696. _rebuild(): void;
  22697. /**
  22698. * Affects all geometry data in one call
  22699. * @param vertexData defines the geometry data
  22700. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22701. */
  22702. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22703. /**
  22704. * Set specific vertex data
  22705. * @param kind defines the data kind (Position, normal, etc...)
  22706. * @param data defines the vertex data to use
  22707. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22708. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22709. */
  22710. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22711. /**
  22712. * Removes a specific vertex data
  22713. * @param kind defines the data kind (Position, normal, etc...)
  22714. */
  22715. removeVerticesData(kind: string): void;
  22716. /**
  22717. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22718. * @param buffer defines the vertex buffer to use
  22719. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22720. */
  22721. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22722. /**
  22723. * Update a specific vertex buffer
  22724. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22725. * It will do nothing if the buffer is not updatable
  22726. * @param kind defines the data kind (Position, normal, etc...)
  22727. * @param data defines the data to use
  22728. * @param offset defines the offset in the target buffer where to store the data
  22729. * @param useBytes set to true if the offset is in bytes
  22730. */
  22731. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22732. /**
  22733. * Update a specific vertex buffer
  22734. * This function will create a new buffer if the current one is not updatable
  22735. * @param kind defines the data kind (Position, normal, etc...)
  22736. * @param data defines the data to use
  22737. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22738. */
  22739. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22740. private _updateBoundingInfo;
  22741. /** @hidden */
  22742. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22743. /**
  22744. * Gets total number of vertices
  22745. * @returns the total number of vertices
  22746. */
  22747. getTotalVertices(): number;
  22748. /**
  22749. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22750. * @param kind defines the data kind (Position, normal, etc...)
  22751. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22752. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22753. * @returns a float array containing vertex data
  22754. */
  22755. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22756. /**
  22757. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22758. * @param kind defines the data kind (Position, normal, etc...)
  22759. * @returns true if the vertex buffer with the specified kind is updatable
  22760. */
  22761. isVertexBufferUpdatable(kind: string): boolean;
  22762. /**
  22763. * Gets a specific vertex buffer
  22764. * @param kind defines the data kind (Position, normal, etc...)
  22765. * @returns a VertexBuffer
  22766. */
  22767. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22768. /**
  22769. * Returns all vertex buffers
  22770. * @return an object holding all vertex buffers indexed by kind
  22771. */
  22772. getVertexBuffers(): Nullable<{
  22773. [key: string]: VertexBuffer;
  22774. }>;
  22775. /**
  22776. * Gets a boolean indicating if specific vertex buffer is present
  22777. * @param kind defines the data kind (Position, normal, etc...)
  22778. * @returns true if data is present
  22779. */
  22780. isVerticesDataPresent(kind: string): boolean;
  22781. /**
  22782. * Gets a list of all attached data kinds (Position, normal, etc...)
  22783. * @returns a list of string containing all kinds
  22784. */
  22785. getVerticesDataKinds(): string[];
  22786. /**
  22787. * Update index buffer
  22788. * @param indices defines the indices to store in the index buffer
  22789. * @param offset defines the offset in the target buffer where to store the data
  22790. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22791. */
  22792. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22793. /**
  22794. * Creates a new index buffer
  22795. * @param indices defines the indices to store in the index buffer
  22796. * @param totalVertices defines the total number of vertices (could be null)
  22797. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22798. */
  22799. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22800. /**
  22801. * Return the total number of indices
  22802. * @returns the total number of indices
  22803. */
  22804. getTotalIndices(): number;
  22805. /**
  22806. * Gets the index buffer array
  22807. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22808. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22809. * @returns the index buffer array
  22810. */
  22811. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22812. /**
  22813. * Gets the index buffer
  22814. * @return the index buffer
  22815. */
  22816. getIndexBuffer(): Nullable<DataBuffer>;
  22817. /** @hidden */
  22818. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22819. /**
  22820. * Release the associated resources for a specific mesh
  22821. * @param mesh defines the source mesh
  22822. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22823. */
  22824. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22825. /**
  22826. * Apply current geometry to a given mesh
  22827. * @param mesh defines the mesh to apply geometry to
  22828. */
  22829. applyToMesh(mesh: Mesh): void;
  22830. private _updateExtend;
  22831. private _applyToMesh;
  22832. private notifyUpdate;
  22833. /**
  22834. * Load the geometry if it was flagged as delay loaded
  22835. * @param scene defines the hosting scene
  22836. * @param onLoaded defines a callback called when the geometry is loaded
  22837. */
  22838. load(scene: Scene, onLoaded?: () => void): void;
  22839. private _queueLoad;
  22840. /**
  22841. * Invert the geometry to move from a right handed system to a left handed one.
  22842. */
  22843. toLeftHanded(): void;
  22844. /** @hidden */
  22845. _resetPointsArrayCache(): void;
  22846. /** @hidden */
  22847. _generatePointsArray(): boolean;
  22848. /**
  22849. * Gets a value indicating if the geometry is disposed
  22850. * @returns true if the geometry was disposed
  22851. */
  22852. isDisposed(): boolean;
  22853. private _disposeVertexArrayObjects;
  22854. /**
  22855. * Free all associated resources
  22856. */
  22857. dispose(): void;
  22858. /**
  22859. * Clone the current geometry into a new geometry
  22860. * @param id defines the unique ID of the new geometry
  22861. * @returns a new geometry object
  22862. */
  22863. copy(id: string): Geometry;
  22864. /**
  22865. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22866. * @return a JSON representation of the current geometry data (without the vertices data)
  22867. */
  22868. serialize(): any;
  22869. private toNumberArray;
  22870. /**
  22871. * Serialize all vertices data into a JSON oject
  22872. * @returns a JSON representation of the current geometry data
  22873. */
  22874. serializeVerticeData(): any;
  22875. /**
  22876. * Extracts a clone of a mesh geometry
  22877. * @param mesh defines the source mesh
  22878. * @param id defines the unique ID of the new geometry object
  22879. * @returns the new geometry object
  22880. */
  22881. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22882. /**
  22883. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22884. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22885. * Be aware Math.random() could cause collisions, but:
  22886. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22887. * @returns a string containing a new GUID
  22888. */
  22889. static RandomId(): string;
  22890. /** @hidden */
  22891. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22892. private static _CleanMatricesWeights;
  22893. /**
  22894. * Create a new geometry from persisted data (Using .babylon file format)
  22895. * @param parsedVertexData defines the persisted data
  22896. * @param scene defines the hosting scene
  22897. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22898. * @returns the new geometry object
  22899. */
  22900. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22901. }
  22902. }
  22903. declare module "babylonjs/Meshes/mesh.vertexData" {
  22904. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22905. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22906. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22907. import { Geometry } from "babylonjs/Meshes/geometry";
  22908. import { Mesh } from "babylonjs/Meshes/mesh";
  22909. /**
  22910. * Define an interface for all classes that will get and set the data on vertices
  22911. */
  22912. export interface IGetSetVerticesData {
  22913. /**
  22914. * Gets a boolean indicating if specific vertex data is present
  22915. * @param kind defines the vertex data kind to use
  22916. * @returns true is data kind is present
  22917. */
  22918. isVerticesDataPresent(kind: string): boolean;
  22919. /**
  22920. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22921. * @param kind defines the data kind (Position, normal, etc...)
  22922. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22923. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22924. * @returns a float array containing vertex data
  22925. */
  22926. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22927. /**
  22928. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22929. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22931. * @returns the indices array or an empty array if the mesh has no geometry
  22932. */
  22933. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22934. /**
  22935. * Set specific vertex data
  22936. * @param kind defines the data kind (Position, normal, etc...)
  22937. * @param data defines the vertex data to use
  22938. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22939. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22940. */
  22941. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22942. /**
  22943. * Update a specific associated vertex buffer
  22944. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22945. * - VertexBuffer.PositionKind
  22946. * - VertexBuffer.UVKind
  22947. * - VertexBuffer.UV2Kind
  22948. * - VertexBuffer.UV3Kind
  22949. * - VertexBuffer.UV4Kind
  22950. * - VertexBuffer.UV5Kind
  22951. * - VertexBuffer.UV6Kind
  22952. * - VertexBuffer.ColorKind
  22953. * - VertexBuffer.MatricesIndicesKind
  22954. * - VertexBuffer.MatricesIndicesExtraKind
  22955. * - VertexBuffer.MatricesWeightsKind
  22956. * - VertexBuffer.MatricesWeightsExtraKind
  22957. * @param data defines the data source
  22958. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22959. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22960. */
  22961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22962. /**
  22963. * Creates a new index buffer
  22964. * @param indices defines the indices to store in the index buffer
  22965. * @param totalVertices defines the total number of vertices (could be null)
  22966. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22967. */
  22968. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22969. }
  22970. /**
  22971. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22972. */
  22973. export class VertexData {
  22974. /**
  22975. * Mesh side orientation : usually the external or front surface
  22976. */
  22977. static readonly FRONTSIDE: number;
  22978. /**
  22979. * Mesh side orientation : usually the internal or back surface
  22980. */
  22981. static readonly BACKSIDE: number;
  22982. /**
  22983. * Mesh side orientation : both internal and external or front and back surfaces
  22984. */
  22985. static readonly DOUBLESIDE: number;
  22986. /**
  22987. * Mesh side orientation : by default, `FRONTSIDE`
  22988. */
  22989. static readonly DEFAULTSIDE: number;
  22990. /**
  22991. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22992. */
  22993. positions: Nullable<FloatArray>;
  22994. /**
  22995. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22996. */
  22997. normals: Nullable<FloatArray>;
  22998. /**
  22999. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23000. */
  23001. tangents: Nullable<FloatArray>;
  23002. /**
  23003. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23004. */
  23005. uvs: Nullable<FloatArray>;
  23006. /**
  23007. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23008. */
  23009. uvs2: Nullable<FloatArray>;
  23010. /**
  23011. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23012. */
  23013. uvs3: Nullable<FloatArray>;
  23014. /**
  23015. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23016. */
  23017. uvs4: Nullable<FloatArray>;
  23018. /**
  23019. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23020. */
  23021. uvs5: Nullable<FloatArray>;
  23022. /**
  23023. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23024. */
  23025. uvs6: Nullable<FloatArray>;
  23026. /**
  23027. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23028. */
  23029. colors: Nullable<FloatArray>;
  23030. /**
  23031. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  23032. */
  23033. matricesIndices: Nullable<FloatArray>;
  23034. /**
  23035. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23036. */
  23037. matricesWeights: Nullable<FloatArray>;
  23038. /**
  23039. * An array extending the number of possible indices
  23040. */
  23041. matricesIndicesExtra: Nullable<FloatArray>;
  23042. /**
  23043. * An array extending the number of possible weights when the number of indices is extended
  23044. */
  23045. matricesWeightsExtra: Nullable<FloatArray>;
  23046. /**
  23047. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23048. */
  23049. indices: Nullable<IndicesArray>;
  23050. /**
  23051. * Uses the passed data array to set the set the values for the specified kind of data
  23052. * @param data a linear array of floating numbers
  23053. * @param kind the type of data that is being set, eg positions, colors etc
  23054. */
  23055. set(data: FloatArray, kind: string): void;
  23056. /**
  23057. * Associates the vertexData to the passed Mesh.
  23058. * Sets it as updatable or not (default `false`)
  23059. * @param mesh the mesh the vertexData is applied to
  23060. * @param updatable when used and having the value true allows new data to update the vertexData
  23061. * @returns the VertexData
  23062. */
  23063. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23064. /**
  23065. * Associates the vertexData to the passed Geometry.
  23066. * Sets it as updatable or not (default `false`)
  23067. * @param geometry the geometry the vertexData is applied to
  23068. * @param updatable when used and having the value true allows new data to update the vertexData
  23069. * @returns VertexData
  23070. */
  23071. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23072. /**
  23073. * Updates the associated mesh
  23074. * @param mesh the mesh to be updated
  23075. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23076. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  23077. * @returns VertexData
  23078. */
  23079. updateMesh(mesh: Mesh): VertexData;
  23080. /**
  23081. * Updates the associated geometry
  23082. * @param geometry the geometry to be updated
  23083. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23084. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  23085. * @returns VertexData.
  23086. */
  23087. updateGeometry(geometry: Geometry): VertexData;
  23088. private _applyTo;
  23089. private _update;
  23090. /**
  23091. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23092. * @param matrix the transforming matrix
  23093. * @returns the VertexData
  23094. */
  23095. transform(matrix: Matrix): VertexData;
  23096. /**
  23097. * Merges the passed VertexData into the current one
  23098. * @param other the VertexData to be merged into the current one
  23099. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23100. * @returns the modified VertexData
  23101. */
  23102. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23103. private _mergeElement;
  23104. private _validate;
  23105. /**
  23106. * Serializes the VertexData
  23107. * @returns a serialized object
  23108. */
  23109. serialize(): any;
  23110. /**
  23111. * Extracts the vertexData from a mesh
  23112. * @param mesh the mesh from which to extract the VertexData
  23113. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23114. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23115. * @returns the object VertexData associated to the passed mesh
  23116. */
  23117. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23118. /**
  23119. * Extracts the vertexData from the geometry
  23120. * @param geometry the geometry from which to extract the VertexData
  23121. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23122. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23123. * @returns the object VertexData associated to the passed mesh
  23124. */
  23125. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23126. private static _ExtractFrom;
  23127. /**
  23128. * Creates the VertexData for a Ribbon
  23129. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23130. * * pathArray array of paths, each of which an array of successive Vector3
  23131. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23132. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23133. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  23134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23135. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23136. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23137. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23138. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23139. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23140. * @returns the VertexData of the ribbon
  23141. */
  23142. static CreateRibbon(options: {
  23143. pathArray: Vector3[][];
  23144. closeArray?: boolean;
  23145. closePath?: boolean;
  23146. offset?: number;
  23147. sideOrientation?: number;
  23148. frontUVs?: Vector4;
  23149. backUVs?: Vector4;
  23150. invertUV?: boolean;
  23151. uvs?: Vector2[];
  23152. colors?: Color4[];
  23153. }): VertexData;
  23154. /**
  23155. * Creates the VertexData for a box
  23156. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23157. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23158. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23159. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23160. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23161. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23162. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23164. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23165. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23166. * @returns the VertexData of the box
  23167. */
  23168. static CreateBox(options: {
  23169. size?: number;
  23170. width?: number;
  23171. height?: number;
  23172. depth?: number;
  23173. faceUV?: Vector4[];
  23174. faceColors?: Color4[];
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for a tiled box
  23181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23182. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23183. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23184. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * @returns the VertexData of the box
  23187. */
  23188. static CreateTiledBox(options: {
  23189. pattern?: number;
  23190. width?: number;
  23191. height?: number;
  23192. depth?: number;
  23193. tileSize?: number;
  23194. tileWidth?: number;
  23195. tileHeight?: number;
  23196. alignHorizontal?: number;
  23197. alignVertical?: number;
  23198. faceUV?: Vector4[];
  23199. faceColors?: Color4[];
  23200. sideOrientation?: number;
  23201. }): VertexData;
  23202. /**
  23203. * Creates the VertexData for a tiled plane
  23204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23205. * * pattern a limited pattern arrangement depending on the number
  23206. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23207. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23208. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23210. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23211. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23212. * @returns the VertexData of the tiled plane
  23213. */
  23214. static CreateTiledPlane(options: {
  23215. pattern?: number;
  23216. tileSize?: number;
  23217. tileWidth?: number;
  23218. tileHeight?: number;
  23219. size?: number;
  23220. width?: number;
  23221. height?: number;
  23222. alignHorizontal?: number;
  23223. alignVertical?: number;
  23224. sideOrientation?: number;
  23225. frontUVs?: Vector4;
  23226. backUVs?: Vector4;
  23227. }): VertexData;
  23228. /**
  23229. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23231. * * segments sets the number of horizontal strips optional, default 32
  23232. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23233. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23234. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23235. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23236. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  23237. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23240. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23241. * @returns the VertexData of the ellipsoid
  23242. */
  23243. static CreateSphere(options: {
  23244. segments?: number;
  23245. diameter?: number;
  23246. diameterX?: number;
  23247. diameterY?: number;
  23248. diameterZ?: number;
  23249. arc?: number;
  23250. slice?: number;
  23251. sideOrientation?: number;
  23252. frontUVs?: Vector4;
  23253. backUVs?: Vector4;
  23254. }): VertexData;
  23255. /**
  23256. * Creates the VertexData for a cylinder, cone or prism
  23257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23258. * * height sets the height (y direction) of the cylinder, optional, default 2
  23259. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23260. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23261. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23262. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23263. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23264. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  23265. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23266. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23267. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23268. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23270. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23271. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23272. * @returns the VertexData of the cylinder, cone or prism
  23273. */
  23274. static CreateCylinder(options: {
  23275. height?: number;
  23276. diameterTop?: number;
  23277. diameterBottom?: number;
  23278. diameter?: number;
  23279. tessellation?: number;
  23280. subdivisions?: number;
  23281. arc?: number;
  23282. faceColors?: Color4[];
  23283. faceUV?: Vector4[];
  23284. hasRings?: boolean;
  23285. enclose?: boolean;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData for a torus
  23292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23293. * * diameter the diameter of the torus, optional default 1
  23294. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23295. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23298. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23299. * @returns the VertexData of the torus
  23300. */
  23301. static CreateTorus(options: {
  23302. diameter?: number;
  23303. thickness?: number;
  23304. tessellation?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData of the LineSystem
  23311. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23312. * - lines an array of lines, each line being an array of successive Vector3
  23313. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23314. * @returns the VertexData of the LineSystem
  23315. */
  23316. static CreateLineSystem(options: {
  23317. lines: Vector3[][];
  23318. colors?: Nullable<Color4[][]>;
  23319. }): VertexData;
  23320. /**
  23321. * Create the VertexData for a DashedLines
  23322. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23323. * - points an array successive Vector3
  23324. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23325. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23326. * - dashNb the intended total number of dashes, optional, default 200
  23327. * @returns the VertexData for the DashedLines
  23328. */
  23329. static CreateDashedLines(options: {
  23330. points: Vector3[];
  23331. dashSize?: number;
  23332. gapSize?: number;
  23333. dashNb?: number;
  23334. }): VertexData;
  23335. /**
  23336. * Creates the VertexData for a Ground
  23337. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23338. * - width the width (x direction) of the ground, optional, default 1
  23339. * - height the height (z direction) of the ground, optional, default 1
  23340. * - subdivisions the number of subdivisions per side, optional, default 1
  23341. * @returns the VertexData of the Ground
  23342. */
  23343. static CreateGround(options: {
  23344. width?: number;
  23345. height?: number;
  23346. subdivisions?: number;
  23347. subdivisionsX?: number;
  23348. subdivisionsY?: number;
  23349. }): VertexData;
  23350. /**
  23351. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23352. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23353. * * xmin the ground minimum X coordinate, optional, default -1
  23354. * * zmin the ground minimum Z coordinate, optional, default -1
  23355. * * xmax the ground maximum X coordinate, optional, default 1
  23356. * * zmax the ground maximum Z coordinate, optional, default 1
  23357. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  23358. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  23359. * @returns the VertexData of the TiledGround
  23360. */
  23361. static CreateTiledGround(options: {
  23362. xmin: number;
  23363. zmin: number;
  23364. xmax: number;
  23365. zmax: number;
  23366. subdivisions?: {
  23367. w: number;
  23368. h: number;
  23369. };
  23370. precision?: {
  23371. w: number;
  23372. h: number;
  23373. };
  23374. }): VertexData;
  23375. /**
  23376. * Creates the VertexData of the Ground designed from a heightmap
  23377. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23378. * * width the width (x direction) of the ground
  23379. * * height the height (z direction) of the ground
  23380. * * subdivisions the number of subdivisions per side
  23381. * * minHeight the minimum altitude on the ground, optional, default 0
  23382. * * maxHeight the maximum altitude on the ground, optional default 1
  23383. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23384. * * buffer the array holding the image color data
  23385. * * bufferWidth the width of image
  23386. * * bufferHeight the height of image
  23387. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23388. * @returns the VertexData of the Ground designed from a heightmap
  23389. */
  23390. static CreateGroundFromHeightMap(options: {
  23391. width: number;
  23392. height: number;
  23393. subdivisions: number;
  23394. minHeight: number;
  23395. maxHeight: number;
  23396. colorFilter: Color3;
  23397. buffer: Uint8Array;
  23398. bufferWidth: number;
  23399. bufferHeight: number;
  23400. alphaFilter: number;
  23401. }): VertexData;
  23402. /**
  23403. * Creates the VertexData for a Plane
  23404. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23405. * * size sets the width and height of the plane to the value of size, optional default 1
  23406. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23407. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23409. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23410. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23411. * @returns the VertexData of the box
  23412. */
  23413. static CreatePlane(options: {
  23414. size?: number;
  23415. width?: number;
  23416. height?: number;
  23417. sideOrientation?: number;
  23418. frontUVs?: Vector4;
  23419. backUVs?: Vector4;
  23420. }): VertexData;
  23421. /**
  23422. * Creates the VertexData of the Disc or regular Polygon
  23423. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23424. * * radius the radius of the disc, optional default 0.5
  23425. * * tessellation the number of polygon sides, optional, default 64
  23426. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  23427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23428. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23429. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23430. * @returns the VertexData of the box
  23431. */
  23432. static CreateDisc(options: {
  23433. radius?: number;
  23434. tessellation?: number;
  23435. arc?: number;
  23436. sideOrientation?: number;
  23437. frontUVs?: Vector4;
  23438. backUVs?: Vector4;
  23439. }): VertexData;
  23440. /**
  23441. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23442. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23443. * @param polygon a mesh built from polygonTriangulation.build()
  23444. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23445. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23446. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23447. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23448. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23449. * @returns the VertexData of the Polygon
  23450. */
  23451. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23452. /**
  23453. * Creates the VertexData of the IcoSphere
  23454. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23455. * * radius the radius of the IcoSphere, optional default 1
  23456. * * radiusX allows stretching in the x direction, optional, default radius
  23457. * * radiusY allows stretching in the y direction, optional, default radius
  23458. * * radiusZ allows stretching in the z direction, optional, default radius
  23459. * * flat when true creates a flat shaded mesh, optional, default true
  23460. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23462. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23463. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23464. * @returns the VertexData of the IcoSphere
  23465. */
  23466. static CreateIcoSphere(options: {
  23467. radius?: number;
  23468. radiusX?: number;
  23469. radiusY?: number;
  23470. radiusZ?: number;
  23471. flat?: boolean;
  23472. subdivisions?: number;
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. }): VertexData;
  23477. /**
  23478. * Creates the VertexData for a Polyhedron
  23479. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23480. * * type provided types are:
  23481. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23482. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  23483. * * size the size of the IcoSphere, optional default 1
  23484. * * sizeX allows stretching in the x direction, optional, default size
  23485. * * sizeY allows stretching in the y direction, optional, default size
  23486. * * sizeZ allows stretching in the z direction, optional, default size
  23487. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  23488. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23489. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23490. * * flat when true creates a flat shaded mesh, optional, default true
  23491. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23493. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23494. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23495. * @returns the VertexData of the Polyhedron
  23496. */
  23497. static CreatePolyhedron(options: {
  23498. type?: number;
  23499. size?: number;
  23500. sizeX?: number;
  23501. sizeY?: number;
  23502. sizeZ?: number;
  23503. custom?: any;
  23504. faceUV?: Vector4[];
  23505. faceColors?: Color4[];
  23506. flat?: boolean;
  23507. sideOrientation?: number;
  23508. frontUVs?: Vector4;
  23509. backUVs?: Vector4;
  23510. }): VertexData;
  23511. /**
  23512. * Creates the VertexData for a TorusKnot
  23513. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23514. * * radius the radius of the torus knot, optional, default 2
  23515. * * tube the thickness of the tube, optional, default 0.5
  23516. * * radialSegments the number of sides on each tube segments, optional, default 32
  23517. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23518. * * p the number of windings around the z axis, optional, default 2
  23519. * * q the number of windings around the x axis, optional, default 3
  23520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23521. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23522. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23523. * @returns the VertexData of the Torus Knot
  23524. */
  23525. static CreateTorusKnot(options: {
  23526. radius?: number;
  23527. tube?: number;
  23528. radialSegments?: number;
  23529. tubularSegments?: number;
  23530. p?: number;
  23531. q?: number;
  23532. sideOrientation?: number;
  23533. frontUVs?: Vector4;
  23534. backUVs?: Vector4;
  23535. }): VertexData;
  23536. /**
  23537. * Compute normals for given positions and indices
  23538. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23539. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23540. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23541. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23542. * * facetNormals : optional array of facet normals (vector3)
  23543. * * facetPositions : optional array of facet positions (vector3)
  23544. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23545. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23546. * * bInfo : optional bounding info, required for facetPartitioning computation
  23547. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23548. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23549. * * useRightHandedSystem: optional boolean to for right handed system computation
  23550. * * depthSort : optional boolean to enable the facet depth sort computation
  23551. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23552. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23553. */
  23554. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23555. facetNormals?: any;
  23556. facetPositions?: any;
  23557. facetPartitioning?: any;
  23558. ratio?: number;
  23559. bInfo?: any;
  23560. bbSize?: Vector3;
  23561. subDiv?: any;
  23562. useRightHandedSystem?: boolean;
  23563. depthSort?: boolean;
  23564. distanceTo?: Vector3;
  23565. depthSortedFacets?: any;
  23566. }): void;
  23567. /** @hidden */
  23568. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23569. /**
  23570. * Applies VertexData created from the imported parameters to the geometry
  23571. * @param parsedVertexData the parsed data from an imported file
  23572. * @param geometry the geometry to apply the VertexData to
  23573. */
  23574. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23575. }
  23576. }
  23577. declare module "babylonjs/Morph/morphTarget" {
  23578. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23579. import { Observable } from "babylonjs/Misc/observable";
  23580. import { Nullable, FloatArray } from "babylonjs/types";
  23581. import { Scene } from "babylonjs/scene";
  23582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23583. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23584. /**
  23585. * Defines a target to use with MorphTargetManager
  23586. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23587. */
  23588. export class MorphTarget implements IAnimatable {
  23589. /** defines the name of the target */
  23590. name: string;
  23591. /**
  23592. * Gets or sets the list of animations
  23593. */
  23594. animations: import("babylonjs/Animations/animation").Animation[];
  23595. private _scene;
  23596. private _positions;
  23597. private _normals;
  23598. private _tangents;
  23599. private _uvs;
  23600. private _influence;
  23601. private _uniqueId;
  23602. /**
  23603. * Observable raised when the influence changes
  23604. */
  23605. onInfluenceChanged: Observable<boolean>;
  23606. /** @hidden */
  23607. _onDataLayoutChanged: Observable<void>;
  23608. /**
  23609. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23610. */
  23611. get influence(): number;
  23612. set influence(influence: number);
  23613. /**
  23614. * Gets or sets the id of the morph Target
  23615. */
  23616. id: string;
  23617. private _animationPropertiesOverride;
  23618. /**
  23619. * Gets or sets the animation properties override
  23620. */
  23621. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23622. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23623. /**
  23624. * Creates a new MorphTarget
  23625. * @param name defines the name of the target
  23626. * @param influence defines the influence to use
  23627. * @param scene defines the scene the morphtarget belongs to
  23628. */
  23629. constructor(
  23630. /** defines the name of the target */
  23631. name: string, influence?: number, scene?: Nullable<Scene>);
  23632. /**
  23633. * Gets the unique ID of this manager
  23634. */
  23635. get uniqueId(): number;
  23636. /**
  23637. * Gets a boolean defining if the target contains position data
  23638. */
  23639. get hasPositions(): boolean;
  23640. /**
  23641. * Gets a boolean defining if the target contains normal data
  23642. */
  23643. get hasNormals(): boolean;
  23644. /**
  23645. * Gets a boolean defining if the target contains tangent data
  23646. */
  23647. get hasTangents(): boolean;
  23648. /**
  23649. * Gets a boolean defining if the target contains texture coordinates data
  23650. */
  23651. get hasUVs(): boolean;
  23652. /**
  23653. * Affects position data to this target
  23654. * @param data defines the position data to use
  23655. */
  23656. setPositions(data: Nullable<FloatArray>): void;
  23657. /**
  23658. * Gets the position data stored in this target
  23659. * @returns a FloatArray containing the position data (or null if not present)
  23660. */
  23661. getPositions(): Nullable<FloatArray>;
  23662. /**
  23663. * Affects normal data to this target
  23664. * @param data defines the normal data to use
  23665. */
  23666. setNormals(data: Nullable<FloatArray>): void;
  23667. /**
  23668. * Gets the normal data stored in this target
  23669. * @returns a FloatArray containing the normal data (or null if not present)
  23670. */
  23671. getNormals(): Nullable<FloatArray>;
  23672. /**
  23673. * Affects tangent data to this target
  23674. * @param data defines the tangent data to use
  23675. */
  23676. setTangents(data: Nullable<FloatArray>): void;
  23677. /**
  23678. * Gets the tangent data stored in this target
  23679. * @returns a FloatArray containing the tangent data (or null if not present)
  23680. */
  23681. getTangents(): Nullable<FloatArray>;
  23682. /**
  23683. * Affects texture coordinates data to this target
  23684. * @param data defines the texture coordinates data to use
  23685. */
  23686. setUVs(data: Nullable<FloatArray>): void;
  23687. /**
  23688. * Gets the texture coordinates data stored in this target
  23689. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23690. */
  23691. getUVs(): Nullable<FloatArray>;
  23692. /**
  23693. * Clone the current target
  23694. * @returns a new MorphTarget
  23695. */
  23696. clone(): MorphTarget;
  23697. /**
  23698. * Serializes the current target into a Serialization object
  23699. * @returns the serialized object
  23700. */
  23701. serialize(): any;
  23702. /**
  23703. * Returns the string "MorphTarget"
  23704. * @returns "MorphTarget"
  23705. */
  23706. getClassName(): string;
  23707. /**
  23708. * Creates a new target from serialized data
  23709. * @param serializationObject defines the serialized data to use
  23710. * @returns a new MorphTarget
  23711. */
  23712. static Parse(serializationObject: any): MorphTarget;
  23713. /**
  23714. * Creates a MorphTarget from mesh data
  23715. * @param mesh defines the source mesh
  23716. * @param name defines the name to use for the new target
  23717. * @param influence defines the influence to attach to the target
  23718. * @returns a new MorphTarget
  23719. */
  23720. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23721. }
  23722. }
  23723. declare module "babylonjs/Morph/morphTargetManager" {
  23724. import { Nullable } from "babylonjs/types";
  23725. import { Scene } from "babylonjs/scene";
  23726. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23727. /**
  23728. * This class is used to deform meshes using morphing between different targets
  23729. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23730. */
  23731. export class MorphTargetManager {
  23732. private _targets;
  23733. private _targetInfluenceChangedObservers;
  23734. private _targetDataLayoutChangedObservers;
  23735. private _activeTargets;
  23736. private _scene;
  23737. private _influences;
  23738. private _supportsNormals;
  23739. private _supportsTangents;
  23740. private _supportsUVs;
  23741. private _vertexCount;
  23742. private _uniqueId;
  23743. private _tempInfluences;
  23744. /**
  23745. * Gets or sets a boolean indicating if normals must be morphed
  23746. */
  23747. enableNormalMorphing: boolean;
  23748. /**
  23749. * Gets or sets a boolean indicating if tangents must be morphed
  23750. */
  23751. enableTangentMorphing: boolean;
  23752. /**
  23753. * Gets or sets a boolean indicating if UV must be morphed
  23754. */
  23755. enableUVMorphing: boolean;
  23756. /**
  23757. * Creates a new MorphTargetManager
  23758. * @param scene defines the current scene
  23759. */
  23760. constructor(scene?: Nullable<Scene>);
  23761. /**
  23762. * Gets the unique ID of this manager
  23763. */
  23764. get uniqueId(): number;
  23765. /**
  23766. * Gets the number of vertices handled by this manager
  23767. */
  23768. get vertexCount(): number;
  23769. /**
  23770. * Gets a boolean indicating if this manager supports morphing of normals
  23771. */
  23772. get supportsNormals(): boolean;
  23773. /**
  23774. * Gets a boolean indicating if this manager supports morphing of tangents
  23775. */
  23776. get supportsTangents(): boolean;
  23777. /**
  23778. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23779. */
  23780. get supportsUVs(): boolean;
  23781. /**
  23782. * Gets the number of targets stored in this manager
  23783. */
  23784. get numTargets(): number;
  23785. /**
  23786. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23787. */
  23788. get numInfluencers(): number;
  23789. /**
  23790. * Gets the list of influences (one per target)
  23791. */
  23792. get influences(): Float32Array;
  23793. /**
  23794. * Gets the active target at specified index. An active target is a target with an influence > 0
  23795. * @param index defines the index to check
  23796. * @returns the requested target
  23797. */
  23798. getActiveTarget(index: number): MorphTarget;
  23799. /**
  23800. * Gets the target at specified index
  23801. * @param index defines the index to check
  23802. * @returns the requested target
  23803. */
  23804. getTarget(index: number): MorphTarget;
  23805. /**
  23806. * Add a new target to this manager
  23807. * @param target defines the target to add
  23808. */
  23809. addTarget(target: MorphTarget): void;
  23810. /**
  23811. * Removes a target from the manager
  23812. * @param target defines the target to remove
  23813. */
  23814. removeTarget(target: MorphTarget): void;
  23815. /**
  23816. * Clone the current manager
  23817. * @returns a new MorphTargetManager
  23818. */
  23819. clone(): MorphTargetManager;
  23820. /**
  23821. * Serializes the current manager into a Serialization object
  23822. * @returns the serialized object
  23823. */
  23824. serialize(): any;
  23825. private _syncActiveTargets;
  23826. /**
  23827. * Syncrhonize the targets with all the meshes using this morph target manager
  23828. */
  23829. synchronize(): void;
  23830. /**
  23831. * Creates a new MorphTargetManager from serialized data
  23832. * @param serializationObject defines the serialized data
  23833. * @param scene defines the hosting scene
  23834. * @returns the new MorphTargetManager
  23835. */
  23836. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23837. }
  23838. }
  23839. declare module "babylonjs/Meshes/meshLODLevel" {
  23840. import { Mesh } from "babylonjs/Meshes/mesh";
  23841. import { Nullable } from "babylonjs/types";
  23842. /**
  23843. * Class used to represent a specific level of detail of a mesh
  23844. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23845. */
  23846. export class MeshLODLevel {
  23847. /** Defines the distance where this level should start being displayed */
  23848. distance: number;
  23849. /** Defines the mesh to use to render this level */
  23850. mesh: Nullable<Mesh>;
  23851. /**
  23852. * Creates a new LOD level
  23853. * @param distance defines the distance where this level should star being displayed
  23854. * @param mesh defines the mesh to use to render this level
  23855. */
  23856. constructor(
  23857. /** Defines the distance where this level should start being displayed */
  23858. distance: number,
  23859. /** Defines the mesh to use to render this level */
  23860. mesh: Nullable<Mesh>);
  23861. }
  23862. }
  23863. declare module "babylonjs/Meshes/groundMesh" {
  23864. import { Scene } from "babylonjs/scene";
  23865. import { Vector3 } from "babylonjs/Maths/math.vector";
  23866. import { Mesh } from "babylonjs/Meshes/mesh";
  23867. /**
  23868. * Mesh representing the gorund
  23869. */
  23870. export class GroundMesh extends Mesh {
  23871. /** If octree should be generated */
  23872. generateOctree: boolean;
  23873. private _heightQuads;
  23874. /** @hidden */
  23875. _subdivisionsX: number;
  23876. /** @hidden */
  23877. _subdivisionsY: number;
  23878. /** @hidden */
  23879. _width: number;
  23880. /** @hidden */
  23881. _height: number;
  23882. /** @hidden */
  23883. _minX: number;
  23884. /** @hidden */
  23885. _maxX: number;
  23886. /** @hidden */
  23887. _minZ: number;
  23888. /** @hidden */
  23889. _maxZ: number;
  23890. constructor(name: string, scene: Scene);
  23891. /**
  23892. * "GroundMesh"
  23893. * @returns "GroundMesh"
  23894. */
  23895. getClassName(): string;
  23896. /**
  23897. * The minimum of x and y subdivisions
  23898. */
  23899. get subdivisions(): number;
  23900. /**
  23901. * X subdivisions
  23902. */
  23903. get subdivisionsX(): number;
  23904. /**
  23905. * Y subdivisions
  23906. */
  23907. get subdivisionsY(): number;
  23908. /**
  23909. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23910. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23911. * @param chunksCount the number of subdivisions for x and y
  23912. * @param octreeBlocksSize (Default: 32)
  23913. */
  23914. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23915. /**
  23916. * Returns a height (y) value in the Worl system :
  23917. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23918. * @param x x coordinate
  23919. * @param z z coordinate
  23920. * @returns the ground y position if (x, z) are outside the ground surface.
  23921. */
  23922. getHeightAtCoordinates(x: number, z: number): number;
  23923. /**
  23924. * Returns a normalized vector (Vector3) orthogonal to the ground
  23925. * at the ground coordinates (x, z) expressed in the World system.
  23926. * @param x x coordinate
  23927. * @param z z coordinate
  23928. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23929. */
  23930. getNormalAtCoordinates(x: number, z: number): Vector3;
  23931. /**
  23932. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23933. * at the ground coordinates (x, z) expressed in the World system.
  23934. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23935. * @param x x coordinate
  23936. * @param z z coordinate
  23937. * @param ref vector to store the result
  23938. * @returns the GroundMesh.
  23939. */
  23940. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23941. /**
  23942. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23943. * if the ground has been updated.
  23944. * This can be used in the render loop.
  23945. * @returns the GroundMesh.
  23946. */
  23947. updateCoordinateHeights(): GroundMesh;
  23948. private _getFacetAt;
  23949. private _initHeightQuads;
  23950. private _computeHeightQuads;
  23951. /**
  23952. * Serializes this ground mesh
  23953. * @param serializationObject object to write serialization to
  23954. */
  23955. serialize(serializationObject: any): void;
  23956. /**
  23957. * Parses a serialized ground mesh
  23958. * @param parsedMesh the serialized mesh
  23959. * @param scene the scene to create the ground mesh in
  23960. * @returns the created ground mesh
  23961. */
  23962. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23963. }
  23964. }
  23965. declare module "babylonjs/Physics/physicsJoint" {
  23966. import { Vector3 } from "babylonjs/Maths/math.vector";
  23967. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23968. /**
  23969. * Interface for Physics-Joint data
  23970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23971. */
  23972. export interface PhysicsJointData {
  23973. /**
  23974. * The main pivot of the joint
  23975. */
  23976. mainPivot?: Vector3;
  23977. /**
  23978. * The connected pivot of the joint
  23979. */
  23980. connectedPivot?: Vector3;
  23981. /**
  23982. * The main axis of the joint
  23983. */
  23984. mainAxis?: Vector3;
  23985. /**
  23986. * The connected axis of the joint
  23987. */
  23988. connectedAxis?: Vector3;
  23989. /**
  23990. * The collision of the joint
  23991. */
  23992. collision?: boolean;
  23993. /**
  23994. * Native Oimo/Cannon/Energy data
  23995. */
  23996. nativeParams?: any;
  23997. }
  23998. /**
  23999. * This is a holder class for the physics joint created by the physics plugin
  24000. * It holds a set of functions to control the underlying joint
  24001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24002. */
  24003. export class PhysicsJoint {
  24004. /**
  24005. * The type of the physics joint
  24006. */
  24007. type: number;
  24008. /**
  24009. * The data for the physics joint
  24010. */
  24011. jointData: PhysicsJointData;
  24012. private _physicsJoint;
  24013. protected _physicsPlugin: IPhysicsEnginePlugin;
  24014. /**
  24015. * Initializes the physics joint
  24016. * @param type The type of the physics joint
  24017. * @param jointData The data for the physics joint
  24018. */
  24019. constructor(
  24020. /**
  24021. * The type of the physics joint
  24022. */
  24023. type: number,
  24024. /**
  24025. * The data for the physics joint
  24026. */
  24027. jointData: PhysicsJointData);
  24028. /**
  24029. * Gets the physics joint
  24030. */
  24031. get physicsJoint(): any;
  24032. /**
  24033. * Sets the physics joint
  24034. */
  24035. set physicsJoint(newJoint: any);
  24036. /**
  24037. * Sets the physics plugin
  24038. */
  24039. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24040. /**
  24041. * Execute a function that is physics-plugin specific.
  24042. * @param {Function} func the function that will be executed.
  24043. * It accepts two parameters: the physics world and the physics joint
  24044. */
  24045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24046. /**
  24047. * Distance-Joint type
  24048. */
  24049. static DistanceJoint: number;
  24050. /**
  24051. * Hinge-Joint type
  24052. */
  24053. static HingeJoint: number;
  24054. /**
  24055. * Ball-and-Socket joint type
  24056. */
  24057. static BallAndSocketJoint: number;
  24058. /**
  24059. * Wheel-Joint type
  24060. */
  24061. static WheelJoint: number;
  24062. /**
  24063. * Slider-Joint type
  24064. */
  24065. static SliderJoint: number;
  24066. /**
  24067. * Prismatic-Joint type
  24068. */
  24069. static PrismaticJoint: number;
  24070. /**
  24071. * Universal-Joint type
  24072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24073. */
  24074. static UniversalJoint: number;
  24075. /**
  24076. * Hinge-Joint 2 type
  24077. */
  24078. static Hinge2Joint: number;
  24079. /**
  24080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24081. */
  24082. static PointToPointJoint: number;
  24083. /**
  24084. * Spring-Joint type
  24085. */
  24086. static SpringJoint: number;
  24087. /**
  24088. * Lock-Joint type
  24089. */
  24090. static LockJoint: number;
  24091. }
  24092. /**
  24093. * A class representing a physics distance joint
  24094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24095. */
  24096. export class DistanceJoint extends PhysicsJoint {
  24097. /**
  24098. *
  24099. * @param jointData The data for the Distance-Joint
  24100. */
  24101. constructor(jointData: DistanceJointData);
  24102. /**
  24103. * Update the predefined distance.
  24104. * @param maxDistance The maximum preferred distance
  24105. * @param minDistance The minimum preferred distance
  24106. */
  24107. updateDistance(maxDistance: number, minDistance?: number): void;
  24108. }
  24109. /**
  24110. * Represents a Motor-Enabled Joint
  24111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24112. */
  24113. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24114. /**
  24115. * Initializes the Motor-Enabled Joint
  24116. * @param type The type of the joint
  24117. * @param jointData The physica joint data for the joint
  24118. */
  24119. constructor(type: number, jointData: PhysicsJointData);
  24120. /**
  24121. * Set the motor values.
  24122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24123. * @param force the force to apply
  24124. * @param maxForce max force for this motor.
  24125. */
  24126. setMotor(force?: number, maxForce?: number): void;
  24127. /**
  24128. * Set the motor's limits.
  24129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24130. * @param upperLimit The upper limit of the motor
  24131. * @param lowerLimit The lower limit of the motor
  24132. */
  24133. setLimit(upperLimit: number, lowerLimit?: number): void;
  24134. }
  24135. /**
  24136. * This class represents a single physics Hinge-Joint
  24137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24138. */
  24139. export class HingeJoint extends MotorEnabledJoint {
  24140. /**
  24141. * Initializes the Hinge-Joint
  24142. * @param jointData The joint data for the Hinge-Joint
  24143. */
  24144. constructor(jointData: PhysicsJointData);
  24145. /**
  24146. * Set the motor values.
  24147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24148. * @param {number} force the force to apply
  24149. * @param {number} maxForce max force for this motor.
  24150. */
  24151. setMotor(force?: number, maxForce?: number): void;
  24152. /**
  24153. * Set the motor's limits.
  24154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24155. * @param upperLimit The upper limit of the motor
  24156. * @param lowerLimit The lower limit of the motor
  24157. */
  24158. setLimit(upperLimit: number, lowerLimit?: number): void;
  24159. }
  24160. /**
  24161. * This class represents a dual hinge physics joint (same as wheel joint)
  24162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24163. */
  24164. export class Hinge2Joint extends MotorEnabledJoint {
  24165. /**
  24166. * Initializes the Hinge2-Joint
  24167. * @param jointData The joint data for the Hinge2-Joint
  24168. */
  24169. constructor(jointData: PhysicsJointData);
  24170. /**
  24171. * Set the motor values.
  24172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24173. * @param {number} targetSpeed the speed the motor is to reach
  24174. * @param {number} maxForce max force for this motor.
  24175. * @param {motorIndex} the motor's index, 0 or 1.
  24176. */
  24177. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24178. /**
  24179. * Set the motor limits.
  24180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24181. * @param {number} upperLimit the upper limit
  24182. * @param {number} lowerLimit lower limit
  24183. * @param {motorIndex} the motor's index, 0 or 1.
  24184. */
  24185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24186. }
  24187. /**
  24188. * Interface for a motor enabled joint
  24189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24190. */
  24191. export interface IMotorEnabledJoint {
  24192. /**
  24193. * Physics joint
  24194. */
  24195. physicsJoint: any;
  24196. /**
  24197. * Sets the motor of the motor-enabled joint
  24198. * @param force The force of the motor
  24199. * @param maxForce The maximum force of the motor
  24200. * @param motorIndex The index of the motor
  24201. */
  24202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24203. /**
  24204. * Sets the limit of the motor
  24205. * @param upperLimit The upper limit of the motor
  24206. * @param lowerLimit The lower limit of the motor
  24207. * @param motorIndex The index of the motor
  24208. */
  24209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24210. }
  24211. /**
  24212. * Joint data for a Distance-Joint
  24213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24214. */
  24215. export interface DistanceJointData extends PhysicsJointData {
  24216. /**
  24217. * Max distance the 2 joint objects can be apart
  24218. */
  24219. maxDistance: number;
  24220. }
  24221. /**
  24222. * Joint data from a spring joint
  24223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24224. */
  24225. export interface SpringJointData extends PhysicsJointData {
  24226. /**
  24227. * Length of the spring
  24228. */
  24229. length: number;
  24230. /**
  24231. * Stiffness of the spring
  24232. */
  24233. stiffness: number;
  24234. /**
  24235. * Damping of the spring
  24236. */
  24237. damping: number;
  24238. /** this callback will be called when applying the force to the impostors. */
  24239. forceApplicationCallback: () => void;
  24240. }
  24241. }
  24242. declare module "babylonjs/Physics/physicsRaycastResult" {
  24243. import { Vector3 } from "babylonjs/Maths/math.vector";
  24244. /**
  24245. * Holds the data for the raycast result
  24246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24247. */
  24248. export class PhysicsRaycastResult {
  24249. private _hasHit;
  24250. private _hitDistance;
  24251. private _hitNormalWorld;
  24252. private _hitPointWorld;
  24253. private _rayFromWorld;
  24254. private _rayToWorld;
  24255. /**
  24256. * Gets if there was a hit
  24257. */
  24258. get hasHit(): boolean;
  24259. /**
  24260. * Gets the distance from the hit
  24261. */
  24262. get hitDistance(): number;
  24263. /**
  24264. * Gets the hit normal/direction in the world
  24265. */
  24266. get hitNormalWorld(): Vector3;
  24267. /**
  24268. * Gets the hit point in the world
  24269. */
  24270. get hitPointWorld(): Vector3;
  24271. /**
  24272. * Gets the ray "start point" of the ray in the world
  24273. */
  24274. get rayFromWorld(): Vector3;
  24275. /**
  24276. * Gets the ray "end point" of the ray in the world
  24277. */
  24278. get rayToWorld(): Vector3;
  24279. /**
  24280. * Sets the hit data (normal & point in world space)
  24281. * @param hitNormalWorld defines the normal in world space
  24282. * @param hitPointWorld defines the point in world space
  24283. */
  24284. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24285. /**
  24286. * Sets the distance from the start point to the hit point
  24287. * @param distance
  24288. */
  24289. setHitDistance(distance: number): void;
  24290. /**
  24291. * Calculates the distance manually
  24292. */
  24293. calculateHitDistance(): void;
  24294. /**
  24295. * Resets all the values to default
  24296. * @param from The from point on world space
  24297. * @param to The to point on world space
  24298. */
  24299. reset(from?: Vector3, to?: Vector3): void;
  24300. }
  24301. /**
  24302. * Interface for the size containing width and height
  24303. */
  24304. interface IXYZ {
  24305. /**
  24306. * X
  24307. */
  24308. x: number;
  24309. /**
  24310. * Y
  24311. */
  24312. y: number;
  24313. /**
  24314. * Z
  24315. */
  24316. z: number;
  24317. }
  24318. }
  24319. declare module "babylonjs/Physics/IPhysicsEngine" {
  24320. import { Nullable } from "babylonjs/types";
  24321. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24323. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24324. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24325. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24326. /**
  24327. * Interface used to describe a physics joint
  24328. */
  24329. export interface PhysicsImpostorJoint {
  24330. /** Defines the main impostor to which the joint is linked */
  24331. mainImpostor: PhysicsImpostor;
  24332. /** Defines the impostor that is connected to the main impostor using this joint */
  24333. connectedImpostor: PhysicsImpostor;
  24334. /** Defines the joint itself */
  24335. joint: PhysicsJoint;
  24336. }
  24337. /** @hidden */
  24338. export interface IPhysicsEnginePlugin {
  24339. world: any;
  24340. name: string;
  24341. setGravity(gravity: Vector3): void;
  24342. setTimeStep(timeStep: number): void;
  24343. getTimeStep(): number;
  24344. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24348. removePhysicsBody(impostor: PhysicsImpostor): void;
  24349. generateJoint(joint: PhysicsImpostorJoint): void;
  24350. removeJoint(joint: PhysicsImpostorJoint): void;
  24351. isSupported(): boolean;
  24352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24353. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24359. getBodyMass(impostor: PhysicsImpostor): number;
  24360. getBodyFriction(impostor: PhysicsImpostor): number;
  24361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24362. getBodyRestitution(impostor: PhysicsImpostor): number;
  24363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24364. getBodyPressure?(impostor: PhysicsImpostor): number;
  24365. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24366. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24367. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24368. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24369. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24370. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24371. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24372. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24373. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24374. sleepBody(impostor: PhysicsImpostor): void;
  24375. wakeUpBody(impostor: PhysicsImpostor): void;
  24376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24377. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24378. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24380. getRadius(impostor: PhysicsImpostor): number;
  24381. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24383. dispose(): void;
  24384. }
  24385. /**
  24386. * Interface used to define a physics engine
  24387. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24388. */
  24389. export interface IPhysicsEngine {
  24390. /**
  24391. * Gets the gravity vector used by the simulation
  24392. */
  24393. gravity: Vector3;
  24394. /**
  24395. * Sets the gravity vector used by the simulation
  24396. * @param gravity defines the gravity vector to use
  24397. */
  24398. setGravity(gravity: Vector3): void;
  24399. /**
  24400. * Set the time step of the physics engine.
  24401. * Default is 1/60.
  24402. * To slow it down, enter 1/600 for example.
  24403. * To speed it up, 1/30
  24404. * @param newTimeStep the new timestep to apply to this world.
  24405. */
  24406. setTimeStep(newTimeStep: number): void;
  24407. /**
  24408. * Get the time step of the physics engine.
  24409. * @returns the current time step
  24410. */
  24411. getTimeStep(): number;
  24412. /**
  24413. * Set the sub time step of the physics engine.
  24414. * Default is 0 meaning there is no sub steps
  24415. * To increase physics resolution precision, set a small value (like 1 ms)
  24416. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24417. */
  24418. setSubTimeStep(subTimeStep: number): void;
  24419. /**
  24420. * Get the sub time step of the physics engine.
  24421. * @returns the current sub time step
  24422. */
  24423. getSubTimeStep(): number;
  24424. /**
  24425. * Release all resources
  24426. */
  24427. dispose(): void;
  24428. /**
  24429. * Gets the name of the current physics plugin
  24430. * @returns the name of the plugin
  24431. */
  24432. getPhysicsPluginName(): string;
  24433. /**
  24434. * Adding a new impostor for the impostor tracking.
  24435. * This will be done by the impostor itself.
  24436. * @param impostor the impostor to add
  24437. */
  24438. addImpostor(impostor: PhysicsImpostor): void;
  24439. /**
  24440. * Remove an impostor from the engine.
  24441. * This impostor and its mesh will not longer be updated by the physics engine.
  24442. * @param impostor the impostor to remove
  24443. */
  24444. removeImpostor(impostor: PhysicsImpostor): void;
  24445. /**
  24446. * Add a joint to the physics engine
  24447. * @param mainImpostor defines the main impostor to which the joint is added.
  24448. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24449. * @param joint defines the joint that will connect both impostors.
  24450. */
  24451. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24452. /**
  24453. * Removes a joint from the simulation
  24454. * @param mainImpostor defines the impostor used with the joint
  24455. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24456. * @param joint defines the joint to remove
  24457. */
  24458. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24459. /**
  24460. * Gets the current plugin used to run the simulation
  24461. * @returns current plugin
  24462. */
  24463. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24464. /**
  24465. * Gets the list of physic impostors
  24466. * @returns an array of PhysicsImpostor
  24467. */
  24468. getImpostors(): Array<PhysicsImpostor>;
  24469. /**
  24470. * Gets the impostor for a physics enabled object
  24471. * @param object defines the object impersonated by the impostor
  24472. * @returns the PhysicsImpostor or null if not found
  24473. */
  24474. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24475. /**
  24476. * Gets the impostor for a physics body object
  24477. * @param body defines physics body used by the impostor
  24478. * @returns the PhysicsImpostor or null if not found
  24479. */
  24480. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24481. /**
  24482. * Does a raycast in the physics world
  24483. * @param from when should the ray start?
  24484. * @param to when should the ray end?
  24485. * @returns PhysicsRaycastResult
  24486. */
  24487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24488. /**
  24489. * Called by the scene. No need to call it.
  24490. * @param delta defines the timespam between frames
  24491. */
  24492. _step(delta: number): void;
  24493. }
  24494. }
  24495. declare module "babylonjs/Physics/physicsImpostor" {
  24496. import { Nullable, IndicesArray } from "babylonjs/types";
  24497. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24500. import { Scene } from "babylonjs/scene";
  24501. import { Bone } from "babylonjs/Bones/bone";
  24502. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24503. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24504. import { Space } from "babylonjs/Maths/math.axis";
  24505. /**
  24506. * The interface for the physics imposter parameters
  24507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24508. */
  24509. export interface PhysicsImpostorParameters {
  24510. /**
  24511. * The mass of the physics imposter
  24512. */
  24513. mass: number;
  24514. /**
  24515. * The friction of the physics imposter
  24516. */
  24517. friction?: number;
  24518. /**
  24519. * The coefficient of restitution of the physics imposter
  24520. */
  24521. restitution?: number;
  24522. /**
  24523. * The native options of the physics imposter
  24524. */
  24525. nativeOptions?: any;
  24526. /**
  24527. * Specifies if the parent should be ignored
  24528. */
  24529. ignoreParent?: boolean;
  24530. /**
  24531. * Specifies if bi-directional transformations should be disabled
  24532. */
  24533. disableBidirectionalTransformation?: boolean;
  24534. /**
  24535. * The pressure inside the physics imposter, soft object only
  24536. */
  24537. pressure?: number;
  24538. /**
  24539. * The stiffness the physics imposter, soft object only
  24540. */
  24541. stiffness?: number;
  24542. /**
  24543. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24544. */
  24545. velocityIterations?: number;
  24546. /**
  24547. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24548. */
  24549. positionIterations?: number;
  24550. /**
  24551. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24552. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24553. * Add to fix multiple points
  24554. */
  24555. fixedPoints?: number;
  24556. /**
  24557. * The collision margin around a soft object
  24558. */
  24559. margin?: number;
  24560. /**
  24561. * The collision margin around a soft object
  24562. */
  24563. damping?: number;
  24564. /**
  24565. * The path for a rope based on an extrusion
  24566. */
  24567. path?: any;
  24568. /**
  24569. * The shape of an extrusion used for a rope based on an extrusion
  24570. */
  24571. shape?: any;
  24572. }
  24573. /**
  24574. * Interface for a physics-enabled object
  24575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24576. */
  24577. export interface IPhysicsEnabledObject {
  24578. /**
  24579. * The position of the physics-enabled object
  24580. */
  24581. position: Vector3;
  24582. /**
  24583. * The rotation of the physics-enabled object
  24584. */
  24585. rotationQuaternion: Nullable<Quaternion>;
  24586. /**
  24587. * The scale of the physics-enabled object
  24588. */
  24589. scaling: Vector3;
  24590. /**
  24591. * The rotation of the physics-enabled object
  24592. */
  24593. rotation?: Vector3;
  24594. /**
  24595. * The parent of the physics-enabled object
  24596. */
  24597. parent?: any;
  24598. /**
  24599. * The bounding info of the physics-enabled object
  24600. * @returns The bounding info of the physics-enabled object
  24601. */
  24602. getBoundingInfo(): BoundingInfo;
  24603. /**
  24604. * Computes the world matrix
  24605. * @param force Specifies if the world matrix should be computed by force
  24606. * @returns A world matrix
  24607. */
  24608. computeWorldMatrix(force: boolean): Matrix;
  24609. /**
  24610. * Gets the world matrix
  24611. * @returns A world matrix
  24612. */
  24613. getWorldMatrix?(): Matrix;
  24614. /**
  24615. * Gets the child meshes
  24616. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24617. * @returns An array of abstract meshes
  24618. */
  24619. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24620. /**
  24621. * Gets the vertex data
  24622. * @param kind The type of vertex data
  24623. * @returns A nullable array of numbers, or a float32 array
  24624. */
  24625. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24626. /**
  24627. * Gets the indices from the mesh
  24628. * @returns A nullable array of index arrays
  24629. */
  24630. getIndices?(): Nullable<IndicesArray>;
  24631. /**
  24632. * Gets the scene from the mesh
  24633. * @returns the indices array or null
  24634. */
  24635. getScene?(): Scene;
  24636. /**
  24637. * Gets the absolute position from the mesh
  24638. * @returns the absolute position
  24639. */
  24640. getAbsolutePosition(): Vector3;
  24641. /**
  24642. * Gets the absolute pivot point from the mesh
  24643. * @returns the absolute pivot point
  24644. */
  24645. getAbsolutePivotPoint(): Vector3;
  24646. /**
  24647. * Rotates the mesh
  24648. * @param axis The axis of rotation
  24649. * @param amount The amount of rotation
  24650. * @param space The space of the rotation
  24651. * @returns The rotation transform node
  24652. */
  24653. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24654. /**
  24655. * Translates the mesh
  24656. * @param axis The axis of translation
  24657. * @param distance The distance of translation
  24658. * @param space The space of the translation
  24659. * @returns The transform node
  24660. */
  24661. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24662. /**
  24663. * Sets the absolute position of the mesh
  24664. * @param absolutePosition The absolute position of the mesh
  24665. * @returns The transform node
  24666. */
  24667. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24668. /**
  24669. * Gets the class name of the mesh
  24670. * @returns The class name
  24671. */
  24672. getClassName(): string;
  24673. }
  24674. /**
  24675. * Represents a physics imposter
  24676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24677. */
  24678. export class PhysicsImpostor {
  24679. /**
  24680. * The physics-enabled object used as the physics imposter
  24681. */
  24682. object: IPhysicsEnabledObject;
  24683. /**
  24684. * The type of the physics imposter
  24685. */
  24686. type: number;
  24687. private _options;
  24688. private _scene?;
  24689. /**
  24690. * The default object size of the imposter
  24691. */
  24692. static DEFAULT_OBJECT_SIZE: Vector3;
  24693. /**
  24694. * The identity quaternion of the imposter
  24695. */
  24696. static IDENTITY_QUATERNION: Quaternion;
  24697. /** @hidden */
  24698. _pluginData: any;
  24699. private _physicsEngine;
  24700. private _physicsBody;
  24701. private _bodyUpdateRequired;
  24702. private _onBeforePhysicsStepCallbacks;
  24703. private _onAfterPhysicsStepCallbacks;
  24704. /** @hidden */
  24705. _onPhysicsCollideCallbacks: Array<{
  24706. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24707. otherImpostors: Array<PhysicsImpostor>;
  24708. }>;
  24709. private _deltaPosition;
  24710. private _deltaRotation;
  24711. private _deltaRotationConjugated;
  24712. /** @hidden */
  24713. _isFromLine: boolean;
  24714. private _parent;
  24715. private _isDisposed;
  24716. private static _tmpVecs;
  24717. private static _tmpQuat;
  24718. /**
  24719. * Specifies if the physics imposter is disposed
  24720. */
  24721. get isDisposed(): boolean;
  24722. /**
  24723. * Gets the mass of the physics imposter
  24724. */
  24725. get mass(): number;
  24726. set mass(value: number);
  24727. /**
  24728. * Gets the coefficient of friction
  24729. */
  24730. get friction(): number;
  24731. /**
  24732. * Sets the coefficient of friction
  24733. */
  24734. set friction(value: number);
  24735. /**
  24736. * Gets the coefficient of restitution
  24737. */
  24738. get restitution(): number;
  24739. /**
  24740. * Sets the coefficient of restitution
  24741. */
  24742. set restitution(value: number);
  24743. /**
  24744. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24745. */
  24746. get pressure(): number;
  24747. /**
  24748. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24749. */
  24750. set pressure(value: number);
  24751. /**
  24752. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24753. */
  24754. get stiffness(): number;
  24755. /**
  24756. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24757. */
  24758. set stiffness(value: number);
  24759. /**
  24760. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24761. */
  24762. get velocityIterations(): number;
  24763. /**
  24764. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24765. */
  24766. set velocityIterations(value: number);
  24767. /**
  24768. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24769. */
  24770. get positionIterations(): number;
  24771. /**
  24772. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24773. */
  24774. set positionIterations(value: number);
  24775. /**
  24776. * The unique id of the physics imposter
  24777. * set by the physics engine when adding this impostor to the array
  24778. */
  24779. uniqueId: number;
  24780. /**
  24781. * @hidden
  24782. */
  24783. soft: boolean;
  24784. /**
  24785. * @hidden
  24786. */
  24787. segments: number;
  24788. private _joints;
  24789. /**
  24790. * Initializes the physics imposter
  24791. * @param object The physics-enabled object used as the physics imposter
  24792. * @param type The type of the physics imposter
  24793. * @param _options The options for the physics imposter
  24794. * @param _scene The Babylon scene
  24795. */
  24796. constructor(
  24797. /**
  24798. * The physics-enabled object used as the physics imposter
  24799. */
  24800. object: IPhysicsEnabledObject,
  24801. /**
  24802. * The type of the physics imposter
  24803. */
  24804. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24805. /**
  24806. * This function will completly initialize this impostor.
  24807. * It will create a new body - but only if this mesh has no parent.
  24808. * If it has, this impostor will not be used other than to define the impostor
  24809. * of the child mesh.
  24810. * @hidden
  24811. */
  24812. _init(): void;
  24813. private _getPhysicsParent;
  24814. /**
  24815. * Should a new body be generated.
  24816. * @returns boolean specifying if body initialization is required
  24817. */
  24818. isBodyInitRequired(): boolean;
  24819. /**
  24820. * Sets the updated scaling
  24821. * @param updated Specifies if the scaling is updated
  24822. */
  24823. setScalingUpdated(): void;
  24824. /**
  24825. * Force a regeneration of this or the parent's impostor's body.
  24826. * Use under cautious - This will remove all joints already implemented.
  24827. */
  24828. forceUpdate(): void;
  24829. /**
  24830. * Gets the body that holds this impostor. Either its own, or its parent.
  24831. */
  24832. get physicsBody(): any;
  24833. /**
  24834. * Get the parent of the physics imposter
  24835. * @returns Physics imposter or null
  24836. */
  24837. get parent(): Nullable<PhysicsImpostor>;
  24838. /**
  24839. * Sets the parent of the physics imposter
  24840. */
  24841. set parent(value: Nullable<PhysicsImpostor>);
  24842. /**
  24843. * Set the physics body. Used mainly by the physics engine/plugin
  24844. */
  24845. set physicsBody(physicsBody: any);
  24846. /**
  24847. * Resets the update flags
  24848. */
  24849. resetUpdateFlags(): void;
  24850. /**
  24851. * Gets the object extend size
  24852. * @returns the object extend size
  24853. */
  24854. getObjectExtendSize(): Vector3;
  24855. /**
  24856. * Gets the object center
  24857. * @returns The object center
  24858. */
  24859. getObjectCenter(): Vector3;
  24860. /**
  24861. * Get a specific parameter from the options parameters
  24862. * @param paramName The object parameter name
  24863. * @returns The object parameter
  24864. */
  24865. getParam(paramName: string): any;
  24866. /**
  24867. * Sets a specific parameter in the options given to the physics plugin
  24868. * @param paramName The parameter name
  24869. * @param value The value of the parameter
  24870. */
  24871. setParam(paramName: string, value: number): void;
  24872. /**
  24873. * Specifically change the body's mass option. Won't recreate the physics body object
  24874. * @param mass The mass of the physics imposter
  24875. */
  24876. setMass(mass: number): void;
  24877. /**
  24878. * Gets the linear velocity
  24879. * @returns linear velocity or null
  24880. */
  24881. getLinearVelocity(): Nullable<Vector3>;
  24882. /**
  24883. * Sets the linear velocity
  24884. * @param velocity linear velocity or null
  24885. */
  24886. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24887. /**
  24888. * Gets the angular velocity
  24889. * @returns angular velocity or null
  24890. */
  24891. getAngularVelocity(): Nullable<Vector3>;
  24892. /**
  24893. * Sets the angular velocity
  24894. * @param velocity The velocity or null
  24895. */
  24896. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24897. /**
  24898. * Execute a function with the physics plugin native code
  24899. * Provide a function the will have two variables - the world object and the physics body object
  24900. * @param func The function to execute with the physics plugin native code
  24901. */
  24902. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24903. /**
  24904. * Register a function that will be executed before the physics world is stepping forward
  24905. * @param func The function to execute before the physics world is stepped forward
  24906. */
  24907. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24908. /**
  24909. * Unregister a function that will be executed before the physics world is stepping forward
  24910. * @param func The function to execute before the physics world is stepped forward
  24911. */
  24912. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24913. /**
  24914. * Register a function that will be executed after the physics step
  24915. * @param func The function to execute after physics step
  24916. */
  24917. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24918. /**
  24919. * Unregisters a function that will be executed after the physics step
  24920. * @param func The function to execute after physics step
  24921. */
  24922. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24923. /**
  24924. * register a function that will be executed when this impostor collides against a different body
  24925. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24926. * @param func Callback that is executed on collision
  24927. */
  24928. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24929. /**
  24930. * Unregisters the physics imposter on contact
  24931. * @param collideAgainst The physics object to collide against
  24932. * @param func Callback to execute on collision
  24933. */
  24934. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24935. private _tmpQuat;
  24936. private _tmpQuat2;
  24937. /**
  24938. * Get the parent rotation
  24939. * @returns The parent rotation
  24940. */
  24941. getParentsRotation(): Quaternion;
  24942. /**
  24943. * this function is executed by the physics engine.
  24944. */
  24945. beforeStep: () => void;
  24946. /**
  24947. * this function is executed by the physics engine
  24948. */
  24949. afterStep: () => void;
  24950. /**
  24951. * Legacy collision detection event support
  24952. */
  24953. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24954. /**
  24955. * event and body object due to cannon's event-based architecture.
  24956. */
  24957. onCollide: (e: {
  24958. body: any;
  24959. }) => void;
  24960. /**
  24961. * Apply a force
  24962. * @param force The force to apply
  24963. * @param contactPoint The contact point for the force
  24964. * @returns The physics imposter
  24965. */
  24966. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24967. /**
  24968. * Apply an impulse
  24969. * @param force The impulse force
  24970. * @param contactPoint The contact point for the impulse force
  24971. * @returns The physics imposter
  24972. */
  24973. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24974. /**
  24975. * A help function to create a joint
  24976. * @param otherImpostor A physics imposter used to create a joint
  24977. * @param jointType The type of joint
  24978. * @param jointData The data for the joint
  24979. * @returns The physics imposter
  24980. */
  24981. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24982. /**
  24983. * Add a joint to this impostor with a different impostor
  24984. * @param otherImpostor A physics imposter used to add a joint
  24985. * @param joint The joint to add
  24986. * @returns The physics imposter
  24987. */
  24988. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24989. /**
  24990. * Add an anchor to a cloth impostor
  24991. * @param otherImpostor rigid impostor to anchor to
  24992. * @param width ratio across width from 0 to 1
  24993. * @param height ratio up height from 0 to 1
  24994. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24995. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24996. * @returns impostor the soft imposter
  24997. */
  24998. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24999. /**
  25000. * Add a hook to a rope impostor
  25001. * @param otherImpostor rigid impostor to anchor to
  25002. * @param length ratio across rope from 0 to 1
  25003. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25004. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25005. * @returns impostor the rope imposter
  25006. */
  25007. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25008. /**
  25009. * Will keep this body still, in a sleep mode.
  25010. * @returns the physics imposter
  25011. */
  25012. sleep(): PhysicsImpostor;
  25013. /**
  25014. * Wake the body up.
  25015. * @returns The physics imposter
  25016. */
  25017. wakeUp(): PhysicsImpostor;
  25018. /**
  25019. * Clones the physics imposter
  25020. * @param newObject The physics imposter clones to this physics-enabled object
  25021. * @returns A nullable physics imposter
  25022. */
  25023. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25024. /**
  25025. * Disposes the physics imposter
  25026. */
  25027. dispose(): void;
  25028. /**
  25029. * Sets the delta position
  25030. * @param position The delta position amount
  25031. */
  25032. setDeltaPosition(position: Vector3): void;
  25033. /**
  25034. * Sets the delta rotation
  25035. * @param rotation The delta rotation amount
  25036. */
  25037. setDeltaRotation(rotation: Quaternion): void;
  25038. /**
  25039. * Gets the box size of the physics imposter and stores the result in the input parameter
  25040. * @param result Stores the box size
  25041. * @returns The physics imposter
  25042. */
  25043. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25044. /**
  25045. * Gets the radius of the physics imposter
  25046. * @returns Radius of the physics imposter
  25047. */
  25048. getRadius(): number;
  25049. /**
  25050. * Sync a bone with this impostor
  25051. * @param bone The bone to sync to the impostor.
  25052. * @param boneMesh The mesh that the bone is influencing.
  25053. * @param jointPivot The pivot of the joint / bone in local space.
  25054. * @param distToJoint Optional distance from the impostor to the joint.
  25055. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25056. */
  25057. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25058. /**
  25059. * Sync impostor to a bone
  25060. * @param bone The bone that the impostor will be synced to.
  25061. * @param boneMesh The mesh that the bone is influencing.
  25062. * @param jointPivot The pivot of the joint / bone in local space.
  25063. * @param distToJoint Optional distance from the impostor to the joint.
  25064. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25065. * @param boneAxis Optional vector3 axis the bone is aligned with
  25066. */
  25067. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25068. /**
  25069. * No-Imposter type
  25070. */
  25071. static NoImpostor: number;
  25072. /**
  25073. * Sphere-Imposter type
  25074. */
  25075. static SphereImpostor: number;
  25076. /**
  25077. * Box-Imposter type
  25078. */
  25079. static BoxImpostor: number;
  25080. /**
  25081. * Plane-Imposter type
  25082. */
  25083. static PlaneImpostor: number;
  25084. /**
  25085. * Mesh-imposter type
  25086. */
  25087. static MeshImpostor: number;
  25088. /**
  25089. * Capsule-Impostor type (Ammo.js plugin only)
  25090. */
  25091. static CapsuleImpostor: number;
  25092. /**
  25093. * Cylinder-Imposter type
  25094. */
  25095. static CylinderImpostor: number;
  25096. /**
  25097. * Particle-Imposter type
  25098. */
  25099. static ParticleImpostor: number;
  25100. /**
  25101. * Heightmap-Imposter type
  25102. */
  25103. static HeightmapImpostor: number;
  25104. /**
  25105. * ConvexHull-Impostor type (Ammo.js plugin only)
  25106. */
  25107. static ConvexHullImpostor: number;
  25108. /**
  25109. * Custom-Imposter type (Ammo.js plugin only)
  25110. */
  25111. static CustomImpostor: number;
  25112. /**
  25113. * Rope-Imposter type
  25114. */
  25115. static RopeImpostor: number;
  25116. /**
  25117. * Cloth-Imposter type
  25118. */
  25119. static ClothImpostor: number;
  25120. /**
  25121. * Softbody-Imposter type
  25122. */
  25123. static SoftbodyImpostor: number;
  25124. }
  25125. }
  25126. declare module "babylonjs/Meshes/mesh" {
  25127. import { Observable } from "babylonjs/Misc/observable";
  25128. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25129. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25130. import { Camera } from "babylonjs/Cameras/camera";
  25131. import { Scene } from "babylonjs/scene";
  25132. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25133. import { Color4 } from "babylonjs/Maths/math.color";
  25134. import { Engine } from "babylonjs/Engines/engine";
  25135. import { Node } from "babylonjs/node";
  25136. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25137. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25138. import { Buffer } from "babylonjs/Meshes/buffer";
  25139. import { Geometry } from "babylonjs/Meshes/geometry";
  25140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25142. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25143. import { Effect } from "babylonjs/Materials/effect";
  25144. import { Material } from "babylonjs/Materials/material";
  25145. import { Skeleton } from "babylonjs/Bones/skeleton";
  25146. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25147. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25148. import { Path3D } from "babylonjs/Maths/math.path";
  25149. import { Plane } from "babylonjs/Maths/math.plane";
  25150. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25151. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25152. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25153. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25154. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25155. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25156. /**
  25157. * @hidden
  25158. **/
  25159. export class _CreationDataStorage {
  25160. closePath?: boolean;
  25161. closeArray?: boolean;
  25162. idx: number[];
  25163. dashSize: number;
  25164. gapSize: number;
  25165. path3D: Path3D;
  25166. pathArray: Vector3[][];
  25167. arc: number;
  25168. radius: number;
  25169. cap: number;
  25170. tessellation: number;
  25171. }
  25172. /**
  25173. * @hidden
  25174. **/
  25175. class _InstanceDataStorage {
  25176. visibleInstances: any;
  25177. batchCache: _InstancesBatch;
  25178. instancesBufferSize: number;
  25179. instancesBuffer: Nullable<Buffer>;
  25180. instancesData: Float32Array;
  25181. overridenInstanceCount: number;
  25182. isFrozen: boolean;
  25183. previousBatch: Nullable<_InstancesBatch>;
  25184. hardwareInstancedRendering: boolean;
  25185. sideOrientation: number;
  25186. manualUpdate: boolean;
  25187. }
  25188. /**
  25189. * @hidden
  25190. **/
  25191. export class _InstancesBatch {
  25192. mustReturn: boolean;
  25193. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25194. renderSelf: boolean[];
  25195. hardwareInstancedRendering: boolean[];
  25196. }
  25197. /**
  25198. * Class used to represent renderable models
  25199. */
  25200. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25201. /**
  25202. * Mesh side orientation : usually the external or front surface
  25203. */
  25204. static readonly FRONTSIDE: number;
  25205. /**
  25206. * Mesh side orientation : usually the internal or back surface
  25207. */
  25208. static readonly BACKSIDE: number;
  25209. /**
  25210. * Mesh side orientation : both internal and external or front and back surfaces
  25211. */
  25212. static readonly DOUBLESIDE: number;
  25213. /**
  25214. * Mesh side orientation : by default, `FRONTSIDE`
  25215. */
  25216. static readonly DEFAULTSIDE: number;
  25217. /**
  25218. * Mesh cap setting : no cap
  25219. */
  25220. static readonly NO_CAP: number;
  25221. /**
  25222. * Mesh cap setting : one cap at the beginning of the mesh
  25223. */
  25224. static readonly CAP_START: number;
  25225. /**
  25226. * Mesh cap setting : one cap at the end of the mesh
  25227. */
  25228. static readonly CAP_END: number;
  25229. /**
  25230. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25231. */
  25232. static readonly CAP_ALL: number;
  25233. /**
  25234. * Mesh pattern setting : no flip or rotate
  25235. */
  25236. static readonly NO_FLIP: number;
  25237. /**
  25238. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25239. */
  25240. static readonly FLIP_TILE: number;
  25241. /**
  25242. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25243. */
  25244. static readonly ROTATE_TILE: number;
  25245. /**
  25246. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25247. */
  25248. static readonly FLIP_ROW: number;
  25249. /**
  25250. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25251. */
  25252. static readonly ROTATE_ROW: number;
  25253. /**
  25254. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25255. */
  25256. static readonly FLIP_N_ROTATE_TILE: number;
  25257. /**
  25258. * Mesh pattern setting : rotate pattern and rotate
  25259. */
  25260. static readonly FLIP_N_ROTATE_ROW: number;
  25261. /**
  25262. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25263. */
  25264. static readonly CENTER: number;
  25265. /**
  25266. * Mesh tile positioning : part tiles on left
  25267. */
  25268. static readonly LEFT: number;
  25269. /**
  25270. * Mesh tile positioning : part tiles on right
  25271. */
  25272. static readonly RIGHT: number;
  25273. /**
  25274. * Mesh tile positioning : part tiles on top
  25275. */
  25276. static readonly TOP: number;
  25277. /**
  25278. * Mesh tile positioning : part tiles on bottom
  25279. */
  25280. static readonly BOTTOM: number;
  25281. /**
  25282. * Gets the default side orientation.
  25283. * @param orientation the orientation to value to attempt to get
  25284. * @returns the default orientation
  25285. * @hidden
  25286. */
  25287. static _GetDefaultSideOrientation(orientation?: number): number;
  25288. private _internalMeshDataInfo;
  25289. /**
  25290. * An event triggered before rendering the mesh
  25291. */
  25292. get onBeforeRenderObservable(): Observable<Mesh>;
  25293. /**
  25294. * An event triggered before binding the mesh
  25295. */
  25296. get onBeforeBindObservable(): Observable<Mesh>;
  25297. /**
  25298. * An event triggered after rendering the mesh
  25299. */
  25300. get onAfterRenderObservable(): Observable<Mesh>;
  25301. /**
  25302. * An event triggered before drawing the mesh
  25303. */
  25304. get onBeforeDrawObservable(): Observable<Mesh>;
  25305. private _onBeforeDrawObserver;
  25306. /**
  25307. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25308. */
  25309. set onBeforeDraw(callback: () => void);
  25310. get hasInstances(): boolean;
  25311. /**
  25312. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25313. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25314. */
  25315. delayLoadState: number;
  25316. /**
  25317. * Gets the list of instances created from this mesh
  25318. * it is not supposed to be modified manually.
  25319. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25321. */
  25322. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25323. /**
  25324. * Gets the file containing delay loading data for this mesh
  25325. */
  25326. delayLoadingFile: string;
  25327. /** @hidden */
  25328. _binaryInfo: any;
  25329. /**
  25330. * User defined function used to change how LOD level selection is done
  25331. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25332. */
  25333. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25334. /**
  25335. * Gets or sets the morph target manager
  25336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25337. */
  25338. get morphTargetManager(): Nullable<MorphTargetManager>;
  25339. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25340. /** @hidden */
  25341. _creationDataStorage: Nullable<_CreationDataStorage>;
  25342. /** @hidden */
  25343. _geometry: Nullable<Geometry>;
  25344. /** @hidden */
  25345. _delayInfo: Array<string>;
  25346. /** @hidden */
  25347. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25348. /** @hidden */
  25349. _instanceDataStorage: _InstanceDataStorage;
  25350. private _effectiveMaterial;
  25351. /** @hidden */
  25352. _shouldGenerateFlatShading: boolean;
  25353. /** @hidden */
  25354. _originalBuilderSideOrientation: number;
  25355. /**
  25356. * Use this property to change the original side orientation defined at construction time
  25357. */
  25358. overrideMaterialSideOrientation: Nullable<number>;
  25359. /**
  25360. * Gets the source mesh (the one used to clone this one from)
  25361. */
  25362. get source(): Nullable<Mesh>;
  25363. /**
  25364. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25365. */
  25366. get isUnIndexed(): boolean;
  25367. set isUnIndexed(value: boolean);
  25368. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25369. get worldMatrixInstancedBuffer(): Float32Array;
  25370. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25371. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25372. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25373. /**
  25374. * @constructor
  25375. * @param name The value used by scene.getMeshByName() to do a lookup.
  25376. * @param scene The scene to add this mesh to.
  25377. * @param parent The parent of this mesh, if it has one
  25378. * @param source An optional Mesh from which geometry is shared, cloned.
  25379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25380. * When false, achieved by calling a clone(), also passing False.
  25381. * This will make creation of children, recursive.
  25382. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25383. */
  25384. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25385. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25386. doNotInstantiate: boolean;
  25387. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25388. /**
  25389. * Gets the class name
  25390. * @returns the string "Mesh".
  25391. */
  25392. getClassName(): string;
  25393. /** @hidden */
  25394. get _isMesh(): boolean;
  25395. /**
  25396. * Returns a description of this mesh
  25397. * @param fullDetails define if full details about this mesh must be used
  25398. * @returns a descriptive string representing this mesh
  25399. */
  25400. toString(fullDetails?: boolean): string;
  25401. /** @hidden */
  25402. _unBindEffect(): void;
  25403. /**
  25404. * Gets a boolean indicating if this mesh has LOD
  25405. */
  25406. get hasLODLevels(): boolean;
  25407. /**
  25408. * Gets the list of MeshLODLevel associated with the current mesh
  25409. * @returns an array of MeshLODLevel
  25410. */
  25411. getLODLevels(): MeshLODLevel[];
  25412. private _sortLODLevels;
  25413. /**
  25414. * Add a mesh as LOD level triggered at the given distance.
  25415. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25416. * @param distance The distance from the center of the object to show this level
  25417. * @param mesh The mesh to be added as LOD level (can be null)
  25418. * @return This mesh (for chaining)
  25419. */
  25420. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25421. /**
  25422. * Returns the LOD level mesh at the passed distance or null if not found.
  25423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25424. * @param distance The distance from the center of the object to show this level
  25425. * @returns a Mesh or `null`
  25426. */
  25427. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25428. /**
  25429. * Remove a mesh from the LOD array
  25430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25431. * @param mesh defines the mesh to be removed
  25432. * @return This mesh (for chaining)
  25433. */
  25434. removeLODLevel(mesh: Mesh): Mesh;
  25435. /**
  25436. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25438. * @param camera defines the camera to use to compute distance
  25439. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25440. * @return This mesh (for chaining)
  25441. */
  25442. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25443. /**
  25444. * Gets the mesh internal Geometry object
  25445. */
  25446. get geometry(): Nullable<Geometry>;
  25447. /**
  25448. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25449. * @returns the total number of vertices
  25450. */
  25451. getTotalVertices(): number;
  25452. /**
  25453. * Returns the content of an associated vertex buffer
  25454. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25455. * - VertexBuffer.PositionKind
  25456. * - VertexBuffer.UVKind
  25457. * - VertexBuffer.UV2Kind
  25458. * - VertexBuffer.UV3Kind
  25459. * - VertexBuffer.UV4Kind
  25460. * - VertexBuffer.UV5Kind
  25461. * - VertexBuffer.UV6Kind
  25462. * - VertexBuffer.ColorKind
  25463. * - VertexBuffer.MatricesIndicesKind
  25464. * - VertexBuffer.MatricesIndicesExtraKind
  25465. * - VertexBuffer.MatricesWeightsKind
  25466. * - VertexBuffer.MatricesWeightsExtraKind
  25467. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  25468. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25469. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25470. */
  25471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25472. /**
  25473. * Returns the mesh VertexBuffer object from the requested `kind`
  25474. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25475. * - VertexBuffer.PositionKind
  25476. * - VertexBuffer.NormalKind
  25477. * - VertexBuffer.UVKind
  25478. * - VertexBuffer.UV2Kind
  25479. * - VertexBuffer.UV3Kind
  25480. * - VertexBuffer.UV4Kind
  25481. * - VertexBuffer.UV5Kind
  25482. * - VertexBuffer.UV6Kind
  25483. * - VertexBuffer.ColorKind
  25484. * - VertexBuffer.MatricesIndicesKind
  25485. * - VertexBuffer.MatricesIndicesExtraKind
  25486. * - VertexBuffer.MatricesWeightsKind
  25487. * - VertexBuffer.MatricesWeightsExtraKind
  25488. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25489. */
  25490. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25491. /**
  25492. * Tests if a specific vertex buffer is associated with this mesh
  25493. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25494. * - VertexBuffer.PositionKind
  25495. * - VertexBuffer.NormalKind
  25496. * - VertexBuffer.UVKind
  25497. * - VertexBuffer.UV2Kind
  25498. * - VertexBuffer.UV3Kind
  25499. * - VertexBuffer.UV4Kind
  25500. * - VertexBuffer.UV5Kind
  25501. * - VertexBuffer.UV6Kind
  25502. * - VertexBuffer.ColorKind
  25503. * - VertexBuffer.MatricesIndicesKind
  25504. * - VertexBuffer.MatricesIndicesExtraKind
  25505. * - VertexBuffer.MatricesWeightsKind
  25506. * - VertexBuffer.MatricesWeightsExtraKind
  25507. * @returns a boolean
  25508. */
  25509. isVerticesDataPresent(kind: string): boolean;
  25510. /**
  25511. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25512. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25513. * - VertexBuffer.PositionKind
  25514. * - VertexBuffer.UVKind
  25515. * - VertexBuffer.UV2Kind
  25516. * - VertexBuffer.UV3Kind
  25517. * - VertexBuffer.UV4Kind
  25518. * - VertexBuffer.UV5Kind
  25519. * - VertexBuffer.UV6Kind
  25520. * - VertexBuffer.ColorKind
  25521. * - VertexBuffer.MatricesIndicesKind
  25522. * - VertexBuffer.MatricesIndicesExtraKind
  25523. * - VertexBuffer.MatricesWeightsKind
  25524. * - VertexBuffer.MatricesWeightsExtraKind
  25525. * @returns a boolean
  25526. */
  25527. isVertexBufferUpdatable(kind: string): boolean;
  25528. /**
  25529. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25530. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25531. * - VertexBuffer.PositionKind
  25532. * - VertexBuffer.NormalKind
  25533. * - VertexBuffer.UVKind
  25534. * - VertexBuffer.UV2Kind
  25535. * - VertexBuffer.UV3Kind
  25536. * - VertexBuffer.UV4Kind
  25537. * - VertexBuffer.UV5Kind
  25538. * - VertexBuffer.UV6Kind
  25539. * - VertexBuffer.ColorKind
  25540. * - VertexBuffer.MatricesIndicesKind
  25541. * - VertexBuffer.MatricesIndicesExtraKind
  25542. * - VertexBuffer.MatricesWeightsKind
  25543. * - VertexBuffer.MatricesWeightsExtraKind
  25544. * @returns an array of strings
  25545. */
  25546. getVerticesDataKinds(): string[];
  25547. /**
  25548. * Returns a positive integer : the total number of indices in this mesh geometry.
  25549. * @returns the numner of indices or zero if the mesh has no geometry.
  25550. */
  25551. getTotalIndices(): number;
  25552. /**
  25553. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25554. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  25555. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25556. * @returns the indices array or an empty array if the mesh has no geometry
  25557. */
  25558. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25559. get isBlocked(): boolean;
  25560. /**
  25561. * Determine if the current mesh is ready to be rendered
  25562. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25563. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25564. * @returns true if all associated assets are ready (material, textures, shaders)
  25565. */
  25566. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25567. /**
  25568. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  25569. */
  25570. get areNormalsFrozen(): boolean;
  25571. /**
  25572. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  25573. * @returns the current mesh
  25574. */
  25575. freezeNormals(): Mesh;
  25576. /**
  25577. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  25578. * @returns the current mesh
  25579. */
  25580. unfreezeNormals(): Mesh;
  25581. /**
  25582. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25583. */
  25584. set overridenInstanceCount(count: number);
  25585. /** @hidden */
  25586. _preActivate(): Mesh;
  25587. /** @hidden */
  25588. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25589. /** @hidden */
  25590. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25591. /**
  25592. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25593. * This means the mesh underlying bounding box and sphere are recomputed.
  25594. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25595. * @returns the current mesh
  25596. */
  25597. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25598. /** @hidden */
  25599. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25600. /**
  25601. * This function will subdivide the mesh into multiple submeshes
  25602. * @param count defines the expected number of submeshes
  25603. */
  25604. subdivide(count: number): void;
  25605. /**
  25606. * Copy a FloatArray into a specific associated vertex buffer
  25607. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25608. * - VertexBuffer.PositionKind
  25609. * - VertexBuffer.UVKind
  25610. * - VertexBuffer.UV2Kind
  25611. * - VertexBuffer.UV3Kind
  25612. * - VertexBuffer.UV4Kind
  25613. * - VertexBuffer.UV5Kind
  25614. * - VertexBuffer.UV6Kind
  25615. * - VertexBuffer.ColorKind
  25616. * - VertexBuffer.MatricesIndicesKind
  25617. * - VertexBuffer.MatricesIndicesExtraKind
  25618. * - VertexBuffer.MatricesWeightsKind
  25619. * - VertexBuffer.MatricesWeightsExtraKind
  25620. * @param data defines the data source
  25621. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25622. * @param stride defines the data stride size (can be null)
  25623. * @returns the current mesh
  25624. */
  25625. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25626. /**
  25627. * Delete a vertex buffer associated with this mesh
  25628. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25629. * - VertexBuffer.PositionKind
  25630. * - VertexBuffer.UVKind
  25631. * - VertexBuffer.UV2Kind
  25632. * - VertexBuffer.UV3Kind
  25633. * - VertexBuffer.UV4Kind
  25634. * - VertexBuffer.UV5Kind
  25635. * - VertexBuffer.UV6Kind
  25636. * - VertexBuffer.ColorKind
  25637. * - VertexBuffer.MatricesIndicesKind
  25638. * - VertexBuffer.MatricesIndicesExtraKind
  25639. * - VertexBuffer.MatricesWeightsKind
  25640. * - VertexBuffer.MatricesWeightsExtraKind
  25641. */
  25642. removeVerticesData(kind: string): void;
  25643. /**
  25644. * Flags an associated vertex buffer as updatable
  25645. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25646. * - VertexBuffer.PositionKind
  25647. * - VertexBuffer.UVKind
  25648. * - VertexBuffer.UV2Kind
  25649. * - VertexBuffer.UV3Kind
  25650. * - VertexBuffer.UV4Kind
  25651. * - VertexBuffer.UV5Kind
  25652. * - VertexBuffer.UV6Kind
  25653. * - VertexBuffer.ColorKind
  25654. * - VertexBuffer.MatricesIndicesKind
  25655. * - VertexBuffer.MatricesIndicesExtraKind
  25656. * - VertexBuffer.MatricesWeightsKind
  25657. * - VertexBuffer.MatricesWeightsExtraKind
  25658. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25659. */
  25660. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25661. /**
  25662. * Sets the mesh global Vertex Buffer
  25663. * @param buffer defines the buffer to use
  25664. * @returns the current mesh
  25665. */
  25666. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25667. /**
  25668. * Update a specific associated vertex buffer
  25669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25670. * - VertexBuffer.PositionKind
  25671. * - VertexBuffer.UVKind
  25672. * - VertexBuffer.UV2Kind
  25673. * - VertexBuffer.UV3Kind
  25674. * - VertexBuffer.UV4Kind
  25675. * - VertexBuffer.UV5Kind
  25676. * - VertexBuffer.UV6Kind
  25677. * - VertexBuffer.ColorKind
  25678. * - VertexBuffer.MatricesIndicesKind
  25679. * - VertexBuffer.MatricesIndicesExtraKind
  25680. * - VertexBuffer.MatricesWeightsKind
  25681. * - VertexBuffer.MatricesWeightsExtraKind
  25682. * @param data defines the data source
  25683. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25684. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  25685. * @returns the current mesh
  25686. */
  25687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25688. /**
  25689. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25690. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25691. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25692. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25693. * @returns the current mesh
  25694. */
  25695. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25696. /**
  25697. * Creates a un-shared specific occurence of the geometry for the mesh.
  25698. * @returns the current mesh
  25699. */
  25700. makeGeometryUnique(): Mesh;
  25701. /**
  25702. * Set the index buffer of this mesh
  25703. * @param indices defines the source data
  25704. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25705. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25706. * @returns the current mesh
  25707. */
  25708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25709. /**
  25710. * Update the current index buffer
  25711. * @param indices defines the source data
  25712. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25713. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25714. * @returns the current mesh
  25715. */
  25716. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25717. /**
  25718. * Invert the geometry to move from a right handed system to a left handed one.
  25719. * @returns the current mesh
  25720. */
  25721. toLeftHanded(): Mesh;
  25722. /** @hidden */
  25723. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25724. /** @hidden */
  25725. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25726. /**
  25727. * Registers for this mesh a javascript function called just before the rendering process
  25728. * @param func defines the function to call before rendering this mesh
  25729. * @returns the current mesh
  25730. */
  25731. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25732. /**
  25733. * Disposes a previously registered javascript function called before the rendering
  25734. * @param func defines the function to remove
  25735. * @returns the current mesh
  25736. */
  25737. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25738. /**
  25739. * Registers for this mesh a javascript function called just after the rendering is complete
  25740. * @param func defines the function to call after rendering this mesh
  25741. * @returns the current mesh
  25742. */
  25743. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25744. /**
  25745. * Disposes a previously registered javascript function called after the rendering.
  25746. * @param func defines the function to remove
  25747. * @returns the current mesh
  25748. */
  25749. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25750. /** @hidden */
  25751. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25752. /** @hidden */
  25753. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25754. /** @hidden */
  25755. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25756. /** @hidden */
  25757. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25758. /** @hidden */
  25759. _rebuild(): void;
  25760. /** @hidden */
  25761. _freeze(): void;
  25762. /** @hidden */
  25763. _unFreeze(): void;
  25764. /**
  25765. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25766. * @param subMesh defines the subMesh to render
  25767. * @param enableAlphaMode defines if alpha mode can be changed
  25768. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25769. * @returns the current mesh
  25770. */
  25771. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25772. private _onBeforeDraw;
  25773. /**
  25774. * Renormalize the mesh and patch it up if there are no weights
  25775. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25776. * However in the case of zero weights then we set just a single influence to 1.
  25777. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25778. */
  25779. cleanMatrixWeights(): void;
  25780. private normalizeSkinFourWeights;
  25781. private normalizeSkinWeightsAndExtra;
  25782. /**
  25783. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25784. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25785. * the user know there was an issue with importing the mesh
  25786. * @returns a validation object with skinned, valid and report string
  25787. */
  25788. validateSkinning(): {
  25789. skinned: boolean;
  25790. valid: boolean;
  25791. report: string;
  25792. };
  25793. /** @hidden */
  25794. _checkDelayState(): Mesh;
  25795. private _queueLoad;
  25796. /**
  25797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25798. * A mesh is in the frustum if its bounding box intersects the frustum
  25799. * @param frustumPlanes defines the frustum to test
  25800. * @returns true if the mesh is in the frustum planes
  25801. */
  25802. isInFrustum(frustumPlanes: Plane[]): boolean;
  25803. /**
  25804. * Sets the mesh material by the material or multiMaterial `id` property
  25805. * @param id is a string identifying the material or the multiMaterial
  25806. * @returns the current mesh
  25807. */
  25808. setMaterialByID(id: string): Mesh;
  25809. /**
  25810. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25811. * @returns an array of IAnimatable
  25812. */
  25813. getAnimatables(): IAnimatable[];
  25814. /**
  25815. * Modifies the mesh geometry according to the passed transformation matrix.
  25816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25817. * The mesh normals are modified using the same transformation.
  25818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25819. * @param transform defines the transform matrix to use
  25820. * @see http://doc.babylonjs.com/resources/baking_transformations
  25821. * @returns the current mesh
  25822. */
  25823. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25824. /**
  25825. * Modifies the mesh geometry according to its own current World Matrix.
  25826. * The mesh World Matrix is then reset.
  25827. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25829. * @see http://doc.babylonjs.com/resources/baking_transformations
  25830. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25831. * @returns the current mesh
  25832. */
  25833. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25834. /** @hidden */
  25835. get _positions(): Nullable<Vector3[]>;
  25836. /** @hidden */
  25837. _resetPointsArrayCache(): Mesh;
  25838. /** @hidden */
  25839. _generatePointsArray(): boolean;
  25840. /**
  25841. * Returns a new Mesh object generated from the current mesh properties.
  25842. * This method must not get confused with createInstance()
  25843. * @param name is a string, the name given to the new mesh
  25844. * @param newParent can be any Node object (default `null`)
  25845. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25846. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25847. * @returns a new mesh
  25848. */
  25849. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25850. /**
  25851. * Releases resources associated with this mesh.
  25852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25854. */
  25855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25856. /** @hidden */
  25857. _disposeInstanceSpecificData(): void;
  25858. /**
  25859. * Modifies the mesh geometry according to a displacement map.
  25860. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25861. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25862. * @param url is a string, the URL from the image file is to be downloaded.
  25863. * @param minHeight is the lower limit of the displacement.
  25864. * @param maxHeight is the upper limit of the displacement.
  25865. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25866. * @param uvOffset is an optional vector2 used to offset UV.
  25867. * @param uvScale is an optional vector2 used to scale UV.
  25868. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25869. * @returns the Mesh.
  25870. */
  25871. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25872. /**
  25873. * Modifies the mesh geometry according to a displacementMap buffer.
  25874. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25875. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25876. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25877. * @param heightMapWidth is the width of the buffer image.
  25878. * @param heightMapHeight is the height of the buffer image.
  25879. * @param minHeight is the lower limit of the displacement.
  25880. * @param maxHeight is the upper limit of the displacement.
  25881. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25882. * @param uvOffset is an optional vector2 used to offset UV.
  25883. * @param uvScale is an optional vector2 used to scale UV.
  25884. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25885. * @returns the Mesh.
  25886. */
  25887. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25888. /**
  25889. * Modify the mesh to get a flat shading rendering.
  25890. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25891. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25892. * @returns current mesh
  25893. */
  25894. convertToFlatShadedMesh(): Mesh;
  25895. /**
  25896. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25897. * In other words, more vertices, no more indices and a single bigger VBO.
  25898. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25899. * @returns current mesh
  25900. */
  25901. convertToUnIndexedMesh(): Mesh;
  25902. /**
  25903. * Inverses facet orientations.
  25904. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25905. * @param flipNormals will also inverts the normals
  25906. * @returns current mesh
  25907. */
  25908. flipFaces(flipNormals?: boolean): Mesh;
  25909. /**
  25910. * Increase the number of facets and hence vertices in a mesh
  25911. * Vertex normals are interpolated from existing vertex normals
  25912. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25913. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25914. */
  25915. increaseVertices(numberPerEdge: number): void;
  25916. /**
  25917. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25918. * This will undo any application of covertToFlatShadedMesh
  25919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25920. */
  25921. forceSharedVertices(): void;
  25922. /** @hidden */
  25923. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25924. /** @hidden */
  25925. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25926. /**
  25927. * Creates a new InstancedMesh object from the mesh model.
  25928. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25929. * @param name defines the name of the new instance
  25930. * @returns a new InstancedMesh
  25931. */
  25932. createInstance(name: string): InstancedMesh;
  25933. /**
  25934. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25935. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25936. * @returns the current mesh
  25937. */
  25938. synchronizeInstances(): Mesh;
  25939. /**
  25940. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25941. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25942. * This should be used together with the simplification to avoid disappearing triangles.
  25943. * @param successCallback an optional success callback to be called after the optimization finished.
  25944. * @returns the current mesh
  25945. */
  25946. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25947. /**
  25948. * Serialize current mesh
  25949. * @param serializationObject defines the object which will receive the serialization data
  25950. */
  25951. serialize(serializationObject: any): void;
  25952. /** @hidden */
  25953. _syncGeometryWithMorphTargetManager(): void;
  25954. /** @hidden */
  25955. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25956. /**
  25957. * Returns a new Mesh object parsed from the source provided.
  25958. * @param parsedMesh is the source
  25959. * @param scene defines the hosting scene
  25960. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25961. * @returns a new Mesh
  25962. */
  25963. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25964. /**
  25965. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25966. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25967. * @param name defines the name of the mesh to create
  25968. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25969. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25970. * @param closePath creates a seam between the first and the last points of each path of the path array
  25971. * @param offset is taken in account only if the `pathArray` is containing a single path
  25972. * @param scene defines the hosting scene
  25973. * @param updatable defines if the mesh must be flagged as updatable
  25974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25975. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25976. * @returns a new Mesh
  25977. */
  25978. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25979. /**
  25980. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25981. * @param name defines the name of the mesh to create
  25982. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25983. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25984. * @param scene defines the hosting scene
  25985. * @param updatable defines if the mesh must be flagged as updatable
  25986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25987. * @returns a new Mesh
  25988. */
  25989. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25990. /**
  25991. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25992. * @param name defines the name of the mesh to create
  25993. * @param size sets the size (float) of each box side (default 1)
  25994. * @param scene defines the hosting scene
  25995. * @param updatable defines if the mesh must be flagged as updatable
  25996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25997. * @returns a new Mesh
  25998. */
  25999. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26000. /**
  26001. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26002. * @param name defines the name of the mesh to create
  26003. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26004. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26005. * @param scene defines the hosting scene
  26006. * @param updatable defines if the mesh must be flagged as updatable
  26007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26008. * @returns a new Mesh
  26009. */
  26010. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26011. /**
  26012. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26013. * @param name defines the name of the mesh to create
  26014. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26015. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26016. * @param scene defines the hosting scene
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26020. /**
  26021. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26022. * @param name defines the name of the mesh to create
  26023. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26024. * @param diameterTop set the top cap diameter (floats, default 1)
  26025. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26026. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26027. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26028. * @param scene defines the hosting scene
  26029. * @param updatable defines if the mesh must be flagged as updatable
  26030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26031. * @returns a new Mesh
  26032. */
  26033. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26034. /**
  26035. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26036. * @param name defines the name of the mesh to create
  26037. * @param diameter sets the diameter size (float) of the torus (default 1)
  26038. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26039. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26040. * @param scene defines the hosting scene
  26041. * @param updatable defines if the mesh must be flagged as updatable
  26042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26043. * @returns a new Mesh
  26044. */
  26045. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26046. /**
  26047. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26048. * @param name defines the name of the mesh to create
  26049. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26050. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26051. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26052. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26053. * @param p the number of windings on X axis (positive integers, default 2)
  26054. * @param q the number of windings on Y axis (positive integers, default 3)
  26055. * @param scene defines the hosting scene
  26056. * @param updatable defines if the mesh must be flagged as updatable
  26057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26058. * @returns a new Mesh
  26059. */
  26060. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26061. /**
  26062. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26063. * @param name defines the name of the mesh to create
  26064. * @param points is an array successive Vector3
  26065. * @param scene defines the hosting scene
  26066. * @param updatable defines if the mesh must be flagged as updatable
  26067. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  26068. * @returns a new Mesh
  26069. */
  26070. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26071. /**
  26072. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26073. * @param name defines the name of the mesh to create
  26074. * @param points is an array successive Vector3
  26075. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26076. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26077. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26078. * @param scene defines the hosting scene
  26079. * @param updatable defines if the mesh must be flagged as updatable
  26080. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  26081. * @returns a new Mesh
  26082. */
  26083. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26084. /**
  26085. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26086. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26087. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  26088. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26089. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26090. * Remember you can only change the shape positions, not their number when updating a polygon.
  26091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26092. * @param name defines the name of the mesh to create
  26093. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  26094. * @param scene defines the hosting scene
  26095. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26096. * @param updatable defines if the mesh must be flagged as updatable
  26097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26098. * @param earcutInjection can be used to inject your own earcut reference
  26099. * @returns a new Mesh
  26100. */
  26101. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26102. /**
  26103. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26104. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26105. * @param name defines the name of the mesh to create
  26106. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  26107. * @param depth defines the height of extrusion
  26108. * @param scene defines the hosting scene
  26109. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26110. * @param updatable defines if the mesh must be flagged as updatable
  26111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26112. * @param earcutInjection can be used to inject your own earcut reference
  26113. * @returns a new Mesh
  26114. */
  26115. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26116. /**
  26117. * Creates an extruded shape mesh.
  26118. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  26119. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26120. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26121. * @param name defines the name of the mesh to create
  26122. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  26123. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26124. * @param scale is the value to scale the shape
  26125. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  26126. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  26127. * @param scene defines the hosting scene
  26128. * @param updatable defines if the mesh must be flagged as updatable
  26129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26130. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  26131. * @returns a new Mesh
  26132. */
  26133. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26134. /**
  26135. * Creates an custom extruded shape mesh.
  26136. * The custom extrusion is a parametric shape.
  26137. * It has no predefined shape. Its final shape will depend on the input parameters.
  26138. * Please consider using the same method from the MeshBuilder class instead
  26139. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26140. * @param name defines the name of the mesh to create
  26141. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  26142. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26143. * @param scaleFunction is a custom Javascript function called on each path point
  26144. * @param rotationFunction is a custom Javascript function called on each path point
  26145. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26146. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26147. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  26148. * @param scene defines the hosting scene
  26149. * @param updatable defines if the mesh must be flagged as updatable
  26150. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26151. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  26152. * @returns a new Mesh
  26153. */
  26154. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26155. /**
  26156. * Creates lathe mesh.
  26157. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26158. * Please consider using the same method from the MeshBuilder class instead
  26159. * @param name defines the name of the mesh to create
  26160. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  26161. * @param radius is the radius value of the lathe
  26162. * @param tessellation is the side number of the lathe.
  26163. * @param scene defines the hosting scene
  26164. * @param updatable defines if the mesh must be flagged as updatable
  26165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26166. * @returns a new Mesh
  26167. */
  26168. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26169. /**
  26170. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26171. * @param name defines the name of the mesh to create
  26172. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26173. * @param scene defines the hosting scene
  26174. * @param updatable defines if the mesh must be flagged as updatable
  26175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26176. * @returns a new Mesh
  26177. */
  26178. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26179. /**
  26180. * Creates a ground mesh.
  26181. * Please consider using the same method from the MeshBuilder class instead
  26182. * @param name defines the name of the mesh to create
  26183. * @param width set the width of the ground
  26184. * @param height set the height of the ground
  26185. * @param subdivisions sets the number of subdivisions per side
  26186. * @param scene defines the hosting scene
  26187. * @param updatable defines if the mesh must be flagged as updatable
  26188. * @returns a new Mesh
  26189. */
  26190. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26191. /**
  26192. * Creates a tiled ground mesh.
  26193. * Please consider using the same method from the MeshBuilder class instead
  26194. * @param name defines the name of the mesh to create
  26195. * @param xmin set the ground minimum X coordinate
  26196. * @param zmin set the ground minimum Y coordinate
  26197. * @param xmax set the ground maximum X coordinate
  26198. * @param zmax set the ground maximum Z coordinate
  26199. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  26200. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  26201. * @param scene defines the hosting scene
  26202. * @param updatable defines if the mesh must be flagged as updatable
  26203. * @returns a new Mesh
  26204. */
  26205. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26206. w: number;
  26207. h: number;
  26208. }, precision: {
  26209. w: number;
  26210. h: number;
  26211. }, scene: Scene, updatable?: boolean): Mesh;
  26212. /**
  26213. * Creates a ground mesh from a height map.
  26214. * Please consider using the same method from the MeshBuilder class instead
  26215. * @see http://doc.babylonjs.com/babylon101/height_map
  26216. * @param name defines the name of the mesh to create
  26217. * @param url sets the URL of the height map image resource
  26218. * @param width set the ground width size
  26219. * @param height set the ground height size
  26220. * @param subdivisions sets the number of subdivision per side
  26221. * @param minHeight is the minimum altitude on the ground
  26222. * @param maxHeight is the maximum altitude on the ground
  26223. * @param scene defines the hosting scene
  26224. * @param updatable defines if the mesh must be flagged as updatable
  26225. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26226. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26227. * @returns a new Mesh
  26228. */
  26229. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  26230. /**
  26231. * Creates a tube mesh.
  26232. * The tube is a parametric shape.
  26233. * It has no predefined shape. Its final shape will depend on the input parameters.
  26234. * Please consider using the same method from the MeshBuilder class instead
  26235. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26236. * @param name defines the name of the mesh to create
  26237. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26238. * @param radius sets the tube radius size
  26239. * @param tessellation is the number of sides on the tubular surface
  26240. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  26241. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  26242. * @param scene defines the hosting scene
  26243. * @param updatable defines if the mesh must be flagged as updatable
  26244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26245. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  26246. * @returns a new Mesh
  26247. */
  26248. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26249. (i: number, distance: number): number;
  26250. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26251. /**
  26252. * Creates a polyhedron mesh.
  26253. * Please consider using the same method from the MeshBuilder class instead.
  26254. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  26255. * * The parameter `size` (positive float, default 1) sets the polygon size
  26256. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26257. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  26258. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  26259. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  26260. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  26261. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  26262. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26265. * @param name defines the name of the mesh to create
  26266. * @param options defines the options used to create the mesh
  26267. * @param scene defines the hosting scene
  26268. * @returns a new Mesh
  26269. */
  26270. static CreatePolyhedron(name: string, options: {
  26271. type?: number;
  26272. size?: number;
  26273. sizeX?: number;
  26274. sizeY?: number;
  26275. sizeZ?: number;
  26276. custom?: any;
  26277. faceUV?: Vector4[];
  26278. faceColors?: Color4[];
  26279. updatable?: boolean;
  26280. sideOrientation?: number;
  26281. }, scene: Scene): Mesh;
  26282. /**
  26283. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26284. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26285. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  26286. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26287. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  26288. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26291. * @param name defines the name of the mesh
  26292. * @param options defines the options used to create the mesh
  26293. * @param scene defines the hosting scene
  26294. * @returns a new Mesh
  26295. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26296. */
  26297. static CreateIcoSphere(name: string, options: {
  26298. radius?: number;
  26299. flat?: boolean;
  26300. subdivisions?: number;
  26301. sideOrientation?: number;
  26302. updatable?: boolean;
  26303. }, scene: Scene): Mesh;
  26304. /**
  26305. * Creates a decal mesh.
  26306. * Please consider using the same method from the MeshBuilder class instead.
  26307. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26308. * @param name defines the name of the mesh
  26309. * @param sourceMesh defines the mesh receiving the decal
  26310. * @param position sets the position of the decal in world coordinates
  26311. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26312. * @param size sets the decal scaling
  26313. * @param angle sets the angle to rotate the decal
  26314. * @returns a new Mesh
  26315. */
  26316. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26317. /**
  26318. * Prepare internal position array for software CPU skinning
  26319. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26320. */
  26321. setPositionsForCPUSkinning(): Float32Array;
  26322. /**
  26323. * Prepare internal normal array for software CPU skinning
  26324. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26325. */
  26326. setNormalsForCPUSkinning(): Float32Array;
  26327. /**
  26328. * Updates the vertex buffer by applying transformation from the bones
  26329. * @param skeleton defines the skeleton to apply to current mesh
  26330. * @returns the current mesh
  26331. */
  26332. applySkeleton(skeleton: Skeleton): Mesh;
  26333. /**
  26334. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  26335. * @param meshes defines the list of meshes to scan
  26336. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26337. */
  26338. static MinMax(meshes: AbstractMesh[]): {
  26339. min: Vector3;
  26340. max: Vector3;
  26341. };
  26342. /**
  26343. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26344. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26345. * @returns a vector3
  26346. */
  26347. static Center(meshesOrMinMaxVector: {
  26348. min: Vector3;
  26349. max: Vector3;
  26350. } | AbstractMesh[]): Vector3;
  26351. /**
  26352. * Merge the array of meshes into a single mesh for performance reasons.
  26353. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26354. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26355. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26356. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26357. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26358. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26359. * @returns a new mesh
  26360. */
  26361. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26362. /** @hidden */
  26363. addInstance(instance: InstancedMesh): void;
  26364. /** @hidden */
  26365. removeInstance(instance: InstancedMesh): void;
  26366. }
  26367. }
  26368. declare module "babylonjs/Cameras/camera" {
  26369. import { SmartArray } from "babylonjs/Misc/smartArray";
  26370. import { Observable } from "babylonjs/Misc/observable";
  26371. import { Nullable } from "babylonjs/types";
  26372. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26373. import { Scene } from "babylonjs/scene";
  26374. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26375. import { Node } from "babylonjs/node";
  26376. import { Mesh } from "babylonjs/Meshes/mesh";
  26377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26378. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26379. import { Viewport } from "babylonjs/Maths/math.viewport";
  26380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26383. import { Ray } from "babylonjs/Culling/ray";
  26384. /**
  26385. * This is the base class of all the camera used in the application.
  26386. * @see http://doc.babylonjs.com/features/cameras
  26387. */
  26388. export class Camera extends Node {
  26389. /** @hidden */
  26390. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26391. /**
  26392. * This is the default projection mode used by the cameras.
  26393. * It helps recreating a feeling of perspective and better appreciate depth.
  26394. * This is the best way to simulate real life cameras.
  26395. */
  26396. static readonly PERSPECTIVE_CAMERA: number;
  26397. /**
  26398. * This helps creating camera with an orthographic mode.
  26399. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  26400. */
  26401. static readonly ORTHOGRAPHIC_CAMERA: number;
  26402. /**
  26403. * This is the default FOV mode for perspective cameras.
  26404. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26405. */
  26406. static readonly FOVMODE_VERTICAL_FIXED: number;
  26407. /**
  26408. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26409. */
  26410. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26411. /**
  26412. * This specifies ther is no need for a camera rig.
  26413. * Basically only one eye is rendered corresponding to the camera.
  26414. */
  26415. static readonly RIG_MODE_NONE: number;
  26416. /**
  26417. * Simulates a camera Rig with one blue eye and one red eye.
  26418. * This can be use with 3d blue and red glasses.
  26419. */
  26420. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26421. /**
  26422. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26423. */
  26424. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26425. /**
  26426. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26427. */
  26428. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26429. /**
  26430. * Defines that both eyes of the camera will be rendered over under each other.
  26431. */
  26432. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26433. /**
  26434. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26435. */
  26436. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26437. /**
  26438. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26439. */
  26440. static readonly RIG_MODE_VR: number;
  26441. /**
  26442. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26443. */
  26444. static readonly RIG_MODE_WEBVR: number;
  26445. /**
  26446. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26447. */
  26448. static readonly RIG_MODE_CUSTOM: number;
  26449. /**
  26450. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26451. */
  26452. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26453. /**
  26454. * Define the input manager associated with the camera.
  26455. */
  26456. inputs: CameraInputsManager<Camera>;
  26457. /** @hidden */
  26458. _position: Vector3;
  26459. /**
  26460. * Define the current local position of the camera in the scene
  26461. */
  26462. get position(): Vector3;
  26463. set position(newPosition: Vector3);
  26464. /**
  26465. * The vector the camera should consider as up.
  26466. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26467. */
  26468. upVector: Vector3;
  26469. /**
  26470. * Define the current limit on the left side for an orthographic camera
  26471. * In scene unit
  26472. */
  26473. orthoLeft: Nullable<number>;
  26474. /**
  26475. * Define the current limit on the right side for an orthographic camera
  26476. * In scene unit
  26477. */
  26478. orthoRight: Nullable<number>;
  26479. /**
  26480. * Define the current limit on the bottom side for an orthographic camera
  26481. * In scene unit
  26482. */
  26483. orthoBottom: Nullable<number>;
  26484. /**
  26485. * Define the current limit on the top side for an orthographic camera
  26486. * In scene unit
  26487. */
  26488. orthoTop: Nullable<number>;
  26489. /**
  26490. * Field Of View is set in Radians. (default is 0.8)
  26491. */
  26492. fov: number;
  26493. /**
  26494. * Define the minimum distance the camera can see from.
  26495. * This is important to note that the depth buffer are not infinite and the closer it starts
  26496. * the more your scene might encounter depth fighting issue.
  26497. */
  26498. minZ: number;
  26499. /**
  26500. * Define the maximum distance the camera can see to.
  26501. * This is important to note that the depth buffer are not infinite and the further it end
  26502. * the more your scene might encounter depth fighting issue.
  26503. */
  26504. maxZ: number;
  26505. /**
  26506. * Define the default inertia of the camera.
  26507. * This helps giving a smooth feeling to the camera movement.
  26508. */
  26509. inertia: number;
  26510. /**
  26511. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26512. */
  26513. mode: number;
  26514. /**
  26515. * Define whether the camera is intermediate.
  26516. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26517. */
  26518. isIntermediate: boolean;
  26519. /**
  26520. * Define the viewport of the camera.
  26521. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26522. */
  26523. viewport: Viewport;
  26524. /**
  26525. * Restricts the camera to viewing objects with the same layerMask.
  26526. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26527. */
  26528. layerMask: number;
  26529. /**
  26530. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26531. */
  26532. fovMode: number;
  26533. /**
  26534. * Rig mode of the camera.
  26535. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26536. * This is normally controlled byt the camera themselves as internal use.
  26537. */
  26538. cameraRigMode: number;
  26539. /**
  26540. * Defines the distance between both "eyes" in case of a RIG
  26541. */
  26542. interaxialDistance: number;
  26543. /**
  26544. * Defines if stereoscopic rendering is done side by side or over under.
  26545. */
  26546. isStereoscopicSideBySide: boolean;
  26547. /**
  26548. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  26549. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26550. * else in the scene. (Eg. security camera)
  26551. *
  26552. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  26553. */
  26554. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26555. /**
  26556. * When set, the camera will render to this render target instead of the default canvas
  26557. *
  26558. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26559. */
  26560. outputRenderTarget: Nullable<RenderTargetTexture>;
  26561. /**
  26562. * Observable triggered when the camera view matrix has changed.
  26563. */
  26564. onViewMatrixChangedObservable: Observable<Camera>;
  26565. /**
  26566. * Observable triggered when the camera Projection matrix has changed.
  26567. */
  26568. onProjectionMatrixChangedObservable: Observable<Camera>;
  26569. /**
  26570. * Observable triggered when the inputs have been processed.
  26571. */
  26572. onAfterCheckInputsObservable: Observable<Camera>;
  26573. /**
  26574. * Observable triggered when reset has been called and applied to the camera.
  26575. */
  26576. onRestoreStateObservable: Observable<Camera>;
  26577. /**
  26578. * Is this camera a part of a rig system?
  26579. */
  26580. isRigCamera: boolean;
  26581. /**
  26582. * If isRigCamera set to true this will be set with the parent camera.
  26583. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26584. */
  26585. rigParent?: Camera;
  26586. /** @hidden */
  26587. _cameraRigParams: any;
  26588. /** @hidden */
  26589. _rigCameras: Camera[];
  26590. /** @hidden */
  26591. _rigPostProcess: Nullable<PostProcess>;
  26592. protected _webvrViewMatrix: Matrix;
  26593. /** @hidden */
  26594. _skipRendering: boolean;
  26595. /** @hidden */
  26596. _projectionMatrix: Matrix;
  26597. /** @hidden */
  26598. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26599. /** @hidden */
  26600. _activeMeshes: SmartArray<AbstractMesh>;
  26601. protected _globalPosition: Vector3;
  26602. /** @hidden */
  26603. _computedViewMatrix: Matrix;
  26604. private _doNotComputeProjectionMatrix;
  26605. private _transformMatrix;
  26606. private _frustumPlanes;
  26607. private _refreshFrustumPlanes;
  26608. private _storedFov;
  26609. private _stateStored;
  26610. /**
  26611. * Instantiates a new camera object.
  26612. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26613. * @see http://doc.babylonjs.com/features/cameras
  26614. * @param name Defines the name of the camera in the scene
  26615. * @param position Defines the position of the camera
  26616. * @param scene Defines the scene the camera belongs too
  26617. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26618. */
  26619. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26620. /**
  26621. * Store current camera state (fov, position, etc..)
  26622. * @returns the camera
  26623. */
  26624. storeState(): Camera;
  26625. /**
  26626. * Restores the camera state values if it has been stored. You must call storeState() first
  26627. */
  26628. protected _restoreStateValues(): boolean;
  26629. /**
  26630. * Restored camera state. You must call storeState() first.
  26631. * @returns true if restored and false otherwise
  26632. */
  26633. restoreState(): boolean;
  26634. /**
  26635. * Gets the class name of the camera.
  26636. * @returns the class name
  26637. */
  26638. getClassName(): string;
  26639. /** @hidden */
  26640. readonly _isCamera: boolean;
  26641. /**
  26642. * Gets a string representation of the camera useful for debug purpose.
  26643. * @param fullDetails Defines that a more verboe level of logging is required
  26644. * @returns the string representation
  26645. */
  26646. toString(fullDetails?: boolean): string;
  26647. /**
  26648. * Gets the current world space position of the camera.
  26649. */
  26650. get globalPosition(): Vector3;
  26651. /**
  26652. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26653. * @returns the active meshe list
  26654. */
  26655. getActiveMeshes(): SmartArray<AbstractMesh>;
  26656. /**
  26657. * Check whether a mesh is part of the current active mesh list of the camera
  26658. * @param mesh Defines the mesh to check
  26659. * @returns true if active, false otherwise
  26660. */
  26661. isActiveMesh(mesh: Mesh): boolean;
  26662. /**
  26663. * Is this camera ready to be used/rendered
  26664. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26665. * @return true if the camera is ready
  26666. */
  26667. isReady(completeCheck?: boolean): boolean;
  26668. /** @hidden */
  26669. _initCache(): void;
  26670. /** @hidden */
  26671. _updateCache(ignoreParentClass?: boolean): void;
  26672. /** @hidden */
  26673. _isSynchronized(): boolean;
  26674. /** @hidden */
  26675. _isSynchronizedViewMatrix(): boolean;
  26676. /** @hidden */
  26677. _isSynchronizedProjectionMatrix(): boolean;
  26678. /**
  26679. * Attach the input controls to a specific dom element to get the input from.
  26680. * @param element Defines the element the controls should be listened from
  26681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26682. */
  26683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26684. /**
  26685. * Detach the current controls from the specified dom element.
  26686. * @param element Defines the element to stop listening the inputs from
  26687. */
  26688. detachControl(element: HTMLElement): void;
  26689. /**
  26690. * Update the camera state according to the different inputs gathered during the frame.
  26691. */
  26692. update(): void;
  26693. /** @hidden */
  26694. _checkInputs(): void;
  26695. /** @hidden */
  26696. get rigCameras(): Camera[];
  26697. /**
  26698. * Gets the post process used by the rig cameras
  26699. */
  26700. get rigPostProcess(): Nullable<PostProcess>;
  26701. /**
  26702. * Internal, gets the first post proces.
  26703. * @returns the first post process to be run on this camera.
  26704. */
  26705. _getFirstPostProcess(): Nullable<PostProcess>;
  26706. private _cascadePostProcessesToRigCams;
  26707. /**
  26708. * Attach a post process to the camera.
  26709. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26710. * @param postProcess The post process to attach to the camera
  26711. * @param insertAt The position of the post process in case several of them are in use in the scene
  26712. * @returns the position the post process has been inserted at
  26713. */
  26714. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26715. /**
  26716. * Detach a post process to the camera.
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26718. * @param postProcess The post process to detach from the camera
  26719. */
  26720. detachPostProcess(postProcess: PostProcess): void;
  26721. /**
  26722. * Gets the current world matrix of the camera
  26723. */
  26724. getWorldMatrix(): Matrix;
  26725. /** @hidden */
  26726. _getViewMatrix(): Matrix;
  26727. /**
  26728. * Gets the current view matrix of the camera.
  26729. * @param force forces the camera to recompute the matrix without looking at the cached state
  26730. * @returns the view matrix
  26731. */
  26732. getViewMatrix(force?: boolean): Matrix;
  26733. /**
  26734. * Freeze the projection matrix.
  26735. * It will prevent the cache check of the camera projection compute and can speed up perf
  26736. * if no parameter of the camera are meant to change
  26737. * @param projection Defines manually a projection if necessary
  26738. */
  26739. freezeProjectionMatrix(projection?: Matrix): void;
  26740. /**
  26741. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26742. */
  26743. unfreezeProjectionMatrix(): void;
  26744. /**
  26745. * Gets the current projection matrix of the camera.
  26746. * @param force forces the camera to recompute the matrix without looking at the cached state
  26747. * @returns the projection matrix
  26748. */
  26749. getProjectionMatrix(force?: boolean): Matrix;
  26750. /**
  26751. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26752. * @returns a Matrix
  26753. */
  26754. getTransformationMatrix(): Matrix;
  26755. private _updateFrustumPlanes;
  26756. /**
  26757. * Checks if a cullable object (mesh...) is in the camera frustum
  26758. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26759. * @param target The object to check
  26760. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26761. * @returns true if the object is in frustum otherwise false
  26762. */
  26763. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26764. /**
  26765. * Checks if a cullable object (mesh...) is in the camera frustum
  26766. * Unlike isInFrustum this cheks the full bounding box
  26767. * @param target The object to check
  26768. * @returns true if the object is in frustum otherwise false
  26769. */
  26770. isCompletelyInFrustum(target: ICullable): boolean;
  26771. /**
  26772. * Gets a ray in the forward direction from the camera.
  26773. * @param length Defines the length of the ray to create
  26774. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26775. * @param origin Defines the start point of the ray which defaults to the camera position
  26776. * @returns the forward ray
  26777. */
  26778. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26779. /**
  26780. * Releases resources associated with this node.
  26781. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26782. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26783. */
  26784. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26785. /** @hidden */
  26786. _isLeftCamera: boolean;
  26787. /**
  26788. * Gets the left camera of a rig setup in case of Rigged Camera
  26789. */
  26790. get isLeftCamera(): boolean;
  26791. /** @hidden */
  26792. _isRightCamera: boolean;
  26793. /**
  26794. * Gets the right camera of a rig setup in case of Rigged Camera
  26795. */
  26796. get isRightCamera(): boolean;
  26797. /**
  26798. * Gets the left camera of a rig setup in case of Rigged Camera
  26799. */
  26800. get leftCamera(): Nullable<FreeCamera>;
  26801. /**
  26802. * Gets the right camera of a rig setup in case of Rigged Camera
  26803. */
  26804. get rightCamera(): Nullable<FreeCamera>;
  26805. /**
  26806. * Gets the left camera target of a rig setup in case of Rigged Camera
  26807. * @returns the target position
  26808. */
  26809. getLeftTarget(): Nullable<Vector3>;
  26810. /**
  26811. * Gets the right camera target of a rig setup in case of Rigged Camera
  26812. * @returns the target position
  26813. */
  26814. getRightTarget(): Nullable<Vector3>;
  26815. /**
  26816. * @hidden
  26817. */
  26818. setCameraRigMode(mode: number, rigParams: any): void;
  26819. /** @hidden */
  26820. static _setStereoscopicRigMode(camera: Camera): void;
  26821. /** @hidden */
  26822. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26823. /** @hidden */
  26824. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26825. /** @hidden */
  26826. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26827. /** @hidden */
  26828. _getVRProjectionMatrix(): Matrix;
  26829. protected _updateCameraRotationMatrix(): void;
  26830. protected _updateWebVRCameraRotationMatrix(): void;
  26831. /**
  26832. * This function MUST be overwritten by the different WebVR cameras available.
  26833. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26834. * @hidden
  26835. */
  26836. _getWebVRProjectionMatrix(): Matrix;
  26837. /**
  26838. * This function MUST be overwritten by the different WebVR cameras available.
  26839. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26840. * @hidden
  26841. */
  26842. _getWebVRViewMatrix(): Matrix;
  26843. /** @hidden */
  26844. setCameraRigParameter(name: string, value: any): void;
  26845. /**
  26846. * needs to be overridden by children so sub has required properties to be copied
  26847. * @hidden
  26848. */
  26849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26850. /**
  26851. * May need to be overridden by children
  26852. * @hidden
  26853. */
  26854. _updateRigCameras(): void;
  26855. /** @hidden */
  26856. _setupInputs(): void;
  26857. /**
  26858. * Serialiaze the camera setup to a json represention
  26859. * @returns the JSON representation
  26860. */
  26861. serialize(): any;
  26862. /**
  26863. * Clones the current camera.
  26864. * @param name The cloned camera name
  26865. * @returns the cloned camera
  26866. */
  26867. clone(name: string): Camera;
  26868. /**
  26869. * Gets the direction of the camera relative to a given local axis.
  26870. * @param localAxis Defines the reference axis to provide a relative direction.
  26871. * @return the direction
  26872. */
  26873. getDirection(localAxis: Vector3): Vector3;
  26874. /**
  26875. * Returns the current camera absolute rotation
  26876. */
  26877. get absoluteRotation(): Quaternion;
  26878. /**
  26879. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26880. * @param localAxis Defines the reference axis to provide a relative direction.
  26881. * @param result Defines the vector to store the result in
  26882. */
  26883. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26884. /**
  26885. * Gets a camera constructor for a given camera type
  26886. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26887. * @param name The name of the camera the result will be able to instantiate
  26888. * @param scene The scene the result will construct the camera in
  26889. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26890. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26891. * @returns a factory method to construc the camera
  26892. */
  26893. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26894. /**
  26895. * Compute the world matrix of the camera.
  26896. * @returns the camera world matrix
  26897. */
  26898. computeWorldMatrix(): Matrix;
  26899. /**
  26900. * Parse a JSON and creates the camera from the parsed information
  26901. * @param parsedCamera The JSON to parse
  26902. * @param scene The scene to instantiate the camera in
  26903. * @returns the newly constructed camera
  26904. */
  26905. static Parse(parsedCamera: any, scene: Scene): Camera;
  26906. }
  26907. }
  26908. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26909. import { Nullable } from "babylonjs/types";
  26910. import { Scene } from "babylonjs/scene";
  26911. import { Vector4 } from "babylonjs/Maths/math.vector";
  26912. import { Mesh } from "babylonjs/Meshes/mesh";
  26913. /**
  26914. * Class containing static functions to help procedurally build meshes
  26915. */
  26916. export class DiscBuilder {
  26917. /**
  26918. * Creates a plane polygonal mesh. By default, this is a disc
  26919. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26920. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26921. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26925. * @param name defines the name of the mesh
  26926. * @param options defines the options used to create the mesh
  26927. * @param scene defines the hosting scene
  26928. * @returns the plane polygonal mesh
  26929. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26930. */
  26931. static CreateDisc(name: string, options: {
  26932. radius?: number;
  26933. tessellation?: number;
  26934. arc?: number;
  26935. updatable?: boolean;
  26936. sideOrientation?: number;
  26937. frontUVs?: Vector4;
  26938. backUVs?: Vector4;
  26939. }, scene?: Nullable<Scene>): Mesh;
  26940. }
  26941. }
  26942. declare module "babylonjs/Materials/fresnelParameters" {
  26943. import { DeepImmutable } from "babylonjs/types";
  26944. import { Color3 } from "babylonjs/Maths/math.color";
  26945. /**
  26946. * Options to be used when creating a FresnelParameters.
  26947. */
  26948. export type IFresnelParametersCreationOptions = {
  26949. /**
  26950. * Define the color used on edges (grazing angle)
  26951. */
  26952. leftColor?: Color3;
  26953. /**
  26954. * Define the color used on center
  26955. */
  26956. rightColor?: Color3;
  26957. /**
  26958. * Define bias applied to computed fresnel term
  26959. */
  26960. bias?: number;
  26961. /**
  26962. * Defined the power exponent applied to fresnel term
  26963. */
  26964. power?: number;
  26965. /**
  26966. * Define if the fresnel effect is enable or not.
  26967. */
  26968. isEnabled?: boolean;
  26969. };
  26970. /**
  26971. * Serialized format for FresnelParameters.
  26972. */
  26973. export type IFresnelParametersSerialized = {
  26974. /**
  26975. * Define the color used on edges (grazing angle) [as an array]
  26976. */
  26977. leftColor: number[];
  26978. /**
  26979. * Define the color used on center [as an array]
  26980. */
  26981. rightColor: number[];
  26982. /**
  26983. * Define bias applied to computed fresnel term
  26984. */
  26985. bias: number;
  26986. /**
  26987. * Defined the power exponent applied to fresnel term
  26988. */
  26989. power?: number;
  26990. /**
  26991. * Define if the fresnel effect is enable or not.
  26992. */
  26993. isEnabled: boolean;
  26994. };
  26995. /**
  26996. * This represents all the required information to add a fresnel effect on a material:
  26997. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26998. */
  26999. export class FresnelParameters {
  27000. private _isEnabled;
  27001. /**
  27002. * Define if the fresnel effect is enable or not.
  27003. */
  27004. get isEnabled(): boolean;
  27005. set isEnabled(value: boolean);
  27006. /**
  27007. * Define the color used on edges (grazing angle)
  27008. */
  27009. leftColor: Color3;
  27010. /**
  27011. * Define the color used on center
  27012. */
  27013. rightColor: Color3;
  27014. /**
  27015. * Define bias applied to computed fresnel term
  27016. */
  27017. bias: number;
  27018. /**
  27019. * Defined the power exponent applied to fresnel term
  27020. */
  27021. power: number;
  27022. /**
  27023. * Creates a new FresnelParameters object.
  27024. *
  27025. * @param options provide your own settings to optionally to override defaults
  27026. */
  27027. constructor(options?: IFresnelParametersCreationOptions);
  27028. /**
  27029. * Clones the current fresnel and its valuues
  27030. * @returns a clone fresnel configuration
  27031. */
  27032. clone(): FresnelParameters;
  27033. /**
  27034. * Determines equality between FresnelParameters objects
  27035. * @param otherFresnelParameters defines the second operand
  27036. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27037. */
  27038. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27039. /**
  27040. * Serializes the current fresnel parameters to a JSON representation.
  27041. * @return the JSON serialization
  27042. */
  27043. serialize(): IFresnelParametersSerialized;
  27044. /**
  27045. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27046. * @param parsedFresnelParameters Define the JSON representation
  27047. * @returns the parsed parameters
  27048. */
  27049. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27050. }
  27051. }
  27052. declare module "babylonjs/Materials/pushMaterial" {
  27053. import { Nullable } from "babylonjs/types";
  27054. import { Scene } from "babylonjs/scene";
  27055. import { Matrix } from "babylonjs/Maths/math.vector";
  27056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27057. import { Mesh } from "babylonjs/Meshes/mesh";
  27058. import { Material } from "babylonjs/Materials/material";
  27059. import { Effect } from "babylonjs/Materials/effect";
  27060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27061. /**
  27062. * Base class of materials working in push mode in babylon JS
  27063. * @hidden
  27064. */
  27065. export class PushMaterial extends Material {
  27066. protected _activeEffect: Effect;
  27067. protected _normalMatrix: Matrix;
  27068. /**
  27069. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27070. * This means that the material can keep using a previous shader while a new one is being compiled.
  27071. * This is mostly used when shader parallel compilation is supported (true by default)
  27072. */
  27073. allowShaderHotSwapping: boolean;
  27074. constructor(name: string, scene: Scene);
  27075. getEffect(): Effect;
  27076. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27077. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27078. /**
  27079. * Binds the given world matrix to the active effect
  27080. *
  27081. * @param world the matrix to bind
  27082. */
  27083. bindOnlyWorldMatrix(world: Matrix): void;
  27084. /**
  27085. * Binds the given normal matrix to the active effect
  27086. *
  27087. * @param normalMatrix the matrix to bind
  27088. */
  27089. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27090. bind(world: Matrix, mesh?: Mesh): void;
  27091. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27092. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27093. }
  27094. }
  27095. declare module "babylonjs/Materials/materialFlags" {
  27096. /**
  27097. * This groups all the flags used to control the materials channel.
  27098. */
  27099. export class MaterialFlags {
  27100. private static _DiffuseTextureEnabled;
  27101. /**
  27102. * Are diffuse textures enabled in the application.
  27103. */
  27104. static get DiffuseTextureEnabled(): boolean;
  27105. static set DiffuseTextureEnabled(value: boolean);
  27106. private static _AmbientTextureEnabled;
  27107. /**
  27108. * Are ambient textures enabled in the application.
  27109. */
  27110. static get AmbientTextureEnabled(): boolean;
  27111. static set AmbientTextureEnabled(value: boolean);
  27112. private static _OpacityTextureEnabled;
  27113. /**
  27114. * Are opacity textures enabled in the application.
  27115. */
  27116. static get OpacityTextureEnabled(): boolean;
  27117. static set OpacityTextureEnabled(value: boolean);
  27118. private static _ReflectionTextureEnabled;
  27119. /**
  27120. * Are reflection textures enabled in the application.
  27121. */
  27122. static get ReflectionTextureEnabled(): boolean;
  27123. static set ReflectionTextureEnabled(value: boolean);
  27124. private static _EmissiveTextureEnabled;
  27125. /**
  27126. * Are emissive textures enabled in the application.
  27127. */
  27128. static get EmissiveTextureEnabled(): boolean;
  27129. static set EmissiveTextureEnabled(value: boolean);
  27130. private static _SpecularTextureEnabled;
  27131. /**
  27132. * Are specular textures enabled in the application.
  27133. */
  27134. static get SpecularTextureEnabled(): boolean;
  27135. static set SpecularTextureEnabled(value: boolean);
  27136. private static _BumpTextureEnabled;
  27137. /**
  27138. * Are bump textures enabled in the application.
  27139. */
  27140. static get BumpTextureEnabled(): boolean;
  27141. static set BumpTextureEnabled(value: boolean);
  27142. private static _LightmapTextureEnabled;
  27143. /**
  27144. * Are lightmap textures enabled in the application.
  27145. */
  27146. static get LightmapTextureEnabled(): boolean;
  27147. static set LightmapTextureEnabled(value: boolean);
  27148. private static _RefractionTextureEnabled;
  27149. /**
  27150. * Are refraction textures enabled in the application.
  27151. */
  27152. static get RefractionTextureEnabled(): boolean;
  27153. static set RefractionTextureEnabled(value: boolean);
  27154. private static _ColorGradingTextureEnabled;
  27155. /**
  27156. * Are color grading textures enabled in the application.
  27157. */
  27158. static get ColorGradingTextureEnabled(): boolean;
  27159. static set ColorGradingTextureEnabled(value: boolean);
  27160. private static _FresnelEnabled;
  27161. /**
  27162. * Are fresnels enabled in the application.
  27163. */
  27164. static get FresnelEnabled(): boolean;
  27165. static set FresnelEnabled(value: boolean);
  27166. private static _ClearCoatTextureEnabled;
  27167. /**
  27168. * Are clear coat textures enabled in the application.
  27169. */
  27170. static get ClearCoatTextureEnabled(): boolean;
  27171. static set ClearCoatTextureEnabled(value: boolean);
  27172. private static _ClearCoatBumpTextureEnabled;
  27173. /**
  27174. * Are clear coat bump textures enabled in the application.
  27175. */
  27176. static get ClearCoatBumpTextureEnabled(): boolean;
  27177. static set ClearCoatBumpTextureEnabled(value: boolean);
  27178. private static _ClearCoatTintTextureEnabled;
  27179. /**
  27180. * Are clear coat tint textures enabled in the application.
  27181. */
  27182. static get ClearCoatTintTextureEnabled(): boolean;
  27183. static set ClearCoatTintTextureEnabled(value: boolean);
  27184. private static _SheenTextureEnabled;
  27185. /**
  27186. * Are sheen textures enabled in the application.
  27187. */
  27188. static get SheenTextureEnabled(): boolean;
  27189. static set SheenTextureEnabled(value: boolean);
  27190. private static _AnisotropicTextureEnabled;
  27191. /**
  27192. * Are anisotropic textures enabled in the application.
  27193. */
  27194. static get AnisotropicTextureEnabled(): boolean;
  27195. static set AnisotropicTextureEnabled(value: boolean);
  27196. private static _ThicknessTextureEnabled;
  27197. /**
  27198. * Are thickness textures enabled in the application.
  27199. */
  27200. static get ThicknessTextureEnabled(): boolean;
  27201. static set ThicknessTextureEnabled(value: boolean);
  27202. }
  27203. }
  27204. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27205. /** @hidden */
  27206. export var defaultFragmentDeclaration: {
  27207. name: string;
  27208. shader: string;
  27209. };
  27210. }
  27211. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27212. /** @hidden */
  27213. export var defaultUboDeclaration: {
  27214. name: string;
  27215. shader: string;
  27216. };
  27217. }
  27218. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27219. /** @hidden */
  27220. export var lightFragmentDeclaration: {
  27221. name: string;
  27222. shader: string;
  27223. };
  27224. }
  27225. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27226. /** @hidden */
  27227. export var lightUboDeclaration: {
  27228. name: string;
  27229. shader: string;
  27230. };
  27231. }
  27232. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27233. /** @hidden */
  27234. export var lightsFragmentFunctions: {
  27235. name: string;
  27236. shader: string;
  27237. };
  27238. }
  27239. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27240. /** @hidden */
  27241. export var shadowsFragmentFunctions: {
  27242. name: string;
  27243. shader: string;
  27244. };
  27245. }
  27246. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27247. /** @hidden */
  27248. export var fresnelFunction: {
  27249. name: string;
  27250. shader: string;
  27251. };
  27252. }
  27253. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27254. /** @hidden */
  27255. export var reflectionFunction: {
  27256. name: string;
  27257. shader: string;
  27258. };
  27259. }
  27260. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27261. /** @hidden */
  27262. export var bumpFragmentFunctions: {
  27263. name: string;
  27264. shader: string;
  27265. };
  27266. }
  27267. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27268. /** @hidden */
  27269. export var logDepthDeclaration: {
  27270. name: string;
  27271. shader: string;
  27272. };
  27273. }
  27274. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27275. /** @hidden */
  27276. export var bumpFragment: {
  27277. name: string;
  27278. shader: string;
  27279. };
  27280. }
  27281. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27282. /** @hidden */
  27283. export var depthPrePass: {
  27284. name: string;
  27285. shader: string;
  27286. };
  27287. }
  27288. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27289. /** @hidden */
  27290. export var lightFragment: {
  27291. name: string;
  27292. shader: string;
  27293. };
  27294. }
  27295. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27296. /** @hidden */
  27297. export var logDepthFragment: {
  27298. name: string;
  27299. shader: string;
  27300. };
  27301. }
  27302. declare module "babylonjs/Shaders/default.fragment" {
  27303. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27304. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27306. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27307. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27308. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27309. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27310. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27311. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27312. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27313. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27314. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27315. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27316. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27317. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27319. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27320. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27321. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27322. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27323. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27324. /** @hidden */
  27325. export var defaultPixelShader: {
  27326. name: string;
  27327. shader: string;
  27328. };
  27329. }
  27330. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27331. /** @hidden */
  27332. export var defaultVertexDeclaration: {
  27333. name: string;
  27334. shader: string;
  27335. };
  27336. }
  27337. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27338. /** @hidden */
  27339. export var bumpVertexDeclaration: {
  27340. name: string;
  27341. shader: string;
  27342. };
  27343. }
  27344. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27345. /** @hidden */
  27346. export var bumpVertex: {
  27347. name: string;
  27348. shader: string;
  27349. };
  27350. }
  27351. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27352. /** @hidden */
  27353. export var fogVertex: {
  27354. name: string;
  27355. shader: string;
  27356. };
  27357. }
  27358. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27359. /** @hidden */
  27360. export var shadowsVertex: {
  27361. name: string;
  27362. shader: string;
  27363. };
  27364. }
  27365. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27366. /** @hidden */
  27367. export var pointCloudVertex: {
  27368. name: string;
  27369. shader: string;
  27370. };
  27371. }
  27372. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27373. /** @hidden */
  27374. export var logDepthVertex: {
  27375. name: string;
  27376. shader: string;
  27377. };
  27378. }
  27379. declare module "babylonjs/Shaders/default.vertex" {
  27380. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27381. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27385. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27387. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27388. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27389. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27398. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27399. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27400. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27401. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27402. /** @hidden */
  27403. export var defaultVertexShader: {
  27404. name: string;
  27405. shader: string;
  27406. };
  27407. }
  27408. declare module "babylonjs/Materials/standardMaterial" {
  27409. import { SmartArray } from "babylonjs/Misc/smartArray";
  27410. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27411. import { Nullable } from "babylonjs/types";
  27412. import { Scene } from "babylonjs/scene";
  27413. import { Matrix } from "babylonjs/Maths/math.vector";
  27414. import { Color3 } from "babylonjs/Maths/math.color";
  27415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27417. import { Mesh } from "babylonjs/Meshes/mesh";
  27418. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27419. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27420. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27421. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27422. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27425. import "babylonjs/Shaders/default.fragment";
  27426. import "babylonjs/Shaders/default.vertex";
  27427. /** @hidden */
  27428. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27429. MAINUV1: boolean;
  27430. MAINUV2: boolean;
  27431. DIFFUSE: boolean;
  27432. DIFFUSEDIRECTUV: number;
  27433. AMBIENT: boolean;
  27434. AMBIENTDIRECTUV: number;
  27435. OPACITY: boolean;
  27436. OPACITYDIRECTUV: number;
  27437. OPACITYRGB: boolean;
  27438. REFLECTION: boolean;
  27439. EMISSIVE: boolean;
  27440. EMISSIVEDIRECTUV: number;
  27441. SPECULAR: boolean;
  27442. SPECULARDIRECTUV: number;
  27443. BUMP: boolean;
  27444. BUMPDIRECTUV: number;
  27445. PARALLAX: boolean;
  27446. PARALLAXOCCLUSION: boolean;
  27447. SPECULAROVERALPHA: boolean;
  27448. CLIPPLANE: boolean;
  27449. CLIPPLANE2: boolean;
  27450. CLIPPLANE3: boolean;
  27451. CLIPPLANE4: boolean;
  27452. CLIPPLANE5: boolean;
  27453. CLIPPLANE6: boolean;
  27454. ALPHATEST: boolean;
  27455. DEPTHPREPASS: boolean;
  27456. ALPHAFROMDIFFUSE: boolean;
  27457. POINTSIZE: boolean;
  27458. FOG: boolean;
  27459. SPECULARTERM: boolean;
  27460. DIFFUSEFRESNEL: boolean;
  27461. OPACITYFRESNEL: boolean;
  27462. REFLECTIONFRESNEL: boolean;
  27463. REFRACTIONFRESNEL: boolean;
  27464. EMISSIVEFRESNEL: boolean;
  27465. FRESNEL: boolean;
  27466. NORMAL: boolean;
  27467. UV1: boolean;
  27468. UV2: boolean;
  27469. VERTEXCOLOR: boolean;
  27470. VERTEXALPHA: boolean;
  27471. NUM_BONE_INFLUENCERS: number;
  27472. BonesPerMesh: number;
  27473. BONETEXTURE: boolean;
  27474. INSTANCES: boolean;
  27475. GLOSSINESS: boolean;
  27476. ROUGHNESS: boolean;
  27477. EMISSIVEASILLUMINATION: boolean;
  27478. LINKEMISSIVEWITHDIFFUSE: boolean;
  27479. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27480. LIGHTMAP: boolean;
  27481. LIGHTMAPDIRECTUV: number;
  27482. OBJECTSPACE_NORMALMAP: boolean;
  27483. USELIGHTMAPASSHADOWMAP: boolean;
  27484. REFLECTIONMAP_3D: boolean;
  27485. REFLECTIONMAP_SPHERICAL: boolean;
  27486. REFLECTIONMAP_PLANAR: boolean;
  27487. REFLECTIONMAP_CUBIC: boolean;
  27488. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27489. REFLECTIONMAP_PROJECTION: boolean;
  27490. REFLECTIONMAP_SKYBOX: boolean;
  27491. REFLECTIONMAP_EXPLICIT: boolean;
  27492. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27493. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27494. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27495. INVERTCUBICMAP: boolean;
  27496. LOGARITHMICDEPTH: boolean;
  27497. REFRACTION: boolean;
  27498. REFRACTIONMAP_3D: boolean;
  27499. REFLECTIONOVERALPHA: boolean;
  27500. TWOSIDEDLIGHTING: boolean;
  27501. SHADOWFLOAT: boolean;
  27502. MORPHTARGETS: boolean;
  27503. MORPHTARGETS_NORMAL: boolean;
  27504. MORPHTARGETS_TANGENT: boolean;
  27505. MORPHTARGETS_UV: boolean;
  27506. NUM_MORPH_INFLUENCERS: number;
  27507. NONUNIFORMSCALING: boolean;
  27508. PREMULTIPLYALPHA: boolean;
  27509. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27510. ALPHABLEND: boolean;
  27511. IMAGEPROCESSING: boolean;
  27512. VIGNETTE: boolean;
  27513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27514. VIGNETTEBLENDMODEOPAQUE: boolean;
  27515. TONEMAPPING: boolean;
  27516. TONEMAPPING_ACES: boolean;
  27517. CONTRAST: boolean;
  27518. COLORCURVES: boolean;
  27519. COLORGRADING: boolean;
  27520. COLORGRADING3D: boolean;
  27521. SAMPLER3DGREENDEPTH: boolean;
  27522. SAMPLER3DBGRMAP: boolean;
  27523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27524. MULTIVIEW: boolean;
  27525. /**
  27526. * If the reflection texture on this material is in linear color space
  27527. * @hidden
  27528. */
  27529. IS_REFLECTION_LINEAR: boolean;
  27530. /**
  27531. * If the refraction texture on this material is in linear color space
  27532. * @hidden
  27533. */
  27534. IS_REFRACTION_LINEAR: boolean;
  27535. EXPOSURE: boolean;
  27536. constructor();
  27537. setReflectionMode(modeToEnable: string): void;
  27538. }
  27539. /**
  27540. * This is the default material used in Babylon. It is the best trade off between quality
  27541. * and performances.
  27542. * @see http://doc.babylonjs.com/babylon101/materials
  27543. */
  27544. export class StandardMaterial extends PushMaterial {
  27545. private _diffuseTexture;
  27546. /**
  27547. * The basic texture of the material as viewed under a light.
  27548. */
  27549. diffuseTexture: Nullable<BaseTexture>;
  27550. private _ambientTexture;
  27551. /**
  27552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27553. */
  27554. ambientTexture: Nullable<BaseTexture>;
  27555. private _opacityTexture;
  27556. /**
  27557. * Define the transparency of the material from a texture.
  27558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27560. */
  27561. opacityTexture: Nullable<BaseTexture>;
  27562. private _reflectionTexture;
  27563. /**
  27564. * Define the texture used to display the reflection.
  27565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27566. */
  27567. reflectionTexture: Nullable<BaseTexture>;
  27568. private _emissiveTexture;
  27569. /**
  27570. * Define texture of the material as if self lit.
  27571. * This will be mixed in the final result even in the absence of light.
  27572. */
  27573. emissiveTexture: Nullable<BaseTexture>;
  27574. private _specularTexture;
  27575. /**
  27576. * Define how the color and intensity of the highlight given by the light in the material.
  27577. */
  27578. specularTexture: Nullable<BaseTexture>;
  27579. private _bumpTexture;
  27580. /**
  27581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27582. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  27583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27584. */
  27585. bumpTexture: Nullable<BaseTexture>;
  27586. private _lightmapTexture;
  27587. /**
  27588. * Complex lighting can be computationally expensive to compute at runtime.
  27589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27591. */
  27592. lightmapTexture: Nullable<BaseTexture>;
  27593. private _refractionTexture;
  27594. /**
  27595. * Define the texture used to display the refraction.
  27596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27597. */
  27598. refractionTexture: Nullable<BaseTexture>;
  27599. /**
  27600. * The color of the material lit by the environmental background lighting.
  27601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27602. */
  27603. ambientColor: Color3;
  27604. /**
  27605. * The basic color of the material as viewed under a light.
  27606. */
  27607. diffuseColor: Color3;
  27608. /**
  27609. * Define how the color and intensity of the highlight given by the light in the material.
  27610. */
  27611. specularColor: Color3;
  27612. /**
  27613. * Define the color of the material as if self lit.
  27614. * This will be mixed in the final result even in the absence of light.
  27615. */
  27616. emissiveColor: Color3;
  27617. /**
  27618. * Defines how sharp are the highlights in the material.
  27619. * The bigger the value the sharper giving a more glossy feeling to the result.
  27620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27621. */
  27622. specularPower: number;
  27623. private _useAlphaFromDiffuseTexture;
  27624. /**
  27625. * Does the transparency come from the diffuse texture alpha channel.
  27626. */
  27627. useAlphaFromDiffuseTexture: boolean;
  27628. private _useEmissiveAsIllumination;
  27629. /**
  27630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27631. */
  27632. useEmissiveAsIllumination: boolean;
  27633. private _linkEmissiveWithDiffuse;
  27634. /**
  27635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27636. * the emissive level when the final color is close to one.
  27637. */
  27638. linkEmissiveWithDiffuse: boolean;
  27639. private _useSpecularOverAlpha;
  27640. /**
  27641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27643. */
  27644. useSpecularOverAlpha: boolean;
  27645. private _useReflectionOverAlpha;
  27646. /**
  27647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27649. */
  27650. useReflectionOverAlpha: boolean;
  27651. private _disableLighting;
  27652. /**
  27653. * Does lights from the scene impacts this material.
  27654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27655. */
  27656. disableLighting: boolean;
  27657. private _useObjectSpaceNormalMap;
  27658. /**
  27659. * Allows using an object space normal map (instead of tangent space).
  27660. */
  27661. useObjectSpaceNormalMap: boolean;
  27662. private _useParallax;
  27663. /**
  27664. * Is parallax enabled or not.
  27665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27666. */
  27667. useParallax: boolean;
  27668. private _useParallaxOcclusion;
  27669. /**
  27670. * Is parallax occlusion enabled or not.
  27671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27673. */
  27674. useParallaxOcclusion: boolean;
  27675. /**
  27676. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  27677. */
  27678. parallaxScaleBias: number;
  27679. private _roughness;
  27680. /**
  27681. * Helps to define how blurry the reflections should appears in the material.
  27682. */
  27683. roughness: number;
  27684. /**
  27685. * In case of refraction, define the value of the index of refraction.
  27686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27687. */
  27688. indexOfRefraction: number;
  27689. /**
  27690. * Invert the refraction texture alongside the y axis.
  27691. * It can be useful with procedural textures or probe for instance.
  27692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27693. */
  27694. invertRefractionY: boolean;
  27695. /**
  27696. * Defines the alpha limits in alpha test mode.
  27697. */
  27698. alphaCutOff: number;
  27699. private _useLightmapAsShadowmap;
  27700. /**
  27701. * In case of light mapping, define whether the map contains light or shadow informations.
  27702. */
  27703. useLightmapAsShadowmap: boolean;
  27704. private _diffuseFresnelParameters;
  27705. /**
  27706. * Define the diffuse fresnel parameters of the material.
  27707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27708. */
  27709. diffuseFresnelParameters: FresnelParameters;
  27710. private _opacityFresnelParameters;
  27711. /**
  27712. * Define the opacity fresnel parameters of the material.
  27713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27714. */
  27715. opacityFresnelParameters: FresnelParameters;
  27716. private _reflectionFresnelParameters;
  27717. /**
  27718. * Define the reflection fresnel parameters of the material.
  27719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27720. */
  27721. reflectionFresnelParameters: FresnelParameters;
  27722. private _refractionFresnelParameters;
  27723. /**
  27724. * Define the refraction fresnel parameters of the material.
  27725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27726. */
  27727. refractionFresnelParameters: FresnelParameters;
  27728. private _emissiveFresnelParameters;
  27729. /**
  27730. * Define the emissive fresnel parameters of the material.
  27731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27732. */
  27733. emissiveFresnelParameters: FresnelParameters;
  27734. private _useReflectionFresnelFromSpecular;
  27735. /**
  27736. * If true automatically deducts the fresnels values from the material specularity.
  27737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27738. */
  27739. useReflectionFresnelFromSpecular: boolean;
  27740. private _useGlossinessFromSpecularMapAlpha;
  27741. /**
  27742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27743. */
  27744. useGlossinessFromSpecularMapAlpha: boolean;
  27745. private _maxSimultaneousLights;
  27746. /**
  27747. * Defines the maximum number of lights that can be used in the material
  27748. */
  27749. maxSimultaneousLights: number;
  27750. private _invertNormalMapX;
  27751. /**
  27752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27753. */
  27754. invertNormalMapX: boolean;
  27755. private _invertNormalMapY;
  27756. /**
  27757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27758. */
  27759. invertNormalMapY: boolean;
  27760. private _twoSidedLighting;
  27761. /**
  27762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27763. */
  27764. twoSidedLighting: boolean;
  27765. /**
  27766. * Default configuration related to image processing available in the standard Material.
  27767. */
  27768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27769. /**
  27770. * Gets the image processing configuration used either in this material.
  27771. */
  27772. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27773. /**
  27774. * Sets the Default image processing configuration used either in the this material.
  27775. *
  27776. * If sets to null, the scene one is in use.
  27777. */
  27778. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27779. /**
  27780. * Keep track of the image processing observer to allow dispose and replace.
  27781. */
  27782. private _imageProcessingObserver;
  27783. /**
  27784. * Attaches a new image processing configuration to the Standard Material.
  27785. * @param configuration
  27786. */
  27787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27788. /**
  27789. * Gets wether the color curves effect is enabled.
  27790. */
  27791. get cameraColorCurvesEnabled(): boolean;
  27792. /**
  27793. * Sets wether the color curves effect is enabled.
  27794. */
  27795. set cameraColorCurvesEnabled(value: boolean);
  27796. /**
  27797. * Gets wether the color grading effect is enabled.
  27798. */
  27799. get cameraColorGradingEnabled(): boolean;
  27800. /**
  27801. * Gets wether the color grading effect is enabled.
  27802. */
  27803. set cameraColorGradingEnabled(value: boolean);
  27804. /**
  27805. * Gets wether tonemapping is enabled or not.
  27806. */
  27807. get cameraToneMappingEnabled(): boolean;
  27808. /**
  27809. * Sets wether tonemapping is enabled or not
  27810. */
  27811. set cameraToneMappingEnabled(value: boolean);
  27812. /**
  27813. * The camera exposure used on this material.
  27814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27815. * This corresponds to a photographic exposure.
  27816. */
  27817. get cameraExposure(): number;
  27818. /**
  27819. * The camera exposure used on this material.
  27820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27821. * This corresponds to a photographic exposure.
  27822. */
  27823. set cameraExposure(value: number);
  27824. /**
  27825. * Gets The camera contrast used on this material.
  27826. */
  27827. get cameraContrast(): number;
  27828. /**
  27829. * Sets The camera contrast used on this material.
  27830. */
  27831. set cameraContrast(value: number);
  27832. /**
  27833. * Gets the Color Grading 2D Lookup Texture.
  27834. */
  27835. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27836. /**
  27837. * Sets the Color Grading 2D Lookup Texture.
  27838. */
  27839. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27840. /**
  27841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27843. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27845. */
  27846. get cameraColorCurves(): Nullable<ColorCurves>;
  27847. /**
  27848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27850. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27852. */
  27853. set cameraColorCurves(value: Nullable<ColorCurves>);
  27854. /**
  27855. * Custom callback helping to override the default shader used in the material.
  27856. */
  27857. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27858. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27859. protected _worldViewProjectionMatrix: Matrix;
  27860. protected _globalAmbientColor: Color3;
  27861. protected _useLogarithmicDepth: boolean;
  27862. protected _rebuildInParallel: boolean;
  27863. /**
  27864. * Instantiates a new standard material.
  27865. * This is the default material used in Babylon. It is the best trade off between quality
  27866. * and performances.
  27867. * @see http://doc.babylonjs.com/babylon101/materials
  27868. * @param name Define the name of the material in the scene
  27869. * @param scene Define the scene the material belong to
  27870. */
  27871. constructor(name: string, scene: Scene);
  27872. /**
  27873. * Gets a boolean indicating that current material needs to register RTT
  27874. */
  27875. get hasRenderTargetTextures(): boolean;
  27876. /**
  27877. * Gets the current class name of the material e.g. "StandardMaterial"
  27878. * Mainly use in serialization.
  27879. * @returns the class name
  27880. */
  27881. getClassName(): string;
  27882. /**
  27883. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27884. * You can try switching to logarithmic depth.
  27885. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27886. */
  27887. get useLogarithmicDepth(): boolean;
  27888. set useLogarithmicDepth(value: boolean);
  27889. /**
  27890. * Specifies if the material will require alpha blending
  27891. * @returns a boolean specifying if alpha blending is needed
  27892. */
  27893. needAlphaBlending(): boolean;
  27894. /**
  27895. * Specifies if this material should be rendered in alpha test mode
  27896. * @returns a boolean specifying if an alpha test is needed.
  27897. */
  27898. needAlphaTesting(): boolean;
  27899. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27900. /**
  27901. * Get the texture used for alpha test purpose.
  27902. * @returns the diffuse texture in case of the standard material.
  27903. */
  27904. getAlphaTestTexture(): Nullable<BaseTexture>;
  27905. /**
  27906. * Get if the submesh is ready to be used and all its information available.
  27907. * Child classes can use it to update shaders
  27908. * @param mesh defines the mesh to check
  27909. * @param subMesh defines which submesh to check
  27910. * @param useInstances specifies that instances should be used
  27911. * @returns a boolean indicating that the submesh is ready or not
  27912. */
  27913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27914. /**
  27915. * Builds the material UBO layouts.
  27916. * Used internally during the effect preparation.
  27917. */
  27918. buildUniformLayout(): void;
  27919. /**
  27920. * Unbinds the material from the mesh
  27921. */
  27922. unbind(): void;
  27923. /**
  27924. * Binds the submesh to this material by preparing the effect and shader to draw
  27925. * @param world defines the world transformation matrix
  27926. * @param mesh defines the mesh containing the submesh
  27927. * @param subMesh defines the submesh to bind the material to
  27928. */
  27929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27930. /**
  27931. * Get the list of animatables in the material.
  27932. * @returns the list of animatables object used in the material
  27933. */
  27934. getAnimatables(): IAnimatable[];
  27935. /**
  27936. * Gets the active textures from the material
  27937. * @returns an array of textures
  27938. */
  27939. getActiveTextures(): BaseTexture[];
  27940. /**
  27941. * Specifies if the material uses a texture
  27942. * @param texture defines the texture to check against the material
  27943. * @returns a boolean specifying if the material uses the texture
  27944. */
  27945. hasTexture(texture: BaseTexture): boolean;
  27946. /**
  27947. * Disposes the material
  27948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27950. */
  27951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27952. /**
  27953. * Makes a duplicate of the material, and gives it a new name
  27954. * @param name defines the new name for the duplicated material
  27955. * @returns the cloned material
  27956. */
  27957. clone(name: string): StandardMaterial;
  27958. /**
  27959. * Serializes this material in a JSON representation
  27960. * @returns the serialized material object
  27961. */
  27962. serialize(): any;
  27963. /**
  27964. * Creates a standard material from parsed material data
  27965. * @param source defines the JSON representation of the material
  27966. * @param scene defines the hosting scene
  27967. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27968. * @returns a new standard material
  27969. */
  27970. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27971. /**
  27972. * Are diffuse textures enabled in the application.
  27973. */
  27974. static get DiffuseTextureEnabled(): boolean;
  27975. static set DiffuseTextureEnabled(value: boolean);
  27976. /**
  27977. * Are ambient textures enabled in the application.
  27978. */
  27979. static get AmbientTextureEnabled(): boolean;
  27980. static set AmbientTextureEnabled(value: boolean);
  27981. /**
  27982. * Are opacity textures enabled in the application.
  27983. */
  27984. static get OpacityTextureEnabled(): boolean;
  27985. static set OpacityTextureEnabled(value: boolean);
  27986. /**
  27987. * Are reflection textures enabled in the application.
  27988. */
  27989. static get ReflectionTextureEnabled(): boolean;
  27990. static set ReflectionTextureEnabled(value: boolean);
  27991. /**
  27992. * Are emissive textures enabled in the application.
  27993. */
  27994. static get EmissiveTextureEnabled(): boolean;
  27995. static set EmissiveTextureEnabled(value: boolean);
  27996. /**
  27997. * Are specular textures enabled in the application.
  27998. */
  27999. static get SpecularTextureEnabled(): boolean;
  28000. static set SpecularTextureEnabled(value: boolean);
  28001. /**
  28002. * Are bump textures enabled in the application.
  28003. */
  28004. static get BumpTextureEnabled(): boolean;
  28005. static set BumpTextureEnabled(value: boolean);
  28006. /**
  28007. * Are lightmap textures enabled in the application.
  28008. */
  28009. static get LightmapTextureEnabled(): boolean;
  28010. static set LightmapTextureEnabled(value: boolean);
  28011. /**
  28012. * Are refraction textures enabled in the application.
  28013. */
  28014. static get RefractionTextureEnabled(): boolean;
  28015. static set RefractionTextureEnabled(value: boolean);
  28016. /**
  28017. * Are color grading textures enabled in the application.
  28018. */
  28019. static get ColorGradingTextureEnabled(): boolean;
  28020. static set ColorGradingTextureEnabled(value: boolean);
  28021. /**
  28022. * Are fresnels enabled in the application.
  28023. */
  28024. static get FresnelEnabled(): boolean;
  28025. static set FresnelEnabled(value: boolean);
  28026. }
  28027. }
  28028. declare module "babylonjs/Particles/solidParticleSystem" {
  28029. import { Nullable } from "babylonjs/types";
  28030. import { Vector3 } from "babylonjs/Maths/math.vector";
  28031. import { Mesh } from "babylonjs/Meshes/mesh";
  28032. import { Scene, IDisposable } from "babylonjs/scene";
  28033. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28034. import { Material } from "babylonjs/Materials/material";
  28035. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28036. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28037. /**
  28038. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28039. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  28040. * The SPS is also a particle system. It provides some methods to manage the particles.
  28041. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28042. *
  28043. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28044. */
  28045. export class SolidParticleSystem implements IDisposable {
  28046. /**
  28047. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28048. * Example : var p = SPS.particles[i];
  28049. */
  28050. particles: SolidParticle[];
  28051. /**
  28052. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28053. */
  28054. nbParticles: number;
  28055. /**
  28056. * If the particles must ever face the camera (default false). Useful for planar particles.
  28057. */
  28058. billboard: boolean;
  28059. /**
  28060. * Recompute normals when adding a shape
  28061. */
  28062. recomputeNormals: boolean;
  28063. /**
  28064. * This a counter ofr your own usage. It's not set by any SPS functions.
  28065. */
  28066. counter: number;
  28067. /**
  28068. * The SPS name. This name is also given to the underlying mesh.
  28069. */
  28070. name: string;
  28071. /**
  28072. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28073. */
  28074. mesh: Mesh;
  28075. /**
  28076. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28077. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28078. */
  28079. vars: any;
  28080. /**
  28081. * This array is populated when the SPS is set as 'pickable'.
  28082. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28083. * Each element of this array is an object `{idx: int, faceId: int}`.
  28084. * `idx` is the picked particle index in the `SPS.particles` array
  28085. * `faceId` is the picked face index counted within this particle.
  28086. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28087. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28088. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28089. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28090. */
  28091. pickedParticles: {
  28092. idx: number;
  28093. faceId: number;
  28094. }[];
  28095. /**
  28096. * This array is populated when the SPS is set as 'pickable'
  28097. * Each key of this array is a submesh index.
  28098. * Each element of this array is a second array defined like this :
  28099. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28100. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28101. * `idx` is the picked particle index in the `SPS.particles` array
  28102. * `faceId` is the picked face index counted within this particle.
  28103. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28104. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28105. */
  28106. pickedBySubMesh: {
  28107. idx: number;
  28108. faceId: number;
  28109. }[][];
  28110. /**
  28111. * This array is populated when `enableDepthSort` is set to true.
  28112. * Each element of this array is an instance of the class DepthSortedParticle.
  28113. */
  28114. depthSortedParticles: DepthSortedParticle[];
  28115. /**
  28116. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28117. * @hidden
  28118. */
  28119. _bSphereOnly: boolean;
  28120. /**
  28121. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28122. * @hidden
  28123. */
  28124. _bSphereRadiusFactor: number;
  28125. private _scene;
  28126. private _positions;
  28127. private _indices;
  28128. private _normals;
  28129. private _colors;
  28130. private _uvs;
  28131. private _indices32;
  28132. private _positions32;
  28133. private _normals32;
  28134. private _fixedNormal32;
  28135. private _colors32;
  28136. private _uvs32;
  28137. private _index;
  28138. private _updatable;
  28139. private _pickable;
  28140. private _isVisibilityBoxLocked;
  28141. private _alwaysVisible;
  28142. private _depthSort;
  28143. private _expandable;
  28144. private _shapeCounter;
  28145. private _copy;
  28146. private _color;
  28147. private _computeParticleColor;
  28148. private _computeParticleTexture;
  28149. private _computeParticleRotation;
  28150. private _computeParticleVertex;
  28151. private _computeBoundingBox;
  28152. private _depthSortParticles;
  28153. private _camera;
  28154. private _mustUnrotateFixedNormals;
  28155. private _particlesIntersect;
  28156. private _needs32Bits;
  28157. private _isNotBuilt;
  28158. private _lastParticleId;
  28159. private _idxOfId;
  28160. private _multimaterialEnabled;
  28161. private _useModelMaterial;
  28162. private _indicesByMaterial;
  28163. private _materialIndexes;
  28164. private _depthSortFunction;
  28165. private _materialSortFunction;
  28166. private _materials;
  28167. private _multimaterial;
  28168. private _materialIndexesById;
  28169. private _defaultMaterial;
  28170. private _autoUpdateSubMeshes;
  28171. /**
  28172. * Creates a SPS (Solid Particle System) object.
  28173. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28174. * @param scene (Scene) is the scene in which the SPS is added.
  28175. * @param options defines the options of the sps e.g.
  28176. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28177. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28178. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28179. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  28180. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28181. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28182. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28183. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28184. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28185. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28186. */
  28187. constructor(name: string, scene: Scene, options?: {
  28188. updatable?: boolean;
  28189. isPickable?: boolean;
  28190. enableDepthSort?: boolean;
  28191. particleIntersection?: boolean;
  28192. boundingSphereOnly?: boolean;
  28193. bSphereRadiusFactor?: number;
  28194. expandable?: boolean;
  28195. useModelMaterial?: boolean;
  28196. enableMultiMaterial?: boolean;
  28197. });
  28198. /**
  28199. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28200. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28201. * @returns the created mesh
  28202. */
  28203. buildMesh(): Mesh;
  28204. /**
  28205. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28206. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28207. * Thus the particles generated from `digest()` have their property `position` set yet.
  28208. * @param mesh ( Mesh ) is the mesh to be digested
  28209. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  28210. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28211. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28212. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28213. * @returns the current SPS
  28214. */
  28215. digest(mesh: Mesh, options?: {
  28216. facetNb?: number;
  28217. number?: number;
  28218. delta?: number;
  28219. storage?: [];
  28220. }): SolidParticleSystem;
  28221. /**
  28222. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28223. * @hidden
  28224. */
  28225. private _unrotateFixedNormals;
  28226. /**
  28227. * Resets the temporary working copy particle
  28228. * @hidden
  28229. */
  28230. private _resetCopy;
  28231. /**
  28232. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28233. * @param p the current index in the positions array to be updated
  28234. * @param ind the current index in the indices array
  28235. * @param shape a Vector3 array, the shape geometry
  28236. * @param positions the positions array to be updated
  28237. * @param meshInd the shape indices array
  28238. * @param indices the indices array to be updated
  28239. * @param meshUV the shape uv array
  28240. * @param uvs the uv array to be updated
  28241. * @param meshCol the shape color array
  28242. * @param colors the color array to be updated
  28243. * @param meshNor the shape normals array
  28244. * @param normals the normals array to be updated
  28245. * @param idx the particle index
  28246. * @param idxInShape the particle index in its shape
  28247. * @param options the addShape() method passed options
  28248. * @model the particle model
  28249. * @hidden
  28250. */
  28251. private _meshBuilder;
  28252. /**
  28253. * Returns a shape Vector3 array from positions float array
  28254. * @param positions float array
  28255. * @returns a vector3 array
  28256. * @hidden
  28257. */
  28258. private _posToShape;
  28259. /**
  28260. * Returns a shapeUV array from a float uvs (array deep copy)
  28261. * @param uvs as a float array
  28262. * @returns a shapeUV array
  28263. * @hidden
  28264. */
  28265. private _uvsToShapeUV;
  28266. /**
  28267. * Adds a new particle object in the particles array
  28268. * @param idx particle index in particles array
  28269. * @param id particle id
  28270. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28271. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28272. * @param model particle ModelShape object
  28273. * @param shapeId model shape identifier
  28274. * @param idxInShape index of the particle in the current model
  28275. * @param bInfo model bounding info object
  28276. * @param storage target storage array, if any
  28277. * @hidden
  28278. */
  28279. private _addParticle;
  28280. /**
  28281. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28282. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28283. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28284. * @param nb (positive integer) the number of particles to be created from this model
  28285. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28286. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28287. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28288. * @returns the number of shapes in the system
  28289. */
  28290. addShape(mesh: Mesh, nb: number, options?: {
  28291. positionFunction?: any;
  28292. vertexFunction?: any;
  28293. storage?: [];
  28294. }): number;
  28295. /**
  28296. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28297. * @hidden
  28298. */
  28299. private _rebuildParticle;
  28300. /**
  28301. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28302. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  28303. * @returns the SPS.
  28304. */
  28305. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28306. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28307. * Returns an array with the removed particles.
  28308. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28309. * The SPS can't be empty so at least one particle needs to remain in place.
  28310. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28311. * @param start index of the first particle to remove
  28312. * @param end index of the last particle to remove (included)
  28313. * @returns an array populated with the removed particles
  28314. */
  28315. removeParticles(start: number, end: number): SolidParticle[];
  28316. /**
  28317. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28318. * @param solidParticleArray an array populated with Solid Particles objects
  28319. * @returns the SPS
  28320. */
  28321. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28322. /**
  28323. * Creates a new particle and modifies the SPS mesh geometry :
  28324. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28325. * - calls _addParticle() to populate the particle array
  28326. * factorized code from addShape() and insertParticlesFromArray()
  28327. * @param idx particle index in the particles array
  28328. * @param i particle index in its shape
  28329. * @param modelShape particle ModelShape object
  28330. * @param shape shape vertex array
  28331. * @param meshInd shape indices array
  28332. * @param meshUV shape uv array
  28333. * @param meshCol shape color array
  28334. * @param meshNor shape normals array
  28335. * @param bbInfo shape bounding info
  28336. * @param storage target particle storage
  28337. * @options addShape() passed options
  28338. * @hidden
  28339. */
  28340. private _insertNewParticle;
  28341. /**
  28342. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28343. * This method calls `updateParticle()` for each particle of the SPS.
  28344. * For an animated SPS, it is usually called within the render loop.
  28345. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28346. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28347. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28348. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28349. * @returns the SPS.
  28350. */
  28351. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28352. /**
  28353. * Disposes the SPS.
  28354. */
  28355. dispose(): void;
  28356. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28357. * idx is the particle index in the SPS
  28358. * faceId is the picked face index counted within this particle.
  28359. * Returns null if the pickInfo can't identify a picked particle.
  28360. * @param pickingInfo (PickingInfo object)
  28361. * @returns {idx: number, faceId: number} or null
  28362. */
  28363. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28364. idx: number;
  28365. faceId: number;
  28366. }>;
  28367. /**
  28368. * Returns a SolidParticle object from its identifier : particle.id
  28369. * @param id (integer) the particle Id
  28370. * @returns the searched particle or null if not found in the SPS.
  28371. */
  28372. getParticleById(id: number): Nullable<SolidParticle>;
  28373. /**
  28374. * Returns a new array populated with the particles having the passed shapeId.
  28375. * @param shapeId (integer) the shape identifier
  28376. * @returns a new solid particle array
  28377. */
  28378. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28379. /**
  28380. * Populates the passed array "ref" with the particles having the passed shapeId.
  28381. * @param shapeId the shape identifier
  28382. * @returns the SPS
  28383. * @param ref
  28384. */
  28385. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28386. /**
  28387. * Computes the required SubMeshes according the materials assigned to the particles.
  28388. * @returns the solid particle system.
  28389. * Does nothing if called before the SPS mesh is built.
  28390. */
  28391. computeSubMeshes(): SolidParticleSystem;
  28392. /**
  28393. * Sorts the solid particles by material when MultiMaterial is enabled.
  28394. * Updates the indices32 array.
  28395. * Updates the indicesByMaterial array.
  28396. * Updates the mesh indices array.
  28397. * @returns the SPS
  28398. * @hidden
  28399. */
  28400. private _sortParticlesByMaterial;
  28401. /**
  28402. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28403. * @hidden
  28404. */
  28405. private _setMaterialIndexesById;
  28406. /**
  28407. * Returns an array with unique values of Materials from the passed array
  28408. * @param array the material array to be checked and filtered
  28409. * @hidden
  28410. */
  28411. private _filterUniqueMaterialId;
  28412. /**
  28413. * Sets a new Standard Material as _defaultMaterial if not already set.
  28414. * @hidden
  28415. */
  28416. private _setDefaultMaterial;
  28417. /**
  28418. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28419. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28420. * @returns the SPS.
  28421. */
  28422. refreshVisibleSize(): SolidParticleSystem;
  28423. /**
  28424. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28425. * @param size the size (float) of the visibility box
  28426. * note : this doesn't lock the SPS mesh bounding box.
  28427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28428. */
  28429. setVisibilityBox(size: number): void;
  28430. /**
  28431. * Gets whether the SPS as always visible or not
  28432. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28433. */
  28434. get isAlwaysVisible(): boolean;
  28435. /**
  28436. * Sets the SPS as always visible or not
  28437. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28438. */
  28439. set isAlwaysVisible(val: boolean);
  28440. /**
  28441. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28442. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28443. */
  28444. set isVisibilityBoxLocked(val: boolean);
  28445. /**
  28446. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28447. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28448. */
  28449. get isVisibilityBoxLocked(): boolean;
  28450. /**
  28451. * Tells to `setParticles()` to compute the particle rotations or not.
  28452. * Default value : true. The SPS is faster when it's set to false.
  28453. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28454. */
  28455. set computeParticleRotation(val: boolean);
  28456. /**
  28457. * Tells to `setParticles()` to compute the particle colors or not.
  28458. * Default value : true. The SPS is faster when it's set to false.
  28459. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28460. */
  28461. set computeParticleColor(val: boolean);
  28462. set computeParticleTexture(val: boolean);
  28463. /**
  28464. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28465. * Default value : false. The SPS is faster when it's set to false.
  28466. * Note : the particle custom vertex positions aren't stored values.
  28467. */
  28468. set computeParticleVertex(val: boolean);
  28469. /**
  28470. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28471. */
  28472. set computeBoundingBox(val: boolean);
  28473. /**
  28474. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28475. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28476. * Default : `true`
  28477. */
  28478. set depthSortParticles(val: boolean);
  28479. /**
  28480. * Gets if `setParticles()` computes the particle rotations or not.
  28481. * Default value : true. The SPS is faster when it's set to false.
  28482. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28483. */
  28484. get computeParticleRotation(): boolean;
  28485. /**
  28486. * Gets if `setParticles()` computes the particle colors or not.
  28487. * Default value : true. The SPS is faster when it's set to false.
  28488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28489. */
  28490. get computeParticleColor(): boolean;
  28491. /**
  28492. * Gets if `setParticles()` computes the particle textures or not.
  28493. * Default value : true. The SPS is faster when it's set to false.
  28494. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28495. */
  28496. get computeParticleTexture(): boolean;
  28497. /**
  28498. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28499. * Default value : false. The SPS is faster when it's set to false.
  28500. * Note : the particle custom vertex positions aren't stored values.
  28501. */
  28502. get computeParticleVertex(): boolean;
  28503. /**
  28504. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28505. */
  28506. get computeBoundingBox(): boolean;
  28507. /**
  28508. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28509. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28510. * Default : `true`
  28511. */
  28512. get depthSortParticles(): boolean;
  28513. /**
  28514. * Gets if the SPS is created as expandable at construction time.
  28515. * Default : `false`
  28516. */
  28517. get expandable(): boolean;
  28518. /**
  28519. * Gets if the SPS supports the Multi Materials
  28520. */
  28521. get multimaterialEnabled(): boolean;
  28522. /**
  28523. * Gets if the SPS uses the model materials for its own multimaterial.
  28524. */
  28525. get useModelMaterial(): boolean;
  28526. /**
  28527. * The SPS used material array.
  28528. */
  28529. get materials(): Material[];
  28530. /**
  28531. * Sets the SPS MultiMaterial from the passed materials.
  28532. * Note : the passed array is internally copied and not used then by reference.
  28533. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28534. */
  28535. setMultiMaterial(materials: Material[]): void;
  28536. /**
  28537. * The SPS computed multimaterial object
  28538. */
  28539. get multimaterial(): MultiMaterial;
  28540. set multimaterial(mm: MultiMaterial);
  28541. /**
  28542. * If the subMeshes must be updated on the next call to setParticles()
  28543. */
  28544. get autoUpdateSubMeshes(): boolean;
  28545. set autoUpdateSubMeshes(val: boolean);
  28546. /**
  28547. * This function does nothing. It may be overwritten to set all the particle first values.
  28548. * The SPS doesn't call this function, you may have to call it by your own.
  28549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28550. */
  28551. initParticles(): void;
  28552. /**
  28553. * This function does nothing. It may be overwritten to recycle a particle.
  28554. * The SPS doesn't call this function, you may have to call it by your own.
  28555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28556. * @param particle The particle to recycle
  28557. * @returns the recycled particle
  28558. */
  28559. recycleParticle(particle: SolidParticle): SolidParticle;
  28560. /**
  28561. * Updates a particle : this function should be overwritten by the user.
  28562. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28564. * @example : just set a particle position or velocity and recycle conditions
  28565. * @param particle The particle to update
  28566. * @returns the updated particle
  28567. */
  28568. updateParticle(particle: SolidParticle): SolidParticle;
  28569. /**
  28570. * Updates a vertex of a particle : it can be overwritten by the user.
  28571. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28572. * @param particle the current particle
  28573. * @param vertex the current index of the current particle
  28574. * @param pt the index of the current vertex in the particle shape
  28575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28576. * @example : just set a vertex particle position
  28577. * @returns the updated vertex
  28578. */
  28579. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28580. /**
  28581. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28582. * This does nothing and may be overwritten by the user.
  28583. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28584. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28585. * @param update the boolean update value actually passed to setParticles()
  28586. */
  28587. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28588. /**
  28589. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28590. * This will be passed three parameters.
  28591. * This does nothing and may be overwritten by the user.
  28592. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28593. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28594. * @param update the boolean update value actually passed to setParticles()
  28595. */
  28596. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28597. }
  28598. }
  28599. declare module "babylonjs/Particles/solidParticle" {
  28600. import { Nullable } from "babylonjs/types";
  28601. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28602. import { Color4 } from "babylonjs/Maths/math.color";
  28603. import { Mesh } from "babylonjs/Meshes/mesh";
  28604. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28605. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28606. import { Plane } from "babylonjs/Maths/math.plane";
  28607. import { Material } from "babylonjs/Materials/material";
  28608. /**
  28609. * Represents one particle of a solid particle system.
  28610. */
  28611. export class SolidParticle {
  28612. /**
  28613. * particle global index
  28614. */
  28615. idx: number;
  28616. /**
  28617. * particle identifier
  28618. */
  28619. id: number;
  28620. /**
  28621. * The color of the particle
  28622. */
  28623. color: Nullable<Color4>;
  28624. /**
  28625. * The world space position of the particle.
  28626. */
  28627. position: Vector3;
  28628. /**
  28629. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28630. */
  28631. rotation: Vector3;
  28632. /**
  28633. * The world space rotation quaternion of the particle.
  28634. */
  28635. rotationQuaternion: Nullable<Quaternion>;
  28636. /**
  28637. * The scaling of the particle.
  28638. */
  28639. scaling: Vector3;
  28640. /**
  28641. * The uvs of the particle.
  28642. */
  28643. uvs: Vector4;
  28644. /**
  28645. * The current speed of the particle.
  28646. */
  28647. velocity: Vector3;
  28648. /**
  28649. * The pivot point in the particle local space.
  28650. */
  28651. pivot: Vector3;
  28652. /**
  28653. * Must the particle be translated from its pivot point in its local space ?
  28654. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28655. * Default : false
  28656. */
  28657. translateFromPivot: boolean;
  28658. /**
  28659. * Is the particle active or not ?
  28660. */
  28661. alive: boolean;
  28662. /**
  28663. * Is the particle visible or not ?
  28664. */
  28665. isVisible: boolean;
  28666. /**
  28667. * Index of this particle in the global "positions" array (Internal use)
  28668. * @hidden
  28669. */
  28670. _pos: number;
  28671. /**
  28672. * @hidden Index of this particle in the global "indices" array (Internal use)
  28673. */
  28674. _ind: number;
  28675. /**
  28676. * @hidden ModelShape of this particle (Internal use)
  28677. */
  28678. _model: ModelShape;
  28679. /**
  28680. * ModelShape id of this particle
  28681. */
  28682. shapeId: number;
  28683. /**
  28684. * Index of the particle in its shape id
  28685. */
  28686. idxInShape: number;
  28687. /**
  28688. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28689. */
  28690. _modelBoundingInfo: BoundingInfo;
  28691. /**
  28692. * @hidden Particle BoundingInfo object (Internal use)
  28693. */
  28694. _boundingInfo: BoundingInfo;
  28695. /**
  28696. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28697. */
  28698. _sps: SolidParticleSystem;
  28699. /**
  28700. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28701. */
  28702. _stillInvisible: boolean;
  28703. /**
  28704. * @hidden Last computed particle rotation matrix
  28705. */
  28706. _rotationMatrix: number[];
  28707. /**
  28708. * Parent particle Id, if any.
  28709. * Default null.
  28710. */
  28711. parentId: Nullable<number>;
  28712. /**
  28713. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28714. */
  28715. materialIndex: Nullable<number>;
  28716. /**
  28717. * Custom object or properties.
  28718. */
  28719. props: Nullable<any>;
  28720. /**
  28721. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28722. * The possible values are :
  28723. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28724. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28725. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28727. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28728. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28729. * */
  28730. cullingStrategy: number;
  28731. /**
  28732. * @hidden Internal global position in the SPS.
  28733. */
  28734. _globalPosition: Vector3;
  28735. /**
  28736. * Creates a Solid Particle object.
  28737. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28738. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28739. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28740. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28741. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28742. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28743. * @param shapeId (integer) is the model shape identifier in the SPS.
  28744. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28745. * @param sps defines the sps it is associated to
  28746. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28747. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28748. */
  28749. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28750. /**
  28751. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28752. * @param target the particle target
  28753. * @returns the current particle
  28754. */
  28755. copyToRef(target: SolidParticle): SolidParticle;
  28756. /**
  28757. * Legacy support, changed scale to scaling
  28758. */
  28759. get scale(): Vector3;
  28760. /**
  28761. * Legacy support, changed scale to scaling
  28762. */
  28763. set scale(scale: Vector3);
  28764. /**
  28765. * Legacy support, changed quaternion to rotationQuaternion
  28766. */
  28767. get quaternion(): Nullable<Quaternion>;
  28768. /**
  28769. * Legacy support, changed quaternion to rotationQuaternion
  28770. */
  28771. set quaternion(q: Nullable<Quaternion>);
  28772. /**
  28773. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28774. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28775. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28776. * @returns true if it intersects
  28777. */
  28778. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28779. /**
  28780. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28781. * A particle is in the frustum if its bounding box intersects the frustum
  28782. * @param frustumPlanes defines the frustum to test
  28783. * @returns true if the particle is in the frustum planes
  28784. */
  28785. isInFrustum(frustumPlanes: Plane[]): boolean;
  28786. /**
  28787. * get the rotation matrix of the particle
  28788. * @hidden
  28789. */
  28790. getRotationMatrix(m: Matrix): void;
  28791. }
  28792. /**
  28793. * Represents the shape of the model used by one particle of a solid particle system.
  28794. * SPS internal tool, don't use it manually.
  28795. */
  28796. export class ModelShape {
  28797. /**
  28798. * The shape id
  28799. * @hidden
  28800. */
  28801. shapeID: number;
  28802. /**
  28803. * flat array of model positions (internal use)
  28804. * @hidden
  28805. */
  28806. _shape: Vector3[];
  28807. /**
  28808. * flat array of model UVs (internal use)
  28809. * @hidden
  28810. */
  28811. _shapeUV: number[];
  28812. /**
  28813. * color array of the model
  28814. * @hidden
  28815. */
  28816. _shapeColors: number[];
  28817. /**
  28818. * indices array of the model
  28819. * @hidden
  28820. */
  28821. _indices: number[];
  28822. /**
  28823. * normals array of the model
  28824. * @hidden
  28825. */
  28826. _normals: number[];
  28827. /**
  28828. * length of the shape in the model indices array (internal use)
  28829. * @hidden
  28830. */
  28831. _indicesLength: number;
  28832. /**
  28833. * Custom position function (internal use)
  28834. * @hidden
  28835. */
  28836. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28837. /**
  28838. * Custom vertex function (internal use)
  28839. * @hidden
  28840. */
  28841. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28842. /**
  28843. * Model material (internal use)
  28844. * @hidden
  28845. */
  28846. _material: Nullable<Material>;
  28847. /**
  28848. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  28849. * SPS internal tool, don't use it manually.
  28850. * @hidden
  28851. */
  28852. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28853. }
  28854. /**
  28855. * Represents a Depth Sorted Particle in the solid particle system.
  28856. * @hidden
  28857. */
  28858. export class DepthSortedParticle {
  28859. /**
  28860. * Particle index
  28861. */
  28862. idx: number;
  28863. /**
  28864. * Index of the particle in the "indices" array
  28865. */
  28866. ind: number;
  28867. /**
  28868. * Length of the particle shape in the "indices" array
  28869. */
  28870. indicesLength: number;
  28871. /**
  28872. * Squared distance from the particle to the camera
  28873. */
  28874. sqDistance: number;
  28875. /**
  28876. * Material index when used with MultiMaterials
  28877. */
  28878. materialIndex: number;
  28879. /**
  28880. * Creates a new sorted particle
  28881. * @param materialIndex
  28882. */
  28883. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28884. }
  28885. }
  28886. declare module "babylonjs/Collisions/meshCollisionData" {
  28887. import { Collider } from "babylonjs/Collisions/collider";
  28888. import { Vector3 } from "babylonjs/Maths/math.vector";
  28889. import { Nullable } from "babylonjs/types";
  28890. import { Observer } from "babylonjs/Misc/observable";
  28891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28892. /**
  28893. * @hidden
  28894. */
  28895. export class _MeshCollisionData {
  28896. _checkCollisions: boolean;
  28897. _collisionMask: number;
  28898. _collisionGroup: number;
  28899. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28900. _collider: Nullable<Collider>;
  28901. _oldPositionForCollisions: Vector3;
  28902. _diffPositionForCollisions: Vector3;
  28903. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28904. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28905. }
  28906. }
  28907. declare module "babylonjs/Meshes/abstractMesh" {
  28908. import { Observable } from "babylonjs/Misc/observable";
  28909. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28910. import { Camera } from "babylonjs/Cameras/camera";
  28911. import { Scene, IDisposable } from "babylonjs/scene";
  28912. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28913. import { Node } from "babylonjs/node";
  28914. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28915. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28918. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28919. import { Material } from "babylonjs/Materials/material";
  28920. import { Light } from "babylonjs/Lights/light";
  28921. import { Skeleton } from "babylonjs/Bones/skeleton";
  28922. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28923. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28924. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28925. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28926. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28927. import { Plane } from "babylonjs/Maths/math.plane";
  28928. import { Ray } from "babylonjs/Culling/ray";
  28929. import { Collider } from "babylonjs/Collisions/collider";
  28930. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28931. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28932. /** @hidden */
  28933. class _FacetDataStorage {
  28934. facetPositions: Vector3[];
  28935. facetNormals: Vector3[];
  28936. facetPartitioning: number[][];
  28937. facetNb: number;
  28938. partitioningSubdivisions: number;
  28939. partitioningBBoxRatio: number;
  28940. facetDataEnabled: boolean;
  28941. facetParameters: any;
  28942. bbSize: Vector3;
  28943. subDiv: {
  28944. max: number;
  28945. X: number;
  28946. Y: number;
  28947. Z: number;
  28948. };
  28949. facetDepthSort: boolean;
  28950. facetDepthSortEnabled: boolean;
  28951. depthSortedIndices: IndicesArray;
  28952. depthSortedFacets: {
  28953. ind: number;
  28954. sqDistance: number;
  28955. }[];
  28956. facetDepthSortFunction: (f1: {
  28957. ind: number;
  28958. sqDistance: number;
  28959. }, f2: {
  28960. ind: number;
  28961. sqDistance: number;
  28962. }) => number;
  28963. facetDepthSortFrom: Vector3;
  28964. facetDepthSortOrigin: Vector3;
  28965. invertedMatrix: Matrix;
  28966. }
  28967. /**
  28968. * @hidden
  28969. **/
  28970. class _InternalAbstractMeshDataInfo {
  28971. _hasVertexAlpha: boolean;
  28972. _useVertexColors: boolean;
  28973. _numBoneInfluencers: number;
  28974. _applyFog: boolean;
  28975. _receiveShadows: boolean;
  28976. _facetData: _FacetDataStorage;
  28977. _visibility: number;
  28978. _skeleton: Nullable<Skeleton>;
  28979. _layerMask: number;
  28980. _computeBonesUsingShaders: boolean;
  28981. _isActive: boolean;
  28982. _onlyForInstances: boolean;
  28983. _isActiveIntermediate: boolean;
  28984. _onlyForInstancesIntermediate: boolean;
  28985. _actAsRegularMesh: boolean;
  28986. }
  28987. /**
  28988. * Class used to store all common mesh properties
  28989. */
  28990. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28991. /** No occlusion */
  28992. static OCCLUSION_TYPE_NONE: number;
  28993. /** Occlusion set to optimisitic */
  28994. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28995. /** Occlusion set to strict */
  28996. static OCCLUSION_TYPE_STRICT: number;
  28997. /** Use an accurante occlusion algorithm */
  28998. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28999. /** Use a conservative occlusion algorithm */
  29000. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29001. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29002. * Test order :
  29003. * Is the bounding sphere outside the frustum ?
  29004. * If not, are the bounding box vertices outside the frustum ?
  29005. * It not, then the cullable object is in the frustum.
  29006. */
  29007. static readonly CULLINGSTRATEGY_STANDARD: number;
  29008. /** Culling strategy : Bounding Sphere Only.
  29009. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29010. * It's also less accurate than the standard because some not visible objects can still be selected.
  29011. * Test : is the bounding sphere outside the frustum ?
  29012. * If not, then the cullable object is in the frustum.
  29013. */
  29014. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29015. /** Culling strategy : Optimistic Inclusion.
  29016. * This in an inclusion test first, then the standard exclusion test.
  29017. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29018. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  29019. * Anyway, it's as accurate as the standard strategy.
  29020. * Test :
  29021. * Is the cullable object bounding sphere center in the frustum ?
  29022. * If not, apply the default culling strategy.
  29023. */
  29024. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29025. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29026. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29027. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29028. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  29029. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29030. * Test :
  29031. * Is the cullable object bounding sphere center in the frustum ?
  29032. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29033. */
  29034. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29035. /**
  29036. * No billboard
  29037. */
  29038. static get BILLBOARDMODE_NONE(): number;
  29039. /** Billboard on X axis */
  29040. static get BILLBOARDMODE_X(): number;
  29041. /** Billboard on Y axis */
  29042. static get BILLBOARDMODE_Y(): number;
  29043. /** Billboard on Z axis */
  29044. static get BILLBOARDMODE_Z(): number;
  29045. /** Billboard on all axes */
  29046. static get BILLBOARDMODE_ALL(): number;
  29047. /** Billboard on using position instead of orientation */
  29048. static get BILLBOARDMODE_USE_POSITION(): number;
  29049. /** @hidden */
  29050. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29051. /**
  29052. * The culling strategy to use to check whether the mesh must be rendered or not.
  29053. * This value can be changed at any time and will be used on the next render mesh selection.
  29054. * The possible values are :
  29055. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29056. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29058. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29059. * Please read each static variable documentation to get details about the culling process.
  29060. * */
  29061. cullingStrategy: number;
  29062. /**
  29063. * Gets the number of facets in the mesh
  29064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29065. */
  29066. get facetNb(): number;
  29067. /**
  29068. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29070. */
  29071. get partitioningSubdivisions(): number;
  29072. set partitioningSubdivisions(nb: number);
  29073. /**
  29074. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29075. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29077. */
  29078. get partitioningBBoxRatio(): number;
  29079. set partitioningBBoxRatio(ratio: number);
  29080. /**
  29081. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29082. * Works only for updatable meshes.
  29083. * Doesn't work with multi-materials
  29084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29085. */
  29086. get mustDepthSortFacets(): boolean;
  29087. set mustDepthSortFacets(sort: boolean);
  29088. /**
  29089. * The location (Vector3) where the facet depth sort must be computed from.
  29090. * By default, the active camera position.
  29091. * Used only when facet depth sort is enabled
  29092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29093. */
  29094. get facetDepthSortFrom(): Vector3;
  29095. set facetDepthSortFrom(location: Vector3);
  29096. /**
  29097. * gets a boolean indicating if facetData is enabled
  29098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29099. */
  29100. get isFacetDataEnabled(): boolean;
  29101. /** @hidden */
  29102. _updateNonUniformScalingState(value: boolean): boolean;
  29103. /**
  29104. * An event triggered when this mesh collides with another one
  29105. */
  29106. onCollideObservable: Observable<AbstractMesh>;
  29107. /** Set a function to call when this mesh collides with another one */
  29108. set onCollide(callback: () => void);
  29109. /**
  29110. * An event triggered when the collision's position changes
  29111. */
  29112. onCollisionPositionChangeObservable: Observable<Vector3>;
  29113. /** Set a function to call when the collision's position changes */
  29114. set onCollisionPositionChange(callback: () => void);
  29115. /**
  29116. * An event triggered when material is changed
  29117. */
  29118. onMaterialChangedObservable: Observable<AbstractMesh>;
  29119. /**
  29120. * Gets or sets the orientation for POV movement & rotation
  29121. */
  29122. definedFacingForward: boolean;
  29123. /** @hidden */
  29124. _occlusionQuery: Nullable<WebGLQuery>;
  29125. /** @hidden */
  29126. _renderingGroup: Nullable<RenderingGroup>;
  29127. /**
  29128. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29129. */
  29130. get visibility(): number;
  29131. /**
  29132. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29133. */
  29134. set visibility(value: number);
  29135. /** Gets or sets the alpha index used to sort transparent meshes
  29136. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29137. */
  29138. alphaIndex: number;
  29139. /**
  29140. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29141. */
  29142. isVisible: boolean;
  29143. /**
  29144. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29145. */
  29146. isPickable: boolean;
  29147. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29148. showSubMeshesBoundingBox: boolean;
  29149. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29151. */
  29152. isBlocker: boolean;
  29153. /**
  29154. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29155. */
  29156. enablePointerMoveEvents: boolean;
  29157. /**
  29158. * Specifies the rendering group id for this mesh (0 by default)
  29159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29160. */
  29161. renderingGroupId: number;
  29162. private _material;
  29163. /** Gets or sets current material */
  29164. get material(): Nullable<Material>;
  29165. set material(value: Nullable<Material>);
  29166. /**
  29167. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29168. * @see http://doc.babylonjs.com/babylon101/shadows
  29169. */
  29170. get receiveShadows(): boolean;
  29171. set receiveShadows(value: boolean);
  29172. /** Defines color to use when rendering outline */
  29173. outlineColor: Color3;
  29174. /** Define width to use when rendering outline */
  29175. outlineWidth: number;
  29176. /** Defines color to use when rendering overlay */
  29177. overlayColor: Color3;
  29178. /** Defines alpha to use when rendering overlay */
  29179. overlayAlpha: number;
  29180. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29181. get hasVertexAlpha(): boolean;
  29182. set hasVertexAlpha(value: boolean);
  29183. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  29184. get useVertexColors(): boolean;
  29185. set useVertexColors(value: boolean);
  29186. /**
  29187. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29188. */
  29189. get computeBonesUsingShaders(): boolean;
  29190. set computeBonesUsingShaders(value: boolean);
  29191. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29192. get numBoneInfluencers(): number;
  29193. set numBoneInfluencers(value: number);
  29194. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29195. get applyFog(): boolean;
  29196. set applyFog(value: boolean);
  29197. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29198. useOctreeForRenderingSelection: boolean;
  29199. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29200. useOctreeForPicking: boolean;
  29201. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29202. useOctreeForCollisions: boolean;
  29203. /**
  29204. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29205. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29206. */
  29207. get layerMask(): number;
  29208. set layerMask(value: number);
  29209. /**
  29210. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29211. */
  29212. alwaysSelectAsActiveMesh: boolean;
  29213. /**
  29214. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29215. */
  29216. doNotSyncBoundingInfo: boolean;
  29217. /**
  29218. * Gets or sets the current action manager
  29219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29220. */
  29221. actionManager: Nullable<AbstractActionManager>;
  29222. private _meshCollisionData;
  29223. /**
  29224. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29226. */
  29227. ellipsoid: Vector3;
  29228. /**
  29229. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29231. */
  29232. ellipsoidOffset: Vector3;
  29233. /**
  29234. * Gets or sets a collision mask used to mask collisions (default is -1).
  29235. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29236. */
  29237. get collisionMask(): number;
  29238. set collisionMask(mask: number);
  29239. /**
  29240. * Gets or sets the current collision group mask (-1 by default).
  29241. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29242. */
  29243. get collisionGroup(): number;
  29244. set collisionGroup(mask: number);
  29245. /**
  29246. * Gets or sets current surrounding meshes (null by default).
  29247. *
  29248. * By default collision detection is tested against every mesh in the scene.
  29249. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29250. * meshes will be tested for the collision.
  29251. *
  29252. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29253. */
  29254. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29255. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29256. /**
  29257. * Defines edge width used when edgesRenderer is enabled
  29258. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29259. */
  29260. edgesWidth: number;
  29261. /**
  29262. * Defines edge color used when edgesRenderer is enabled
  29263. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29264. */
  29265. edgesColor: Color4;
  29266. /** @hidden */
  29267. _edgesRenderer: Nullable<IEdgesRenderer>;
  29268. /** @hidden */
  29269. _masterMesh: Nullable<AbstractMesh>;
  29270. /** @hidden */
  29271. _boundingInfo: Nullable<BoundingInfo>;
  29272. /** @hidden */
  29273. _renderId: number;
  29274. /**
  29275. * Gets or sets the list of subMeshes
  29276. * @see http://doc.babylonjs.com/how_to/multi_materials
  29277. */
  29278. subMeshes: SubMesh[];
  29279. /** @hidden */
  29280. _intersectionsInProgress: AbstractMesh[];
  29281. /** @hidden */
  29282. _unIndexed: boolean;
  29283. /** @hidden */
  29284. _lightSources: Light[];
  29285. /** Gets the list of lights affecting that mesh */
  29286. get lightSources(): Light[];
  29287. /** @hidden */
  29288. get _positions(): Nullable<Vector3[]>;
  29289. /** @hidden */
  29290. _waitingData: {
  29291. lods: Nullable<any>;
  29292. actions: Nullable<any>;
  29293. freezeWorldMatrix: Nullable<boolean>;
  29294. };
  29295. /** @hidden */
  29296. _bonesTransformMatrices: Nullable<Float32Array>;
  29297. /** @hidden */
  29298. _transformMatrixTexture: Nullable<RawTexture>;
  29299. /**
  29300. * Gets or sets a skeleton to apply skining transformations
  29301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29302. */
  29303. set skeleton(value: Nullable<Skeleton>);
  29304. get skeleton(): Nullable<Skeleton>;
  29305. /**
  29306. * An event triggered when the mesh is rebuilt.
  29307. */
  29308. onRebuildObservable: Observable<AbstractMesh>;
  29309. /**
  29310. * Creates a new AbstractMesh
  29311. * @param name defines the name of the mesh
  29312. * @param scene defines the hosting scene
  29313. */
  29314. constructor(name: string, scene?: Nullable<Scene>);
  29315. /**
  29316. * Returns the string "AbstractMesh"
  29317. * @returns "AbstractMesh"
  29318. */
  29319. getClassName(): string;
  29320. /**
  29321. * Gets a string representation of the current mesh
  29322. * @param fullDetails defines a boolean indicating if full details must be included
  29323. * @returns a string representation of the current mesh
  29324. */
  29325. toString(fullDetails?: boolean): string;
  29326. /**
  29327. * @hidden
  29328. */
  29329. protected _getEffectiveParent(): Nullable<Node>;
  29330. /** @hidden */
  29331. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29332. /** @hidden */
  29333. _rebuild(): void;
  29334. /** @hidden */
  29335. _resyncLightSources(): void;
  29336. /** @hidden */
  29337. _resyncLightSource(light: Light): void;
  29338. /** @hidden */
  29339. _unBindEffect(): void;
  29340. /** @hidden */
  29341. _removeLightSource(light: Light, dispose: boolean): void;
  29342. private _markSubMeshesAsDirty;
  29343. /** @hidden */
  29344. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29345. /** @hidden */
  29346. _markSubMeshesAsAttributesDirty(): void;
  29347. /** @hidden */
  29348. _markSubMeshesAsMiscDirty(): void;
  29349. /**
  29350. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29351. */
  29352. get scaling(): Vector3;
  29353. set scaling(newScaling: Vector3);
  29354. /**
  29355. * Returns true if the mesh is blocked. Implemented by child classes
  29356. */
  29357. get isBlocked(): boolean;
  29358. /**
  29359. * Returns the mesh itself by default. Implemented by child classes
  29360. * @param camera defines the camera to use to pick the right LOD level
  29361. * @returns the currentAbstractMesh
  29362. */
  29363. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29364. /**
  29365. * Returns 0 by default. Implemented by child classes
  29366. * @returns an integer
  29367. */
  29368. getTotalVertices(): number;
  29369. /**
  29370. * Returns a positive integer : the total number of indices in this mesh geometry.
  29371. * @returns the numner of indices or zero if the mesh has no geometry.
  29372. */
  29373. getTotalIndices(): number;
  29374. /**
  29375. * Returns null by default. Implemented by child classes
  29376. * @returns null
  29377. */
  29378. getIndices(): Nullable<IndicesArray>;
  29379. /**
  29380. * Returns the array of the requested vertex data kind. Implemented by child classes
  29381. * @param kind defines the vertex data kind to use
  29382. * @returns null
  29383. */
  29384. getVerticesData(kind: string): Nullable<FloatArray>;
  29385. /**
  29386. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29387. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29388. * Note that a new underlying VertexBuffer object is created each call.
  29389. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29390. * @param kind defines vertex data kind:
  29391. * * VertexBuffer.PositionKind
  29392. * * VertexBuffer.UVKind
  29393. * * VertexBuffer.UV2Kind
  29394. * * VertexBuffer.UV3Kind
  29395. * * VertexBuffer.UV4Kind
  29396. * * VertexBuffer.UV5Kind
  29397. * * VertexBuffer.UV6Kind
  29398. * * VertexBuffer.ColorKind
  29399. * * VertexBuffer.MatricesIndicesKind
  29400. * * VertexBuffer.MatricesIndicesExtraKind
  29401. * * VertexBuffer.MatricesWeightsKind
  29402. * * VertexBuffer.MatricesWeightsExtraKind
  29403. * @param data defines the data source
  29404. * @param updatable defines if the data must be flagged as updatable (or static)
  29405. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  29406. * @returns the current mesh
  29407. */
  29408. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29409. /**
  29410. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29411. * If the mesh has no geometry, it is simply returned as it is.
  29412. * @param kind defines vertex data kind:
  29413. * * VertexBuffer.PositionKind
  29414. * * VertexBuffer.UVKind
  29415. * * VertexBuffer.UV2Kind
  29416. * * VertexBuffer.UV3Kind
  29417. * * VertexBuffer.UV4Kind
  29418. * * VertexBuffer.UV5Kind
  29419. * * VertexBuffer.UV6Kind
  29420. * * VertexBuffer.ColorKind
  29421. * * VertexBuffer.MatricesIndicesKind
  29422. * * VertexBuffer.MatricesIndicesExtraKind
  29423. * * VertexBuffer.MatricesWeightsKind
  29424. * * VertexBuffer.MatricesWeightsExtraKind
  29425. * @param data defines the data source
  29426. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  29427. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29428. * @returns the current mesh
  29429. */
  29430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29431. /**
  29432. * Sets the mesh indices,
  29433. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29434. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29435. * @param totalVertices Defines the total number of vertices
  29436. * @returns the current mesh
  29437. */
  29438. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29439. /**
  29440. * Gets a boolean indicating if specific vertex data is present
  29441. * @param kind defines the vertex data kind to use
  29442. * @returns true is data kind is present
  29443. */
  29444. isVerticesDataPresent(kind: string): boolean;
  29445. /**
  29446. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29447. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29448. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29449. * @returns a BoundingInfo
  29450. */
  29451. getBoundingInfo(): BoundingInfo;
  29452. /**
  29453. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29454. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29455. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29456. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29457. * @returns the current mesh
  29458. */
  29459. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29460. /**
  29461. * Overwrite the current bounding info
  29462. * @param boundingInfo defines the new bounding info
  29463. * @returns the current mesh
  29464. */
  29465. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29466. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29467. get useBones(): boolean;
  29468. /** @hidden */
  29469. _preActivate(): void;
  29470. /** @hidden */
  29471. _preActivateForIntermediateRendering(renderId: number): void;
  29472. /** @hidden */
  29473. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29474. /** @hidden */
  29475. _postActivate(): void;
  29476. /** @hidden */
  29477. _freeze(): void;
  29478. /** @hidden */
  29479. _unFreeze(): void;
  29480. /**
  29481. * Gets the current world matrix
  29482. * @returns a Matrix
  29483. */
  29484. getWorldMatrix(): Matrix;
  29485. /** @hidden */
  29486. _getWorldMatrixDeterminant(): number;
  29487. /**
  29488. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29489. */
  29490. get isAnInstance(): boolean;
  29491. /**
  29492. * Gets a boolean indicating if this mesh has instances
  29493. */
  29494. get hasInstances(): boolean;
  29495. /**
  29496. * Perform relative position change from the point of view of behind the front of the mesh.
  29497. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29498. * Supports definition of mesh facing forward or backward
  29499. * @param amountRight defines the distance on the right axis
  29500. * @param amountUp defines the distance on the up axis
  29501. * @param amountForward defines the distance on the forward axis
  29502. * @returns the current mesh
  29503. */
  29504. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29505. /**
  29506. * Calculate relative position change from the point of view of behind the front of the mesh.
  29507. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29508. * Supports definition of mesh facing forward or backward
  29509. * @param amountRight defines the distance on the right axis
  29510. * @param amountUp defines the distance on the up axis
  29511. * @param amountForward defines the distance on the forward axis
  29512. * @returns the new displacement vector
  29513. */
  29514. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29515. /**
  29516. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29517. * Supports definition of mesh facing forward or backward
  29518. * @param flipBack defines the flip
  29519. * @param twirlClockwise defines the twirl
  29520. * @param tiltRight defines the tilt
  29521. * @returns the current mesh
  29522. */
  29523. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29524. /**
  29525. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29526. * Supports definition of mesh facing forward or backward.
  29527. * @param flipBack defines the flip
  29528. * @param twirlClockwise defines the twirl
  29529. * @param tiltRight defines the tilt
  29530. * @returns the new rotation vector
  29531. */
  29532. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29533. /**
  29534. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29535. * This means the mesh underlying bounding box and sphere are recomputed.
  29536. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29537. * @returns the current mesh
  29538. */
  29539. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29540. /** @hidden */
  29541. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29542. /** @hidden */
  29543. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29544. /** @hidden */
  29545. _updateBoundingInfo(): AbstractMesh;
  29546. /** @hidden */
  29547. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29548. /** @hidden */
  29549. protected _afterComputeWorldMatrix(): void;
  29550. /** @hidden */
  29551. get _effectiveMesh(): AbstractMesh;
  29552. /**
  29553. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29554. * A mesh is in the frustum if its bounding box intersects the frustum
  29555. * @param frustumPlanes defines the frustum to test
  29556. * @returns true if the mesh is in the frustum planes
  29557. */
  29558. isInFrustum(frustumPlanes: Plane[]): boolean;
  29559. /**
  29560. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29561. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29562. * @param frustumPlanes defines the frustum to test
  29563. * @returns true if the mesh is completely in the frustum planes
  29564. */
  29565. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29566. /**
  29567. * True if the mesh intersects another mesh or a SolidParticle object
  29568. * @param mesh defines a target mesh or SolidParticle to test
  29569. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  29570. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29571. * @returns true if there is an intersection
  29572. */
  29573. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29574. /**
  29575. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29576. * @param point defines the point to test
  29577. * @returns true if there is an intersection
  29578. */
  29579. intersectsPoint(point: Vector3): boolean;
  29580. /**
  29581. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29583. */
  29584. get checkCollisions(): boolean;
  29585. set checkCollisions(collisionEnabled: boolean);
  29586. /**
  29587. * Gets Collider object used to compute collisions (not physics)
  29588. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29589. */
  29590. get collider(): Nullable<Collider>;
  29591. /**
  29592. * Move the mesh using collision engine
  29593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29594. * @param displacement defines the requested displacement vector
  29595. * @returns the current mesh
  29596. */
  29597. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29598. private _onCollisionPositionChange;
  29599. /** @hidden */
  29600. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29601. /** @hidden */
  29602. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29603. /** @hidden */
  29604. _checkCollision(collider: Collider): AbstractMesh;
  29605. /** @hidden */
  29606. _generatePointsArray(): boolean;
  29607. /**
  29608. * Checks if the passed Ray intersects with the mesh
  29609. * @param ray defines the ray to use
  29610. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29611. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29612. * @returns the picking info
  29613. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29614. */
  29615. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29616. /**
  29617. * Clones the current mesh
  29618. * @param name defines the mesh name
  29619. * @param newParent defines the new mesh parent
  29620. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29621. * @returns the new mesh
  29622. */
  29623. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29624. /**
  29625. * Disposes all the submeshes of the current meshnp
  29626. * @returns the current mesh
  29627. */
  29628. releaseSubMeshes(): AbstractMesh;
  29629. /**
  29630. * Releases resources associated with this abstract mesh.
  29631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29633. */
  29634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29635. /**
  29636. * Adds the passed mesh as a child to the current mesh
  29637. * @param mesh defines the child mesh
  29638. * @returns the current mesh
  29639. */
  29640. addChild(mesh: AbstractMesh): AbstractMesh;
  29641. /**
  29642. * Removes the passed mesh from the current mesh children list
  29643. * @param mesh defines the child mesh
  29644. * @returns the current mesh
  29645. */
  29646. removeChild(mesh: AbstractMesh): AbstractMesh;
  29647. /** @hidden */
  29648. private _initFacetData;
  29649. /**
  29650. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29651. * This method can be called within the render loop.
  29652. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  29653. * @returns the current mesh
  29654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29655. */
  29656. updateFacetData(): AbstractMesh;
  29657. /**
  29658. * Returns the facetLocalNormals array.
  29659. * The normals are expressed in the mesh local spac
  29660. * @returns an array of Vector3
  29661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29662. */
  29663. getFacetLocalNormals(): Vector3[];
  29664. /**
  29665. * Returns the facetLocalPositions array.
  29666. * The facet positions are expressed in the mesh local space
  29667. * @returns an array of Vector3
  29668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29669. */
  29670. getFacetLocalPositions(): Vector3[];
  29671. /**
  29672. * Returns the facetLocalPartioning array
  29673. * @returns an array of array of numbers
  29674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29675. */
  29676. getFacetLocalPartitioning(): number[][];
  29677. /**
  29678. * Returns the i-th facet position in the world system.
  29679. * This method allocates a new Vector3 per call
  29680. * @param i defines the facet index
  29681. * @returns a new Vector3
  29682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29683. */
  29684. getFacetPosition(i: number): Vector3;
  29685. /**
  29686. * Sets the reference Vector3 with the i-th facet position in the world system
  29687. * @param i defines the facet index
  29688. * @param ref defines the target vector
  29689. * @returns the current mesh
  29690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29691. */
  29692. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29693. /**
  29694. * Returns the i-th facet normal in the world system.
  29695. * This method allocates a new Vector3 per call
  29696. * @param i defines the facet index
  29697. * @returns a new Vector3
  29698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29699. */
  29700. getFacetNormal(i: number): Vector3;
  29701. /**
  29702. * Sets the reference Vector3 with the i-th facet normal in the world system
  29703. * @param i defines the facet index
  29704. * @param ref defines the target vector
  29705. * @returns the current mesh
  29706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29707. */
  29708. getFacetNormalToRef(i: number, ref: Vector3): this;
  29709. /**
  29710. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  29711. * @param x defines x coordinate
  29712. * @param y defines y coordinate
  29713. * @param z defines z coordinate
  29714. * @returns the array of facet indexes
  29715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29716. */
  29717. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29718. /**
  29719. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29720. * @param projected sets as the (x,y,z) world projection on the facet
  29721. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29722. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29723. * @param x defines x coordinate
  29724. * @param y defines y coordinate
  29725. * @param z defines z coordinate
  29726. * @returns the face index if found (or null instead)
  29727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29728. */
  29729. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29730. /**
  29731. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29732. * @param projected sets as the (x,y,z) local projection on the facet
  29733. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29734. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29735. * @param x defines x coordinate
  29736. * @param y defines y coordinate
  29737. * @param z defines z coordinate
  29738. * @returns the face index if found (or null instead)
  29739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29740. */
  29741. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29742. /**
  29743. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29744. * @returns the parameters
  29745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29746. */
  29747. getFacetDataParameters(): any;
  29748. /**
  29749. * Disables the feature FacetData and frees the related memory
  29750. * @returns the current mesh
  29751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29752. */
  29753. disableFacetData(): AbstractMesh;
  29754. /**
  29755. * Updates the AbstractMesh indices array
  29756. * @param indices defines the data source
  29757. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29758. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  29759. * @returns the current mesh
  29760. */
  29761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29762. /**
  29763. * Creates new normals data for the mesh
  29764. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29765. * @returns the current mesh
  29766. */
  29767. createNormals(updatable: boolean): AbstractMesh;
  29768. /**
  29769. * Align the mesh with a normal
  29770. * @param normal defines the normal to use
  29771. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29772. * @returns the current mesh
  29773. */
  29774. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29775. /** @hidden */
  29776. _checkOcclusionQuery(): boolean;
  29777. /**
  29778. * Disables the mesh edge rendering mode
  29779. * @returns the currentAbstractMesh
  29780. */
  29781. disableEdgesRendering(): AbstractMesh;
  29782. /**
  29783. * Enables the edge rendering mode on the mesh.
  29784. * This mode makes the mesh edges visible
  29785. * @param epsilon defines the maximal distance between two angles to detect a face
  29786. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29787. * @returns the currentAbstractMesh
  29788. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29789. */
  29790. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29791. }
  29792. }
  29793. declare module "babylonjs/Actions/actionEvent" {
  29794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29795. import { Nullable } from "babylonjs/types";
  29796. import { Sprite } from "babylonjs/Sprites/sprite";
  29797. import { Scene } from "babylonjs/scene";
  29798. import { Vector2 } from "babylonjs/Maths/math.vector";
  29799. /**
  29800. * Interface used to define ActionEvent
  29801. */
  29802. export interface IActionEvent {
  29803. /** The mesh or sprite that triggered the action */
  29804. source: any;
  29805. /** The X mouse cursor position at the time of the event */
  29806. pointerX: number;
  29807. /** The Y mouse cursor position at the time of the event */
  29808. pointerY: number;
  29809. /** The mesh that is currently pointed at (can be null) */
  29810. meshUnderPointer: Nullable<AbstractMesh>;
  29811. /** the original (browser) event that triggered the ActionEvent */
  29812. sourceEvent?: any;
  29813. /** additional data for the event */
  29814. additionalData?: any;
  29815. }
  29816. /**
  29817. * ActionEvent is the event being sent when an action is triggered.
  29818. */
  29819. export class ActionEvent implements IActionEvent {
  29820. /** The mesh or sprite that triggered the action */
  29821. source: any;
  29822. /** The X mouse cursor position at the time of the event */
  29823. pointerX: number;
  29824. /** The Y mouse cursor position at the time of the event */
  29825. pointerY: number;
  29826. /** The mesh that is currently pointed at (can be null) */
  29827. meshUnderPointer: Nullable<AbstractMesh>;
  29828. /** the original (browser) event that triggered the ActionEvent */
  29829. sourceEvent?: any;
  29830. /** additional data for the event */
  29831. additionalData?: any;
  29832. /**
  29833. * Creates a new ActionEvent
  29834. * @param source The mesh or sprite that triggered the action
  29835. * @param pointerX The X mouse cursor position at the time of the event
  29836. * @param pointerY The Y mouse cursor position at the time of the event
  29837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29839. * @param additionalData additional data for the event
  29840. */
  29841. constructor(
  29842. /** The mesh or sprite that triggered the action */
  29843. source: any,
  29844. /** The X mouse cursor position at the time of the event */
  29845. pointerX: number,
  29846. /** The Y mouse cursor position at the time of the event */
  29847. pointerY: number,
  29848. /** The mesh that is currently pointed at (can be null) */
  29849. meshUnderPointer: Nullable<AbstractMesh>,
  29850. /** the original (browser) event that triggered the ActionEvent */
  29851. sourceEvent?: any,
  29852. /** additional data for the event */
  29853. additionalData?: any);
  29854. /**
  29855. * Helper function to auto-create an ActionEvent from a source mesh.
  29856. * @param source The source mesh that triggered the event
  29857. * @param evt The original (browser) event
  29858. * @param additionalData additional data for the event
  29859. * @returns the new ActionEvent
  29860. */
  29861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29862. /**
  29863. * Helper function to auto-create an ActionEvent from a source sprite
  29864. * @param source The source sprite that triggered the event
  29865. * @param scene Scene associated with the sprite
  29866. * @param evt The original (browser) event
  29867. * @param additionalData additional data for the event
  29868. * @returns the new ActionEvent
  29869. */
  29870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29871. /**
  29872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29873. * @param scene the scene where the event occurred
  29874. * @param evt The original (browser) event
  29875. * @returns the new ActionEvent
  29876. */
  29877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29878. /**
  29879. * Helper function to auto-create an ActionEvent from a primitive
  29880. * @param prim defines the target primitive
  29881. * @param pointerPos defines the pointer position
  29882. * @param evt The original (browser) event
  29883. * @param additionalData additional data for the event
  29884. * @returns the new ActionEvent
  29885. */
  29886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29887. }
  29888. }
  29889. declare module "babylonjs/Actions/abstractActionManager" {
  29890. import { IDisposable } from "babylonjs/scene";
  29891. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29892. import { IAction } from "babylonjs/Actions/action";
  29893. import { Nullable } from "babylonjs/types";
  29894. /**
  29895. * Abstract class used to decouple action Manager from scene and meshes.
  29896. * Do not instantiate.
  29897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29898. */
  29899. export abstract class AbstractActionManager implements IDisposable {
  29900. /** Gets the list of active triggers */
  29901. static Triggers: {
  29902. [key: string]: number;
  29903. };
  29904. /** Gets the cursor to use when hovering items */
  29905. hoverCursor: string;
  29906. /** Gets the list of actions */
  29907. actions: IAction[];
  29908. /**
  29909. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29910. */
  29911. isRecursive: boolean;
  29912. /**
  29913. * Releases all associated resources
  29914. */
  29915. abstract dispose(): void;
  29916. /**
  29917. * Does this action manager has pointer triggers
  29918. */
  29919. abstract get hasPointerTriggers(): boolean;
  29920. /**
  29921. * Does this action manager has pick triggers
  29922. */
  29923. abstract get hasPickTriggers(): boolean;
  29924. /**
  29925. * Process a specific trigger
  29926. * @param trigger defines the trigger to process
  29927. * @param evt defines the event details to be processed
  29928. */
  29929. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29930. /**
  29931. * Does this action manager handles actions of any of the given triggers
  29932. * @param triggers defines the triggers to be tested
  29933. * @return a boolean indicating whether one (or more) of the triggers is handled
  29934. */
  29935. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29936. /**
  29937. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29938. * speed.
  29939. * @param triggerA defines the trigger to be tested
  29940. * @param triggerB defines the trigger to be tested
  29941. * @return a boolean indicating whether one (or more) of the triggers is handled
  29942. */
  29943. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29944. /**
  29945. * Does this action manager handles actions of a given trigger
  29946. * @param trigger defines the trigger to be tested
  29947. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29948. * @return whether the trigger is handled
  29949. */
  29950. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29951. /**
  29952. * Serialize this manager to a JSON object
  29953. * @param name defines the property name to store this manager
  29954. * @returns a JSON representation of this manager
  29955. */
  29956. abstract serialize(name: string): any;
  29957. /**
  29958. * Registers an action to this action manager
  29959. * @param action defines the action to be registered
  29960. * @return the action amended (prepared) after registration
  29961. */
  29962. abstract registerAction(action: IAction): Nullable<IAction>;
  29963. /**
  29964. * Unregisters an action to this action manager
  29965. * @param action defines the action to be unregistered
  29966. * @return a boolean indicating whether the action has been unregistered
  29967. */
  29968. abstract unregisterAction(action: IAction): Boolean;
  29969. /**
  29970. * Does exist one action manager with at least one trigger
  29971. **/
  29972. static get HasTriggers(): boolean;
  29973. /**
  29974. * Does exist one action manager with at least one pick trigger
  29975. **/
  29976. static get HasPickTriggers(): boolean;
  29977. /**
  29978. * Does exist one action manager that handles actions of a given trigger
  29979. * @param trigger defines the trigger to be tested
  29980. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29981. **/
  29982. static HasSpecificTrigger(trigger: number): boolean;
  29983. }
  29984. }
  29985. declare module "babylonjs/node" {
  29986. import { Scene } from "babylonjs/scene";
  29987. import { Nullable } from "babylonjs/types";
  29988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29989. import { Engine } from "babylonjs/Engines/engine";
  29990. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29991. import { Observable } from "babylonjs/Misc/observable";
  29992. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29993. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29994. import { Animatable } from "babylonjs/Animations/animatable";
  29995. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29996. import { Animation } from "babylonjs/Animations/animation";
  29997. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29999. /**
  30000. * Defines how a node can be built from a string name.
  30001. */
  30002. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30003. /**
  30004. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30005. */
  30006. export class Node implements IBehaviorAware<Node> {
  30007. /** @hidden */
  30008. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30009. private static _NodeConstructors;
  30010. /**
  30011. * Add a new node constructor
  30012. * @param type defines the type name of the node to construct
  30013. * @param constructorFunc defines the constructor function
  30014. */
  30015. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30016. /**
  30017. * Returns a node constructor based on type name
  30018. * @param type defines the type name
  30019. * @param name defines the new node name
  30020. * @param scene defines the hosting scene
  30021. * @param options defines optional options to transmit to constructors
  30022. * @returns the new constructor or null
  30023. */
  30024. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30025. /**
  30026. * Gets or sets the name of the node
  30027. */
  30028. name: string;
  30029. /**
  30030. * Gets or sets the id of the node
  30031. */
  30032. id: string;
  30033. /**
  30034. * Gets or sets the unique id of the node
  30035. */
  30036. uniqueId: number;
  30037. /**
  30038. * Gets or sets a string used to store user defined state for the node
  30039. */
  30040. state: string;
  30041. /**
  30042. * Gets or sets an object used to store user defined information for the node
  30043. */
  30044. metadata: any;
  30045. /**
  30046. * For internal use only. Please do not use.
  30047. */
  30048. reservedDataStore: any;
  30049. /**
  30050. * List of inspectable custom properties (used by the Inspector)
  30051. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30052. */
  30053. inspectableCustomProperties: IInspectable[];
  30054. private _doNotSerialize;
  30055. /**
  30056. * Gets or sets a boolean used to define if the node must be serialized
  30057. */
  30058. get doNotSerialize(): boolean;
  30059. set doNotSerialize(value: boolean);
  30060. /** @hidden */
  30061. _isDisposed: boolean;
  30062. /**
  30063. * Gets a list of Animations associated with the node
  30064. */
  30065. animations: import("babylonjs/Animations/animation").Animation[];
  30066. protected _ranges: {
  30067. [name: string]: Nullable<AnimationRange>;
  30068. };
  30069. /**
  30070. * Callback raised when the node is ready to be used
  30071. */
  30072. onReady: Nullable<(node: Node) => void>;
  30073. private _isEnabled;
  30074. private _isParentEnabled;
  30075. private _isReady;
  30076. /** @hidden */
  30077. _currentRenderId: number;
  30078. private _parentUpdateId;
  30079. /** @hidden */
  30080. _childUpdateId: number;
  30081. /** @hidden */
  30082. _waitingParentId: Nullable<string>;
  30083. /** @hidden */
  30084. _scene: Scene;
  30085. /** @hidden */
  30086. _cache: any;
  30087. private _parentNode;
  30088. private _children;
  30089. /** @hidden */
  30090. _worldMatrix: Matrix;
  30091. /** @hidden */
  30092. _worldMatrixDeterminant: number;
  30093. /** @hidden */
  30094. _worldMatrixDeterminantIsDirty: boolean;
  30095. /** @hidden */
  30096. private _sceneRootNodesIndex;
  30097. /**
  30098. * Gets a boolean indicating if the node has been disposed
  30099. * @returns true if the node was disposed
  30100. */
  30101. isDisposed(): boolean;
  30102. /**
  30103. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30104. * @see https://doc.babylonjs.com/how_to/parenting
  30105. */
  30106. set parent(parent: Nullable<Node>);
  30107. get parent(): Nullable<Node>;
  30108. /** @hidden */
  30109. _addToSceneRootNodes(): void;
  30110. /** @hidden */
  30111. _removeFromSceneRootNodes(): void;
  30112. private _animationPropertiesOverride;
  30113. /**
  30114. * Gets or sets the animation properties override
  30115. */
  30116. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30117. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30118. /**
  30119. * Gets a string idenfifying the name of the class
  30120. * @returns "Node" string
  30121. */
  30122. getClassName(): string;
  30123. /** @hidden */
  30124. readonly _isNode: boolean;
  30125. /**
  30126. * An event triggered when the mesh is disposed
  30127. */
  30128. onDisposeObservable: Observable<Node>;
  30129. private _onDisposeObserver;
  30130. /**
  30131. * Sets a callback that will be raised when the node will be disposed
  30132. */
  30133. set onDispose(callback: () => void);
  30134. /**
  30135. * Creates a new Node
  30136. * @param name the name and id to be given to this node
  30137. * @param scene the scene this node will be added to
  30138. */
  30139. constructor(name: string, scene?: Nullable<Scene>);
  30140. /**
  30141. * Gets the scene of the node
  30142. * @returns a scene
  30143. */
  30144. getScene(): Scene;
  30145. /**
  30146. * Gets the engine of the node
  30147. * @returns a Engine
  30148. */
  30149. getEngine(): Engine;
  30150. private _behaviors;
  30151. /**
  30152. * Attach a behavior to the node
  30153. * @see http://doc.babylonjs.com/features/behaviour
  30154. * @param behavior defines the behavior to attach
  30155. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30156. * @returns the current Node
  30157. */
  30158. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30159. /**
  30160. * Remove an attached behavior
  30161. * @see http://doc.babylonjs.com/features/behaviour
  30162. * @param behavior defines the behavior to attach
  30163. * @returns the current Node
  30164. */
  30165. removeBehavior(behavior: Behavior<Node>): Node;
  30166. /**
  30167. * Gets the list of attached behaviors
  30168. * @see http://doc.babylonjs.com/features/behaviour
  30169. */
  30170. get behaviors(): Behavior<Node>[];
  30171. /**
  30172. * Gets an attached behavior by name
  30173. * @param name defines the name of the behavior to look for
  30174. * @see http://doc.babylonjs.com/features/behaviour
  30175. * @returns null if behavior was not found else the requested behavior
  30176. */
  30177. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30178. /**
  30179. * Returns the latest update of the World matrix
  30180. * @returns a Matrix
  30181. */
  30182. getWorldMatrix(): Matrix;
  30183. /** @hidden */
  30184. _getWorldMatrixDeterminant(): number;
  30185. /**
  30186. * Returns directly the latest state of the mesh World matrix.
  30187. * A Matrix is returned.
  30188. */
  30189. get worldMatrixFromCache(): Matrix;
  30190. /** @hidden */
  30191. _initCache(): void;
  30192. /** @hidden */
  30193. updateCache(force?: boolean): void;
  30194. /** @hidden */
  30195. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30196. /** @hidden */
  30197. _updateCache(ignoreParentClass?: boolean): void;
  30198. /** @hidden */
  30199. _isSynchronized(): boolean;
  30200. /** @hidden */
  30201. _markSyncedWithParent(): void;
  30202. /** @hidden */
  30203. isSynchronizedWithParent(): boolean;
  30204. /** @hidden */
  30205. isSynchronized(): boolean;
  30206. /**
  30207. * Is this node ready to be used/rendered
  30208. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30209. * @return true if the node is ready
  30210. */
  30211. isReady(completeCheck?: boolean): boolean;
  30212. /**
  30213. * Is this node enabled?
  30214. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  30215. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  30216. * @return whether this node (and its parent) is enabled
  30217. */
  30218. isEnabled(checkAncestors?: boolean): boolean;
  30219. /** @hidden */
  30220. protected _syncParentEnabledState(): void;
  30221. /**
  30222. * Set the enabled state of this node
  30223. * @param value defines the new enabled state
  30224. */
  30225. setEnabled(value: boolean): void;
  30226. /**
  30227. * Is this node a descendant of the given node?
  30228. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30229. * @param ancestor defines the parent node to inspect
  30230. * @returns a boolean indicating if this node is a descendant of the given node
  30231. */
  30232. isDescendantOf(ancestor: Node): boolean;
  30233. /** @hidden */
  30234. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30235. /**
  30236. * Will return all nodes that have this node as ascendant
  30237. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  30238. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30239. * @return all children nodes of all types
  30240. */
  30241. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30242. /**
  30243. * Get all child-meshes of this node
  30244. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  30245. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30246. * @returns an array of AbstractMesh
  30247. */
  30248. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30249. /**
  30250. * Get all direct children of this node
  30251. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30252. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  30253. * @returns an array of Node
  30254. */
  30255. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30256. /** @hidden */
  30257. _setReady(state: boolean): void;
  30258. /**
  30259. * Get an animation by name
  30260. * @param name defines the name of the animation to look for
  30261. * @returns null if not found else the requested animation
  30262. */
  30263. getAnimationByName(name: string): Nullable<Animation>;
  30264. /**
  30265. * Creates an animation range for this node
  30266. * @param name defines the name of the range
  30267. * @param from defines the starting key
  30268. * @param to defines the end key
  30269. */
  30270. createAnimationRange(name: string, from: number, to: number): void;
  30271. /**
  30272. * Delete a specific animation range
  30273. * @param name defines the name of the range to delete
  30274. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30275. */
  30276. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30277. /**
  30278. * Get an animation range by name
  30279. * @param name defines the name of the animation range to look for
  30280. * @returns null if not found else the requested animation range
  30281. */
  30282. getAnimationRange(name: string): Nullable<AnimationRange>;
  30283. /**
  30284. * Gets the list of all animation ranges defined on this node
  30285. * @returns an array
  30286. */
  30287. getAnimationRanges(): Nullable<AnimationRange>[];
  30288. /**
  30289. * Will start the animation sequence
  30290. * @param name defines the range frames for animation sequence
  30291. * @param loop defines if the animation should loop (false by default)
  30292. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30293. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30294. * @returns the object created for this animation. If range does not exist, it will return null
  30295. */
  30296. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30297. /**
  30298. * Serialize animation ranges into a JSON compatible object
  30299. * @returns serialization object
  30300. */
  30301. serializeAnimationRanges(): any;
  30302. /**
  30303. * Computes the world matrix of the node
  30304. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30305. * @returns the world matrix
  30306. */
  30307. computeWorldMatrix(force?: boolean): Matrix;
  30308. /**
  30309. * Releases resources associated with this node.
  30310. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30311. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30312. */
  30313. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30314. /**
  30315. * Parse animation range data from a serialization object and store them into a given node
  30316. * @param node defines where to store the animation ranges
  30317. * @param parsedNode defines the serialization object to read data from
  30318. * @param scene defines the hosting scene
  30319. */
  30320. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30321. /**
  30322. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30323. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30324. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  30325. * @returns the new bounding vectors
  30326. */
  30327. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30328. min: Vector3;
  30329. max: Vector3;
  30330. };
  30331. }
  30332. }
  30333. declare module "babylonjs/Animations/animation" {
  30334. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30335. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30336. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30337. import { Nullable } from "babylonjs/types";
  30338. import { Scene } from "babylonjs/scene";
  30339. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30340. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30341. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30342. import { Node } from "babylonjs/node";
  30343. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30344. import { Size } from "babylonjs/Maths/math.size";
  30345. import { Animatable } from "babylonjs/Animations/animatable";
  30346. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30347. /**
  30348. * @hidden
  30349. */
  30350. export class _IAnimationState {
  30351. key: number;
  30352. repeatCount: number;
  30353. workValue?: any;
  30354. loopMode?: number;
  30355. offsetValue?: any;
  30356. highLimitValue?: any;
  30357. }
  30358. /**
  30359. * Class used to store any kind of animation
  30360. */
  30361. export class Animation {
  30362. /**Name of the animation */
  30363. name: string;
  30364. /**Property to animate */
  30365. targetProperty: string;
  30366. /**The frames per second of the animation */
  30367. framePerSecond: number;
  30368. /**The data type of the animation */
  30369. dataType: number;
  30370. /**The loop mode of the animation */
  30371. loopMode?: number | undefined;
  30372. /**Specifies if blending should be enabled */
  30373. enableBlending?: boolean | undefined;
  30374. /**
  30375. * Use matrix interpolation instead of using direct key value when animating matrices
  30376. */
  30377. static AllowMatricesInterpolation: boolean;
  30378. /**
  30379. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30380. */
  30381. static AllowMatrixDecomposeForInterpolation: boolean;
  30382. /**
  30383. * Stores the key frames of the animation
  30384. */
  30385. private _keys;
  30386. /**
  30387. * Stores the easing function of the animation
  30388. */
  30389. private _easingFunction;
  30390. /**
  30391. * @hidden Internal use only
  30392. */
  30393. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30394. /**
  30395. * The set of event that will be linked to this animation
  30396. */
  30397. private _events;
  30398. /**
  30399. * Stores an array of target property paths
  30400. */
  30401. targetPropertyPath: string[];
  30402. /**
  30403. * Stores the blending speed of the animation
  30404. */
  30405. blendingSpeed: number;
  30406. /**
  30407. * Stores the animation ranges for the animation
  30408. */
  30409. private _ranges;
  30410. /**
  30411. * @hidden Internal use
  30412. */
  30413. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30414. /**
  30415. * Sets up an animation
  30416. * @param property The property to animate
  30417. * @param animationType The animation type to apply
  30418. * @param framePerSecond The frames per second of the animation
  30419. * @param easingFunction The easing function used in the animation
  30420. * @returns The created animation
  30421. */
  30422. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30423. /**
  30424. * Create and start an animation on a node
  30425. * @param name defines the name of the global animation that will be run on all nodes
  30426. * @param node defines the root node where the animation will take place
  30427. * @param targetProperty defines property to animate
  30428. * @param framePerSecond defines the number of frame per second yo use
  30429. * @param totalFrame defines the number of frames in total
  30430. * @param from defines the initial value
  30431. * @param to defines the final value
  30432. * @param loopMode defines which loop mode you want to use (off by default)
  30433. * @param easingFunction defines the easing function to use (linear by default)
  30434. * @param onAnimationEnd defines the callback to call when animation end
  30435. * @returns the animatable created for this animation
  30436. */
  30437. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30438. /**
  30439. * Create and start an animation on a node and its descendants
  30440. * @param name defines the name of the global animation that will be run on all nodes
  30441. * @param node defines the root node where the animation will take place
  30442. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  30443. * @param targetProperty defines property to animate
  30444. * @param framePerSecond defines the number of frame per second to use
  30445. * @param totalFrame defines the number of frames in total
  30446. * @param from defines the initial value
  30447. * @param to defines the final value
  30448. * @param loopMode defines which loop mode you want to use (off by default)
  30449. * @param easingFunction defines the easing function to use (linear by default)
  30450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30451. * @returns the list of animatables created for all nodes
  30452. * @example https://www.babylonjs-playground.com/#MH0VLI
  30453. */
  30454. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  30455. /**
  30456. * Creates a new animation, merges it with the existing animations and starts it
  30457. * @param name Name of the animation
  30458. * @param node Node which contains the scene that begins the animations
  30459. * @param targetProperty Specifies which property to animate
  30460. * @param framePerSecond The frames per second of the animation
  30461. * @param totalFrame The total number of frames
  30462. * @param from The frame at the beginning of the animation
  30463. * @param to The frame at the end of the animation
  30464. * @param loopMode Specifies the loop mode of the animation
  30465. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30466. * @param onAnimationEnd Callback to run once the animation is complete
  30467. * @returns Nullable animation
  30468. */
  30469. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30470. /**
  30471. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30472. * @param sourceAnimation defines the Animation containing keyframes to convert
  30473. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30474. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30475. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30476. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30477. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30478. */
  30479. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30480. /**
  30481. * Transition property of an host to the target Value
  30482. * @param property The property to transition
  30483. * @param targetValue The target Value of the property
  30484. * @param host The object where the property to animate belongs
  30485. * @param scene Scene used to run the animation
  30486. * @param frameRate Framerate (in frame/s) to use
  30487. * @param transition The transition type we want to use
  30488. * @param duration The duration of the animation, in milliseconds
  30489. * @param onAnimationEnd Callback trigger at the end of the animation
  30490. * @returns Nullable animation
  30491. */
  30492. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30493. /**
  30494. * Return the array of runtime animations currently using this animation
  30495. */
  30496. get runtimeAnimations(): RuntimeAnimation[];
  30497. /**
  30498. * Specifies if any of the runtime animations are currently running
  30499. */
  30500. get hasRunningRuntimeAnimations(): boolean;
  30501. /**
  30502. * Initializes the animation
  30503. * @param name Name of the animation
  30504. * @param targetProperty Property to animate
  30505. * @param framePerSecond The frames per second of the animation
  30506. * @param dataType The data type of the animation
  30507. * @param loopMode The loop mode of the animation
  30508. * @param enableBlending Specifies if blending should be enabled
  30509. */
  30510. constructor(
  30511. /**Name of the animation */
  30512. name: string,
  30513. /**Property to animate */
  30514. targetProperty: string,
  30515. /**The frames per second of the animation */
  30516. framePerSecond: number,
  30517. /**The data type of the animation */
  30518. dataType: number,
  30519. /**The loop mode of the animation */
  30520. loopMode?: number | undefined,
  30521. /**Specifies if blending should be enabled */
  30522. enableBlending?: boolean | undefined);
  30523. /**
  30524. * Converts the animation to a string
  30525. * @param fullDetails support for multiple levels of logging within scene loading
  30526. * @returns String form of the animation
  30527. */
  30528. toString(fullDetails?: boolean): string;
  30529. /**
  30530. * Add an event to this animation
  30531. * @param event Event to add
  30532. */
  30533. addEvent(event: AnimationEvent): void;
  30534. /**
  30535. * Remove all events found at the given frame
  30536. * @param frame The frame to remove events from
  30537. */
  30538. removeEvents(frame: number): void;
  30539. /**
  30540. * Retrieves all the events from the animation
  30541. * @returns Events from the animation
  30542. */
  30543. getEvents(): AnimationEvent[];
  30544. /**
  30545. * Creates an animation range
  30546. * @param name Name of the animation range
  30547. * @param from Starting frame of the animation range
  30548. * @param to Ending frame of the animation
  30549. */
  30550. createRange(name: string, from: number, to: number): void;
  30551. /**
  30552. * Deletes an animation range by name
  30553. * @param name Name of the animation range to delete
  30554. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30555. */
  30556. deleteRange(name: string, deleteFrames?: boolean): void;
  30557. /**
  30558. * Gets the animation range by name, or null if not defined
  30559. * @param name Name of the animation range
  30560. * @returns Nullable animation range
  30561. */
  30562. getRange(name: string): Nullable<AnimationRange>;
  30563. /**
  30564. * Gets the key frames from the animation
  30565. * @returns The key frames of the animation
  30566. */
  30567. getKeys(): Array<IAnimationKey>;
  30568. /**
  30569. * Gets the highest frame rate of the animation
  30570. * @returns Highest frame rate of the animation
  30571. */
  30572. getHighestFrame(): number;
  30573. /**
  30574. * Gets the easing function of the animation
  30575. * @returns Easing function of the animation
  30576. */
  30577. getEasingFunction(): IEasingFunction;
  30578. /**
  30579. * Sets the easing function of the animation
  30580. * @param easingFunction A custom mathematical formula for animation
  30581. */
  30582. setEasingFunction(easingFunction: EasingFunction): void;
  30583. /**
  30584. * Interpolates a scalar linearly
  30585. * @param startValue Start value of the animation curve
  30586. * @param endValue End value of the animation curve
  30587. * @param gradient Scalar amount to interpolate
  30588. * @returns Interpolated scalar value
  30589. */
  30590. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30591. /**
  30592. * Interpolates a scalar cubically
  30593. * @param startValue Start value of the animation curve
  30594. * @param outTangent End tangent of the animation
  30595. * @param endValue End value of the animation curve
  30596. * @param inTangent Start tangent of the animation curve
  30597. * @param gradient Scalar amount to interpolate
  30598. * @returns Interpolated scalar value
  30599. */
  30600. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30601. /**
  30602. * Interpolates a quaternion using a spherical linear interpolation
  30603. * @param startValue Start value of the animation curve
  30604. * @param endValue End value of the animation curve
  30605. * @param gradient Scalar amount to interpolate
  30606. * @returns Interpolated quaternion value
  30607. */
  30608. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30609. /**
  30610. * Interpolates a quaternion cubically
  30611. * @param startValue Start value of the animation curve
  30612. * @param outTangent End tangent of the animation curve
  30613. * @param endValue End value of the animation curve
  30614. * @param inTangent Start tangent of the animation curve
  30615. * @param gradient Scalar amount to interpolate
  30616. * @returns Interpolated quaternion value
  30617. */
  30618. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30619. /**
  30620. * Interpolates a Vector3 linearl
  30621. * @param startValue Start value of the animation curve
  30622. * @param endValue End value of the animation curve
  30623. * @param gradient Scalar amount to interpolate
  30624. * @returns Interpolated scalar value
  30625. */
  30626. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30627. /**
  30628. * Interpolates a Vector3 cubically
  30629. * @param startValue Start value of the animation curve
  30630. * @param outTangent End tangent of the animation
  30631. * @param endValue End value of the animation curve
  30632. * @param inTangent Start tangent of the animation curve
  30633. * @param gradient Scalar amount to interpolate
  30634. * @returns InterpolatedVector3 value
  30635. */
  30636. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30637. /**
  30638. * Interpolates a Vector2 linearly
  30639. * @param startValue Start value of the animation curve
  30640. * @param endValue End value of the animation curve
  30641. * @param gradient Scalar amount to interpolate
  30642. * @returns Interpolated Vector2 value
  30643. */
  30644. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30645. /**
  30646. * Interpolates a Vector2 cubically
  30647. * @param startValue Start value of the animation curve
  30648. * @param outTangent End tangent of the animation
  30649. * @param endValue End value of the animation curve
  30650. * @param inTangent Start tangent of the animation curve
  30651. * @param gradient Scalar amount to interpolate
  30652. * @returns Interpolated Vector2 value
  30653. */
  30654. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30655. /**
  30656. * Interpolates a size linearly
  30657. * @param startValue Start value of the animation curve
  30658. * @param endValue End value of the animation curve
  30659. * @param gradient Scalar amount to interpolate
  30660. * @returns Interpolated Size value
  30661. */
  30662. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30663. /**
  30664. * Interpolates a Color3 linearly
  30665. * @param startValue Start value of the animation curve
  30666. * @param endValue End value of the animation curve
  30667. * @param gradient Scalar amount to interpolate
  30668. * @returns Interpolated Color3 value
  30669. */
  30670. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30671. /**
  30672. * Interpolates a Color4 linearly
  30673. * @param startValue Start value of the animation curve
  30674. * @param endValue End value of the animation curve
  30675. * @param gradient Scalar amount to interpolate
  30676. * @returns Interpolated Color3 value
  30677. */
  30678. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30679. /**
  30680. * @hidden Internal use only
  30681. */
  30682. _getKeyValue(value: any): any;
  30683. /**
  30684. * @hidden Internal use only
  30685. */
  30686. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30687. /**
  30688. * Defines the function to use to interpolate matrices
  30689. * @param startValue defines the start matrix
  30690. * @param endValue defines the end matrix
  30691. * @param gradient defines the gradient between both matrices
  30692. * @param result defines an optional target matrix where to store the interpolation
  30693. * @returns the interpolated matrix
  30694. */
  30695. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30696. /**
  30697. * Makes a copy of the animation
  30698. * @returns Cloned animation
  30699. */
  30700. clone(): Animation;
  30701. /**
  30702. * Sets the key frames of the animation
  30703. * @param values The animation key frames to set
  30704. */
  30705. setKeys(values: Array<IAnimationKey>): void;
  30706. /**
  30707. * Serializes the animation to an object
  30708. * @returns Serialized object
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Float animation type
  30713. */
  30714. static readonly ANIMATIONTYPE_FLOAT: number;
  30715. /**
  30716. * Vector3 animation type
  30717. */
  30718. static readonly ANIMATIONTYPE_VECTOR3: number;
  30719. /**
  30720. * Quaternion animation type
  30721. */
  30722. static readonly ANIMATIONTYPE_QUATERNION: number;
  30723. /**
  30724. * Matrix animation type
  30725. */
  30726. static readonly ANIMATIONTYPE_MATRIX: number;
  30727. /**
  30728. * Color3 animation type
  30729. */
  30730. static readonly ANIMATIONTYPE_COLOR3: number;
  30731. /**
  30732. * Color3 animation type
  30733. */
  30734. static readonly ANIMATIONTYPE_COLOR4: number;
  30735. /**
  30736. * Vector2 animation type
  30737. */
  30738. static readonly ANIMATIONTYPE_VECTOR2: number;
  30739. /**
  30740. * Size animation type
  30741. */
  30742. static readonly ANIMATIONTYPE_SIZE: number;
  30743. /**
  30744. * Relative Loop Mode
  30745. */
  30746. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30747. /**
  30748. * Cycle Loop Mode
  30749. */
  30750. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30751. /**
  30752. * Constant Loop Mode
  30753. */
  30754. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30755. /** @hidden */
  30756. static _UniversalLerp(left: any, right: any, amount: number): any;
  30757. /**
  30758. * Parses an animation object and creates an animation
  30759. * @param parsedAnimation Parsed animation object
  30760. * @returns Animation object
  30761. */
  30762. static Parse(parsedAnimation: any): Animation;
  30763. /**
  30764. * Appends the serialized animations from the source animations
  30765. * @param source Source containing the animations
  30766. * @param destination Target to store the animations
  30767. */
  30768. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30769. }
  30770. }
  30771. declare module "babylonjs/Animations/animatable.interface" {
  30772. import { Nullable } from "babylonjs/types";
  30773. import { Animation } from "babylonjs/Animations/animation";
  30774. /**
  30775. * Interface containing an array of animations
  30776. */
  30777. export interface IAnimatable {
  30778. /**
  30779. * Array of animations
  30780. */
  30781. animations: Nullable<Array<Animation>>;
  30782. }
  30783. }
  30784. declare module "babylonjs/Misc/decorators" {
  30785. import { Nullable } from "babylonjs/types";
  30786. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30787. import { Scene } from "babylonjs/scene";
  30788. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30789. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30790. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30791. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30792. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30793. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30794. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30795. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30796. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30797. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30798. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30799. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30800. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30801. /**
  30802. * Decorator used to define property that can be serialized as reference to a camera
  30803. * @param sourceName defines the name of the property to decorate
  30804. */
  30805. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30806. /**
  30807. * Class used to help serialization objects
  30808. */
  30809. export class SerializationHelper {
  30810. /** @hidden */
  30811. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30812. /** @hidden */
  30813. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30814. /** @hidden */
  30815. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30816. /** @hidden */
  30817. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30818. /**
  30819. * Appends the serialized animations from the source animations
  30820. * @param source Source containing the animations
  30821. * @param destination Target to store the animations
  30822. */
  30823. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30824. /**
  30825. * Static function used to serialized a specific entity
  30826. * @param entity defines the entity to serialize
  30827. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30828. * @returns a JSON compatible object representing the serialization of the entity
  30829. */
  30830. static Serialize<T>(entity: T, serializationObject?: any): any;
  30831. /**
  30832. * Creates a new entity from a serialization data object
  30833. * @param creationFunction defines a function used to instanciated the new entity
  30834. * @param source defines the source serialization data
  30835. * @param scene defines the hosting scene
  30836. * @param rootUrl defines the root url for resources
  30837. * @returns a new entity
  30838. */
  30839. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30840. /**
  30841. * Clones an object
  30842. * @param creationFunction defines the function used to instanciate the new object
  30843. * @param source defines the source object
  30844. * @returns the cloned object
  30845. */
  30846. static Clone<T>(creationFunction: () => T, source: T): T;
  30847. /**
  30848. * Instanciates a new object based on a source one (some data will be shared between both object)
  30849. * @param creationFunction defines the function used to instanciate the new object
  30850. * @param source defines the source object
  30851. * @returns the new object
  30852. */
  30853. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30854. }
  30855. }
  30856. declare module "babylonjs/Misc/guid" {
  30857. /**
  30858. * Class used to manipulate GUIDs
  30859. */
  30860. export class GUID {
  30861. /**
  30862. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30863. * Be aware Math.random() could cause collisions, but:
  30864. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30865. * @returns a pseudo random id
  30866. */
  30867. static RandomId(): string;
  30868. }
  30869. }
  30870. declare module "babylonjs/Materials/Textures/baseTexture" {
  30871. import { Observable } from "babylonjs/Misc/observable";
  30872. import { Nullable } from "babylonjs/types";
  30873. import { Scene } from "babylonjs/scene";
  30874. import { Matrix } from "babylonjs/Maths/math.vector";
  30875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30877. import { ISize } from "babylonjs/Maths/math.size";
  30878. import "babylonjs/Misc/fileTools";
  30879. /**
  30880. * Base class of all the textures in babylon.
  30881. * It groups all the common properties the materials, post process, lights... might need
  30882. * in order to make a correct use of the texture.
  30883. */
  30884. export class BaseTexture implements IAnimatable {
  30885. /**
  30886. * Default anisotropic filtering level for the application.
  30887. * It is set to 4 as a good tradeoff between perf and quality.
  30888. */
  30889. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30890. /**
  30891. * Gets or sets the unique id of the texture
  30892. */
  30893. uniqueId: number;
  30894. /**
  30895. * Define the name of the texture.
  30896. */
  30897. name: string;
  30898. /**
  30899. * Gets or sets an object used to store user defined information.
  30900. */
  30901. metadata: any;
  30902. /**
  30903. * For internal use only. Please do not use.
  30904. */
  30905. reservedDataStore: any;
  30906. private _hasAlpha;
  30907. /**
  30908. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30909. */
  30910. set hasAlpha(value: boolean);
  30911. get hasAlpha(): boolean;
  30912. /**
  30913. * Defines if the alpha value should be determined via the rgb values.
  30914. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30915. */
  30916. getAlphaFromRGB: boolean;
  30917. /**
  30918. * Intensity or strength of the texture.
  30919. * It is commonly used by materials to fine tune the intensity of the texture
  30920. */
  30921. level: number;
  30922. /**
  30923. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30924. * This is part of the texture as textures usually maps to one uv set.
  30925. */
  30926. coordinatesIndex: number;
  30927. private _coordinatesMode;
  30928. /**
  30929. * How a texture is mapped.
  30930. *
  30931. * | Value | Type | Description |
  30932. * | ----- | ----------------------------------- | ----------- |
  30933. * | 0 | EXPLICIT_MODE | |
  30934. * | 1 | SPHERICAL_MODE | |
  30935. * | 2 | PLANAR_MODE | |
  30936. * | 3 | CUBIC_MODE | |
  30937. * | 4 | PROJECTION_MODE | |
  30938. * | 5 | SKYBOX_MODE | |
  30939. * | 6 | INVCUBIC_MODE | |
  30940. * | 7 | EQUIRECTANGULAR_MODE | |
  30941. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30942. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30943. */
  30944. set coordinatesMode(value: number);
  30945. get coordinatesMode(): number;
  30946. /**
  30947. * | Value | Type | Description |
  30948. * | ----- | ------------------ | ----------- |
  30949. * | 0 | CLAMP_ADDRESSMODE | |
  30950. * | 1 | WRAP_ADDRESSMODE | |
  30951. * | 2 | MIRROR_ADDRESSMODE | |
  30952. */
  30953. wrapU: number;
  30954. /**
  30955. * | Value | Type | Description |
  30956. * | ----- | ------------------ | ----------- |
  30957. * | 0 | CLAMP_ADDRESSMODE | |
  30958. * | 1 | WRAP_ADDRESSMODE | |
  30959. * | 2 | MIRROR_ADDRESSMODE | |
  30960. */
  30961. wrapV: number;
  30962. /**
  30963. * | Value | Type | Description |
  30964. * | ----- | ------------------ | ----------- |
  30965. * | 0 | CLAMP_ADDRESSMODE | |
  30966. * | 1 | WRAP_ADDRESSMODE | |
  30967. * | 2 | MIRROR_ADDRESSMODE | |
  30968. */
  30969. wrapR: number;
  30970. /**
  30971. * With compliant hardware and browser (supporting anisotropic filtering)
  30972. * this defines the level of anisotropic filtering in the texture.
  30973. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30974. */
  30975. anisotropicFilteringLevel: number;
  30976. /**
  30977. * Define if the texture is a cube texture or if false a 2d texture.
  30978. */
  30979. get isCube(): boolean;
  30980. set isCube(value: boolean);
  30981. /**
  30982. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30983. */
  30984. get is3D(): boolean;
  30985. set is3D(value: boolean);
  30986. /**
  30987. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30988. */
  30989. get is2DArray(): boolean;
  30990. set is2DArray(value: boolean);
  30991. /**
  30992. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30993. * HDR texture are usually stored in linear space.
  30994. * This only impacts the PBR and Background materials
  30995. */
  30996. gammaSpace: boolean;
  30997. /**
  30998. * Gets or sets whether or not the texture contains RGBD data.
  30999. */
  31000. get isRGBD(): boolean;
  31001. set isRGBD(value: boolean);
  31002. /**
  31003. * Is Z inverted in the texture (useful in a cube texture).
  31004. */
  31005. invertZ: boolean;
  31006. /**
  31007. * Are mip maps generated for this texture or not.
  31008. */
  31009. get noMipmap(): boolean;
  31010. /**
  31011. * @hidden
  31012. */
  31013. lodLevelInAlpha: boolean;
  31014. /**
  31015. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31016. */
  31017. get lodGenerationOffset(): number;
  31018. set lodGenerationOffset(value: number);
  31019. /**
  31020. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31021. */
  31022. get lodGenerationScale(): number;
  31023. set lodGenerationScale(value: number);
  31024. /**
  31025. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31026. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31027. * average roughness values.
  31028. */
  31029. get linearSpecularLOD(): boolean;
  31030. set linearSpecularLOD(value: boolean);
  31031. /**
  31032. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31033. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31034. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31035. */
  31036. get irradianceTexture(): Nullable<BaseTexture>;
  31037. set irradianceTexture(value: Nullable<BaseTexture>);
  31038. /**
  31039. * Define if the texture is a render target.
  31040. */
  31041. isRenderTarget: boolean;
  31042. /**
  31043. * Define the unique id of the texture in the scene.
  31044. */
  31045. get uid(): string;
  31046. /**
  31047. * Return a string representation of the texture.
  31048. * @returns the texture as a string
  31049. */
  31050. toString(): string;
  31051. /**
  31052. * Get the class name of the texture.
  31053. * @returns "BaseTexture"
  31054. */
  31055. getClassName(): string;
  31056. /**
  31057. * Define the list of animation attached to the texture.
  31058. */
  31059. animations: import("babylonjs/Animations/animation").Animation[];
  31060. /**
  31061. * An event triggered when the texture is disposed.
  31062. */
  31063. onDisposeObservable: Observable<BaseTexture>;
  31064. private _onDisposeObserver;
  31065. /**
  31066. * Callback triggered when the texture has been disposed.
  31067. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31068. */
  31069. set onDispose(callback: () => void);
  31070. /**
  31071. * Define the current state of the loading sequence when in delayed load mode.
  31072. */
  31073. delayLoadState: number;
  31074. private _scene;
  31075. /** @hidden */
  31076. _texture: Nullable<InternalTexture>;
  31077. private _uid;
  31078. /**
  31079. * Define if the texture is preventinga material to render or not.
  31080. * If not and the texture is not ready, the engine will use a default black texture instead.
  31081. */
  31082. get isBlocking(): boolean;
  31083. /**
  31084. * Instantiates a new BaseTexture.
  31085. * Base class of all the textures in babylon.
  31086. * It groups all the common properties the materials, post process, lights... might need
  31087. * in order to make a correct use of the texture.
  31088. * @param scene Define the scene the texture blongs to
  31089. */
  31090. constructor(scene: Nullable<Scene>);
  31091. /**
  31092. * Get the scene the texture belongs to.
  31093. * @returns the scene or null if undefined
  31094. */
  31095. getScene(): Nullable<Scene>;
  31096. /**
  31097. * Get the texture transform matrix used to offset tile the texture for istance.
  31098. * @returns the transformation matrix
  31099. */
  31100. getTextureMatrix(): Matrix;
  31101. /**
  31102. * Get the texture reflection matrix used to rotate/transform the reflection.
  31103. * @returns the reflection matrix
  31104. */
  31105. getReflectionTextureMatrix(): Matrix;
  31106. /**
  31107. * Get the underlying lower level texture from Babylon.
  31108. * @returns the insternal texture
  31109. */
  31110. getInternalTexture(): Nullable<InternalTexture>;
  31111. /**
  31112. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31113. * @returns true if ready or not blocking
  31114. */
  31115. isReadyOrNotBlocking(): boolean;
  31116. /**
  31117. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31118. * @returns true if fully ready
  31119. */
  31120. isReady(): boolean;
  31121. private _cachedSize;
  31122. /**
  31123. * Get the size of the texture.
  31124. * @returns the texture size.
  31125. */
  31126. getSize(): ISize;
  31127. /**
  31128. * Get the base size of the texture.
  31129. * It can be different from the size if the texture has been resized for POT for instance
  31130. * @returns the base size
  31131. */
  31132. getBaseSize(): ISize;
  31133. /**
  31134. * Update the sampling mode of the texture.
  31135. * Default is Trilinear mode.
  31136. *
  31137. * | Value | Type | Description |
  31138. * | ----- | ------------------ | ----------- |
  31139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31145. * | 7 | NEAREST_LINEAR | |
  31146. * | 8 | NEAREST_NEAREST | |
  31147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31149. * | 11 | LINEAR_LINEAR | |
  31150. * | 12 | LINEAR_NEAREST | |
  31151. *
  31152. * > _mag_: magnification filter (close to the viewer)
  31153. * > _min_: minification filter (far from the viewer)
  31154. * > _mip_: filter used between mip map levels
  31155. *@param samplingMode Define the new sampling mode of the texture
  31156. */
  31157. updateSamplingMode(samplingMode: number): void;
  31158. /**
  31159. * Scales the texture if is `canRescale()`
  31160. * @param ratio the resize factor we want to use to rescale
  31161. */
  31162. scale(ratio: number): void;
  31163. /**
  31164. * Get if the texture can rescale.
  31165. */
  31166. get canRescale(): boolean;
  31167. /** @hidden */
  31168. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31169. /** @hidden */
  31170. _rebuild(): void;
  31171. /**
  31172. * Triggers the load sequence in delayed load mode.
  31173. */
  31174. delayLoad(): void;
  31175. /**
  31176. * Clones the texture.
  31177. * @returns the cloned texture
  31178. */
  31179. clone(): Nullable<BaseTexture>;
  31180. /**
  31181. * Get the texture underlying type (INT, FLOAT...)
  31182. */
  31183. get textureType(): number;
  31184. /**
  31185. * Get the texture underlying format (RGB, RGBA...)
  31186. */
  31187. get textureFormat(): number;
  31188. /**
  31189. * Indicates that textures need to be re-calculated for all materials
  31190. */
  31191. protected _markAllSubMeshesAsTexturesDirty(): void;
  31192. /**
  31193. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31194. * This will returns an RGBA array buffer containing either in values (0-255) or
  31195. * float values (0-1) depending of the underlying buffer type.
  31196. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31197. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31198. * @param buffer defines a user defined buffer to fill with data (can be null)
  31199. * @returns The Array buffer containing the pixels data.
  31200. */
  31201. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31202. /**
  31203. * Release and destroy the underlying lower level texture aka internalTexture.
  31204. */
  31205. releaseInternalTexture(): void;
  31206. /** @hidden */
  31207. get _lodTextureHigh(): Nullable<BaseTexture>;
  31208. /** @hidden */
  31209. get _lodTextureMid(): Nullable<BaseTexture>;
  31210. /** @hidden */
  31211. get _lodTextureLow(): Nullable<BaseTexture>;
  31212. /**
  31213. * Dispose the texture and release its associated resources.
  31214. */
  31215. dispose(): void;
  31216. /**
  31217. * Serialize the texture into a JSON representation that can be parsed later on.
  31218. * @returns the JSON representation of the texture
  31219. */
  31220. serialize(): any;
  31221. /**
  31222. * Helper function to be called back once a list of texture contains only ready textures.
  31223. * @param textures Define the list of textures to wait for
  31224. * @param callback Define the callback triggered once the entire list will be ready
  31225. */
  31226. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31227. }
  31228. }
  31229. declare module "babylonjs/Materials/effect" {
  31230. import { Observable } from "babylonjs/Misc/observable";
  31231. import { Nullable } from "babylonjs/types";
  31232. import { IDisposable } from "babylonjs/scene";
  31233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31234. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31235. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31236. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31237. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31238. import { Engine } from "babylonjs/Engines/engine";
  31239. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31241. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31242. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31243. /**
  31244. * Options to be used when creating an effect.
  31245. */
  31246. export interface IEffectCreationOptions {
  31247. /**
  31248. * Atrributes that will be used in the shader.
  31249. */
  31250. attributes: string[];
  31251. /**
  31252. * Uniform varible names that will be set in the shader.
  31253. */
  31254. uniformsNames: string[];
  31255. /**
  31256. * Uniform buffer variable names that will be set in the shader.
  31257. */
  31258. uniformBuffersNames: string[];
  31259. /**
  31260. * Sampler texture variable names that will be set in the shader.
  31261. */
  31262. samplers: string[];
  31263. /**
  31264. * Define statements that will be set in the shader.
  31265. */
  31266. defines: any;
  31267. /**
  31268. * Possible fallbacks for this effect to improve performance when needed.
  31269. */
  31270. fallbacks: Nullable<IEffectFallbacks>;
  31271. /**
  31272. * Callback that will be called when the shader is compiled.
  31273. */
  31274. onCompiled: Nullable<(effect: Effect) => void>;
  31275. /**
  31276. * Callback that will be called if an error occurs during shader compilation.
  31277. */
  31278. onError: Nullable<(effect: Effect, errors: string) => void>;
  31279. /**
  31280. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31281. */
  31282. indexParameters?: any;
  31283. /**
  31284. * Max number of lights that can be used in the shader.
  31285. */
  31286. maxSimultaneousLights?: number;
  31287. /**
  31288. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31289. */
  31290. transformFeedbackVaryings?: Nullable<string[]>;
  31291. }
  31292. /**
  31293. * Effect containing vertex and fragment shader that can be executed on an object.
  31294. */
  31295. export class Effect implements IDisposable {
  31296. /**
  31297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31298. */
  31299. static ShadersRepository: string;
  31300. /**
  31301. * Enable logging of the shader code when a compilation error occurs
  31302. */
  31303. static LogShaderCodeOnCompilationError: boolean;
  31304. /**
  31305. * Name of the effect.
  31306. */
  31307. name: any;
  31308. /**
  31309. * String container all the define statements that should be set on the shader.
  31310. */
  31311. defines: string;
  31312. /**
  31313. * Callback that will be called when the shader is compiled.
  31314. */
  31315. onCompiled: Nullable<(effect: Effect) => void>;
  31316. /**
  31317. * Callback that will be called if an error occurs during shader compilation.
  31318. */
  31319. onError: Nullable<(effect: Effect, errors: string) => void>;
  31320. /**
  31321. * Callback that will be called when effect is bound.
  31322. */
  31323. onBind: Nullable<(effect: Effect) => void>;
  31324. /**
  31325. * Unique ID of the effect.
  31326. */
  31327. uniqueId: number;
  31328. /**
  31329. * Observable that will be called when the shader is compiled.
  31330. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31331. */
  31332. onCompileObservable: Observable<Effect>;
  31333. /**
  31334. * Observable that will be called if an error occurs during shader compilation.
  31335. */
  31336. onErrorObservable: Observable<Effect>;
  31337. /** @hidden */
  31338. _onBindObservable: Nullable<Observable<Effect>>;
  31339. /**
  31340. * @hidden
  31341. * Specifies if the effect was previously ready
  31342. */
  31343. _wasPreviouslyReady: boolean;
  31344. /**
  31345. * Observable that will be called when effect is bound.
  31346. */
  31347. get onBindObservable(): Observable<Effect>;
  31348. /** @hidden */
  31349. _bonesComputationForcedToCPU: boolean;
  31350. private static _uniqueIdSeed;
  31351. private _engine;
  31352. private _uniformBuffersNames;
  31353. private _uniformsNames;
  31354. private _samplerList;
  31355. private _samplers;
  31356. private _isReady;
  31357. private _compilationError;
  31358. private _allFallbacksProcessed;
  31359. private _attributesNames;
  31360. private _attributes;
  31361. private _attributeLocationByName;
  31362. private _uniforms;
  31363. /**
  31364. * Key for the effect.
  31365. * @hidden
  31366. */
  31367. _key: string;
  31368. private _indexParameters;
  31369. private _fallbacks;
  31370. private _vertexSourceCode;
  31371. private _fragmentSourceCode;
  31372. private _vertexSourceCodeOverride;
  31373. private _fragmentSourceCodeOverride;
  31374. private _transformFeedbackVaryings;
  31375. /**
  31376. * Compiled shader to webGL program.
  31377. * @hidden
  31378. */
  31379. _pipelineContext: Nullable<IPipelineContext>;
  31380. private _valueCache;
  31381. private static _baseCache;
  31382. /**
  31383. * Instantiates an effect.
  31384. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31385. * @param baseName Name of the effect.
  31386. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31387. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31388. * @param samplers List of sampler variables that will be passed to the shader.
  31389. * @param engine Engine to be used to render the effect
  31390. * @param defines Define statements to be added to the shader.
  31391. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31392. * @param onCompiled Callback that will be called when the shader is compiled.
  31393. * @param onError Callback that will be called if an error occurs during shader compilation.
  31394. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31395. */
  31396. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31397. private _useFinalCode;
  31398. /**
  31399. * Unique key for this effect
  31400. */
  31401. get key(): string;
  31402. /**
  31403. * If the effect has been compiled and prepared.
  31404. * @returns if the effect is compiled and prepared.
  31405. */
  31406. isReady(): boolean;
  31407. private _isReadyInternal;
  31408. /**
  31409. * The engine the effect was initialized with.
  31410. * @returns the engine.
  31411. */
  31412. getEngine(): Engine;
  31413. /**
  31414. * The pipeline context for this effect
  31415. * @returns the associated pipeline context
  31416. */
  31417. getPipelineContext(): Nullable<IPipelineContext>;
  31418. /**
  31419. * The set of names of attribute variables for the shader.
  31420. * @returns An array of attribute names.
  31421. */
  31422. getAttributesNames(): string[];
  31423. /**
  31424. * Returns the attribute at the given index.
  31425. * @param index The index of the attribute.
  31426. * @returns The location of the attribute.
  31427. */
  31428. getAttributeLocation(index: number): number;
  31429. /**
  31430. * Returns the attribute based on the name of the variable.
  31431. * @param name of the attribute to look up.
  31432. * @returns the attribute location.
  31433. */
  31434. getAttributeLocationByName(name: string): number;
  31435. /**
  31436. * The number of attributes.
  31437. * @returns the numnber of attributes.
  31438. */
  31439. getAttributesCount(): number;
  31440. /**
  31441. * Gets the index of a uniform variable.
  31442. * @param uniformName of the uniform to look up.
  31443. * @returns the index.
  31444. */
  31445. getUniformIndex(uniformName: string): number;
  31446. /**
  31447. * Returns the attribute based on the name of the variable.
  31448. * @param uniformName of the uniform to look up.
  31449. * @returns the location of the uniform.
  31450. */
  31451. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31452. /**
  31453. * Returns an array of sampler variable names
  31454. * @returns The array of sampler variable neames.
  31455. */
  31456. getSamplers(): string[];
  31457. /**
  31458. * The error from the last compilation.
  31459. * @returns the error string.
  31460. */
  31461. getCompilationError(): string;
  31462. /**
  31463. * Gets a boolean indicating that all fallbacks were used during compilation
  31464. * @returns true if all fallbacks were used
  31465. */
  31466. allFallbacksProcessed(): boolean;
  31467. /**
  31468. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31469. * @param func The callback to be used.
  31470. */
  31471. executeWhenCompiled(func: (effect: Effect) => void): void;
  31472. private _checkIsReady;
  31473. private _loadShader;
  31474. /**
  31475. * Recompiles the webGL program
  31476. * @param vertexSourceCode The source code for the vertex shader.
  31477. * @param fragmentSourceCode The source code for the fragment shader.
  31478. * @param onCompiled Callback called when completed.
  31479. * @param onError Callback called on error.
  31480. * @hidden
  31481. */
  31482. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31483. /**
  31484. * Prepares the effect
  31485. * @hidden
  31486. */
  31487. _prepareEffect(): void;
  31488. private _getShaderCodeAndErrorLine;
  31489. private _processCompilationErrors;
  31490. /**
  31491. * Checks if the effect is supported. (Must be called after compilation)
  31492. */
  31493. get isSupported(): boolean;
  31494. /**
  31495. * Binds a texture to the engine to be used as output of the shader.
  31496. * @param channel Name of the output variable.
  31497. * @param texture Texture to bind.
  31498. * @hidden
  31499. */
  31500. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31501. /**
  31502. * Sets a texture on the engine to be used in the shader.
  31503. * @param channel Name of the sampler variable.
  31504. * @param texture Texture to set.
  31505. */
  31506. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31507. /**
  31508. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31509. * @param channel Name of the sampler variable.
  31510. * @param texture Texture to set.
  31511. */
  31512. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31513. /**
  31514. * Sets an array of textures on the engine to be used in the shader.
  31515. * @param channel Name of the variable.
  31516. * @param textures Textures to set.
  31517. */
  31518. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31519. /**
  31520. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  31521. * @param channel Name of the sampler variable.
  31522. * @param postProcess Post process to get the input texture from.
  31523. */
  31524. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31525. /**
  31526. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31527. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  31528. * @param channel Name of the sampler variable.
  31529. * @param postProcess Post process to get the output texture from.
  31530. */
  31531. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31532. /** @hidden */
  31533. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31534. /** @hidden */
  31535. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31536. /** @hidden */
  31537. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31538. /** @hidden */
  31539. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31540. /**
  31541. * Binds a buffer to a uniform.
  31542. * @param buffer Buffer to bind.
  31543. * @param name Name of the uniform variable to bind to.
  31544. */
  31545. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31546. /**
  31547. * Binds block to a uniform.
  31548. * @param blockName Name of the block to bind.
  31549. * @param index Index to bind.
  31550. */
  31551. bindUniformBlock(blockName: string, index: number): void;
  31552. /**
  31553. * Sets an interger value on a uniform variable.
  31554. * @param uniformName Name of the variable.
  31555. * @param value Value to be set.
  31556. * @returns this effect.
  31557. */
  31558. setInt(uniformName: string, value: number): Effect;
  31559. /**
  31560. * Sets an int array on a uniform variable.
  31561. * @param uniformName Name of the variable.
  31562. * @param array array to be set.
  31563. * @returns this effect.
  31564. */
  31565. setIntArray(uniformName: string, array: Int32Array): Effect;
  31566. /**
  31567. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31568. * @param uniformName Name of the variable.
  31569. * @param array array to be set.
  31570. * @returns this effect.
  31571. */
  31572. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31573. /**
  31574. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31575. * @param uniformName Name of the variable.
  31576. * @param array array to be set.
  31577. * @returns this effect.
  31578. */
  31579. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31580. /**
  31581. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31582. * @param uniformName Name of the variable.
  31583. * @param array array to be set.
  31584. * @returns this effect.
  31585. */
  31586. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31587. /**
  31588. * Sets an float array on a uniform variable.
  31589. * @param uniformName Name of the variable.
  31590. * @param array array to be set.
  31591. * @returns this effect.
  31592. */
  31593. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31594. /**
  31595. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31596. * @param uniformName Name of the variable.
  31597. * @param array array to be set.
  31598. * @returns this effect.
  31599. */
  31600. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31601. /**
  31602. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31603. * @param uniformName Name of the variable.
  31604. * @param array array to be set.
  31605. * @returns this effect.
  31606. */
  31607. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31608. /**
  31609. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31610. * @param uniformName Name of the variable.
  31611. * @param array array to be set.
  31612. * @returns this effect.
  31613. */
  31614. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31615. /**
  31616. * Sets an array on a uniform variable.
  31617. * @param uniformName Name of the variable.
  31618. * @param array array to be set.
  31619. * @returns this effect.
  31620. */
  31621. setArray(uniformName: string, array: number[]): Effect;
  31622. /**
  31623. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31624. * @param uniformName Name of the variable.
  31625. * @param array array to be set.
  31626. * @returns this effect.
  31627. */
  31628. setArray2(uniformName: string, array: number[]): Effect;
  31629. /**
  31630. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31631. * @param uniformName Name of the variable.
  31632. * @param array array to be set.
  31633. * @returns this effect.
  31634. */
  31635. setArray3(uniformName: string, array: number[]): Effect;
  31636. /**
  31637. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31638. * @param uniformName Name of the variable.
  31639. * @param array array to be set.
  31640. * @returns this effect.
  31641. */
  31642. setArray4(uniformName: string, array: number[]): Effect;
  31643. /**
  31644. * Sets matrices on a uniform variable.
  31645. * @param uniformName Name of the variable.
  31646. * @param matrices matrices to be set.
  31647. * @returns this effect.
  31648. */
  31649. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31650. /**
  31651. * Sets matrix on a uniform variable.
  31652. * @param uniformName Name of the variable.
  31653. * @param matrix matrix to be set.
  31654. * @returns this effect.
  31655. */
  31656. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31657. /**
  31658. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  31659. * @param uniformName Name of the variable.
  31660. * @param matrix matrix to be set.
  31661. * @returns this effect.
  31662. */
  31663. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31664. /**
  31665. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31666. * @param uniformName Name of the variable.
  31667. * @param matrix matrix to be set.
  31668. * @returns this effect.
  31669. */
  31670. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31671. /**
  31672. * Sets a float on a uniform variable.
  31673. * @param uniformName Name of the variable.
  31674. * @param value value to be set.
  31675. * @returns this effect.
  31676. */
  31677. setFloat(uniformName: string, value: number): Effect;
  31678. /**
  31679. * Sets a boolean on a uniform variable.
  31680. * @param uniformName Name of the variable.
  31681. * @param bool value to be set.
  31682. * @returns this effect.
  31683. */
  31684. setBool(uniformName: string, bool: boolean): Effect;
  31685. /**
  31686. * Sets a Vector2 on a uniform variable.
  31687. * @param uniformName Name of the variable.
  31688. * @param vector2 vector2 to be set.
  31689. * @returns this effect.
  31690. */
  31691. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31692. /**
  31693. * Sets a float2 on a uniform variable.
  31694. * @param uniformName Name of the variable.
  31695. * @param x First float in float2.
  31696. * @param y Second float in float2.
  31697. * @returns this effect.
  31698. */
  31699. setFloat2(uniformName: string, x: number, y: number): Effect;
  31700. /**
  31701. * Sets a Vector3 on a uniform variable.
  31702. * @param uniformName Name of the variable.
  31703. * @param vector3 Value to be set.
  31704. * @returns this effect.
  31705. */
  31706. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31707. /**
  31708. * Sets a float3 on a uniform variable.
  31709. * @param uniformName Name of the variable.
  31710. * @param x First float in float3.
  31711. * @param y Second float in float3.
  31712. * @param z Third float in float3.
  31713. * @returns this effect.
  31714. */
  31715. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31716. /**
  31717. * Sets a Vector4 on a uniform variable.
  31718. * @param uniformName Name of the variable.
  31719. * @param vector4 Value to be set.
  31720. * @returns this effect.
  31721. */
  31722. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31723. /**
  31724. * Sets a float4 on a uniform variable.
  31725. * @param uniformName Name of the variable.
  31726. * @param x First float in float4.
  31727. * @param y Second float in float4.
  31728. * @param z Third float in float4.
  31729. * @param w Fourth float in float4.
  31730. * @returns this effect.
  31731. */
  31732. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31733. /**
  31734. * Sets a Color3 on a uniform variable.
  31735. * @param uniformName Name of the variable.
  31736. * @param color3 Value to be set.
  31737. * @returns this effect.
  31738. */
  31739. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31740. /**
  31741. * Sets a Color4 on a uniform variable.
  31742. * @param uniformName Name of the variable.
  31743. * @param color3 Value to be set.
  31744. * @param alpha Alpha value to be set.
  31745. * @returns this effect.
  31746. */
  31747. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31748. /**
  31749. * Sets a Color4 on a uniform variable
  31750. * @param uniformName defines the name of the variable
  31751. * @param color4 defines the value to be set
  31752. * @returns this effect.
  31753. */
  31754. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31755. /** Release all associated resources */
  31756. dispose(): void;
  31757. /**
  31758. * This function will add a new shader to the shader store
  31759. * @param name the name of the shader
  31760. * @param pixelShader optional pixel shader content
  31761. * @param vertexShader optional vertex shader content
  31762. */
  31763. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31764. /**
  31765. * Store of each shader (The can be looked up using effect.key)
  31766. */
  31767. static ShadersStore: {
  31768. [key: string]: string;
  31769. };
  31770. /**
  31771. * Store of each included file for a shader (The can be looked up using effect.key)
  31772. */
  31773. static IncludesShadersStore: {
  31774. [key: string]: string;
  31775. };
  31776. /**
  31777. * Resets the cache of effects.
  31778. */
  31779. static ResetCache(): void;
  31780. }
  31781. }
  31782. declare module "babylonjs/Engines/engineCapabilities" {
  31783. /**
  31784. * Interface used to describe the capabilities of the engine relatively to the current browser
  31785. */
  31786. export interface EngineCapabilities {
  31787. /** Maximum textures units per fragment shader */
  31788. maxTexturesImageUnits: number;
  31789. /** Maximum texture units per vertex shader */
  31790. maxVertexTextureImageUnits: number;
  31791. /** Maximum textures units in the entire pipeline */
  31792. maxCombinedTexturesImageUnits: number;
  31793. /** Maximum texture size */
  31794. maxTextureSize: number;
  31795. /** Maximum texture samples */
  31796. maxSamples?: number;
  31797. /** Maximum cube texture size */
  31798. maxCubemapTextureSize: number;
  31799. /** Maximum render texture size */
  31800. maxRenderTextureSize: number;
  31801. /** Maximum number of vertex attributes */
  31802. maxVertexAttribs: number;
  31803. /** Maximum number of varyings */
  31804. maxVaryingVectors: number;
  31805. /** Maximum number of uniforms per vertex shader */
  31806. maxVertexUniformVectors: number;
  31807. /** Maximum number of uniforms per fragment shader */
  31808. maxFragmentUniformVectors: number;
  31809. /** Defines if standard derivates (dx/dy) are supported */
  31810. standardDerivatives: boolean;
  31811. /** Defines if s3tc texture compression is supported */
  31812. s3tc?: WEBGL_compressed_texture_s3tc;
  31813. /** Defines if pvrtc texture compression is supported */
  31814. pvrtc: any;
  31815. /** Defines if etc1 texture compression is supported */
  31816. etc1: any;
  31817. /** Defines if etc2 texture compression is supported */
  31818. etc2: any;
  31819. /** Defines if astc texture compression is supported */
  31820. astc: any;
  31821. /** Defines if float textures are supported */
  31822. textureFloat: boolean;
  31823. /** Defines if vertex array objects are supported */
  31824. vertexArrayObject: boolean;
  31825. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31826. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31827. /** Gets the maximum level of anisotropy supported */
  31828. maxAnisotropy: number;
  31829. /** Defines if instancing is supported */
  31830. instancedArrays: boolean;
  31831. /** Defines if 32 bits indices are supported */
  31832. uintIndices: boolean;
  31833. /** Defines if high precision shaders are supported */
  31834. highPrecisionShaderSupported: boolean;
  31835. /** Defines if depth reading in the fragment shader is supported */
  31836. fragmentDepthSupported: boolean;
  31837. /** Defines if float texture linear filtering is supported*/
  31838. textureFloatLinearFiltering: boolean;
  31839. /** Defines if rendering to float textures is supported */
  31840. textureFloatRender: boolean;
  31841. /** Defines if half float textures are supported*/
  31842. textureHalfFloat: boolean;
  31843. /** Defines if half float texture linear filtering is supported*/
  31844. textureHalfFloatLinearFiltering: boolean;
  31845. /** Defines if rendering to half float textures is supported */
  31846. textureHalfFloatRender: boolean;
  31847. /** Defines if textureLOD shader command is supported */
  31848. textureLOD: boolean;
  31849. /** Defines if draw buffers extension is supported */
  31850. drawBuffersExtension: boolean;
  31851. /** Defines if depth textures are supported */
  31852. depthTextureExtension: boolean;
  31853. /** Defines if float color buffer are supported */
  31854. colorBufferFloat: boolean;
  31855. /** Gets disjoint timer query extension (null if not supported) */
  31856. timerQuery?: EXT_disjoint_timer_query;
  31857. /** Defines if timestamp can be used with timer query */
  31858. canUseTimestampForTimerQuery: boolean;
  31859. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31860. multiview?: any;
  31861. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31862. oculusMultiview?: any;
  31863. /** Function used to let the system compiles shaders in background */
  31864. parallelShaderCompile?: {
  31865. COMPLETION_STATUS_KHR: number;
  31866. };
  31867. /** Max number of texture samples for MSAA */
  31868. maxMSAASamples: number;
  31869. /** Defines if the blend min max extension is supported */
  31870. blendMinMax: boolean;
  31871. }
  31872. }
  31873. declare module "babylonjs/States/depthCullingState" {
  31874. import { Nullable } from "babylonjs/types";
  31875. /**
  31876. * @hidden
  31877. **/
  31878. export class DepthCullingState {
  31879. private _isDepthTestDirty;
  31880. private _isDepthMaskDirty;
  31881. private _isDepthFuncDirty;
  31882. private _isCullFaceDirty;
  31883. private _isCullDirty;
  31884. private _isZOffsetDirty;
  31885. private _isFrontFaceDirty;
  31886. private _depthTest;
  31887. private _depthMask;
  31888. private _depthFunc;
  31889. private _cull;
  31890. private _cullFace;
  31891. private _zOffset;
  31892. private _frontFace;
  31893. /**
  31894. * Initializes the state.
  31895. */
  31896. constructor();
  31897. get isDirty(): boolean;
  31898. get zOffset(): number;
  31899. set zOffset(value: number);
  31900. get cullFace(): Nullable<number>;
  31901. set cullFace(value: Nullable<number>);
  31902. get cull(): Nullable<boolean>;
  31903. set cull(value: Nullable<boolean>);
  31904. get depthFunc(): Nullable<number>;
  31905. set depthFunc(value: Nullable<number>);
  31906. get depthMask(): boolean;
  31907. set depthMask(value: boolean);
  31908. get depthTest(): boolean;
  31909. set depthTest(value: boolean);
  31910. get frontFace(): Nullable<number>;
  31911. set frontFace(value: Nullable<number>);
  31912. reset(): void;
  31913. apply(gl: WebGLRenderingContext): void;
  31914. }
  31915. }
  31916. declare module "babylonjs/States/stencilState" {
  31917. /**
  31918. * @hidden
  31919. **/
  31920. export class StencilState {
  31921. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  31922. static readonly ALWAYS: number;
  31923. /** Passed to stencilOperation to specify that stencil value must be kept */
  31924. static readonly KEEP: number;
  31925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31926. static readonly REPLACE: number;
  31927. private _isStencilTestDirty;
  31928. private _isStencilMaskDirty;
  31929. private _isStencilFuncDirty;
  31930. private _isStencilOpDirty;
  31931. private _stencilTest;
  31932. private _stencilMask;
  31933. private _stencilFunc;
  31934. private _stencilFuncRef;
  31935. private _stencilFuncMask;
  31936. private _stencilOpStencilFail;
  31937. private _stencilOpDepthFail;
  31938. private _stencilOpStencilDepthPass;
  31939. get isDirty(): boolean;
  31940. get stencilFunc(): number;
  31941. set stencilFunc(value: number);
  31942. get stencilFuncRef(): number;
  31943. set stencilFuncRef(value: number);
  31944. get stencilFuncMask(): number;
  31945. set stencilFuncMask(value: number);
  31946. get stencilOpStencilFail(): number;
  31947. set stencilOpStencilFail(value: number);
  31948. get stencilOpDepthFail(): number;
  31949. set stencilOpDepthFail(value: number);
  31950. get stencilOpStencilDepthPass(): number;
  31951. set stencilOpStencilDepthPass(value: number);
  31952. get stencilMask(): number;
  31953. set stencilMask(value: number);
  31954. get stencilTest(): boolean;
  31955. set stencilTest(value: boolean);
  31956. constructor();
  31957. reset(): void;
  31958. apply(gl: WebGLRenderingContext): void;
  31959. }
  31960. }
  31961. declare module "babylonjs/States/alphaCullingState" {
  31962. /**
  31963. * @hidden
  31964. **/
  31965. export class AlphaState {
  31966. private _isAlphaBlendDirty;
  31967. private _isBlendFunctionParametersDirty;
  31968. private _isBlendEquationParametersDirty;
  31969. private _isBlendConstantsDirty;
  31970. private _alphaBlend;
  31971. private _blendFunctionParameters;
  31972. private _blendEquationParameters;
  31973. private _blendConstants;
  31974. /**
  31975. * Initializes the state.
  31976. */
  31977. constructor();
  31978. get isDirty(): boolean;
  31979. get alphaBlend(): boolean;
  31980. set alphaBlend(value: boolean);
  31981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31984. reset(): void;
  31985. apply(gl: WebGLRenderingContext): void;
  31986. }
  31987. }
  31988. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31989. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31990. /** @hidden */
  31991. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31992. attributeProcessor(attribute: string): string;
  31993. varyingProcessor(varying: string, isFragment: boolean): string;
  31994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31995. }
  31996. }
  31997. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31998. /**
  31999. * Interface for attribute information associated with buffer instanciation
  32000. */
  32001. export interface InstancingAttributeInfo {
  32002. /**
  32003. * Name of the GLSL attribute
  32004. * if attribute index is not specified, this is used to retrieve the index from the effect
  32005. */
  32006. attributeName: string;
  32007. /**
  32008. * Index/offset of the attribute in the vertex shader
  32009. * if not specified, this will be computes from the name.
  32010. */
  32011. index?: number;
  32012. /**
  32013. * size of the attribute, 1, 2, 3 or 4
  32014. */
  32015. attributeSize: number;
  32016. /**
  32017. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32018. */
  32019. offset: number;
  32020. /**
  32021. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32022. * default to 1
  32023. */
  32024. divisor?: number;
  32025. /**
  32026. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32027. * default is FLOAT
  32028. */
  32029. attributeType?: number;
  32030. /**
  32031. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32032. */
  32033. normalized?: boolean;
  32034. }
  32035. }
  32036. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32037. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32038. import { Nullable } from "babylonjs/types";
  32039. module "babylonjs/Engines/thinEngine" {
  32040. interface ThinEngine {
  32041. /**
  32042. * Update a video texture
  32043. * @param texture defines the texture to update
  32044. * @param video defines the video element to use
  32045. * @param invertY defines if data must be stored with Y axis inverted
  32046. */
  32047. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32048. }
  32049. }
  32050. }
  32051. declare module "babylonjs/Materials/Textures/videoTexture" {
  32052. import { Observable } from "babylonjs/Misc/observable";
  32053. import { Nullable } from "babylonjs/types";
  32054. import { Scene } from "babylonjs/scene";
  32055. import { Texture } from "babylonjs/Materials/Textures/texture";
  32056. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32057. /**
  32058. * Settings for finer control over video usage
  32059. */
  32060. export interface VideoTextureSettings {
  32061. /**
  32062. * Applies `autoplay` to video, if specified
  32063. */
  32064. autoPlay?: boolean;
  32065. /**
  32066. * Applies `loop` to video, if specified
  32067. */
  32068. loop?: boolean;
  32069. /**
  32070. * Automatically updates internal texture from video at every frame in the render loop
  32071. */
  32072. autoUpdateTexture: boolean;
  32073. /**
  32074. * Image src displayed during the video loading or until the user interacts with the video.
  32075. */
  32076. poster?: string;
  32077. }
  32078. /**
  32079. * If you want to display a video in your scene, this is the special texture for that.
  32080. * This special texture works similar to other textures, with the exception of a few parameters.
  32081. * @see https://doc.babylonjs.com/how_to/video_texture
  32082. */
  32083. export class VideoTexture extends Texture {
  32084. /**
  32085. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32086. */
  32087. readonly autoUpdateTexture: boolean;
  32088. /**
  32089. * The video instance used by the texture internally
  32090. */
  32091. readonly video: HTMLVideoElement;
  32092. private _onUserActionRequestedObservable;
  32093. /**
  32094. * Event triggerd when a dom action is required by the user to play the video.
  32095. * This happens due to recent changes in browser policies preventing video to auto start.
  32096. */
  32097. get onUserActionRequestedObservable(): Observable<Texture>;
  32098. private _generateMipMaps;
  32099. private _engine;
  32100. private _stillImageCaptured;
  32101. private _displayingPosterTexture;
  32102. private _settings;
  32103. private _createInternalTextureOnEvent;
  32104. private _frameId;
  32105. private _currentSrc;
  32106. /**
  32107. * Creates a video texture.
  32108. * If you want to display a video in your scene, this is the special texture for that.
  32109. * This special texture works similar to other textures, with the exception of a few parameters.
  32110. * @see https://doc.babylonjs.com/how_to/video_texture
  32111. * @param name optional name, will detect from video source, if not defined
  32112. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32113. * @param scene is obviously the current scene.
  32114. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32115. * @param invertY is false by default but can be used to invert video on Y axis
  32116. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32117. * @param settings allows finer control over video usage
  32118. */
  32119. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32120. private _getName;
  32121. private _getVideo;
  32122. private _createInternalTexture;
  32123. private reset;
  32124. /**
  32125. * @hidden Internal method to initiate `update`.
  32126. */
  32127. _rebuild(): void;
  32128. /**
  32129. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32130. */
  32131. update(): void;
  32132. /**
  32133. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32134. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32135. */
  32136. updateTexture(isVisible: boolean): void;
  32137. protected _updateInternalTexture: () => void;
  32138. /**
  32139. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32140. * @param url New url.
  32141. */
  32142. updateURL(url: string): void;
  32143. /**
  32144. * Clones the texture.
  32145. * @returns the cloned texture
  32146. */
  32147. clone(): VideoTexture;
  32148. /**
  32149. * Dispose the texture and release its associated resources.
  32150. */
  32151. dispose(): void;
  32152. /**
  32153. * Creates a video texture straight from a stream.
  32154. * @param scene Define the scene the texture should be created in
  32155. * @param stream Define the stream the texture should be created from
  32156. * @returns The created video texture as a promise
  32157. */
  32158. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32159. /**
  32160. * Creates a video texture straight from your WebCam video feed.
  32161. * @param scene Define the scene the texture should be created in
  32162. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32163. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32164. * @returns The created video texture as a promise
  32165. */
  32166. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32167. minWidth: number;
  32168. maxWidth: number;
  32169. minHeight: number;
  32170. maxHeight: number;
  32171. deviceId: string;
  32172. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32173. /**
  32174. * Creates a video texture straight from your WebCam video feed.
  32175. * @param scene Define the scene the texture should be created in
  32176. * @param onReady Define a callback to triggered once the texture will be ready
  32177. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32178. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32179. */
  32180. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32181. minWidth: number;
  32182. maxWidth: number;
  32183. minHeight: number;
  32184. maxHeight: number;
  32185. deviceId: string;
  32186. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32187. }
  32188. }
  32189. declare module "babylonjs/Engines/thinEngine" {
  32190. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32191. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32192. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32193. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32194. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32195. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32196. import { Observable } from "babylonjs/Misc/observable";
  32197. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32198. import { StencilState } from "babylonjs/States/stencilState";
  32199. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32201. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32202. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32203. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32204. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32205. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32206. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32207. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32209. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32210. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32211. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32212. import { WebRequest } from "babylonjs/Misc/webRequest";
  32213. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32214. /**
  32215. * Defines the interface used by objects working like Scene
  32216. * @hidden
  32217. */
  32218. export interface ISceneLike {
  32219. _addPendingData(data: any): void;
  32220. _removePendingData(data: any): void;
  32221. offlineProvider: IOfflineProvider;
  32222. }
  32223. /** Interface defining initialization parameters for Engine class */
  32224. export interface EngineOptions extends WebGLContextAttributes {
  32225. /**
  32226. * Defines if the engine should no exceed a specified device ratio
  32227. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32228. */
  32229. limitDeviceRatio?: number;
  32230. /**
  32231. * Defines if webvr should be enabled automatically
  32232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32233. */
  32234. autoEnableWebVR?: boolean;
  32235. /**
  32236. * Defines if webgl2 should be turned off even if supported
  32237. * @see http://doc.babylonjs.com/features/webgl2
  32238. */
  32239. disableWebGL2Support?: boolean;
  32240. /**
  32241. * Defines if webaudio should be initialized as well
  32242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32243. */
  32244. audioEngine?: boolean;
  32245. /**
  32246. * Defines if animations should run using a deterministic lock step
  32247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32248. */
  32249. deterministicLockstep?: boolean;
  32250. /** Defines the maximum steps to use with deterministic lock step mode */
  32251. lockstepMaxSteps?: number;
  32252. /** Defines the seconds between each deterministic lock step */
  32253. timeStep?: number;
  32254. /**
  32255. * Defines that engine should ignore context lost events
  32256. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32257. */
  32258. doNotHandleContextLost?: boolean;
  32259. /**
  32260. * Defines that engine should ignore modifying touch action attribute and style
  32261. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32262. */
  32263. doNotHandleTouchAction?: boolean;
  32264. /**
  32265. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32266. */
  32267. useHighPrecisionFloats?: boolean;
  32268. }
  32269. /**
  32270. * The base engine class (root of all engines)
  32271. */
  32272. export class ThinEngine {
  32273. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32274. static ExceptionList: ({
  32275. key: string;
  32276. capture: string;
  32277. captureConstraint: number;
  32278. targets: string[];
  32279. } | {
  32280. key: string;
  32281. capture: null;
  32282. captureConstraint: null;
  32283. targets: string[];
  32284. })[];
  32285. /** @hidden */
  32286. static _TextureLoaders: IInternalTextureLoader[];
  32287. /**
  32288. * Returns the current npm package of the sdk
  32289. */
  32290. static get NpmPackage(): string;
  32291. /**
  32292. * Returns the current version of the framework
  32293. */
  32294. static get Version(): string;
  32295. /**
  32296. * Returns a string describing the current engine
  32297. */
  32298. get description(): string;
  32299. /**
  32300. * Gets or sets the epsilon value used by collision engine
  32301. */
  32302. static CollisionsEpsilon: number;
  32303. /**
  32304. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32305. */
  32306. static get ShadersRepository(): string;
  32307. static set ShadersRepository(value: string);
  32308. /** @hidden */
  32309. _shaderProcessor: IShaderProcessor;
  32310. /**
  32311. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32312. */
  32313. forcePOTTextures: boolean;
  32314. /**
  32315. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32316. */
  32317. isFullscreen: boolean;
  32318. /**
  32319. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32320. */
  32321. cullBackFaces: boolean;
  32322. /**
  32323. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32324. */
  32325. renderEvenInBackground: boolean;
  32326. /**
  32327. * Gets or sets a boolean indicating that cache can be kept between frames
  32328. */
  32329. preventCacheWipeBetweenFrames: boolean;
  32330. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32331. validateShaderPrograms: boolean;
  32332. /**
  32333. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32334. * This can provide greater z depth for distant objects.
  32335. */
  32336. useReverseDepthBuffer: boolean;
  32337. /**
  32338. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32339. */
  32340. disableUniformBuffers: boolean;
  32341. /** @hidden */
  32342. _uniformBuffers: UniformBuffer[];
  32343. /**
  32344. * Gets a boolean indicating that the engine supports uniform buffers
  32345. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32346. */
  32347. get supportsUniformBuffers(): boolean;
  32348. /** @hidden */
  32349. _gl: WebGLRenderingContext;
  32350. /** @hidden */
  32351. _webGLVersion: number;
  32352. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32353. protected _windowIsBackground: boolean;
  32354. protected _creationOptions: EngineOptions;
  32355. protected _highPrecisionShadersAllowed: boolean;
  32356. /** @hidden */
  32357. get _shouldUseHighPrecisionShader(): boolean;
  32358. /**
  32359. * Gets a boolean indicating that only power of 2 textures are supported
  32360. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32361. */
  32362. get needPOTTextures(): boolean;
  32363. /** @hidden */
  32364. _badOS: boolean;
  32365. /** @hidden */
  32366. _badDesktopOS: boolean;
  32367. private _hardwareScalingLevel;
  32368. /** @hidden */
  32369. _caps: EngineCapabilities;
  32370. private _isStencilEnable;
  32371. private _glVersion;
  32372. private _glRenderer;
  32373. private _glVendor;
  32374. /** @hidden */
  32375. _videoTextureSupported: boolean;
  32376. protected _renderingQueueLaunched: boolean;
  32377. protected _activeRenderLoops: (() => void)[];
  32378. /**
  32379. * Observable signaled when a context lost event is raised
  32380. */
  32381. onContextLostObservable: Observable<ThinEngine>;
  32382. /**
  32383. * Observable signaled when a context restored event is raised
  32384. */
  32385. onContextRestoredObservable: Observable<ThinEngine>;
  32386. private _onContextLost;
  32387. private _onContextRestored;
  32388. protected _contextWasLost: boolean;
  32389. /** @hidden */
  32390. _doNotHandleContextLost: boolean;
  32391. /**
  32392. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32394. */
  32395. get doNotHandleContextLost(): boolean;
  32396. set doNotHandleContextLost(value: boolean);
  32397. /**
  32398. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32399. */
  32400. disableVertexArrayObjects: boolean;
  32401. /** @hidden */
  32402. protected _colorWrite: boolean;
  32403. /** @hidden */
  32404. protected _colorWriteChanged: boolean;
  32405. /** @hidden */
  32406. protected _depthCullingState: DepthCullingState;
  32407. /** @hidden */
  32408. protected _stencilState: StencilState;
  32409. /** @hidden */
  32410. _alphaState: AlphaState;
  32411. /** @hidden */
  32412. _alphaMode: number;
  32413. /** @hidden */
  32414. _alphaEquation: number;
  32415. /** @hidden */
  32416. _internalTexturesCache: InternalTexture[];
  32417. /** @hidden */
  32418. protected _activeChannel: number;
  32419. private _currentTextureChannel;
  32420. /** @hidden */
  32421. protected _boundTexturesCache: {
  32422. [key: string]: Nullable<InternalTexture>;
  32423. };
  32424. /** @hidden */
  32425. protected _currentEffect: Nullable<Effect>;
  32426. /** @hidden */
  32427. protected _currentProgram: Nullable<WebGLProgram>;
  32428. private _compiledEffects;
  32429. private _vertexAttribArraysEnabled;
  32430. /** @hidden */
  32431. protected _cachedViewport: Nullable<IViewportLike>;
  32432. private _cachedVertexArrayObject;
  32433. /** @hidden */
  32434. protected _cachedVertexBuffers: any;
  32435. /** @hidden */
  32436. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32437. /** @hidden */
  32438. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32439. /** @hidden */
  32440. _currentRenderTarget: Nullable<InternalTexture>;
  32441. private _uintIndicesCurrentlySet;
  32442. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32443. /** @hidden */
  32444. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32445. private _currentBufferPointers;
  32446. private _currentInstanceLocations;
  32447. private _currentInstanceBuffers;
  32448. private _textureUnits;
  32449. /** @hidden */
  32450. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32451. /** @hidden */
  32452. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32453. /** @hidden */
  32454. _boundRenderFunction: any;
  32455. private _vaoRecordInProgress;
  32456. private _mustWipeVertexAttributes;
  32457. private _emptyTexture;
  32458. private _emptyCubeTexture;
  32459. private _emptyTexture3D;
  32460. private _emptyTexture2DArray;
  32461. /** @hidden */
  32462. _frameHandler: number;
  32463. private _nextFreeTextureSlots;
  32464. private _maxSimultaneousTextures;
  32465. private _activeRequests;
  32466. /** @hidden */
  32467. _transformTextureUrl: Nullable<(url: string) => string>;
  32468. protected get _supportsHardwareTextureRescaling(): boolean;
  32469. private _framebufferDimensionsObject;
  32470. /**
  32471. * sets the object from which width and height will be taken from when getting render width and height
  32472. * Will fallback to the gl object
  32473. * @param dimensions the framebuffer width and height that will be used.
  32474. */
  32475. set framebufferDimensionsObject(dimensions: Nullable<{
  32476. framebufferWidth: number;
  32477. framebufferHeight: number;
  32478. }>);
  32479. /**
  32480. * Gets the current viewport
  32481. */
  32482. get currentViewport(): Nullable<IViewportLike>;
  32483. /**
  32484. * Gets the default empty texture
  32485. */
  32486. get emptyTexture(): InternalTexture;
  32487. /**
  32488. * Gets the default empty 3D texture
  32489. */
  32490. get emptyTexture3D(): InternalTexture;
  32491. /**
  32492. * Gets the default empty 2D array texture
  32493. */
  32494. get emptyTexture2DArray(): InternalTexture;
  32495. /**
  32496. * Gets the default empty cube texture
  32497. */
  32498. get emptyCubeTexture(): InternalTexture;
  32499. /**
  32500. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32501. */
  32502. readonly premultipliedAlpha: boolean;
  32503. /**
  32504. * Observable event triggered before each texture is initialized
  32505. */
  32506. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32507. /**
  32508. * Creates a new engine
  32509. * @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
  32510. * @param antialias defines enable antialiasing (default: false)
  32511. * @param options defines further options to be sent to the getContext() function
  32512. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32513. */
  32514. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32515. private _rebuildInternalTextures;
  32516. private _rebuildEffects;
  32517. /**
  32518. * Gets a boolean indicating if all created effects are ready
  32519. * @returns true if all effects are ready
  32520. */
  32521. areAllEffectsReady(): boolean;
  32522. protected _rebuildBuffers(): void;
  32523. protected _initGLContext(): void;
  32524. /**
  32525. * Gets version of the current webGL context
  32526. */
  32527. get webGLVersion(): number;
  32528. /**
  32529. * Gets a string idenfifying the name of the class
  32530. * @returns "Engine" string
  32531. */
  32532. getClassName(): string;
  32533. /**
  32534. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32535. */
  32536. get isStencilEnable(): boolean;
  32537. /** @hidden */
  32538. _prepareWorkingCanvas(): void;
  32539. /**
  32540. * Reset the texture cache to empty state
  32541. */
  32542. resetTextureCache(): void;
  32543. /**
  32544. * Gets an object containing information about the current webGL context
  32545. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32546. */
  32547. getGlInfo(): {
  32548. vendor: string;
  32549. renderer: string;
  32550. version: string;
  32551. };
  32552. /**
  32553. * Defines the hardware scaling level.
  32554. * By default the hardware scaling level is computed from the window device ratio.
  32555. * 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.
  32556. * @param level defines the level to use
  32557. */
  32558. setHardwareScalingLevel(level: number): void;
  32559. /**
  32560. * Gets the current hardware scaling level.
  32561. * By default the hardware scaling level is computed from the window device ratio.
  32562. * 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.
  32563. * @returns a number indicating the current hardware scaling level
  32564. */
  32565. getHardwareScalingLevel(): number;
  32566. /**
  32567. * Gets the list of loaded textures
  32568. * @returns an array containing all loaded textures
  32569. */
  32570. getLoadedTexturesCache(): InternalTexture[];
  32571. /**
  32572. * Gets the object containing all engine capabilities
  32573. * @returns the EngineCapabilities object
  32574. */
  32575. getCaps(): EngineCapabilities;
  32576. /**
  32577. * stop executing a render loop function and remove it from the execution array
  32578. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32579. */
  32580. stopRenderLoop(renderFunction?: () => void): void;
  32581. /** @hidden */
  32582. _renderLoop(): void;
  32583. /**
  32584. * Gets the HTML canvas attached with the current webGL context
  32585. * @returns a HTML canvas
  32586. */
  32587. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32588. /**
  32589. * Gets host window
  32590. * @returns the host window object
  32591. */
  32592. getHostWindow(): Nullable<Window>;
  32593. /**
  32594. * Gets the current render width
  32595. * @param useScreen defines if screen size must be used (or the current render target if any)
  32596. * @returns a number defining the current render width
  32597. */
  32598. getRenderWidth(useScreen?: boolean): number;
  32599. /**
  32600. * Gets the current render height
  32601. * @param useScreen defines if screen size must be used (or the current render target if any)
  32602. * @returns a number defining the current render height
  32603. */
  32604. getRenderHeight(useScreen?: boolean): number;
  32605. /**
  32606. * Can be used to override the current requestAnimationFrame requester.
  32607. * @hidden
  32608. */
  32609. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32610. /**
  32611. * Register and execute a render loop. The engine can have more than one render function
  32612. * @param renderFunction defines the function to continuously execute
  32613. */
  32614. runRenderLoop(renderFunction: () => void): void;
  32615. /**
  32616. * Clear the current render buffer or the current render target (if any is set up)
  32617. * @param color defines the color to use
  32618. * @param backBuffer defines if the back buffer must be cleared
  32619. * @param depth defines if the depth buffer must be cleared
  32620. * @param stencil defines if the stencil buffer must be cleared
  32621. */
  32622. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32623. private _viewportCached;
  32624. /** @hidden */
  32625. _viewport(x: number, y: number, width: number, height: number): void;
  32626. /**
  32627. * Set the WebGL's viewport
  32628. * @param viewport defines the viewport element to be used
  32629. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32630. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32631. */
  32632. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32633. /**
  32634. * Begin a new frame
  32635. */
  32636. beginFrame(): void;
  32637. /**
  32638. * Enf the current frame
  32639. */
  32640. endFrame(): void;
  32641. /**
  32642. * Resize the view according to the canvas' size
  32643. */
  32644. resize(): void;
  32645. /**
  32646. * Force a specific size of the canvas
  32647. * @param width defines the new canvas' width
  32648. * @param height defines the new canvas' height
  32649. */
  32650. setSize(width: number, height: number): void;
  32651. /**
  32652. * Binds the frame buffer to the specified texture.
  32653. * @param texture The texture to render to or null for the default canvas
  32654. * @param faceIndex The face of the texture to render to in case of cube texture
  32655. * @param requiredWidth The width of the target to render to
  32656. * @param requiredHeight The height of the target to render to
  32657. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32658. * @param lodLevel defines the lod level to bind to the frame buffer
  32659. * @param layer defines the 2d array index to bind to frame buffer to
  32660. */
  32661. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32662. /** @hidden */
  32663. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32664. /**
  32665. * Unbind the current render target texture from the webGL context
  32666. * @param texture defines the render target texture to unbind
  32667. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32668. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32669. */
  32670. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32671. /**
  32672. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32673. */
  32674. flushFramebuffer(): void;
  32675. /**
  32676. * Unbind the current render target and bind the default framebuffer
  32677. */
  32678. restoreDefaultFramebuffer(): void;
  32679. /** @hidden */
  32680. protected _resetVertexBufferBinding(): void;
  32681. /**
  32682. * Creates a vertex buffer
  32683. * @param data the data for the vertex buffer
  32684. * @returns the new WebGL static buffer
  32685. */
  32686. createVertexBuffer(data: DataArray): DataBuffer;
  32687. private _createVertexBuffer;
  32688. /**
  32689. * Creates a dynamic vertex buffer
  32690. * @param data the data for the dynamic vertex buffer
  32691. * @returns the new WebGL dynamic buffer
  32692. */
  32693. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32694. protected _resetIndexBufferBinding(): void;
  32695. /**
  32696. * Creates a new index buffer
  32697. * @param indices defines the content of the index buffer
  32698. * @param updatable defines if the index buffer must be updatable
  32699. * @returns a new webGL buffer
  32700. */
  32701. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32702. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32703. /**
  32704. * Bind a webGL buffer to the webGL context
  32705. * @param buffer defines the buffer to bind
  32706. */
  32707. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32708. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32709. private bindBuffer;
  32710. /**
  32711. * update the bound buffer with the given data
  32712. * @param data defines the data to update
  32713. */
  32714. updateArrayBuffer(data: Float32Array): void;
  32715. private _vertexAttribPointer;
  32716. /** @hidden */
  32717. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32718. private _bindVertexBuffersAttributes;
  32719. /**
  32720. * Records a vertex array object
  32721. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32722. * @param vertexBuffers defines the list of vertex buffers to store
  32723. * @param indexBuffer defines the index buffer to store
  32724. * @param effect defines the effect to store
  32725. * @returns the new vertex array object
  32726. */
  32727. recordVertexArrayObject(vertexBuffers: {
  32728. [key: string]: VertexBuffer;
  32729. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32730. /**
  32731. * Bind a specific vertex array object
  32732. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32733. * @param vertexArrayObject defines the vertex array object to bind
  32734. * @param indexBuffer defines the index buffer to bind
  32735. */
  32736. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32737. /**
  32738. * Bind webGl buffers directly to the webGL context
  32739. * @param vertexBuffer defines the vertex buffer to bind
  32740. * @param indexBuffer defines the index buffer to bind
  32741. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32742. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32743. * @param effect defines the effect associated with the vertex buffer
  32744. */
  32745. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32746. private _unbindVertexArrayObject;
  32747. /**
  32748. * Bind a list of vertex buffers to the webGL context
  32749. * @param vertexBuffers defines the list of vertex buffers to bind
  32750. * @param indexBuffer defines the index buffer to bind
  32751. * @param effect defines the effect associated with the vertex buffers
  32752. */
  32753. bindBuffers(vertexBuffers: {
  32754. [key: string]: Nullable<VertexBuffer>;
  32755. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32756. /**
  32757. * Unbind all instance attributes
  32758. */
  32759. unbindInstanceAttributes(): void;
  32760. /**
  32761. * Release and free the memory of a vertex array object
  32762. * @param vao defines the vertex array object to delete
  32763. */
  32764. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32765. /** @hidden */
  32766. _releaseBuffer(buffer: DataBuffer): boolean;
  32767. protected _deleteBuffer(buffer: DataBuffer): void;
  32768. /**
  32769. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32770. * @param instancesBuffer defines the webGL buffer to update and bind
  32771. * @param data defines the data to store in the buffer
  32772. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32773. */
  32774. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32775. /**
  32776. * Bind the content of a webGL buffer used with instantiation
  32777. * @param instancesBuffer defines the webGL buffer to bind
  32778. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32779. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32780. */
  32781. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32782. /**
  32783. * Disable the instance attribute corresponding to the name in parameter
  32784. * @param name defines the name of the attribute to disable
  32785. */
  32786. disableInstanceAttributeByName(name: string): void;
  32787. /**
  32788. * Disable the instance attribute corresponding to the location in parameter
  32789. * @param attributeLocation defines the attribute location of the attribute to disable
  32790. */
  32791. disableInstanceAttribute(attributeLocation: number): void;
  32792. /**
  32793. * Disable the attribute corresponding to the location in parameter
  32794. * @param attributeLocation defines the attribute location of the attribute to disable
  32795. */
  32796. disableAttributeByIndex(attributeLocation: number): void;
  32797. /**
  32798. * Send a draw order
  32799. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32800. * @param indexStart defines the starting index
  32801. * @param indexCount defines the number of index to draw
  32802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32803. */
  32804. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32805. /**
  32806. * Draw a list of points
  32807. * @param verticesStart defines the index of first vertex to draw
  32808. * @param verticesCount defines the count of vertices to draw
  32809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32810. */
  32811. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32812. /**
  32813. * Draw a list of unindexed primitives
  32814. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  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. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32820. /**
  32821. * Draw a list of indexed primitives
  32822. * @param fillMode defines the primitive to use
  32823. * @param indexStart defines the starting index
  32824. * @param indexCount defines the number of index to draw
  32825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32826. */
  32827. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32828. /**
  32829. * Draw a list of unindexed primitives
  32830. * @param fillMode defines the primitive to use
  32831. * @param verticesStart defines the index of first vertex to draw
  32832. * @param verticesCount defines the count of vertices to draw
  32833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32834. */
  32835. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32836. private _drawMode;
  32837. /** @hidden */
  32838. protected _reportDrawCall(): void;
  32839. /** @hidden */
  32840. _releaseEffect(effect: Effect): void;
  32841. /** @hidden */
  32842. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32843. /**
  32844. * Create a new effect (used to store vertex/fragment shaders)
  32845. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32846. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32847. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32848. * @param samplers defines an array of string used to represent textures
  32849. * @param defines defines the string containing the defines to use to compile the shaders
  32850. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32851. * @param onCompiled defines a function to call when the effect creation is successful
  32852. * @param onError defines a function to call when the effect creation has failed
  32853. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32854. * @returns the new Effect
  32855. */
  32856. 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;
  32857. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32858. private _compileShader;
  32859. private _compileRawShader;
  32860. /** @hidden */
  32861. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32862. /**
  32863. * Directly creates a webGL program
  32864. * @param pipelineContext defines the pipeline context to attach to
  32865. * @param vertexCode defines the vertex shader code to use
  32866. * @param fragmentCode defines the fragment shader code to use
  32867. * @param context defines the webGL context to use (if not set, the current one will be used)
  32868. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32869. * @returns the new webGL program
  32870. */
  32871. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32872. /**
  32873. * Creates a webGL program
  32874. * @param pipelineContext defines the pipeline context to attach to
  32875. * @param vertexCode defines the vertex shader code to use
  32876. * @param fragmentCode defines the fragment shader code to use
  32877. * @param defines defines the string containing the defines to use to compile the shaders
  32878. * @param context defines the webGL context to use (if not set, the current one will be used)
  32879. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32880. * @returns the new webGL program
  32881. */
  32882. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32883. /**
  32884. * Creates a new pipeline context
  32885. * @returns the new pipeline
  32886. */
  32887. createPipelineContext(): IPipelineContext;
  32888. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32889. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32890. /** @hidden */
  32891. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32892. /** @hidden */
  32893. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32894. /** @hidden */
  32895. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32896. /**
  32897. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32898. * @param pipelineContext defines the pipeline context to use
  32899. * @param uniformsNames defines the list of uniform names
  32900. * @returns an array of webGL uniform locations
  32901. */
  32902. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32903. /**
  32904. * Gets the lsit of active attributes for a given webGL program
  32905. * @param pipelineContext defines the pipeline context to use
  32906. * @param attributesNames defines the list of attribute names to get
  32907. * @returns an array of indices indicating the offset of each attribute
  32908. */
  32909. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32910. /**
  32911. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32912. * @param effect defines the effect to activate
  32913. */
  32914. enableEffect(effect: Nullable<Effect>): void;
  32915. /**
  32916. * Set the value of an uniform to a number (int)
  32917. * @param uniform defines the webGL uniform location where to store the value
  32918. * @param value defines the int number to store
  32919. */
  32920. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32921. /**
  32922. * Set the value of an uniform to an array of int32
  32923. * @param uniform defines the webGL uniform location where to store the value
  32924. * @param array defines the array of int32 to store
  32925. */
  32926. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32927. /**
  32928. * Set the value of an uniform to an array of int32 (stored as vec2)
  32929. * @param uniform defines the webGL uniform location where to store the value
  32930. * @param array defines the array of int32 to store
  32931. */
  32932. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32933. /**
  32934. * Set the value of an uniform to an array of int32 (stored as vec3)
  32935. * @param uniform defines the webGL uniform location where to store the value
  32936. * @param array defines the array of int32 to store
  32937. */
  32938. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32939. /**
  32940. * Set the value of an uniform to an array of int32 (stored as vec4)
  32941. * @param uniform defines the webGL uniform location where to store the value
  32942. * @param array defines the array of int32 to store
  32943. */
  32944. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32945. /**
  32946. * Set the value of an uniform to an array of number
  32947. * @param uniform defines the webGL uniform location where to store the value
  32948. * @param array defines the array of number to store
  32949. */
  32950. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32951. /**
  32952. * Set the value of an uniform to an array of number (stored as vec2)
  32953. * @param uniform defines the webGL uniform location where to store the value
  32954. * @param array defines the array of number to store
  32955. */
  32956. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32957. /**
  32958. * Set the value of an uniform to an array of number (stored as vec3)
  32959. * @param uniform defines the webGL uniform location where to store the value
  32960. * @param array defines the array of number to store
  32961. */
  32962. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32963. /**
  32964. * Set the value of an uniform to an array of number (stored as vec4)
  32965. * @param uniform defines the webGL uniform location where to store the value
  32966. * @param array defines the array of number to store
  32967. */
  32968. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32969. /**
  32970. * Set the value of an uniform to an array of float32 (stored as matrices)
  32971. * @param uniform defines the webGL uniform location where to store the value
  32972. * @param matrices defines the array of float32 to store
  32973. */
  32974. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32975. /**
  32976. * Set the value of an uniform to a matrix (3x3)
  32977. * @param uniform defines the webGL uniform location where to store the value
  32978. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32979. */
  32980. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32981. /**
  32982. * Set the value of an uniform to a matrix (2x2)
  32983. * @param uniform defines the webGL uniform location where to store the value
  32984. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32985. */
  32986. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32987. /**
  32988. * Set the value of an uniform to a number (float)
  32989. * @param uniform defines the webGL uniform location where to store the value
  32990. * @param value defines the float number to store
  32991. */
  32992. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32993. /**
  32994. * Set the value of an uniform to a vec2
  32995. * @param uniform defines the webGL uniform location where to store the value
  32996. * @param x defines the 1st component of the value
  32997. * @param y defines the 2nd component of the value
  32998. */
  32999. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33000. /**
  33001. * Set the value of an uniform to a vec3
  33002. * @param uniform defines the webGL uniform location where to store the value
  33003. * @param x defines the 1st component of the value
  33004. * @param y defines the 2nd component of the value
  33005. * @param z defines the 3rd component of the value
  33006. */
  33007. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33008. /**
  33009. * Set the value of an uniform to a vec4
  33010. * @param uniform defines the webGL uniform location where to store the value
  33011. * @param x defines the 1st component of the value
  33012. * @param y defines the 2nd component of the value
  33013. * @param z defines the 3rd component of the value
  33014. * @param w defines the 4th component of the value
  33015. */
  33016. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33017. /**
  33018. * Apply all cached states (depth, culling, stencil and alpha)
  33019. */
  33020. applyStates(): void;
  33021. /**
  33022. * Enable or disable color writing
  33023. * @param enable defines the state to set
  33024. */
  33025. setColorWrite(enable: boolean): void;
  33026. /**
  33027. * Gets a boolean indicating if color writing is enabled
  33028. * @returns the current color writing state
  33029. */
  33030. getColorWrite(): boolean;
  33031. /**
  33032. * Gets the depth culling state manager
  33033. */
  33034. get depthCullingState(): DepthCullingState;
  33035. /**
  33036. * Gets the alpha state manager
  33037. */
  33038. get alphaState(): AlphaState;
  33039. /**
  33040. * Gets the stencil state manager
  33041. */
  33042. get stencilState(): StencilState;
  33043. /**
  33044. * Clears the list of texture accessible through engine.
  33045. * This can help preventing texture load conflict due to name collision.
  33046. */
  33047. clearInternalTexturesCache(): void;
  33048. /**
  33049. * Force the entire cache to be cleared
  33050. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33051. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33052. */
  33053. wipeCaches(bruteForce?: boolean): void;
  33054. /** @hidden */
  33055. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33056. min: number;
  33057. mag: number;
  33058. };
  33059. /** @hidden */
  33060. _createTexture(): WebGLTexture;
  33061. /**
  33062. * Usually called from Texture.ts.
  33063. * Passed information to create a WebGLTexture
  33064. * @param url defines a value which contains one of the following:
  33065. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33066. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33067. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33069. * @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)
  33070. * @param scene needed for loading to the correct scene
  33071. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33072. * @param onLoad optional callback to be called upon successful completion
  33073. * @param onError optional callback to be called upon failure
  33074. * @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
  33075. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33076. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33077. * @param forcedExtension defines the extension to use to pick the right loader
  33078. * @param mimeType defines an optional mime type
  33079. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33080. */
  33081. 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;
  33082. /**
  33083. * Loads an image as an HTMLImageElement.
  33084. * @param input url string, ArrayBuffer, or Blob to load
  33085. * @param onLoad callback called when the image successfully loads
  33086. * @param onError callback called when the image fails to load
  33087. * @param offlineProvider offline provider for caching
  33088. * @param mimeType optional mime type
  33089. * @returns the HTMLImageElement of the loaded image
  33090. * @hidden
  33091. */
  33092. 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>;
  33093. /**
  33094. * @hidden
  33095. */
  33096. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33097. /**
  33098. * Creates a raw texture
  33099. * @param data defines the data to store in the texture
  33100. * @param width defines the width of the texture
  33101. * @param height defines the height of the texture
  33102. * @param format defines the format of the data
  33103. * @param generateMipMaps defines if the engine should generate the mip levels
  33104. * @param invertY defines if data must be stored with Y axis inverted
  33105. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33106. * @param compression defines the compression used (null by default)
  33107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33108. * @returns the raw texture inside an InternalTexture
  33109. */
  33110. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33111. /**
  33112. * Creates a new raw cube texture
  33113. * @param data defines the array of data to use to create each face
  33114. * @param size defines the size of the textures
  33115. * @param format defines the format of the data
  33116. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33117. * @param generateMipMaps defines if the engine should generate the mip levels
  33118. * @param invertY defines if data must be stored with Y axis inverted
  33119. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33120. * @param compression defines the compression used (null by default)
  33121. * @returns the cube texture as an InternalTexture
  33122. */
  33123. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33124. /**
  33125. * Creates a new raw 3D texture
  33126. * @param data defines the data used to create the texture
  33127. * @param width defines the width of the texture
  33128. * @param height defines the height of the texture
  33129. * @param depth defines the depth of the texture
  33130. * @param format defines the format of the texture
  33131. * @param generateMipMaps defines if the engine must generate mip levels
  33132. * @param invertY defines if data must be stored with Y axis inverted
  33133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33134. * @param compression defines the compressed used (can be null)
  33135. * @param textureType defines the compressed used (can be null)
  33136. * @returns a new raw 3D texture (stored in an InternalTexture)
  33137. */
  33138. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33139. /**
  33140. * Creates a new raw 2D array texture
  33141. * @param data defines the data used to create the texture
  33142. * @param width defines the width of the texture
  33143. * @param height defines the height of the texture
  33144. * @param depth defines the number of layers of the texture
  33145. * @param format defines the format of the texture
  33146. * @param generateMipMaps defines if the engine must generate mip levels
  33147. * @param invertY defines if data must be stored with Y axis inverted
  33148. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33149. * @param compression defines the compressed used (can be null)
  33150. * @param textureType defines the compressed used (can be null)
  33151. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33152. */
  33153. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33154. private _unpackFlipYCached;
  33155. /**
  33156. * In case you are sharing the context with other applications, it might
  33157. * be interested to not cache the unpack flip y state to ensure a consistent
  33158. * value would be set.
  33159. */
  33160. enableUnpackFlipYCached: boolean;
  33161. /** @hidden */
  33162. _unpackFlipY(value: boolean): void;
  33163. /** @hidden */
  33164. _getUnpackAlignement(): number;
  33165. private _getTextureTarget;
  33166. /**
  33167. * Update the sampling mode of a given texture
  33168. * @param samplingMode defines the required sampling mode
  33169. * @param texture defines the texture to update
  33170. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33171. */
  33172. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33173. /**
  33174. * Update the sampling mode of a given texture
  33175. * @param texture defines the texture to update
  33176. * @param wrapU defines the texture wrap mode of the u coordinates
  33177. * @param wrapV defines the texture wrap mode of the v coordinates
  33178. * @param wrapR defines the texture wrap mode of the r coordinates
  33179. */
  33180. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33181. /** @hidden */
  33182. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33183. width: number;
  33184. height: number;
  33185. layers?: number;
  33186. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33187. /** @hidden */
  33188. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33189. /** @hidden */
  33190. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33191. /**
  33192. * Update a portion of an internal texture
  33193. * @param texture defines the texture to update
  33194. * @param imageData defines the data to store into the texture
  33195. * @param xOffset defines the x coordinates of the update rectangle
  33196. * @param yOffset defines the y coordinates of the update rectangle
  33197. * @param width defines the width of the update rectangle
  33198. * @param height defines the height of the update rectangle
  33199. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33200. * @param lod defines the lod level to update (0 by default)
  33201. */
  33202. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33203. /** @hidden */
  33204. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33205. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33206. private _prepareWebGLTexture;
  33207. /** @hidden */
  33208. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33209. private _getDepthStencilBuffer;
  33210. /** @hidden */
  33211. _releaseFramebufferObjects(texture: InternalTexture): void;
  33212. /** @hidden */
  33213. _releaseTexture(texture: InternalTexture): void;
  33214. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33215. protected _setProgram(program: WebGLProgram): void;
  33216. protected _boundUniforms: {
  33217. [key: number]: WebGLUniformLocation;
  33218. };
  33219. /**
  33220. * Binds an effect to the webGL context
  33221. * @param effect defines the effect to bind
  33222. */
  33223. bindSamplers(effect: Effect): void;
  33224. private _activateCurrentTexture;
  33225. /** @hidden */
  33226. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33227. /** @hidden */
  33228. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33229. /**
  33230. * Unbind all textures from the webGL context
  33231. */
  33232. unbindAllTextures(): void;
  33233. /**
  33234. * Sets a texture to the according uniform.
  33235. * @param channel The texture channel
  33236. * @param uniform The uniform to set
  33237. * @param texture The texture to apply
  33238. */
  33239. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33240. private _bindSamplerUniformToChannel;
  33241. private _getTextureWrapMode;
  33242. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33243. /**
  33244. * Sets an array of texture to the webGL context
  33245. * @param channel defines the channel where the texture array must be set
  33246. * @param uniform defines the associated uniform location
  33247. * @param textures defines the array of textures to bind
  33248. */
  33249. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33250. /** @hidden */
  33251. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33252. private _setTextureParameterFloat;
  33253. private _setTextureParameterInteger;
  33254. /**
  33255. * Unbind all vertex attributes from the webGL context
  33256. */
  33257. unbindAllAttributes(): void;
  33258. /**
  33259. * 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
  33260. */
  33261. releaseEffects(): void;
  33262. /**
  33263. * Dispose and release all associated resources
  33264. */
  33265. dispose(): void;
  33266. /**
  33267. * Attach a new callback raised when context lost event is fired
  33268. * @param callback defines the callback to call
  33269. */
  33270. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33271. /**
  33272. * Attach a new callback raised when context restored event is fired
  33273. * @param callback defines the callback to call
  33274. */
  33275. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33276. /**
  33277. * Get the current error code of the webGL context
  33278. * @returns the error code
  33279. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33280. */
  33281. getError(): number;
  33282. private _canRenderToFloatFramebuffer;
  33283. private _canRenderToHalfFloatFramebuffer;
  33284. private _canRenderToFramebuffer;
  33285. /** @hidden */
  33286. _getWebGLTextureType(type: number): number;
  33287. /** @hidden */
  33288. _getInternalFormat(format: number): number;
  33289. /** @hidden */
  33290. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33291. /** @hidden */
  33292. _getRGBAMultiSampleBufferFormat(type: number): number;
  33293. /** @hidden */
  33294. _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;
  33295. /**
  33296. * Loads a file from a url
  33297. * @param url url to load
  33298. * @param onSuccess callback called when the file successfully loads
  33299. * @param onProgress callback called while file is loading (if the server supports this mode)
  33300. * @param offlineProvider defines the offline provider for caching
  33301. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33302. * @param onError callback called when the file fails to load
  33303. * @returns a file request object
  33304. * @hidden
  33305. */
  33306. 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;
  33307. /**
  33308. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33309. * @param x defines the x coordinate of the rectangle where pixels must be read
  33310. * @param y defines the y coordinate of the rectangle where pixels must be read
  33311. * @param width defines the width of the rectangle where pixels must be read
  33312. * @param height defines the height of the rectangle where pixels must be read
  33313. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33314. * @returns a Uint8Array containing RGBA colors
  33315. */
  33316. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33317. private static _isSupported;
  33318. /**
  33319. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33320. * @returns true if the engine can be created
  33321. * @ignorenaming
  33322. */
  33323. static isSupported(): boolean;
  33324. /**
  33325. * Find the next highest power of two.
  33326. * @param x Number to start search from.
  33327. * @return Next highest power of two.
  33328. */
  33329. static CeilingPOT(x: number): number;
  33330. /**
  33331. * Find the next lowest power of two.
  33332. * @param x Number to start search from.
  33333. * @return Next lowest power of two.
  33334. */
  33335. static FloorPOT(x: number): number;
  33336. /**
  33337. * Find the nearest power of two.
  33338. * @param x Number to start search from.
  33339. * @return Next nearest power of two.
  33340. */
  33341. static NearestPOT(x: number): number;
  33342. /**
  33343. * Get the closest exponent of two
  33344. * @param value defines the value to approximate
  33345. * @param max defines the maximum value to return
  33346. * @param mode defines how to define the closest value
  33347. * @returns closest exponent of two of the given value
  33348. */
  33349. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33350. /**
  33351. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33352. * @param func - the function to be called
  33353. * @param requester - the object that will request the next frame. Falls back to window.
  33354. * @returns frame number
  33355. */
  33356. static QueueNewFrame(func: () => void, requester?: any): number;
  33357. /**
  33358. * Gets host document
  33359. * @returns the host document object
  33360. */
  33361. getHostDocument(): Nullable<Document>;
  33362. }
  33363. }
  33364. declare module "babylonjs/Maths/sphericalPolynomial" {
  33365. import { Vector3 } from "babylonjs/Maths/math.vector";
  33366. import { Color3 } from "babylonjs/Maths/math.color";
  33367. /**
  33368. * Class representing spherical harmonics coefficients to the 3rd degree
  33369. */
  33370. export class SphericalHarmonics {
  33371. /**
  33372. * Defines whether or not the harmonics have been prescaled for rendering.
  33373. */
  33374. preScaled: boolean;
  33375. /**
  33376. * The l0,0 coefficients of the spherical harmonics
  33377. */
  33378. l00: Vector3;
  33379. /**
  33380. * The l1,-1 coefficients of the spherical harmonics
  33381. */
  33382. l1_1: Vector3;
  33383. /**
  33384. * The l1,0 coefficients of the spherical harmonics
  33385. */
  33386. l10: Vector3;
  33387. /**
  33388. * The l1,1 coefficients of the spherical harmonics
  33389. */
  33390. l11: Vector3;
  33391. /**
  33392. * The l2,-2 coefficients of the spherical harmonics
  33393. */
  33394. l2_2: Vector3;
  33395. /**
  33396. * The l2,-1 coefficients of the spherical harmonics
  33397. */
  33398. l2_1: Vector3;
  33399. /**
  33400. * The l2,0 coefficients of the spherical harmonics
  33401. */
  33402. l20: Vector3;
  33403. /**
  33404. * The l2,1 coefficients of the spherical harmonics
  33405. */
  33406. l21: Vector3;
  33407. /**
  33408. * The l2,2 coefficients of the spherical harmonics
  33409. */
  33410. l22: Vector3;
  33411. /**
  33412. * Adds a light to the spherical harmonics
  33413. * @param direction the direction of the light
  33414. * @param color the color of the light
  33415. * @param deltaSolidAngle the delta solid angle of the light
  33416. */
  33417. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33418. /**
  33419. * Scales the spherical harmonics by the given amount
  33420. * @param scale the amount to scale
  33421. */
  33422. scaleInPlace(scale: number): void;
  33423. /**
  33424. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33425. *
  33426. * ```
  33427. * E_lm = A_l * L_lm
  33428. * ```
  33429. *
  33430. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33431. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33432. * the scaling factors are given in equation 9.
  33433. */
  33434. convertIncidentRadianceToIrradiance(): void;
  33435. /**
  33436. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33437. *
  33438. * ```
  33439. * L = (1/pi) * E * rho
  33440. * ```
  33441. *
  33442. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33443. */
  33444. convertIrradianceToLambertianRadiance(): void;
  33445. /**
  33446. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33447. * required operations at run time.
  33448. *
  33449. * This is simply done by scaling back the SH with Ylm constants parameter.
  33450. * The trigonometric part being applied by the shader at run time.
  33451. */
  33452. preScaleForRendering(): void;
  33453. /**
  33454. * Constructs a spherical harmonics from an array.
  33455. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33456. * @returns the spherical harmonics
  33457. */
  33458. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33459. /**
  33460. * Gets the spherical harmonics from polynomial
  33461. * @param polynomial the spherical polynomial
  33462. * @returns the spherical harmonics
  33463. */
  33464. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33465. }
  33466. /**
  33467. * Class representing spherical polynomial coefficients to the 3rd degree
  33468. */
  33469. export class SphericalPolynomial {
  33470. private _harmonics;
  33471. /**
  33472. * The spherical harmonics used to create the polynomials.
  33473. */
  33474. get preScaledHarmonics(): SphericalHarmonics;
  33475. /**
  33476. * The x coefficients of the spherical polynomial
  33477. */
  33478. x: Vector3;
  33479. /**
  33480. * The y coefficients of the spherical polynomial
  33481. */
  33482. y: Vector3;
  33483. /**
  33484. * The z coefficients of the spherical polynomial
  33485. */
  33486. z: Vector3;
  33487. /**
  33488. * The xx coefficients of the spherical polynomial
  33489. */
  33490. xx: Vector3;
  33491. /**
  33492. * The yy coefficients of the spherical polynomial
  33493. */
  33494. yy: Vector3;
  33495. /**
  33496. * The zz coefficients of the spherical polynomial
  33497. */
  33498. zz: Vector3;
  33499. /**
  33500. * The xy coefficients of the spherical polynomial
  33501. */
  33502. xy: Vector3;
  33503. /**
  33504. * The yz coefficients of the spherical polynomial
  33505. */
  33506. yz: Vector3;
  33507. /**
  33508. * The zx coefficients of the spherical polynomial
  33509. */
  33510. zx: Vector3;
  33511. /**
  33512. * Adds an ambient color to the spherical polynomial
  33513. * @param color the color to add
  33514. */
  33515. addAmbient(color: Color3): void;
  33516. /**
  33517. * Scales the spherical polynomial by the given amount
  33518. * @param scale the amount to scale
  33519. */
  33520. scaleInPlace(scale: number): void;
  33521. /**
  33522. * Gets the spherical polynomial from harmonics
  33523. * @param harmonics the spherical harmonics
  33524. * @returns the spherical polynomial
  33525. */
  33526. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33527. /**
  33528. * Constructs a spherical polynomial from an array.
  33529. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33530. * @returns the spherical polynomial
  33531. */
  33532. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33533. }
  33534. }
  33535. declare module "babylonjs/Materials/Textures/internalTexture" {
  33536. import { Observable } from "babylonjs/Misc/observable";
  33537. import { Nullable, int } from "babylonjs/types";
  33538. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33539. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33540. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33541. /**
  33542. * Defines the source of the internal texture
  33543. */
  33544. export enum InternalTextureSource {
  33545. /**
  33546. * The source of the texture data is unknown
  33547. */
  33548. Unknown = 0,
  33549. /**
  33550. * Texture data comes from an URL
  33551. */
  33552. Url = 1,
  33553. /**
  33554. * Texture data is only used for temporary storage
  33555. */
  33556. Temp = 2,
  33557. /**
  33558. * Texture data comes from raw data (ArrayBuffer)
  33559. */
  33560. Raw = 3,
  33561. /**
  33562. * Texture content is dynamic (video or dynamic texture)
  33563. */
  33564. Dynamic = 4,
  33565. /**
  33566. * Texture content is generated by rendering to it
  33567. */
  33568. RenderTarget = 5,
  33569. /**
  33570. * Texture content is part of a multi render target process
  33571. */
  33572. MultiRenderTarget = 6,
  33573. /**
  33574. * Texture data comes from a cube data file
  33575. */
  33576. Cube = 7,
  33577. /**
  33578. * Texture data comes from a raw cube data
  33579. */
  33580. CubeRaw = 8,
  33581. /**
  33582. * Texture data come from a prefiltered cube data file
  33583. */
  33584. CubePrefiltered = 9,
  33585. /**
  33586. * Texture content is raw 3D data
  33587. */
  33588. Raw3D = 10,
  33589. /**
  33590. * Texture content is raw 2D array data
  33591. */
  33592. Raw2DArray = 11,
  33593. /**
  33594. * Texture content is a depth texture
  33595. */
  33596. Depth = 12,
  33597. /**
  33598. * Texture data comes from a raw cube data encoded with RGBD
  33599. */
  33600. CubeRawRGBD = 13
  33601. }
  33602. /**
  33603. * Class used to store data associated with WebGL texture data for the engine
  33604. * This class should not be used directly
  33605. */
  33606. export class InternalTexture {
  33607. /** @hidden */
  33608. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33609. /**
  33610. * Defines if the texture is ready
  33611. */
  33612. isReady: boolean;
  33613. /**
  33614. * Defines if the texture is a cube texture
  33615. */
  33616. isCube: boolean;
  33617. /**
  33618. * Defines if the texture contains 3D data
  33619. */
  33620. is3D: boolean;
  33621. /**
  33622. * Defines if the texture contains 2D array data
  33623. */
  33624. is2DArray: boolean;
  33625. /**
  33626. * Defines if the texture contains multiview data
  33627. */
  33628. isMultiview: boolean;
  33629. /**
  33630. * Gets the URL used to load this texture
  33631. */
  33632. url: string;
  33633. /**
  33634. * Gets the sampling mode of the texture
  33635. */
  33636. samplingMode: number;
  33637. /**
  33638. * Gets a boolean indicating if the texture needs mipmaps generation
  33639. */
  33640. generateMipMaps: boolean;
  33641. /**
  33642. * Gets the number of samples used by the texture (WebGL2+ only)
  33643. */
  33644. samples: number;
  33645. /**
  33646. * Gets the type of the texture (int, float...)
  33647. */
  33648. type: number;
  33649. /**
  33650. * Gets the format of the texture (RGB, RGBA...)
  33651. */
  33652. format: number;
  33653. /**
  33654. * Observable called when the texture is loaded
  33655. */
  33656. onLoadedObservable: Observable<InternalTexture>;
  33657. /**
  33658. * Gets the width of the texture
  33659. */
  33660. width: number;
  33661. /**
  33662. * Gets the height of the texture
  33663. */
  33664. height: number;
  33665. /**
  33666. * Gets the depth of the texture
  33667. */
  33668. depth: number;
  33669. /**
  33670. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33671. */
  33672. baseWidth: number;
  33673. /**
  33674. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33675. */
  33676. baseHeight: number;
  33677. /**
  33678. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33679. */
  33680. baseDepth: number;
  33681. /**
  33682. * Gets a boolean indicating if the texture is inverted on Y axis
  33683. */
  33684. invertY: boolean;
  33685. /** @hidden */
  33686. _invertVScale: boolean;
  33687. /** @hidden */
  33688. _associatedChannel: number;
  33689. /** @hidden */
  33690. _source: InternalTextureSource;
  33691. /** @hidden */
  33692. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33693. /** @hidden */
  33694. _bufferView: Nullable<ArrayBufferView>;
  33695. /** @hidden */
  33696. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33697. /** @hidden */
  33698. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33699. /** @hidden */
  33700. _size: number;
  33701. /** @hidden */
  33702. _extension: string;
  33703. /** @hidden */
  33704. _files: Nullable<string[]>;
  33705. /** @hidden */
  33706. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33707. /** @hidden */
  33708. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33709. /** @hidden */
  33710. _framebuffer: Nullable<WebGLFramebuffer>;
  33711. /** @hidden */
  33712. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33713. /** @hidden */
  33714. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33715. /** @hidden */
  33716. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33717. /** @hidden */
  33718. _attachments: Nullable<number[]>;
  33719. /** @hidden */
  33720. _cachedCoordinatesMode: Nullable<number>;
  33721. /** @hidden */
  33722. _cachedWrapU: Nullable<number>;
  33723. /** @hidden */
  33724. _cachedWrapV: Nullable<number>;
  33725. /** @hidden */
  33726. _cachedWrapR: Nullable<number>;
  33727. /** @hidden */
  33728. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33729. /** @hidden */
  33730. _isDisabled: boolean;
  33731. /** @hidden */
  33732. _compression: Nullable<string>;
  33733. /** @hidden */
  33734. _generateStencilBuffer: boolean;
  33735. /** @hidden */
  33736. _generateDepthBuffer: boolean;
  33737. /** @hidden */
  33738. _comparisonFunction: number;
  33739. /** @hidden */
  33740. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33741. /** @hidden */
  33742. _lodGenerationScale: number;
  33743. /** @hidden */
  33744. _lodGenerationOffset: number;
  33745. /** @hidden */
  33746. _depthStencilTexture: Nullable<InternalTexture>;
  33747. /** @hidden */
  33748. _colorTextureArray: Nullable<WebGLTexture>;
  33749. /** @hidden */
  33750. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33751. /** @hidden */
  33752. _lodTextureHigh: Nullable<BaseTexture>;
  33753. /** @hidden */
  33754. _lodTextureMid: Nullable<BaseTexture>;
  33755. /** @hidden */
  33756. _lodTextureLow: Nullable<BaseTexture>;
  33757. /** @hidden */
  33758. _isRGBD: boolean;
  33759. /** @hidden */
  33760. _linearSpecularLOD: boolean;
  33761. /** @hidden */
  33762. _irradianceTexture: Nullable<BaseTexture>;
  33763. /** @hidden */
  33764. _webGLTexture: Nullable<WebGLTexture>;
  33765. /** @hidden */
  33766. _references: number;
  33767. private _engine;
  33768. /**
  33769. * Gets the Engine the texture belongs to.
  33770. * @returns The babylon engine
  33771. */
  33772. getEngine(): ThinEngine;
  33773. /**
  33774. * Gets the data source type of the texture
  33775. */
  33776. get source(): InternalTextureSource;
  33777. /**
  33778. * Creates a new InternalTexture
  33779. * @param engine defines the engine to use
  33780. * @param source defines the type of data that will be used
  33781. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33782. */
  33783. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33784. /**
  33785. * Increments the number of references (ie. the number of Texture that point to it)
  33786. */
  33787. incrementReferences(): void;
  33788. /**
  33789. * Change the size of the texture (not the size of the content)
  33790. * @param width defines the new width
  33791. * @param height defines the new height
  33792. * @param depth defines the new depth (1 by default)
  33793. */
  33794. updateSize(width: int, height: int, depth?: int): void;
  33795. /** @hidden */
  33796. _rebuild(): void;
  33797. /** @hidden */
  33798. _swapAndDie(target: InternalTexture): void;
  33799. /**
  33800. * Dispose the current allocated resources
  33801. */
  33802. dispose(): void;
  33803. }
  33804. }
  33805. declare module "babylonjs/Audio/analyser" {
  33806. import { Scene } from "babylonjs/scene";
  33807. /**
  33808. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33810. */
  33811. export class Analyser {
  33812. /**
  33813. * Gets or sets the smoothing
  33814. * @ignorenaming
  33815. */
  33816. SMOOTHING: number;
  33817. /**
  33818. * Gets or sets the FFT table size
  33819. * @ignorenaming
  33820. */
  33821. FFT_SIZE: number;
  33822. /**
  33823. * Gets or sets the bar graph amplitude
  33824. * @ignorenaming
  33825. */
  33826. BARGRAPHAMPLITUDE: number;
  33827. /**
  33828. * Gets or sets the position of the debug canvas
  33829. * @ignorenaming
  33830. */
  33831. DEBUGCANVASPOS: {
  33832. x: number;
  33833. y: number;
  33834. };
  33835. /**
  33836. * Gets or sets the debug canvas size
  33837. * @ignorenaming
  33838. */
  33839. DEBUGCANVASSIZE: {
  33840. width: number;
  33841. height: number;
  33842. };
  33843. private _byteFreqs;
  33844. private _byteTime;
  33845. private _floatFreqs;
  33846. private _webAudioAnalyser;
  33847. private _debugCanvas;
  33848. private _debugCanvasContext;
  33849. private _scene;
  33850. private _registerFunc;
  33851. private _audioEngine;
  33852. /**
  33853. * Creates a new analyser
  33854. * @param scene defines hosting scene
  33855. */
  33856. constructor(scene: Scene);
  33857. /**
  33858. * Get the number of data values you will have to play with for the visualization
  33859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33860. * @returns a number
  33861. */
  33862. getFrequencyBinCount(): number;
  33863. /**
  33864. * Gets the current frequency data as a byte array
  33865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33866. * @returns a Uint8Array
  33867. */
  33868. getByteFrequencyData(): Uint8Array;
  33869. /**
  33870. * Gets the current waveform as a byte array
  33871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33872. * @returns a Uint8Array
  33873. */
  33874. getByteTimeDomainData(): Uint8Array;
  33875. /**
  33876. * Gets the current frequency data as a float array
  33877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33878. * @returns a Float32Array
  33879. */
  33880. getFloatFrequencyData(): Float32Array;
  33881. /**
  33882. * Renders the debug canvas
  33883. */
  33884. drawDebugCanvas(): void;
  33885. /**
  33886. * Stops rendering the debug canvas and removes it
  33887. */
  33888. stopDebugCanvas(): void;
  33889. /**
  33890. * Connects two audio nodes
  33891. * @param inputAudioNode defines first node to connect
  33892. * @param outputAudioNode defines second node to connect
  33893. */
  33894. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33895. /**
  33896. * Releases all associated resources
  33897. */
  33898. dispose(): void;
  33899. }
  33900. }
  33901. declare module "babylonjs/Audio/audioEngine" {
  33902. import { IDisposable } from "babylonjs/scene";
  33903. import { Analyser } from "babylonjs/Audio/analyser";
  33904. import { Nullable } from "babylonjs/types";
  33905. import { Observable } from "babylonjs/Misc/observable";
  33906. /**
  33907. * This represents an audio engine and it is responsible
  33908. * to play, synchronize and analyse sounds throughout the application.
  33909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33910. */
  33911. export interface IAudioEngine extends IDisposable {
  33912. /**
  33913. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33914. */
  33915. readonly canUseWebAudio: boolean;
  33916. /**
  33917. * Gets the current AudioContext if available.
  33918. */
  33919. readonly audioContext: Nullable<AudioContext>;
  33920. /**
  33921. * The master gain node defines the global audio volume of your audio engine.
  33922. */
  33923. readonly masterGain: GainNode;
  33924. /**
  33925. * Gets whether or not mp3 are supported by your browser.
  33926. */
  33927. readonly isMP3supported: boolean;
  33928. /**
  33929. * Gets whether or not ogg are supported by your browser.
  33930. */
  33931. readonly isOGGsupported: boolean;
  33932. /**
  33933. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33934. * @ignoreNaming
  33935. */
  33936. WarnedWebAudioUnsupported: boolean;
  33937. /**
  33938. * Defines if the audio engine relies on a custom unlocked button.
  33939. * In this case, the embedded button will not be displayed.
  33940. */
  33941. useCustomUnlockedButton: boolean;
  33942. /**
  33943. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33944. */
  33945. readonly unlocked: boolean;
  33946. /**
  33947. * Event raised when audio has been unlocked on the browser.
  33948. */
  33949. onAudioUnlockedObservable: Observable<AudioEngine>;
  33950. /**
  33951. * Event raised when audio has been locked on the browser.
  33952. */
  33953. onAudioLockedObservable: Observable<AudioEngine>;
  33954. /**
  33955. * Flags the audio engine in Locked state.
  33956. * This happens due to new browser policies preventing audio to autoplay.
  33957. */
  33958. lock(): void;
  33959. /**
  33960. * Unlocks the audio engine once a user action has been done on the dom.
  33961. * This is helpful to resume play once browser policies have been satisfied.
  33962. */
  33963. unlock(): void;
  33964. /**
  33965. * Gets the global volume sets on the master gain.
  33966. * @returns the global volume if set or -1 otherwise
  33967. */
  33968. getGlobalVolume(): number;
  33969. /**
  33970. * Sets the global volume of your experience (sets on the master gain).
  33971. * @param newVolume Defines the new global volume of the application
  33972. */
  33973. setGlobalVolume(newVolume: number): void;
  33974. /**
  33975. * Connect the audio engine to an audio analyser allowing some amazing
  33976. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33978. * @param analyser The analyser to connect to the engine
  33979. */
  33980. connectToAnalyser(analyser: Analyser): void;
  33981. }
  33982. /**
  33983. * This represents the default audio engine used in babylon.
  33984. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33986. */
  33987. export class AudioEngine implements IAudioEngine {
  33988. private _audioContext;
  33989. private _audioContextInitialized;
  33990. private _muteButton;
  33991. private _hostElement;
  33992. /**
  33993. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33994. */
  33995. canUseWebAudio: boolean;
  33996. /**
  33997. * The master gain node defines the global audio volume of your audio engine.
  33998. */
  33999. masterGain: GainNode;
  34000. /**
  34001. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34002. * @ignoreNaming
  34003. */
  34004. WarnedWebAudioUnsupported: boolean;
  34005. /**
  34006. * Gets whether or not mp3 are supported by your browser.
  34007. */
  34008. isMP3supported: boolean;
  34009. /**
  34010. * Gets whether or not ogg are supported by your browser.
  34011. */
  34012. isOGGsupported: boolean;
  34013. /**
  34014. * Gets whether audio has been unlocked on the device.
  34015. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34016. * a user interaction has happened.
  34017. */
  34018. unlocked: boolean;
  34019. /**
  34020. * Defines if the audio engine relies on a custom unlocked button.
  34021. * In this case, the embedded button will not be displayed.
  34022. */
  34023. useCustomUnlockedButton: boolean;
  34024. /**
  34025. * Event raised when audio has been unlocked on the browser.
  34026. */
  34027. onAudioUnlockedObservable: Observable<AudioEngine>;
  34028. /**
  34029. * Event raised when audio has been locked on the browser.
  34030. */
  34031. onAudioLockedObservable: Observable<AudioEngine>;
  34032. /**
  34033. * Gets the current AudioContext if available.
  34034. */
  34035. get audioContext(): Nullable<AudioContext>;
  34036. private _connectedAnalyser;
  34037. /**
  34038. * Instantiates a new audio engine.
  34039. *
  34040. * There should be only one per page as some browsers restrict the number
  34041. * of audio contexts you can create.
  34042. * @param hostElement defines the host element where to display the mute icon if necessary
  34043. */
  34044. constructor(hostElement?: Nullable<HTMLElement>);
  34045. /**
  34046. * Flags the audio engine in Locked state.
  34047. * This happens due to new browser policies preventing audio to autoplay.
  34048. */
  34049. lock(): void;
  34050. /**
  34051. * Unlocks the audio engine once a user action has been done on the dom.
  34052. * This is helpful to resume play once browser policies have been satisfied.
  34053. */
  34054. unlock(): void;
  34055. private _resumeAudioContext;
  34056. private _initializeAudioContext;
  34057. private _tryToRun;
  34058. private _triggerRunningState;
  34059. private _triggerSuspendedState;
  34060. private _displayMuteButton;
  34061. private _moveButtonToTopLeft;
  34062. private _onResize;
  34063. private _hideMuteButton;
  34064. /**
  34065. * Destroy and release the resources associated with the audio ccontext.
  34066. */
  34067. dispose(): void;
  34068. /**
  34069. * Gets the global volume sets on the master gain.
  34070. * @returns the global volume if set or -1 otherwise
  34071. */
  34072. getGlobalVolume(): number;
  34073. /**
  34074. * Sets the global volume of your experience (sets on the master gain).
  34075. * @param newVolume Defines the new global volume of the application
  34076. */
  34077. setGlobalVolume(newVolume: number): void;
  34078. /**
  34079. * Connect the audio engine to an audio analyser allowing some amazing
  34080. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34082. * @param analyser The analyser to connect to the engine
  34083. */
  34084. connectToAnalyser(analyser: Analyser): void;
  34085. }
  34086. }
  34087. declare module "babylonjs/Loading/loadingScreen" {
  34088. /**
  34089. * Interface used to present a loading screen while loading a scene
  34090. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34091. */
  34092. export interface ILoadingScreen {
  34093. /**
  34094. * Function called to display the loading screen
  34095. */
  34096. displayLoadingUI: () => void;
  34097. /**
  34098. * Function called to hide the loading screen
  34099. */
  34100. hideLoadingUI: () => void;
  34101. /**
  34102. * Gets or sets the color to use for the background
  34103. */
  34104. loadingUIBackgroundColor: string;
  34105. /**
  34106. * Gets or sets the text to display while loading
  34107. */
  34108. loadingUIText: string;
  34109. }
  34110. /**
  34111. * Class used for the default loading screen
  34112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34113. */
  34114. export class DefaultLoadingScreen implements ILoadingScreen {
  34115. private _renderingCanvas;
  34116. private _loadingText;
  34117. private _loadingDivBackgroundColor;
  34118. private _loadingDiv;
  34119. private _loadingTextDiv;
  34120. /** Gets or sets the logo url to use for the default loading screen */
  34121. static DefaultLogoUrl: string;
  34122. /** Gets or sets the spinner url to use for the default loading screen */
  34123. static DefaultSpinnerUrl: string;
  34124. /**
  34125. * Creates a new default loading screen
  34126. * @param _renderingCanvas defines the canvas used to render the scene
  34127. * @param _loadingText defines the default text to display
  34128. * @param _loadingDivBackgroundColor defines the default background color
  34129. */
  34130. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34131. /**
  34132. * Function called to display the loading screen
  34133. */
  34134. displayLoadingUI(): void;
  34135. /**
  34136. * Function called to hide the loading screen
  34137. */
  34138. hideLoadingUI(): void;
  34139. /**
  34140. * Gets or sets the text to display while loading
  34141. */
  34142. set loadingUIText(text: string);
  34143. get loadingUIText(): string;
  34144. /**
  34145. * Gets or sets the color to use for the background
  34146. */
  34147. get loadingUIBackgroundColor(): string;
  34148. set loadingUIBackgroundColor(color: string);
  34149. private _resizeLoadingUI;
  34150. }
  34151. }
  34152. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34153. /**
  34154. * Interface for any object that can request an animation frame
  34155. */
  34156. export interface ICustomAnimationFrameRequester {
  34157. /**
  34158. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34159. */
  34160. renderFunction?: Function;
  34161. /**
  34162. * Called to request the next frame to render to
  34163. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34164. */
  34165. requestAnimationFrame: Function;
  34166. /**
  34167. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34168. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34169. */
  34170. requestID?: number;
  34171. }
  34172. }
  34173. declare module "babylonjs/Misc/performanceMonitor" {
  34174. /**
  34175. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34176. */
  34177. export class PerformanceMonitor {
  34178. private _enabled;
  34179. private _rollingFrameTime;
  34180. private _lastFrameTimeMs;
  34181. /**
  34182. * constructor
  34183. * @param frameSampleSize The number of samples required to saturate the sliding window
  34184. */
  34185. constructor(frameSampleSize?: number);
  34186. /**
  34187. * Samples current frame
  34188. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34189. */
  34190. sampleFrame(timeMs?: number): void;
  34191. /**
  34192. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34193. */
  34194. get averageFrameTime(): number;
  34195. /**
  34196. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34197. */
  34198. get averageFrameTimeVariance(): number;
  34199. /**
  34200. * Returns the frame time of the most recent frame
  34201. */
  34202. get instantaneousFrameTime(): number;
  34203. /**
  34204. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34205. */
  34206. get averageFPS(): number;
  34207. /**
  34208. * Returns the average framerate in frames per second using the most recent frame time
  34209. */
  34210. get instantaneousFPS(): number;
  34211. /**
  34212. * Returns true if enough samples have been taken to completely fill the sliding window
  34213. */
  34214. get isSaturated(): boolean;
  34215. /**
  34216. * Enables contributions to the sliding window sample set
  34217. */
  34218. enable(): void;
  34219. /**
  34220. * Disables contributions to the sliding window sample set
  34221. * Samples will not be interpolated over the disabled period
  34222. */
  34223. disable(): void;
  34224. /**
  34225. * Returns true if sampling is enabled
  34226. */
  34227. get isEnabled(): boolean;
  34228. /**
  34229. * Resets performance monitor
  34230. */
  34231. reset(): void;
  34232. }
  34233. /**
  34234. * RollingAverage
  34235. *
  34236. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34237. */
  34238. export class RollingAverage {
  34239. /**
  34240. * Current average
  34241. */
  34242. average: number;
  34243. /**
  34244. * Current variance
  34245. */
  34246. variance: number;
  34247. protected _samples: Array<number>;
  34248. protected _sampleCount: number;
  34249. protected _pos: number;
  34250. protected _m2: number;
  34251. /**
  34252. * constructor
  34253. * @param length The number of samples required to saturate the sliding window
  34254. */
  34255. constructor(length: number);
  34256. /**
  34257. * Adds a sample to the sample set
  34258. * @param v The sample value
  34259. */
  34260. add(v: number): void;
  34261. /**
  34262. * Returns previously added values or null if outside of history or outside the sliding window domain
  34263. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34264. * @return Value previously recorded with add() or null if outside of range
  34265. */
  34266. history(i: number): number;
  34267. /**
  34268. * Returns true if enough samples have been taken to completely fill the sliding window
  34269. * @return true if sample-set saturated
  34270. */
  34271. isSaturated(): boolean;
  34272. /**
  34273. * Resets the rolling average (equivalent to 0 samples taken so far)
  34274. */
  34275. reset(): void;
  34276. /**
  34277. * Wraps a value around the sample range boundaries
  34278. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34279. * @return Wrapped position in sample range
  34280. */
  34281. protected _wrapPosition(i: number): number;
  34282. }
  34283. }
  34284. declare module "babylonjs/Misc/perfCounter" {
  34285. /**
  34286. * This class is used to track a performance counter which is number based.
  34287. * The user has access to many properties which give statistics of different nature.
  34288. *
  34289. * The implementer can track two kinds of Performance Counter: time and count.
  34290. * 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.
  34291. * 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.
  34292. */
  34293. export class PerfCounter {
  34294. /**
  34295. * Gets or sets a global boolean to turn on and off all the counters
  34296. */
  34297. static Enabled: boolean;
  34298. /**
  34299. * Returns the smallest value ever
  34300. */
  34301. get min(): number;
  34302. /**
  34303. * Returns the biggest value ever
  34304. */
  34305. get max(): number;
  34306. /**
  34307. * Returns the average value since the performance counter is running
  34308. */
  34309. get average(): number;
  34310. /**
  34311. * Returns the average value of the last second the counter was monitored
  34312. */
  34313. get lastSecAverage(): number;
  34314. /**
  34315. * Returns the current value
  34316. */
  34317. get current(): number;
  34318. /**
  34319. * Gets the accumulated total
  34320. */
  34321. get total(): number;
  34322. /**
  34323. * Gets the total value count
  34324. */
  34325. get count(): number;
  34326. /**
  34327. * Creates a new counter
  34328. */
  34329. constructor();
  34330. /**
  34331. * Call this method to start monitoring a new frame.
  34332. * 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.
  34333. */
  34334. fetchNewFrame(): void;
  34335. /**
  34336. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34337. * @param newCount the count value to add to the monitored count
  34338. * @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.
  34339. */
  34340. addCount(newCount: number, fetchResult: boolean): void;
  34341. /**
  34342. * Start monitoring this performance counter
  34343. */
  34344. beginMonitoring(): void;
  34345. /**
  34346. * Compute the time lapsed since the previous beginMonitoring() call.
  34347. * @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
  34348. */
  34349. endMonitoring(newFrame?: boolean): void;
  34350. private _fetchResult;
  34351. private _startMonitoringTime;
  34352. private _min;
  34353. private _max;
  34354. private _average;
  34355. private _current;
  34356. private _totalValueCount;
  34357. private _totalAccumulated;
  34358. private _lastSecAverage;
  34359. private _lastSecAccumulated;
  34360. private _lastSecTime;
  34361. private _lastSecValueCount;
  34362. }
  34363. }
  34364. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34365. module "babylonjs/Engines/thinEngine" {
  34366. interface ThinEngine {
  34367. /**
  34368. * Sets alpha constants used by some alpha blending modes
  34369. * @param r defines the red component
  34370. * @param g defines the green component
  34371. * @param b defines the blue component
  34372. * @param a defines the alpha component
  34373. */
  34374. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34375. /**
  34376. * Sets the current alpha mode
  34377. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34378. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34380. */
  34381. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34382. /**
  34383. * Gets the current alpha mode
  34384. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34385. * @returns the current alpha mode
  34386. */
  34387. getAlphaMode(): number;
  34388. /**
  34389. * Sets the current alpha equation
  34390. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34391. */
  34392. setAlphaEquation(equation: number): void;
  34393. /**
  34394. * Gets the current alpha equation.
  34395. * @returns the current alpha equation
  34396. */
  34397. getAlphaEquation(): number;
  34398. }
  34399. }
  34400. }
  34401. declare module "babylonjs/Engines/engine" {
  34402. import { Observable } from "babylonjs/Misc/observable";
  34403. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34404. import { Scene } from "babylonjs/scene";
  34405. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34406. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34408. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34409. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34410. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34411. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34412. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34413. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34415. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34417. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34418. import "babylonjs/Engines/Extensions/engine.alpha";
  34419. import { Material } from "babylonjs/Materials/material";
  34420. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34421. /**
  34422. * Defines the interface used by display changed events
  34423. */
  34424. export interface IDisplayChangedEventArgs {
  34425. /** Gets the vrDisplay object (if any) */
  34426. vrDisplay: Nullable<any>;
  34427. /** Gets a boolean indicating if webVR is supported */
  34428. vrSupported: boolean;
  34429. }
  34430. /**
  34431. * Defines the interface used by objects containing a viewport (like a camera)
  34432. */
  34433. interface IViewportOwnerLike {
  34434. /**
  34435. * Gets or sets the viewport
  34436. */
  34437. viewport: IViewportLike;
  34438. }
  34439. /**
  34440. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34441. */
  34442. export class Engine extends ThinEngine {
  34443. /** Defines that alpha blending is disabled */
  34444. static readonly ALPHA_DISABLE: number;
  34445. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34446. static readonly ALPHA_ADD: number;
  34447. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34448. static readonly ALPHA_COMBINE: number;
  34449. /** Defines that alpha blending to DEST - SRC * DEST */
  34450. static readonly ALPHA_SUBTRACT: number;
  34451. /** Defines that alpha blending to SRC * DEST */
  34452. static readonly ALPHA_MULTIPLY: number;
  34453. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34454. static readonly ALPHA_MAXIMIZED: number;
  34455. /** Defines that alpha blending to SRC + DEST */
  34456. static readonly ALPHA_ONEONE: number;
  34457. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34458. static readonly ALPHA_PREMULTIPLIED: number;
  34459. /**
  34460. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34461. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34462. */
  34463. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34464. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34465. static readonly ALPHA_INTERPOLATE: number;
  34466. /**
  34467. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34468. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34469. */
  34470. static readonly ALPHA_SCREENMODE: number;
  34471. /** Defines that the ressource is not delayed*/
  34472. static readonly DELAYLOADSTATE_NONE: number;
  34473. /** Defines that the ressource was successfully delay loaded */
  34474. static readonly DELAYLOADSTATE_LOADED: number;
  34475. /** Defines that the ressource is currently delay loading */
  34476. static readonly DELAYLOADSTATE_LOADING: number;
  34477. /** Defines that the ressource is delayed and has not started loading */
  34478. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34479. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34480. static readonly NEVER: number;
  34481. /** 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 */
  34482. static readonly ALWAYS: number;
  34483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34484. static readonly LESS: number;
  34485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34486. static readonly EQUAL: number;
  34487. /** 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 */
  34488. static readonly LEQUAL: number;
  34489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34490. static readonly GREATER: number;
  34491. /** 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 */
  34492. static readonly GEQUAL: number;
  34493. /** 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 */
  34494. static readonly NOTEQUAL: number;
  34495. /** Passed to stencilOperation to specify that stencil value must be kept */
  34496. static readonly KEEP: number;
  34497. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34498. static readonly REPLACE: number;
  34499. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34500. static readonly INCR: number;
  34501. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34502. static readonly DECR: number;
  34503. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34504. static readonly INVERT: number;
  34505. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34506. static readonly INCR_WRAP: number;
  34507. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34508. static readonly DECR_WRAP: number;
  34509. /** Texture is not repeating outside of 0..1 UVs */
  34510. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34511. /** Texture is repeating outside of 0..1 UVs */
  34512. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34513. /** Texture is repeating and mirrored */
  34514. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34515. /** ALPHA */
  34516. static readonly TEXTUREFORMAT_ALPHA: number;
  34517. /** LUMINANCE */
  34518. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34519. /** LUMINANCE_ALPHA */
  34520. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34521. /** RGB */
  34522. static readonly TEXTUREFORMAT_RGB: number;
  34523. /** RGBA */
  34524. static readonly TEXTUREFORMAT_RGBA: number;
  34525. /** RED */
  34526. static readonly TEXTUREFORMAT_RED: number;
  34527. /** RED (2nd reference) */
  34528. static readonly TEXTUREFORMAT_R: number;
  34529. /** RG */
  34530. static readonly TEXTUREFORMAT_RG: number;
  34531. /** RED_INTEGER */
  34532. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34533. /** RED_INTEGER (2nd reference) */
  34534. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34535. /** RG_INTEGER */
  34536. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34537. /** RGB_INTEGER */
  34538. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34539. /** RGBA_INTEGER */
  34540. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34541. /** UNSIGNED_BYTE */
  34542. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34543. /** UNSIGNED_BYTE (2nd reference) */
  34544. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34545. /** FLOAT */
  34546. static readonly TEXTURETYPE_FLOAT: number;
  34547. /** HALF_FLOAT */
  34548. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34549. /** BYTE */
  34550. static readonly TEXTURETYPE_BYTE: number;
  34551. /** SHORT */
  34552. static readonly TEXTURETYPE_SHORT: number;
  34553. /** UNSIGNED_SHORT */
  34554. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34555. /** INT */
  34556. static readonly TEXTURETYPE_INT: number;
  34557. /** UNSIGNED_INT */
  34558. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34559. /** UNSIGNED_SHORT_4_4_4_4 */
  34560. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34561. /** UNSIGNED_SHORT_5_5_5_1 */
  34562. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34563. /** UNSIGNED_SHORT_5_6_5 */
  34564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34565. /** UNSIGNED_INT_2_10_10_10_REV */
  34566. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34567. /** UNSIGNED_INT_24_8 */
  34568. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34569. /** UNSIGNED_INT_10F_11F_11F_REV */
  34570. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34571. /** UNSIGNED_INT_5_9_9_9_REV */
  34572. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34573. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34574. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34575. /** nearest is mag = nearest and min = nearest and mip = linear */
  34576. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34577. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34578. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34579. /** Trilinear is mag = linear and min = linear and mip = linear */
  34580. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34581. /** nearest is mag = nearest and min = nearest and mip = linear */
  34582. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34583. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34584. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34585. /** Trilinear is mag = linear and min = linear and mip = linear */
  34586. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34587. /** mag = nearest and min = nearest and mip = nearest */
  34588. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34589. /** mag = nearest and min = linear and mip = nearest */
  34590. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34591. /** mag = nearest and min = linear and mip = linear */
  34592. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34593. /** mag = nearest and min = linear and mip = none */
  34594. static readonly TEXTURE_NEAREST_LINEAR: number;
  34595. /** mag = nearest and min = nearest and mip = none */
  34596. static readonly TEXTURE_NEAREST_NEAREST: number;
  34597. /** mag = linear and min = nearest and mip = nearest */
  34598. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34599. /** mag = linear and min = nearest and mip = linear */
  34600. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34601. /** mag = linear and min = linear and mip = none */
  34602. static readonly TEXTURE_LINEAR_LINEAR: number;
  34603. /** mag = linear and min = nearest and mip = none */
  34604. static readonly TEXTURE_LINEAR_NEAREST: number;
  34605. /** Explicit coordinates mode */
  34606. static readonly TEXTURE_EXPLICIT_MODE: number;
  34607. /** Spherical coordinates mode */
  34608. static readonly TEXTURE_SPHERICAL_MODE: number;
  34609. /** Planar coordinates mode */
  34610. static readonly TEXTURE_PLANAR_MODE: number;
  34611. /** Cubic coordinates mode */
  34612. static readonly TEXTURE_CUBIC_MODE: number;
  34613. /** Projection coordinates mode */
  34614. static readonly TEXTURE_PROJECTION_MODE: number;
  34615. /** Skybox coordinates mode */
  34616. static readonly TEXTURE_SKYBOX_MODE: number;
  34617. /** Inverse Cubic coordinates mode */
  34618. static readonly TEXTURE_INVCUBIC_MODE: number;
  34619. /** Equirectangular coordinates mode */
  34620. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34621. /** Equirectangular Fixed coordinates mode */
  34622. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34623. /** Equirectangular Fixed Mirrored coordinates mode */
  34624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34625. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34626. static readonly SCALEMODE_FLOOR: number;
  34627. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34628. static readonly SCALEMODE_NEAREST: number;
  34629. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34630. static readonly SCALEMODE_CEILING: number;
  34631. /**
  34632. * Returns the current npm package of the sdk
  34633. */
  34634. static get NpmPackage(): string;
  34635. /**
  34636. * Returns the current version of the framework
  34637. */
  34638. static get Version(): string;
  34639. /** Gets the list of created engines */
  34640. static get Instances(): Engine[];
  34641. /**
  34642. * Gets the latest created engine
  34643. */
  34644. static get LastCreatedEngine(): Nullable<Engine>;
  34645. /**
  34646. * Gets the latest created scene
  34647. */
  34648. static get LastCreatedScene(): Nullable<Scene>;
  34649. /**
  34650. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34651. * @param flag defines which part of the materials must be marked as dirty
  34652. * @param predicate defines a predicate used to filter which materials should be affected
  34653. */
  34654. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34655. /**
  34656. * Method called to create the default loading screen.
  34657. * This can be overriden in your own app.
  34658. * @param canvas The rendering canvas element
  34659. * @returns The loading screen
  34660. */
  34661. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34662. /**
  34663. * Method called to create the default rescale post process on each engine.
  34664. */
  34665. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34666. /**
  34667. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34668. **/
  34669. enableOfflineSupport: boolean;
  34670. /**
  34671. * 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)
  34672. **/
  34673. disableManifestCheck: boolean;
  34674. /**
  34675. * Gets the list of created scenes
  34676. */
  34677. scenes: Scene[];
  34678. /**
  34679. * Event raised when a new scene is created
  34680. */
  34681. onNewSceneAddedObservable: Observable<Scene>;
  34682. /**
  34683. * Gets the list of created postprocesses
  34684. */
  34685. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34686. /**
  34687. * Gets a boolean indicating if the pointer is currently locked
  34688. */
  34689. isPointerLock: boolean;
  34690. /**
  34691. * Observable event triggered each time the rendering canvas is resized
  34692. */
  34693. onResizeObservable: Observable<Engine>;
  34694. /**
  34695. * Observable event triggered each time the canvas loses focus
  34696. */
  34697. onCanvasBlurObservable: Observable<Engine>;
  34698. /**
  34699. * Observable event triggered each time the canvas gains focus
  34700. */
  34701. onCanvasFocusObservable: Observable<Engine>;
  34702. /**
  34703. * Observable event triggered each time the canvas receives pointerout event
  34704. */
  34705. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34706. /**
  34707. * Observable raised when the engine begins a new frame
  34708. */
  34709. onBeginFrameObservable: Observable<Engine>;
  34710. /**
  34711. * If set, will be used to request the next animation frame for the render loop
  34712. */
  34713. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34714. /**
  34715. * Observable raised when the engine ends the current frame
  34716. */
  34717. onEndFrameObservable: Observable<Engine>;
  34718. /**
  34719. * Observable raised when the engine is about to compile a shader
  34720. */
  34721. onBeforeShaderCompilationObservable: Observable<Engine>;
  34722. /**
  34723. * Observable raised when the engine has jsut compiled a shader
  34724. */
  34725. onAfterShaderCompilationObservable: Observable<Engine>;
  34726. /**
  34727. * Gets the audio engine
  34728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34729. * @ignorenaming
  34730. */
  34731. static audioEngine: IAudioEngine;
  34732. /**
  34733. * Default AudioEngine factory responsible of creating the Audio Engine.
  34734. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34735. */
  34736. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34737. /**
  34738. * Default offline support factory responsible of creating a tool used to store data locally.
  34739. * By default, this will create a Database object if the workload has been embedded.
  34740. */
  34741. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34742. private _loadingScreen;
  34743. private _pointerLockRequested;
  34744. private _dummyFramebuffer;
  34745. private _rescalePostProcess;
  34746. private _deterministicLockstep;
  34747. private _lockstepMaxSteps;
  34748. private _timeStep;
  34749. protected get _supportsHardwareTextureRescaling(): boolean;
  34750. private _fps;
  34751. private _deltaTime;
  34752. /** @hidden */
  34753. _drawCalls: PerfCounter;
  34754. /** 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 */
  34755. canvasTabIndex: number;
  34756. /**
  34757. * Turn this value on if you want to pause FPS computation when in background
  34758. */
  34759. disablePerformanceMonitorInBackground: boolean;
  34760. private _performanceMonitor;
  34761. /**
  34762. * Gets the performance monitor attached to this engine
  34763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34764. */
  34765. get performanceMonitor(): PerformanceMonitor;
  34766. private _onFocus;
  34767. private _onBlur;
  34768. private _onCanvasPointerOut;
  34769. private _onCanvasBlur;
  34770. private _onCanvasFocus;
  34771. private _onFullscreenChange;
  34772. private _onPointerLockChange;
  34773. /**
  34774. * Gets the HTML element used to attach event listeners
  34775. * @returns a HTML element
  34776. */
  34777. getInputElement(): Nullable<HTMLElement>;
  34778. /**
  34779. * Creates a new engine
  34780. * @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
  34781. * @param antialias defines enable antialiasing (default: false)
  34782. * @param options defines further options to be sent to the getContext() function
  34783. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34784. */
  34785. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34786. /**
  34787. * Gets current aspect ratio
  34788. * @param viewportOwner defines the camera to use to get the aspect ratio
  34789. * @param useScreen defines if screen size must be used (or the current render target if any)
  34790. * @returns a number defining the aspect ratio
  34791. */
  34792. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34793. /**
  34794. * Gets current screen aspect ratio
  34795. * @returns a number defining the aspect ratio
  34796. */
  34797. getScreenAspectRatio(): number;
  34798. /**
  34799. * Gets the client rect of the HTML canvas attached with the current webGL context
  34800. * @returns a client rectanglee
  34801. */
  34802. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34803. /**
  34804. * Gets the client rect of the HTML element used for events
  34805. * @returns a client rectanglee
  34806. */
  34807. getInputElementClientRect(): Nullable<ClientRect>;
  34808. /**
  34809. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34811. * @returns true if engine is in deterministic lock step mode
  34812. */
  34813. isDeterministicLockStep(): boolean;
  34814. /**
  34815. * Gets the max steps when engine is running in deterministic lock step
  34816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34817. * @returns the max steps
  34818. */
  34819. getLockstepMaxSteps(): number;
  34820. /**
  34821. * Returns the time in ms between steps when using deterministic lock step.
  34822. * @returns time step in (ms)
  34823. */
  34824. getTimeStep(): number;
  34825. /**
  34826. * Force the mipmap generation for the given render target texture
  34827. * @param texture defines the render target texture to use
  34828. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34829. */
  34830. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34831. /** States */
  34832. /**
  34833. * Set various states to the webGL context
  34834. * @param culling defines backface culling state
  34835. * @param zOffset defines the value to apply to zOffset (0 by default)
  34836. * @param force defines if states must be applied even if cache is up to date
  34837. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34838. */
  34839. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34840. /**
  34841. * Set the z offset to apply to current rendering
  34842. * @param value defines the offset to apply
  34843. */
  34844. setZOffset(value: number): void;
  34845. /**
  34846. * Gets the current value of the zOffset
  34847. * @returns the current zOffset state
  34848. */
  34849. getZOffset(): number;
  34850. /**
  34851. * Enable or disable depth buffering
  34852. * @param enable defines the state to set
  34853. */
  34854. setDepthBuffer(enable: boolean): void;
  34855. /**
  34856. * Gets a boolean indicating if depth writing is enabled
  34857. * @returns the current depth writing state
  34858. */
  34859. getDepthWrite(): boolean;
  34860. /**
  34861. * Enable or disable depth writing
  34862. * @param enable defines the state to set
  34863. */
  34864. setDepthWrite(enable: boolean): void;
  34865. /**
  34866. * Gets a boolean indicating if stencil buffer is enabled
  34867. * @returns the current stencil buffer state
  34868. */
  34869. getStencilBuffer(): boolean;
  34870. /**
  34871. * Enable or disable the stencil buffer
  34872. * @param enable defines if the stencil buffer must be enabled or disabled
  34873. */
  34874. setStencilBuffer(enable: boolean): void;
  34875. /**
  34876. * Gets the current stencil mask
  34877. * @returns a number defining the new stencil mask to use
  34878. */
  34879. getStencilMask(): number;
  34880. /**
  34881. * Sets the current stencil mask
  34882. * @param mask defines the new stencil mask to use
  34883. */
  34884. setStencilMask(mask: number): void;
  34885. /**
  34886. * Gets the current stencil function
  34887. * @returns a number defining the stencil function to use
  34888. */
  34889. getStencilFunction(): number;
  34890. /**
  34891. * Gets the current stencil reference value
  34892. * @returns a number defining the stencil reference value to use
  34893. */
  34894. getStencilFunctionReference(): number;
  34895. /**
  34896. * Gets the current stencil mask
  34897. * @returns a number defining the stencil mask to use
  34898. */
  34899. getStencilFunctionMask(): number;
  34900. /**
  34901. * Sets the current stencil function
  34902. * @param stencilFunc defines the new stencil function to use
  34903. */
  34904. setStencilFunction(stencilFunc: number): void;
  34905. /**
  34906. * Sets the current stencil reference
  34907. * @param reference defines the new stencil reference to use
  34908. */
  34909. setStencilFunctionReference(reference: number): void;
  34910. /**
  34911. * Sets the current stencil mask
  34912. * @param mask defines the new stencil mask to use
  34913. */
  34914. setStencilFunctionMask(mask: number): void;
  34915. /**
  34916. * Gets the current stencil operation when stencil fails
  34917. * @returns a number defining stencil operation to use when stencil fails
  34918. */
  34919. getStencilOperationFail(): number;
  34920. /**
  34921. * Gets the current stencil operation when depth fails
  34922. * @returns a number defining stencil operation to use when depth fails
  34923. */
  34924. getStencilOperationDepthFail(): number;
  34925. /**
  34926. * Gets the current stencil operation when stencil passes
  34927. * @returns a number defining stencil operation to use when stencil passes
  34928. */
  34929. getStencilOperationPass(): number;
  34930. /**
  34931. * Sets the stencil operation to use when stencil fails
  34932. * @param operation defines the stencil operation to use when stencil fails
  34933. */
  34934. setStencilOperationFail(operation: number): void;
  34935. /**
  34936. * Sets the stencil operation to use when depth fails
  34937. * @param operation defines the stencil operation to use when depth fails
  34938. */
  34939. setStencilOperationDepthFail(operation: number): void;
  34940. /**
  34941. * Sets the stencil operation to use when stencil passes
  34942. * @param operation defines the stencil operation to use when stencil passes
  34943. */
  34944. setStencilOperationPass(operation: number): void;
  34945. /**
  34946. * Sets a boolean indicating if the dithering state is enabled or disabled
  34947. * @param value defines the dithering state
  34948. */
  34949. setDitheringState(value: boolean): void;
  34950. /**
  34951. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34952. * @param value defines the rasterizer state
  34953. */
  34954. setRasterizerState(value: boolean): void;
  34955. /**
  34956. * Gets the current depth function
  34957. * @returns a number defining the depth function
  34958. */
  34959. getDepthFunction(): Nullable<number>;
  34960. /**
  34961. * Sets the current depth function
  34962. * @param depthFunc defines the function to use
  34963. */
  34964. setDepthFunction(depthFunc: number): void;
  34965. /**
  34966. * Sets the current depth function to GREATER
  34967. */
  34968. setDepthFunctionToGreater(): void;
  34969. /**
  34970. * Sets the current depth function to GEQUAL
  34971. */
  34972. setDepthFunctionToGreaterOrEqual(): void;
  34973. /**
  34974. * Sets the current depth function to LESS
  34975. */
  34976. setDepthFunctionToLess(): void;
  34977. /**
  34978. * Sets the current depth function to LEQUAL
  34979. */
  34980. setDepthFunctionToLessOrEqual(): void;
  34981. private _cachedStencilBuffer;
  34982. private _cachedStencilFunction;
  34983. private _cachedStencilMask;
  34984. private _cachedStencilOperationPass;
  34985. private _cachedStencilOperationFail;
  34986. private _cachedStencilOperationDepthFail;
  34987. private _cachedStencilReference;
  34988. /**
  34989. * Caches the the state of the stencil buffer
  34990. */
  34991. cacheStencilState(): void;
  34992. /**
  34993. * Restores the state of the stencil buffer
  34994. */
  34995. restoreStencilState(): void;
  34996. /**
  34997. * Directly set the WebGL Viewport
  34998. * @param x defines the x coordinate of the viewport (in screen space)
  34999. * @param y defines the y coordinate of the viewport (in screen space)
  35000. * @param width defines the width of the viewport (in screen space)
  35001. * @param height defines the height of the viewport (in screen space)
  35002. * @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
  35003. */
  35004. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35005. /**
  35006. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35007. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35008. * @param y defines the y-coordinate of the corner of the clear rectangle
  35009. * @param width defines the width of the clear rectangle
  35010. * @param height defines the height of the clear rectangle
  35011. * @param clearColor defines the clear color
  35012. */
  35013. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35014. /**
  35015. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35016. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35017. * @param y defines the y-coordinate of the corner of the clear rectangle
  35018. * @param width defines the width of the clear rectangle
  35019. * @param height defines the height of the clear rectangle
  35020. */
  35021. enableScissor(x: number, y: number, width: number, height: number): void;
  35022. /**
  35023. * Disable previously set scissor test rectangle
  35024. */
  35025. disableScissor(): void;
  35026. protected _reportDrawCall(): void;
  35027. /**
  35028. * Initializes a webVR display and starts listening to display change events
  35029. * The onVRDisplayChangedObservable will be notified upon these changes
  35030. * @returns The onVRDisplayChangedObservable
  35031. */
  35032. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35033. /** @hidden */
  35034. _prepareVRComponent(): void;
  35035. /** @hidden */
  35036. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35037. /** @hidden */
  35038. _submitVRFrame(): void;
  35039. /**
  35040. * Call this function to leave webVR mode
  35041. * Will do nothing if webVR is not supported or if there is no webVR device
  35042. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35043. */
  35044. disableVR(): void;
  35045. /**
  35046. * Gets a boolean indicating that the system is in VR mode and is presenting
  35047. * @returns true if VR mode is engaged
  35048. */
  35049. isVRPresenting(): boolean;
  35050. /** @hidden */
  35051. _requestVRFrame(): void;
  35052. /** @hidden */
  35053. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35054. /**
  35055. * Gets the source code of the vertex shader associated with a specific webGL program
  35056. * @param program defines the program to use
  35057. * @returns a string containing the source code of the vertex shader associated with the program
  35058. */
  35059. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35060. /**
  35061. * Gets the source code of the fragment shader associated with a specific webGL program
  35062. * @param program defines the program to use
  35063. * @returns a string containing the source code of the fragment shader associated with the program
  35064. */
  35065. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35066. /**
  35067. * Sets a depth stencil texture from a render target to the according uniform.
  35068. * @param channel The texture channel
  35069. * @param uniform The uniform to set
  35070. * @param texture The render target texture containing the depth stencil texture to apply
  35071. */
  35072. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35073. /**
  35074. * Sets a texture to the webGL context from a postprocess
  35075. * @param channel defines the channel to use
  35076. * @param postProcess defines the source postprocess
  35077. */
  35078. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35079. /**
  35080. * Binds the output of the passed in post process to the texture channel specified
  35081. * @param channel The channel the texture should be bound to
  35082. * @param postProcess The post process which's output should be bound
  35083. */
  35084. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35085. /** @hidden */
  35086. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35087. protected _rebuildBuffers(): void;
  35088. /** @hidden */
  35089. _renderFrame(): void;
  35090. _renderLoop(): void;
  35091. /** @hidden */
  35092. _renderViews(): boolean;
  35093. /**
  35094. * Toggle full screen mode
  35095. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35096. */
  35097. switchFullscreen(requestPointerLock: boolean): void;
  35098. /**
  35099. * Enters full screen mode
  35100. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35101. */
  35102. enterFullscreen(requestPointerLock: boolean): void;
  35103. /**
  35104. * Exits full screen mode
  35105. */
  35106. exitFullscreen(): void;
  35107. /**
  35108. * Enters Pointerlock mode
  35109. */
  35110. enterPointerlock(): void;
  35111. /**
  35112. * Exits Pointerlock mode
  35113. */
  35114. exitPointerlock(): void;
  35115. /**
  35116. * Begin a new frame
  35117. */
  35118. beginFrame(): void;
  35119. /**
  35120. * Enf the current frame
  35121. */
  35122. endFrame(): void;
  35123. resize(): void;
  35124. /**
  35125. * Force a specific size of the canvas
  35126. * @param width defines the new canvas' width
  35127. * @param height defines the new canvas' height
  35128. */
  35129. setSize(width: number, height: number): void;
  35130. /**
  35131. * Updates a dynamic vertex buffer.
  35132. * @param vertexBuffer the vertex buffer to update
  35133. * @param data the data used to update the vertex buffer
  35134. * @param byteOffset the byte offset of the data
  35135. * @param byteLength the byte length of the data
  35136. */
  35137. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35138. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35139. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35140. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35141. _releaseTexture(texture: InternalTexture): void;
  35142. /**
  35143. * @hidden
  35144. * Rescales a texture
  35145. * @param source input texutre
  35146. * @param destination destination texture
  35147. * @param scene scene to use to render the resize
  35148. * @param internalFormat format to use when resizing
  35149. * @param onComplete callback to be called when resize has completed
  35150. */
  35151. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35152. /**
  35153. * Gets the current framerate
  35154. * @returns a number representing the framerate
  35155. */
  35156. getFps(): number;
  35157. /**
  35158. * Gets the time spent between current and previous frame
  35159. * @returns a number representing the delta time in ms
  35160. */
  35161. getDeltaTime(): number;
  35162. private _measureFps;
  35163. /** @hidden */
  35164. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35165. /**
  35166. * Update a dynamic index buffer
  35167. * @param indexBuffer defines the target index buffer
  35168. * @param indices defines the data to update
  35169. * @param offset defines the offset in the target index buffer where update should start
  35170. */
  35171. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35172. /**
  35173. * Updates the sample count of a render target texture
  35174. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35175. * @param texture defines the texture to update
  35176. * @param samples defines the sample count to set
  35177. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35178. */
  35179. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35180. /**
  35181. * Updates a depth texture Comparison Mode and Function.
  35182. * If the comparison Function is equal to 0, the mode will be set to none.
  35183. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35184. * @param texture The texture to set the comparison function for
  35185. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35186. */
  35187. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35188. /**
  35189. * Creates a webGL buffer to use with instanciation
  35190. * @param capacity defines the size of the buffer
  35191. * @returns the webGL buffer
  35192. */
  35193. createInstancesBuffer(capacity: number): DataBuffer;
  35194. /**
  35195. * Delete a webGL buffer used with instanciation
  35196. * @param buffer defines the webGL buffer to delete
  35197. */
  35198. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35199. private _clientWaitAsync;
  35200. /** @hidden */
  35201. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35202. /** @hidden */
  35203. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35204. dispose(): void;
  35205. private _disableTouchAction;
  35206. /**
  35207. * Display the loading screen
  35208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35209. */
  35210. displayLoadingUI(): void;
  35211. /**
  35212. * Hide the loading screen
  35213. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35214. */
  35215. hideLoadingUI(): void;
  35216. /**
  35217. * Gets the current loading screen object
  35218. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35219. */
  35220. get loadingScreen(): ILoadingScreen;
  35221. /**
  35222. * Sets the current loading screen object
  35223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35224. */
  35225. set loadingScreen(loadingScreen: ILoadingScreen);
  35226. /**
  35227. * Sets the current loading screen text
  35228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35229. */
  35230. set loadingUIText(text: string);
  35231. /**
  35232. * Sets the current loading screen background color
  35233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35234. */
  35235. set loadingUIBackgroundColor(color: string);
  35236. /** Pointerlock and fullscreen */
  35237. /**
  35238. * Ask the browser to promote the current element to pointerlock mode
  35239. * @param element defines the DOM element to promote
  35240. */
  35241. static _RequestPointerlock(element: HTMLElement): void;
  35242. /**
  35243. * Asks the browser to exit pointerlock mode
  35244. */
  35245. static _ExitPointerlock(): void;
  35246. /**
  35247. * Ask the browser to promote the current element to fullscreen rendering mode
  35248. * @param element defines the DOM element to promote
  35249. */
  35250. static _RequestFullscreen(element: HTMLElement): void;
  35251. /**
  35252. * Asks the browser to exit fullscreen mode
  35253. */
  35254. static _ExitFullscreen(): void;
  35255. }
  35256. }
  35257. declare module "babylonjs/Engines/engineStore" {
  35258. import { Nullable } from "babylonjs/types";
  35259. import { Engine } from "babylonjs/Engines/engine";
  35260. import { Scene } from "babylonjs/scene";
  35261. /**
  35262. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35263. * during the life time of the application.
  35264. */
  35265. export class EngineStore {
  35266. /** Gets the list of created engines */
  35267. static Instances: import("babylonjs/Engines/engine").Engine[];
  35268. /** @hidden */
  35269. static _LastCreatedScene: Nullable<Scene>;
  35270. /**
  35271. * Gets the latest created engine
  35272. */
  35273. static get LastCreatedEngine(): Nullable<Engine>;
  35274. /**
  35275. * Gets the latest created scene
  35276. */
  35277. static get LastCreatedScene(): Nullable<Scene>;
  35278. /**
  35279. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35280. * @ignorenaming
  35281. */
  35282. static UseFallbackTexture: boolean;
  35283. /**
  35284. * Texture content used if a texture cannot loaded
  35285. * @ignorenaming
  35286. */
  35287. static FallbackTexture: string;
  35288. }
  35289. }
  35290. declare module "babylonjs/Misc/promise" {
  35291. /**
  35292. * Helper class that provides a small promise polyfill
  35293. */
  35294. export class PromisePolyfill {
  35295. /**
  35296. * Static function used to check if the polyfill is required
  35297. * If this is the case then the function will inject the polyfill to window.Promise
  35298. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35299. */
  35300. static Apply(force?: boolean): void;
  35301. }
  35302. }
  35303. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35304. /**
  35305. * Interface for screenshot methods with describe argument called `size` as object with options
  35306. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35307. */
  35308. export interface IScreenshotSize {
  35309. /**
  35310. * number in pixels for canvas height
  35311. */
  35312. height?: number;
  35313. /**
  35314. * multiplier allowing render at a higher or lower resolution
  35315. * If value is defined then height and width will be ignored and taken from camera
  35316. */
  35317. precision?: number;
  35318. /**
  35319. * number in pixels for canvas width
  35320. */
  35321. width?: number;
  35322. }
  35323. }
  35324. declare module "babylonjs/Misc/tools" {
  35325. import { Nullable, float } from "babylonjs/types";
  35326. import { DomManagement } from "babylonjs/Misc/domManagement";
  35327. import { WebRequest } from "babylonjs/Misc/webRequest";
  35328. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35329. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35330. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35331. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35332. import { Camera } from "babylonjs/Cameras/camera";
  35333. import { Engine } from "babylonjs/Engines/engine";
  35334. interface IColor4Like {
  35335. r: float;
  35336. g: float;
  35337. b: float;
  35338. a: float;
  35339. }
  35340. /**
  35341. * Class containing a set of static utilities functions
  35342. */
  35343. export class Tools {
  35344. /**
  35345. * Gets or sets the base URL to use to load assets
  35346. */
  35347. static get BaseUrl(): string;
  35348. static set BaseUrl(value: string);
  35349. /**
  35350. * Enable/Disable Custom HTTP Request Headers globally.
  35351. * default = false
  35352. * @see CustomRequestHeaders
  35353. */
  35354. static UseCustomRequestHeaders: boolean;
  35355. /**
  35356. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35357. * i.e. when loading files, where the server/service expects an Authorization header
  35358. */
  35359. static CustomRequestHeaders: {
  35360. [key: string]: string;
  35361. };
  35362. /**
  35363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35364. */
  35365. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35366. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35367. /**
  35368. * Default behaviour for cors in the application.
  35369. * It can be a string if the expected behavior is identical in the entire app.
  35370. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35371. */
  35372. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35373. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35374. /**
  35375. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35376. * @ignorenaming
  35377. */
  35378. static get UseFallbackTexture(): boolean;
  35379. static set UseFallbackTexture(value: boolean);
  35380. /**
  35381. * Use this object to register external classes like custom textures or material
  35382. * to allow the laoders to instantiate them
  35383. */
  35384. static get RegisteredExternalClasses(): {
  35385. [key: string]: Object;
  35386. };
  35387. static set RegisteredExternalClasses(classes: {
  35388. [key: string]: Object;
  35389. });
  35390. /**
  35391. * Texture content used if a texture cannot loaded
  35392. * @ignorenaming
  35393. */
  35394. static get fallbackTexture(): string;
  35395. static set fallbackTexture(value: string);
  35396. /**
  35397. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35398. * @param u defines the coordinate on X axis
  35399. * @param v defines the coordinate on Y axis
  35400. * @param width defines the width of the source data
  35401. * @param height defines the height of the source data
  35402. * @param pixels defines the source byte array
  35403. * @param color defines the output color
  35404. */
  35405. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35406. /**
  35407. * Interpolates between a and b via alpha
  35408. * @param a The lower value (returned when alpha = 0)
  35409. * @param b The upper value (returned when alpha = 1)
  35410. * @param alpha The interpolation-factor
  35411. * @return The mixed value
  35412. */
  35413. static Mix(a: number, b: number, alpha: number): number;
  35414. /**
  35415. * Tries to instantiate a new object from a given class name
  35416. * @param className defines the class name to instantiate
  35417. * @returns the new object or null if the system was not able to do the instantiation
  35418. */
  35419. static Instantiate(className: string): any;
  35420. /**
  35421. * Provides a slice function that will work even on IE
  35422. * @param data defines the array to slice
  35423. * @param start defines the start of the data (optional)
  35424. * @param end defines the end of the data (optional)
  35425. * @returns the new sliced array
  35426. */
  35427. static Slice<T>(data: T, start?: number, end?: number): T;
  35428. /**
  35429. * Polyfill for setImmediate
  35430. * @param action defines the action to execute after the current execution block
  35431. */
  35432. static SetImmediate(action: () => void): void;
  35433. /**
  35434. * Function indicating if a number is an exponent of 2
  35435. * @param value defines the value to test
  35436. * @returns true if the value is an exponent of 2
  35437. */
  35438. static IsExponentOfTwo(value: number): boolean;
  35439. private static _tmpFloatArray;
  35440. /**
  35441. * Returns the nearest 32-bit single precision float representation of a Number
  35442. * @param value A Number. If the parameter is of a different type, it will get converted
  35443. * to a number or to NaN if it cannot be converted
  35444. * @returns number
  35445. */
  35446. static FloatRound(value: number): number;
  35447. /**
  35448. * Extracts the filename from a path
  35449. * @param path defines the path to use
  35450. * @returns the filename
  35451. */
  35452. static GetFilename(path: string): string;
  35453. /**
  35454. * Extracts the "folder" part of a path (everything before the filename).
  35455. * @param uri The URI to extract the info from
  35456. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35457. * @returns The "folder" part of the path
  35458. */
  35459. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35460. /**
  35461. * Extracts text content from a DOM element hierarchy
  35462. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35463. */
  35464. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35465. /**
  35466. * Convert an angle in radians to degrees
  35467. * @param angle defines the angle to convert
  35468. * @returns the angle in degrees
  35469. */
  35470. static ToDegrees(angle: number): number;
  35471. /**
  35472. * Convert an angle in degrees to radians
  35473. * @param angle defines the angle to convert
  35474. * @returns the angle in radians
  35475. */
  35476. static ToRadians(angle: number): number;
  35477. /**
  35478. * Returns an array if obj is not an array
  35479. * @param obj defines the object to evaluate as an array
  35480. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35481. * @returns either obj directly if obj is an array or a new array containing obj
  35482. */
  35483. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35484. /**
  35485. * Gets the pointer prefix to use
  35486. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35487. */
  35488. static GetPointerPrefix(): string;
  35489. /**
  35490. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35491. * @param url define the url we are trying
  35492. * @param element define the dom element where to configure the cors policy
  35493. */
  35494. static SetCorsBehavior(url: string | string[], element: {
  35495. crossOrigin: string | null;
  35496. }): void;
  35497. /**
  35498. * Removes unwanted characters from an url
  35499. * @param url defines the url to clean
  35500. * @returns the cleaned url
  35501. */
  35502. static CleanUrl(url: string): string;
  35503. /**
  35504. * Gets or sets a function used to pre-process url before using them to load assets
  35505. */
  35506. static get PreprocessUrl(): (url: string) => string;
  35507. static set PreprocessUrl(processor: (url: string) => string);
  35508. /**
  35509. * Loads an image as an HTMLImageElement.
  35510. * @param input url string, ArrayBuffer, or Blob to load
  35511. * @param onLoad callback called when the image successfully loads
  35512. * @param onError callback called when the image fails to load
  35513. * @param offlineProvider offline provider for caching
  35514. * @param mimeType optional mime type
  35515. * @returns the HTMLImageElement of the loaded image
  35516. */
  35517. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35518. /**
  35519. * Loads a file from a url
  35520. * @param url url string, ArrayBuffer, or Blob to load
  35521. * @param onSuccess callback called when the file successfully loads
  35522. * @param onProgress callback called while file is loading (if the server supports this mode)
  35523. * @param offlineProvider defines the offline provider for caching
  35524. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35525. * @param onError callback called when the file fails to load
  35526. * @returns a file request object
  35527. */
  35528. 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;
  35529. /**
  35530. * Loads a file from a url
  35531. * @param url the file url to load
  35532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35533. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35534. */
  35535. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35536. /**
  35537. * Load a script (identified by an url). When the url returns, the
  35538. * content of this file is added into a new script element, attached to the DOM (body element)
  35539. * @param scriptUrl defines the url of the script to laod
  35540. * @param onSuccess defines the callback called when the script is loaded
  35541. * @param onError defines the callback to call if an error occurs
  35542. * @param scriptId defines the id of the script element
  35543. */
  35544. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35545. /**
  35546. * Load an asynchronous script (identified by an url). When the url returns, the
  35547. * content of this file is added into a new script element, attached to the DOM (body element)
  35548. * @param scriptUrl defines the url of the script to laod
  35549. * @param scriptId defines the id of the script element
  35550. * @returns a promise request object
  35551. */
  35552. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35553. /**
  35554. * Loads a file from a blob
  35555. * @param fileToLoad defines the blob to use
  35556. * @param callback defines the callback to call when data is loaded
  35557. * @param progressCallback defines the callback to call during loading process
  35558. * @returns a file request object
  35559. */
  35560. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35561. /**
  35562. * Reads a file from a File object
  35563. * @param file defines the file to load
  35564. * @param onSuccess defines the callback to call when data is loaded
  35565. * @param onProgress defines the callback to call during loading process
  35566. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35567. * @param onError defines the callback to call when an error occurs
  35568. * @returns a file request object
  35569. */
  35570. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35571. /**
  35572. * Creates a data url from a given string content
  35573. * @param content defines the content to convert
  35574. * @returns the new data url link
  35575. */
  35576. static FileAsURL(content: string): string;
  35577. /**
  35578. * Format the given number to a specific decimal format
  35579. * @param value defines the number to format
  35580. * @param decimals defines the number of decimals to use
  35581. * @returns the formatted string
  35582. */
  35583. static Format(value: number, decimals?: number): string;
  35584. /**
  35585. * Tries to copy an object by duplicating every property
  35586. * @param source defines the source object
  35587. * @param destination defines the target object
  35588. * @param doNotCopyList defines a list of properties to avoid
  35589. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35590. */
  35591. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35592. /**
  35593. * Gets a boolean indicating if the given object has no own property
  35594. * @param obj defines the object to test
  35595. * @returns true if object has no own property
  35596. */
  35597. static IsEmpty(obj: any): boolean;
  35598. /**
  35599. * Function used to register events at window level
  35600. * @param windowElement defines the Window object to use
  35601. * @param events defines the events to register
  35602. */
  35603. static RegisterTopRootEvents(windowElement: Window, events: {
  35604. name: string;
  35605. handler: Nullable<(e: FocusEvent) => any>;
  35606. }[]): void;
  35607. /**
  35608. * Function used to unregister events from window level
  35609. * @param windowElement defines the Window object to use
  35610. * @param events defines the events to unregister
  35611. */
  35612. static UnregisterTopRootEvents(windowElement: Window, events: {
  35613. name: string;
  35614. handler: Nullable<(e: FocusEvent) => any>;
  35615. }[]): void;
  35616. /**
  35617. * @ignore
  35618. */
  35619. static _ScreenshotCanvas: HTMLCanvasElement;
  35620. /**
  35621. * Dumps the current bound framebuffer
  35622. * @param width defines the rendering width
  35623. * @param height defines the rendering height
  35624. * @param engine defines the hosting engine
  35625. * @param successCallback defines the callback triggered once the data are available
  35626. * @param mimeType defines the mime type of the result
  35627. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35628. */
  35629. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35630. /**
  35631. * Converts the canvas data to blob.
  35632. * This acts as a polyfill for browsers not supporting the to blob function.
  35633. * @param canvas Defines the canvas to extract the data from
  35634. * @param successCallback Defines the callback triggered once the data are available
  35635. * @param mimeType Defines the mime type of the result
  35636. */
  35637. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35638. /**
  35639. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35640. * @param successCallback defines the callback triggered once the data are available
  35641. * @param mimeType defines the mime type of the result
  35642. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35643. */
  35644. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35645. /**
  35646. * Downloads a blob in the browser
  35647. * @param blob defines the blob to download
  35648. * @param fileName defines the name of the downloaded file
  35649. */
  35650. static Download(blob: Blob, fileName: string): void;
  35651. /**
  35652. * Captures a screenshot of the current rendering
  35653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35654. * @param engine defines the rendering engine
  35655. * @param camera defines the source camera
  35656. * @param size This parameter can be set to a single number or to an object with the
  35657. * following (optional) properties: precision, width, height. If a single number is passed,
  35658. * it will be used for both width and height. If an object is passed, the screenshot size
  35659. * will be derived from the parameters. The precision property is a multiplier allowing
  35660. * rendering at a higher or lower resolution
  35661. * @param successCallback defines the callback receives a single parameter which contains the
  35662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35663. * src parameter of an <img> to display it
  35664. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35665. * Check your browser for supported MIME types
  35666. */
  35667. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35668. /**
  35669. * Captures a screenshot of the current rendering
  35670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35671. * @param engine defines the rendering engine
  35672. * @param camera defines the source camera
  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 mimeType defines the MIME type of the screenshot image (default: image/png).
  35679. * Check your browser for supported MIME types
  35680. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35681. * to the src parameter of an <img> to display it
  35682. */
  35683. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35684. /**
  35685. * Generates an image screenshot from the specified camera.
  35686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35687. * @param engine The engine to use for rendering
  35688. * @param camera The camera to use for rendering
  35689. * @param size This parameter can be set to a single number or to an object with the
  35690. * following (optional) properties: precision, width, height. If a single number is passed,
  35691. * it will be used for both width and height. If an object is passed, the screenshot size
  35692. * will be derived from the parameters. The precision property is a multiplier allowing
  35693. * rendering at a higher or lower resolution
  35694. * @param successCallback The callback receives a single parameter which contains the
  35695. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35696. * src parameter of an <img> to display it
  35697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35698. * Check your browser for supported MIME types
  35699. * @param samples Texture samples (default: 1)
  35700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35701. * @param fileName A name for for the downloaded file.
  35702. */
  35703. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35704. /**
  35705. * Generates an image screenshot from the specified camera.
  35706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35707. * @param engine The engine to use for rendering
  35708. * @param camera The camera to use for rendering
  35709. * @param size This parameter can be set to a single number or to an object with the
  35710. * following (optional) properties: precision, width, height. If a single number is passed,
  35711. * it will be used for both width and height. If an object is passed, the screenshot size
  35712. * will be derived from the parameters. The precision property is a multiplier allowing
  35713. * rendering at a higher or lower resolution
  35714. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35715. * Check your browser for supported MIME types
  35716. * @param samples Texture samples (default: 1)
  35717. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35718. * @param fileName A name for for the downloaded file.
  35719. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35720. * to the src parameter of an <img> to display it
  35721. */
  35722. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35723. /**
  35724. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35725. * Be aware Math.random() could cause collisions, but:
  35726. * "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"
  35727. * @returns a pseudo random id
  35728. */
  35729. static RandomId(): string;
  35730. /**
  35731. * Test if the given uri is a base64 string
  35732. * @param uri The uri to test
  35733. * @return True if the uri is a base64 string or false otherwise
  35734. */
  35735. static IsBase64(uri: string): boolean;
  35736. /**
  35737. * Decode the given base64 uri.
  35738. * @param uri The uri to decode
  35739. * @return The decoded base64 data.
  35740. */
  35741. static DecodeBase64(uri: string): ArrayBuffer;
  35742. /**
  35743. * Gets the absolute url.
  35744. * @param url the input url
  35745. * @return the absolute url
  35746. */
  35747. static GetAbsoluteUrl(url: string): string;
  35748. /**
  35749. * No log
  35750. */
  35751. static readonly NoneLogLevel: number;
  35752. /**
  35753. * Only message logs
  35754. */
  35755. static readonly MessageLogLevel: number;
  35756. /**
  35757. * Only warning logs
  35758. */
  35759. static readonly WarningLogLevel: number;
  35760. /**
  35761. * Only error logs
  35762. */
  35763. static readonly ErrorLogLevel: number;
  35764. /**
  35765. * All logs
  35766. */
  35767. static readonly AllLogLevel: number;
  35768. /**
  35769. * Gets a value indicating the number of loading errors
  35770. * @ignorenaming
  35771. */
  35772. static get errorsCount(): number;
  35773. /**
  35774. * Callback called when a new log is added
  35775. */
  35776. static OnNewCacheEntry: (entry: string) => void;
  35777. /**
  35778. * Log a message to the console
  35779. * @param message defines the message to log
  35780. */
  35781. static Log(message: string): void;
  35782. /**
  35783. * Write a warning message to the console
  35784. * @param message defines the message to log
  35785. */
  35786. static Warn(message: string): void;
  35787. /**
  35788. * Write an error message to the console
  35789. * @param message defines the message to log
  35790. */
  35791. static Error(message: string): void;
  35792. /**
  35793. * Gets current log cache (list of logs)
  35794. */
  35795. static get LogCache(): string;
  35796. /**
  35797. * Clears the log cache
  35798. */
  35799. static ClearLogCache(): void;
  35800. /**
  35801. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35802. */
  35803. static set LogLevels(level: number);
  35804. /**
  35805. * Checks if the window object exists
  35806. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35807. */
  35808. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35809. /**
  35810. * No performance log
  35811. */
  35812. static readonly PerformanceNoneLogLevel: number;
  35813. /**
  35814. * Use user marks to log performance
  35815. */
  35816. static readonly PerformanceUserMarkLogLevel: number;
  35817. /**
  35818. * Log performance to the console
  35819. */
  35820. static readonly PerformanceConsoleLogLevel: number;
  35821. private static _performance;
  35822. /**
  35823. * Sets the current performance log level
  35824. */
  35825. static set PerformanceLogLevel(level: number);
  35826. private static _StartPerformanceCounterDisabled;
  35827. private static _EndPerformanceCounterDisabled;
  35828. private static _StartUserMark;
  35829. private static _EndUserMark;
  35830. private static _StartPerformanceConsole;
  35831. private static _EndPerformanceConsole;
  35832. /**
  35833. * Starts a performance counter
  35834. */
  35835. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35836. /**
  35837. * Ends a specific performance coutner
  35838. */
  35839. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35840. /**
  35841. * Gets either window.performance.now() if supported or Date.now() else
  35842. */
  35843. static get Now(): number;
  35844. /**
  35845. * This method will return the name of the class used to create the instance of the given object.
  35846. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35847. * @param object the object to get the class name from
  35848. * @param isType defines if the object is actually a type
  35849. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35850. */
  35851. static GetClassName(object: any, isType?: boolean): string;
  35852. /**
  35853. * Gets the first element of an array satisfying a given predicate
  35854. * @param array defines the array to browse
  35855. * @param predicate defines the predicate to use
  35856. * @returns null if not found or the element
  35857. */
  35858. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35859. /**
  35860. * This method will return the name of the full name of the class, including its owning module (if any).
  35861. * 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).
  35862. * @param object the object to get the class name from
  35863. * @param isType defines if the object is actually a type
  35864. * @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.
  35865. * @ignorenaming
  35866. */
  35867. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35868. /**
  35869. * Returns a promise that resolves after the given amount of time.
  35870. * @param delay Number of milliseconds to delay
  35871. * @returns Promise that resolves after the given amount of time
  35872. */
  35873. static DelayAsync(delay: number): Promise<void>;
  35874. /**
  35875. * Utility function to detect if the current user agent is Safari
  35876. * @returns whether or not the current user agent is safari
  35877. */
  35878. static IsSafari(): boolean;
  35879. }
  35880. /**
  35881. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35882. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35883. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35884. * @param name The name of the class, case should be preserved
  35885. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35886. */
  35887. export function className(name: string, module?: string): (target: Object) => void;
  35888. /**
  35889. * An implementation of a loop for asynchronous functions.
  35890. */
  35891. export class AsyncLoop {
  35892. /**
  35893. * Defines the number of iterations for the loop
  35894. */
  35895. iterations: number;
  35896. /**
  35897. * Defines the current index of the loop.
  35898. */
  35899. index: number;
  35900. private _done;
  35901. private _fn;
  35902. private _successCallback;
  35903. /**
  35904. * Constructor.
  35905. * @param iterations the number of iterations.
  35906. * @param func the function to run each iteration
  35907. * @param successCallback the callback that will be called upon succesful execution
  35908. * @param offset starting offset.
  35909. */
  35910. constructor(
  35911. /**
  35912. * Defines the number of iterations for the loop
  35913. */
  35914. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35915. /**
  35916. * Execute the next iteration. Must be called after the last iteration was finished.
  35917. */
  35918. executeNext(): void;
  35919. /**
  35920. * Break the loop and run the success callback.
  35921. */
  35922. breakLoop(): void;
  35923. /**
  35924. * Create and run an async loop.
  35925. * @param iterations the number of iterations.
  35926. * @param fn the function to run each iteration
  35927. * @param successCallback the callback that will be called upon succesful execution
  35928. * @param offset starting offset.
  35929. * @returns the created async loop object
  35930. */
  35931. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35932. /**
  35933. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35934. * @param iterations total number of iterations
  35935. * @param syncedIterations number of synchronous iterations in each async iteration.
  35936. * @param fn the function to call each iteration.
  35937. * @param callback a success call back that will be called when iterating stops.
  35938. * @param breakFunction a break condition (optional)
  35939. * @param timeout timeout settings for the setTimeout function. default - 0.
  35940. * @returns the created async loop object
  35941. */
  35942. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35943. }
  35944. }
  35945. declare module "babylonjs/Misc/stringDictionary" {
  35946. import { Nullable } from "babylonjs/types";
  35947. /**
  35948. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35949. * The underlying implementation relies on an associative array to ensure the best performances.
  35950. * The value can be anything including 'null' but except 'undefined'
  35951. */
  35952. export class StringDictionary<T> {
  35953. /**
  35954. * This will clear this dictionary and copy the content from the 'source' one.
  35955. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35956. * @param source the dictionary to take the content from and copy to this dictionary
  35957. */
  35958. copyFrom(source: StringDictionary<T>): void;
  35959. /**
  35960. * Get a value based from its key
  35961. * @param key the given key to get the matching value from
  35962. * @return the value if found, otherwise undefined is returned
  35963. */
  35964. get(key: string): T | undefined;
  35965. /**
  35966. * Get a value from its key or add it if it doesn't exist.
  35967. * This method will ensure you that a given key/data will be present in the dictionary.
  35968. * @param key the given key to get the matching value from
  35969. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35970. * The factory will only be invoked if there's no data for the given key.
  35971. * @return the value corresponding to the key.
  35972. */
  35973. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35974. /**
  35975. * Get a value from its key if present in the dictionary otherwise add it
  35976. * @param key the key to get the value from
  35977. * @param val if there's no such key/value pair in the dictionary add it with this value
  35978. * @return the value corresponding to the key
  35979. */
  35980. getOrAdd(key: string, val: T): T;
  35981. /**
  35982. * Check if there's a given key in the dictionary
  35983. * @param key the key to check for
  35984. * @return true if the key is present, false otherwise
  35985. */
  35986. contains(key: string): boolean;
  35987. /**
  35988. * Add a new key and its corresponding value
  35989. * @param key the key to add
  35990. * @param value the value corresponding to the key
  35991. * @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
  35992. */
  35993. add(key: string, value: T): boolean;
  35994. /**
  35995. * Update a specific value associated to a key
  35996. * @param key defines the key to use
  35997. * @param value defines the value to store
  35998. * @returns true if the value was updated (or false if the key was not found)
  35999. */
  36000. set(key: string, value: T): boolean;
  36001. /**
  36002. * Get the element of the given key and remove it from the dictionary
  36003. * @param key defines the key to search
  36004. * @returns the value associated with the key or null if not found
  36005. */
  36006. getAndRemove(key: string): Nullable<T>;
  36007. /**
  36008. * Remove a key/value from the dictionary.
  36009. * @param key the key to remove
  36010. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36011. */
  36012. remove(key: string): boolean;
  36013. /**
  36014. * Clear the whole content of the dictionary
  36015. */
  36016. clear(): void;
  36017. /**
  36018. * Gets the current count
  36019. */
  36020. get count(): number;
  36021. /**
  36022. * Execute a callback on each key/val of the dictionary.
  36023. * Note that you can remove any element in this dictionary in the callback implementation
  36024. * @param callback the callback to execute on a given key/value pair
  36025. */
  36026. forEach(callback: (key: string, val: T) => void): void;
  36027. /**
  36028. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36029. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36030. * Note that you can remove any element in this dictionary in the callback implementation
  36031. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36032. * @returns the first item
  36033. */
  36034. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36035. private _count;
  36036. private _data;
  36037. }
  36038. }
  36039. declare module "babylonjs/Collisions/collisionCoordinator" {
  36040. import { Nullable } from "babylonjs/types";
  36041. import { Scene } from "babylonjs/scene";
  36042. import { Vector3 } from "babylonjs/Maths/math.vector";
  36043. import { Collider } from "babylonjs/Collisions/collider";
  36044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36045. /** @hidden */
  36046. export interface ICollisionCoordinator {
  36047. createCollider(): Collider;
  36048. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36049. init(scene: Scene): void;
  36050. }
  36051. /** @hidden */
  36052. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36053. private _scene;
  36054. private _scaledPosition;
  36055. private _scaledVelocity;
  36056. private _finalPosition;
  36057. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36058. createCollider(): Collider;
  36059. init(scene: Scene): void;
  36060. private _collideWithWorld;
  36061. }
  36062. }
  36063. declare module "babylonjs/Inputs/scene.inputManager" {
  36064. import { Nullable } from "babylonjs/types";
  36065. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36066. import { Vector2 } from "babylonjs/Maths/math.vector";
  36067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36068. import { Scene } from "babylonjs/scene";
  36069. /**
  36070. * Class used to manage all inputs for the scene.
  36071. */
  36072. export class InputManager {
  36073. /** The distance in pixel that you have to move to prevent some events */
  36074. static DragMovementThreshold: number;
  36075. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36076. static LongPressDelay: number;
  36077. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36078. static DoubleClickDelay: number;
  36079. /** If you need to check double click without raising a single click at first click, enable this flag */
  36080. static ExclusiveDoubleClickMode: boolean;
  36081. private _wheelEventName;
  36082. private _onPointerMove;
  36083. private _onPointerDown;
  36084. private _onPointerUp;
  36085. private _initClickEvent;
  36086. private _initActionManager;
  36087. private _delayedSimpleClick;
  36088. private _delayedSimpleClickTimeout;
  36089. private _previousDelayedSimpleClickTimeout;
  36090. private _meshPickProceed;
  36091. private _previousButtonPressed;
  36092. private _currentPickResult;
  36093. private _previousPickResult;
  36094. private _totalPointersPressed;
  36095. private _doubleClickOccured;
  36096. private _pointerOverMesh;
  36097. private _pickedDownMesh;
  36098. private _pickedUpMesh;
  36099. private _pointerX;
  36100. private _pointerY;
  36101. private _unTranslatedPointerX;
  36102. private _unTranslatedPointerY;
  36103. private _startingPointerPosition;
  36104. private _previousStartingPointerPosition;
  36105. private _startingPointerTime;
  36106. private _previousStartingPointerTime;
  36107. private _pointerCaptures;
  36108. private _onKeyDown;
  36109. private _onKeyUp;
  36110. private _onCanvasFocusObserver;
  36111. private _onCanvasBlurObserver;
  36112. private _scene;
  36113. /**
  36114. * Creates a new InputManager
  36115. * @param scene defines the hosting scene
  36116. */
  36117. constructor(scene: Scene);
  36118. /**
  36119. * Gets the mesh that is currently under the pointer
  36120. */
  36121. get meshUnderPointer(): Nullable<AbstractMesh>;
  36122. /**
  36123. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36124. */
  36125. get unTranslatedPointer(): Vector2;
  36126. /**
  36127. * Gets or sets the current on-screen X position of the pointer
  36128. */
  36129. get pointerX(): number;
  36130. set pointerX(value: number);
  36131. /**
  36132. * Gets or sets the current on-screen Y position of the pointer
  36133. */
  36134. get pointerY(): number;
  36135. set pointerY(value: number);
  36136. private _updatePointerPosition;
  36137. private _processPointerMove;
  36138. private _setRayOnPointerInfo;
  36139. private _checkPrePointerObservable;
  36140. /**
  36141. * Use this method to simulate a pointer move on a mesh
  36142. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36143. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36144. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36145. */
  36146. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36147. /**
  36148. * Use this method to simulate a pointer down on a mesh
  36149. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36150. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36151. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36152. */
  36153. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36154. private _processPointerDown;
  36155. /** @hidden */
  36156. _isPointerSwiping(): boolean;
  36157. /**
  36158. * Use this method to simulate a pointer up on a mesh
  36159. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36160. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36161. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36162. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36163. */
  36164. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36165. private _processPointerUp;
  36166. /**
  36167. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36168. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36169. * @returns true if the pointer was captured
  36170. */
  36171. isPointerCaptured(pointerId?: number): boolean;
  36172. /**
  36173. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36174. * @param attachUp defines if you want to attach events to pointerup
  36175. * @param attachDown defines if you want to attach events to pointerdown
  36176. * @param attachMove defines if you want to attach events to pointermove
  36177. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36178. */
  36179. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36180. /**
  36181. * Detaches all event handlers
  36182. */
  36183. detachControl(): void;
  36184. /**
  36185. * Force the value of meshUnderPointer
  36186. * @param mesh defines the mesh to use
  36187. */
  36188. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36189. /**
  36190. * Gets the mesh under the pointer
  36191. * @returns a Mesh or null if no mesh is under the pointer
  36192. */
  36193. getPointerOverMesh(): Nullable<AbstractMesh>;
  36194. }
  36195. }
  36196. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36197. /**
  36198. * Helper class used to generate session unique ID
  36199. */
  36200. export class UniqueIdGenerator {
  36201. private static _UniqueIdCounter;
  36202. /**
  36203. * Gets an unique (relatively to the current scene) Id
  36204. */
  36205. static get UniqueId(): number;
  36206. }
  36207. }
  36208. declare module "babylonjs/Animations/animationGroup" {
  36209. import { Animatable } from "babylonjs/Animations/animatable";
  36210. import { Animation } from "babylonjs/Animations/animation";
  36211. import { Scene, IDisposable } from "babylonjs/scene";
  36212. import { Observable } from "babylonjs/Misc/observable";
  36213. import { Nullable } from "babylonjs/types";
  36214. import "babylonjs/Animations/animatable";
  36215. /**
  36216. * This class defines the direct association between an animation and a target
  36217. */
  36218. export class TargetedAnimation {
  36219. /**
  36220. * Animation to perform
  36221. */
  36222. animation: Animation;
  36223. /**
  36224. * Target to animate
  36225. */
  36226. target: any;
  36227. /**
  36228. * Serialize the object
  36229. * @returns the JSON object representing the current entity
  36230. */
  36231. serialize(): any;
  36232. }
  36233. /**
  36234. * Use this class to create coordinated animations on multiple targets
  36235. */
  36236. export class AnimationGroup implements IDisposable {
  36237. /** The name of the animation group */
  36238. name: string;
  36239. private _scene;
  36240. private _targetedAnimations;
  36241. private _animatables;
  36242. private _from;
  36243. private _to;
  36244. private _isStarted;
  36245. private _isPaused;
  36246. private _speedRatio;
  36247. private _loopAnimation;
  36248. private _isAdditive;
  36249. /**
  36250. * Gets or sets the unique id of the node
  36251. */
  36252. uniqueId: number;
  36253. /**
  36254. * This observable will notify when one animation have ended
  36255. */
  36256. onAnimationEndObservable: Observable<TargetedAnimation>;
  36257. /**
  36258. * Observer raised when one animation loops
  36259. */
  36260. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36261. /**
  36262. * Observer raised when all animations have looped
  36263. */
  36264. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36265. /**
  36266. * This observable will notify when all animations have ended.
  36267. */
  36268. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36269. /**
  36270. * This observable will notify when all animations have paused.
  36271. */
  36272. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36273. /**
  36274. * This observable will notify when all animations are playing.
  36275. */
  36276. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36277. /**
  36278. * Gets the first frame
  36279. */
  36280. get from(): number;
  36281. /**
  36282. * Gets the last frame
  36283. */
  36284. get to(): number;
  36285. /**
  36286. * Define if the animations are started
  36287. */
  36288. get isStarted(): boolean;
  36289. /**
  36290. * Gets a value indicating that the current group is playing
  36291. */
  36292. get isPlaying(): boolean;
  36293. /**
  36294. * Gets or sets the speed ratio to use for all animations
  36295. */
  36296. get speedRatio(): number;
  36297. /**
  36298. * Gets or sets the speed ratio to use for all animations
  36299. */
  36300. set speedRatio(value: number);
  36301. /**
  36302. * Gets or sets if all animations should loop or not
  36303. */
  36304. get loopAnimation(): boolean;
  36305. set loopAnimation(value: boolean);
  36306. /**
  36307. * Gets or sets if all animations should be evaluated additively
  36308. */
  36309. get isAdditive(): boolean;
  36310. set isAdditive(value: boolean);
  36311. /**
  36312. * Gets the targeted animations for this animation group
  36313. */
  36314. get targetedAnimations(): Array<TargetedAnimation>;
  36315. /**
  36316. * returning the list of animatables controlled by this animation group.
  36317. */
  36318. get animatables(): Array<Animatable>;
  36319. /**
  36320. * Instantiates a new Animation Group.
  36321. * This helps managing several animations at once.
  36322. * @see http://doc.babylonjs.com/how_to/group
  36323. * @param name Defines the name of the group
  36324. * @param scene Defines the scene the group belongs to
  36325. */
  36326. constructor(
  36327. /** The name of the animation group */
  36328. name: string, scene?: Nullable<Scene>);
  36329. /**
  36330. * Add an animation (with its target) in the group
  36331. * @param animation defines the animation we want to add
  36332. * @param target defines the target of the animation
  36333. * @returns the TargetedAnimation object
  36334. */
  36335. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36336. /**
  36337. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36338. * It can add constant keys at begin or end
  36339. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36340. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36341. * @returns the animation group
  36342. */
  36343. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36344. private _animationLoopCount;
  36345. private _animationLoopFlags;
  36346. private _processLoop;
  36347. /**
  36348. * Start all animations on given targets
  36349. * @param loop defines if animations must loop
  36350. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36351. * @param from defines the from key (optional)
  36352. * @param to defines the to key (optional)
  36353. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36354. * @returns the current animation group
  36355. */
  36356. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36357. /**
  36358. * Pause all animations
  36359. * @returns the animation group
  36360. */
  36361. pause(): AnimationGroup;
  36362. /**
  36363. * Play all animations to initial state
  36364. * This function will start() the animations if they were not started or will restart() them if they were paused
  36365. * @param loop defines if animations must loop
  36366. * @returns the animation group
  36367. */
  36368. play(loop?: boolean): AnimationGroup;
  36369. /**
  36370. * Reset all animations to initial state
  36371. * @returns the animation group
  36372. */
  36373. reset(): AnimationGroup;
  36374. /**
  36375. * Restart animations from key 0
  36376. * @returns the animation group
  36377. */
  36378. restart(): AnimationGroup;
  36379. /**
  36380. * Stop all animations
  36381. * @returns the animation group
  36382. */
  36383. stop(): AnimationGroup;
  36384. /**
  36385. * Set animation weight for all animatables
  36386. * @param weight defines the weight to use
  36387. * @return the animationGroup
  36388. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36389. */
  36390. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36391. /**
  36392. * Synchronize and normalize all animatables with a source animatable
  36393. * @param root defines the root animatable to synchronize with
  36394. * @return the animationGroup
  36395. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36396. */
  36397. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36398. /**
  36399. * Goes to a specific frame in this animation group
  36400. * @param frame the frame number to go to
  36401. * @return the animationGroup
  36402. */
  36403. goToFrame(frame: number): AnimationGroup;
  36404. /**
  36405. * Dispose all associated resources
  36406. */
  36407. dispose(): void;
  36408. private _checkAnimationGroupEnded;
  36409. /**
  36410. * Clone the current animation group and returns a copy
  36411. * @param newName defines the name of the new group
  36412. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36413. * @returns the new aniamtion group
  36414. */
  36415. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36416. /**
  36417. * Serializes the animationGroup to an object
  36418. * @returns Serialized object
  36419. */
  36420. serialize(): any;
  36421. /**
  36422. * Returns a new AnimationGroup object parsed from the source provided.
  36423. * @param parsedAnimationGroup defines the source
  36424. * @param scene defines the scene that will receive the animationGroup
  36425. * @returns a new AnimationGroup
  36426. */
  36427. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36428. /**
  36429. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36430. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36431. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36432. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36433. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36434. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36435. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36436. */
  36437. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36438. /**
  36439. * Returns the string "AnimationGroup"
  36440. * @returns "AnimationGroup"
  36441. */
  36442. getClassName(): string;
  36443. /**
  36444. * Creates a detailled string about the object
  36445. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36446. * @returns a string representing the object
  36447. */
  36448. toString(fullDetails?: boolean): string;
  36449. }
  36450. }
  36451. declare module "babylonjs/scene" {
  36452. import { Nullable } from "babylonjs/types";
  36453. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36454. import { Observable } from "babylonjs/Misc/observable";
  36455. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36456. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36457. import { Geometry } from "babylonjs/Meshes/geometry";
  36458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36461. import { Mesh } from "babylonjs/Meshes/mesh";
  36462. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36463. import { Bone } from "babylonjs/Bones/bone";
  36464. import { Skeleton } from "babylonjs/Bones/skeleton";
  36465. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36466. import { Camera } from "babylonjs/Cameras/camera";
  36467. import { AbstractScene } from "babylonjs/abstractScene";
  36468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36470. import { Material } from "babylonjs/Materials/material";
  36471. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36472. import { Effect } from "babylonjs/Materials/effect";
  36473. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36474. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36475. import { Light } from "babylonjs/Lights/light";
  36476. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36477. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36478. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36479. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36480. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36481. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36482. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36483. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36484. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36485. import { Engine } from "babylonjs/Engines/engine";
  36486. import { Node } from "babylonjs/node";
  36487. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36488. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36489. import { WebRequest } from "babylonjs/Misc/webRequest";
  36490. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36491. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36492. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36493. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36494. import { Plane } from "babylonjs/Maths/math.plane";
  36495. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36496. import { Ray } from "babylonjs/Culling/ray";
  36497. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36498. import { Animation } from "babylonjs/Animations/animation";
  36499. import { Animatable } from "babylonjs/Animations/animatable";
  36500. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36502. import { Collider } from "babylonjs/Collisions/collider";
  36503. /**
  36504. * Define an interface for all classes that will hold resources
  36505. */
  36506. export interface IDisposable {
  36507. /**
  36508. * Releases all held resources
  36509. */
  36510. dispose(): void;
  36511. }
  36512. /** Interface defining initialization parameters for Scene class */
  36513. export interface SceneOptions {
  36514. /**
  36515. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36516. * It will improve performance when the number of geometries becomes important.
  36517. */
  36518. useGeometryUniqueIdsMap?: boolean;
  36519. /**
  36520. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36521. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36522. */
  36523. useMaterialMeshMap?: boolean;
  36524. /**
  36525. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36526. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36527. */
  36528. useClonedMeshMap?: boolean;
  36529. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36530. virtual?: boolean;
  36531. }
  36532. /**
  36533. * Represents a scene to be rendered by the engine.
  36534. * @see http://doc.babylonjs.com/features/scene
  36535. */
  36536. export class Scene extends AbstractScene implements IAnimatable {
  36537. /** The fog is deactivated */
  36538. static readonly FOGMODE_NONE: number;
  36539. /** The fog density is following an exponential function */
  36540. static readonly FOGMODE_EXP: number;
  36541. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36542. static readonly FOGMODE_EXP2: number;
  36543. /** The fog density is following a linear function. */
  36544. static readonly FOGMODE_LINEAR: number;
  36545. /**
  36546. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36547. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36548. */
  36549. static MinDeltaTime: number;
  36550. /**
  36551. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36552. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36553. */
  36554. static MaxDeltaTime: number;
  36555. /**
  36556. * Factory used to create the default material.
  36557. * @param name The name of the material to create
  36558. * @param scene The scene to create the material for
  36559. * @returns The default material
  36560. */
  36561. static DefaultMaterialFactory(scene: Scene): Material;
  36562. /**
  36563. * Factory used to create the a collision coordinator.
  36564. * @returns The collision coordinator
  36565. */
  36566. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36567. /** @hidden */
  36568. _inputManager: InputManager;
  36569. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36570. cameraToUseForPointers: Nullable<Camera>;
  36571. /** @hidden */
  36572. readonly _isScene: boolean;
  36573. /** @hidden */
  36574. _blockEntityCollection: boolean;
  36575. /**
  36576. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36577. */
  36578. autoClear: boolean;
  36579. /**
  36580. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36581. */
  36582. autoClearDepthAndStencil: boolean;
  36583. /**
  36584. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36585. */
  36586. clearColor: Color4;
  36587. /**
  36588. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36589. */
  36590. ambientColor: Color3;
  36591. /**
  36592. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36593. * It should only be one of the following (if not the default embedded one):
  36594. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36595. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36596. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36597. * The material properties need to be setup according to the type of texture in use.
  36598. */
  36599. environmentBRDFTexture: BaseTexture;
  36600. /** @hidden */
  36601. protected _environmentTexture: Nullable<BaseTexture>;
  36602. /**
  36603. * Texture used in all pbr material as the reflection texture.
  36604. * As in the majority of the scene they are the same (exception for multi room and so on),
  36605. * this is easier to reference from here than from all the materials.
  36606. */
  36607. get environmentTexture(): Nullable<BaseTexture>;
  36608. /**
  36609. * Texture used in all pbr material as the reflection texture.
  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 environmentTexture(value: Nullable<BaseTexture>);
  36614. /** @hidden */
  36615. protected _environmentIntensity: number;
  36616. /**
  36617. * Intensity of the environment in all pbr material.
  36618. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36619. * As in the majority of the scene they are the same (exception for multi room and so on),
  36620. * this is easier to reference from here than from all the materials.
  36621. */
  36622. get environmentIntensity(): number;
  36623. /**
  36624. * Intensity of the environment in all pbr material.
  36625. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36626. * As in the majority of the scene they are the same (exception for multi room and so on),
  36627. * this is easier to set here than in all the materials.
  36628. */
  36629. set environmentIntensity(value: number);
  36630. /** @hidden */
  36631. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36632. /**
  36633. * Default image processing configuration used either in the rendering
  36634. * Forward main pass or through the imageProcessingPostProcess if present.
  36635. * As in the majority of the scene they are the same (exception for multi camera),
  36636. * this is easier to reference from here than from all the materials and post process.
  36637. *
  36638. * No setter as we it is a shared configuration, you can set the values instead.
  36639. */
  36640. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36641. private _forceWireframe;
  36642. /**
  36643. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36644. */
  36645. set forceWireframe(value: boolean);
  36646. get forceWireframe(): boolean;
  36647. private _skipFrustumClipping;
  36648. /**
  36649. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36650. */
  36651. set skipFrustumClipping(value: boolean);
  36652. get skipFrustumClipping(): boolean;
  36653. private _forcePointsCloud;
  36654. /**
  36655. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36656. */
  36657. set forcePointsCloud(value: boolean);
  36658. get forcePointsCloud(): boolean;
  36659. /**
  36660. * Gets or sets the active clipplane 1
  36661. */
  36662. clipPlane: Nullable<Plane>;
  36663. /**
  36664. * Gets or sets the active clipplane 2
  36665. */
  36666. clipPlane2: Nullable<Plane>;
  36667. /**
  36668. * Gets or sets the active clipplane 3
  36669. */
  36670. clipPlane3: Nullable<Plane>;
  36671. /**
  36672. * Gets or sets the active clipplane 4
  36673. */
  36674. clipPlane4: Nullable<Plane>;
  36675. /**
  36676. * Gets or sets the active clipplane 5
  36677. */
  36678. clipPlane5: Nullable<Plane>;
  36679. /**
  36680. * Gets or sets the active clipplane 6
  36681. */
  36682. clipPlane6: Nullable<Plane>;
  36683. /**
  36684. * Gets or sets a boolean indicating if animations are enabled
  36685. */
  36686. animationsEnabled: boolean;
  36687. private _animationPropertiesOverride;
  36688. /**
  36689. * Gets or sets the animation properties override
  36690. */
  36691. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36692. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36693. /**
  36694. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36695. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36696. */
  36697. useConstantAnimationDeltaTime: boolean;
  36698. /**
  36699. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36700. * Please note that it requires to run a ray cast through the scene on every frame
  36701. */
  36702. constantlyUpdateMeshUnderPointer: boolean;
  36703. /**
  36704. * Defines the HTML cursor to use when hovering over interactive elements
  36705. */
  36706. hoverCursor: string;
  36707. /**
  36708. * Defines the HTML default cursor to use (empty by default)
  36709. */
  36710. defaultCursor: string;
  36711. /**
  36712. * Defines whether cursors are handled by the scene.
  36713. */
  36714. doNotHandleCursors: boolean;
  36715. /**
  36716. * This is used to call preventDefault() on pointer down
  36717. * in order to block unwanted artifacts like system double clicks
  36718. */
  36719. preventDefaultOnPointerDown: boolean;
  36720. /**
  36721. * This is used to call preventDefault() on pointer up
  36722. * in order to block unwanted artifacts like system double clicks
  36723. */
  36724. preventDefaultOnPointerUp: boolean;
  36725. /**
  36726. * Gets or sets user defined metadata
  36727. */
  36728. metadata: any;
  36729. /**
  36730. * For internal use only. Please do not use.
  36731. */
  36732. reservedDataStore: any;
  36733. /**
  36734. * Gets the name of the plugin used to load this scene (null by default)
  36735. */
  36736. loadingPluginName: string;
  36737. /**
  36738. * Use this array to add regular expressions used to disable offline support for specific urls
  36739. */
  36740. disableOfflineSupportExceptionRules: RegExp[];
  36741. /**
  36742. * An event triggered when the scene is disposed.
  36743. */
  36744. onDisposeObservable: Observable<Scene>;
  36745. private _onDisposeObserver;
  36746. /** Sets a function to be executed when this scene is disposed. */
  36747. set onDispose(callback: () => void);
  36748. /**
  36749. * An event triggered before rendering the scene (right after animations and physics)
  36750. */
  36751. onBeforeRenderObservable: Observable<Scene>;
  36752. private _onBeforeRenderObserver;
  36753. /** Sets a function to be executed before rendering this scene */
  36754. set beforeRender(callback: Nullable<() => void>);
  36755. /**
  36756. * An event triggered after rendering the scene
  36757. */
  36758. onAfterRenderObservable: Observable<Scene>;
  36759. /**
  36760. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36761. */
  36762. onAfterRenderCameraObservable: Observable<Camera>;
  36763. private _onAfterRenderObserver;
  36764. /** Sets a function to be executed after rendering this scene */
  36765. set afterRender(callback: Nullable<() => void>);
  36766. /**
  36767. * An event triggered before animating the scene
  36768. */
  36769. onBeforeAnimationsObservable: Observable<Scene>;
  36770. /**
  36771. * An event triggered after animations processing
  36772. */
  36773. onAfterAnimationsObservable: Observable<Scene>;
  36774. /**
  36775. * An event triggered before draw calls are ready to be sent
  36776. */
  36777. onBeforeDrawPhaseObservable: Observable<Scene>;
  36778. /**
  36779. * An event triggered after draw calls have been sent
  36780. */
  36781. onAfterDrawPhaseObservable: Observable<Scene>;
  36782. /**
  36783. * An event triggered when the scene is ready
  36784. */
  36785. onReadyObservable: Observable<Scene>;
  36786. /**
  36787. * An event triggered before rendering a camera
  36788. */
  36789. onBeforeCameraRenderObservable: Observable<Camera>;
  36790. private _onBeforeCameraRenderObserver;
  36791. /** Sets a function to be executed before rendering a camera*/
  36792. set beforeCameraRender(callback: () => void);
  36793. /**
  36794. * An event triggered after rendering a camera
  36795. */
  36796. onAfterCameraRenderObservable: Observable<Camera>;
  36797. private _onAfterCameraRenderObserver;
  36798. /** Sets a function to be executed after rendering a camera*/
  36799. set afterCameraRender(callback: () => void);
  36800. /**
  36801. * An event triggered when active meshes evaluation is about to start
  36802. */
  36803. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36804. /**
  36805. * An event triggered when active meshes evaluation is done
  36806. */
  36807. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36808. /**
  36809. * An event triggered when particles rendering is about to start
  36810. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36811. */
  36812. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36813. /**
  36814. * An event triggered when particles rendering is done
  36815. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36816. */
  36817. onAfterParticlesRenderingObservable: Observable<Scene>;
  36818. /**
  36819. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36820. */
  36821. onDataLoadedObservable: Observable<Scene>;
  36822. /**
  36823. * An event triggered when a camera is created
  36824. */
  36825. onNewCameraAddedObservable: Observable<Camera>;
  36826. /**
  36827. * An event triggered when a camera is removed
  36828. */
  36829. onCameraRemovedObservable: Observable<Camera>;
  36830. /**
  36831. * An event triggered when a light is created
  36832. */
  36833. onNewLightAddedObservable: Observable<Light>;
  36834. /**
  36835. * An event triggered when a light is removed
  36836. */
  36837. onLightRemovedObservable: Observable<Light>;
  36838. /**
  36839. * An event triggered when a geometry is created
  36840. */
  36841. onNewGeometryAddedObservable: Observable<Geometry>;
  36842. /**
  36843. * An event triggered when a geometry is removed
  36844. */
  36845. onGeometryRemovedObservable: Observable<Geometry>;
  36846. /**
  36847. * An event triggered when a transform node is created
  36848. */
  36849. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36850. /**
  36851. * An event triggered when a transform node is removed
  36852. */
  36853. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36854. /**
  36855. * An event triggered when a mesh is created
  36856. */
  36857. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36858. /**
  36859. * An event triggered when a mesh is removed
  36860. */
  36861. onMeshRemovedObservable: Observable<AbstractMesh>;
  36862. /**
  36863. * An event triggered when a skeleton is created
  36864. */
  36865. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36866. /**
  36867. * An event triggered when a skeleton is removed
  36868. */
  36869. onSkeletonRemovedObservable: Observable<Skeleton>;
  36870. /**
  36871. * An event triggered when a material is created
  36872. */
  36873. onNewMaterialAddedObservable: Observable<Material>;
  36874. /**
  36875. * An event triggered when a material is removed
  36876. */
  36877. onMaterialRemovedObservable: Observable<Material>;
  36878. /**
  36879. * An event triggered when a texture is created
  36880. */
  36881. onNewTextureAddedObservable: Observable<BaseTexture>;
  36882. /**
  36883. * An event triggered when a texture is removed
  36884. */
  36885. onTextureRemovedObservable: Observable<BaseTexture>;
  36886. /**
  36887. * An event triggered when render targets are about to be rendered
  36888. * Can happen multiple times per frame.
  36889. */
  36890. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36891. /**
  36892. * An event triggered when render targets were rendered.
  36893. * Can happen multiple times per frame.
  36894. */
  36895. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36896. /**
  36897. * An event triggered before calculating deterministic simulation step
  36898. */
  36899. onBeforeStepObservable: Observable<Scene>;
  36900. /**
  36901. * An event triggered after calculating deterministic simulation step
  36902. */
  36903. onAfterStepObservable: Observable<Scene>;
  36904. /**
  36905. * An event triggered when the activeCamera property is updated
  36906. */
  36907. onActiveCameraChanged: Observable<Scene>;
  36908. /**
  36909. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36910. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36911. * 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)
  36912. */
  36913. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36914. /**
  36915. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36916. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36917. * 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)
  36918. */
  36919. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36920. /**
  36921. * This Observable will when a mesh has been imported into the scene.
  36922. */
  36923. onMeshImportedObservable: Observable<AbstractMesh>;
  36924. /**
  36925. * This Observable will when an animation file has been imported into the scene.
  36926. */
  36927. onAnimationFileImportedObservable: Observable<Scene>;
  36928. /**
  36929. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36930. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36931. */
  36932. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36933. /** @hidden */
  36934. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36935. /**
  36936. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36937. */
  36938. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36939. /**
  36940. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36941. */
  36942. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36943. /**
  36944. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36945. */
  36946. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36947. /** Callback called when a pointer move is detected */
  36948. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36949. /** Callback called when a pointer down is detected */
  36950. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36951. /** Callback called when a pointer up is detected */
  36952. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36953. /** Callback called when a pointer pick is detected */
  36954. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36955. /**
  36956. * 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).
  36957. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36958. */
  36959. onPrePointerObservable: Observable<PointerInfoPre>;
  36960. /**
  36961. * Observable event triggered each time an input event is received from the rendering canvas
  36962. */
  36963. onPointerObservable: Observable<PointerInfo>;
  36964. /**
  36965. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36966. */
  36967. get unTranslatedPointer(): Vector2;
  36968. /**
  36969. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36970. */
  36971. static get DragMovementThreshold(): number;
  36972. static set DragMovementThreshold(value: number);
  36973. /**
  36974. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36975. */
  36976. static get LongPressDelay(): number;
  36977. static set LongPressDelay(value: number);
  36978. /**
  36979. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36980. */
  36981. static get DoubleClickDelay(): number;
  36982. static set DoubleClickDelay(value: number);
  36983. /** If you need to check double click without raising a single click at first click, enable this flag */
  36984. static get ExclusiveDoubleClickMode(): boolean;
  36985. static set ExclusiveDoubleClickMode(value: boolean);
  36986. /** @hidden */
  36987. _mirroredCameraPosition: Nullable<Vector3>;
  36988. /**
  36989. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36990. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36991. */
  36992. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36993. /**
  36994. * Observable event triggered each time an keyboard event is received from the hosting window
  36995. */
  36996. onKeyboardObservable: Observable<KeyboardInfo>;
  36997. private _useRightHandedSystem;
  36998. /**
  36999. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37000. */
  37001. set useRightHandedSystem(value: boolean);
  37002. get useRightHandedSystem(): boolean;
  37003. private _timeAccumulator;
  37004. private _currentStepId;
  37005. private _currentInternalStep;
  37006. /**
  37007. * Sets the step Id used by deterministic lock step
  37008. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37009. * @param newStepId defines the step Id
  37010. */
  37011. setStepId(newStepId: number): void;
  37012. /**
  37013. * Gets the step Id used by deterministic lock step
  37014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37015. * @returns the step Id
  37016. */
  37017. getStepId(): number;
  37018. /**
  37019. * Gets the internal step used by deterministic lock step
  37020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37021. * @returns the internal step
  37022. */
  37023. getInternalStep(): number;
  37024. private _fogEnabled;
  37025. /**
  37026. * Gets or sets a boolean indicating if fog is enabled on this scene
  37027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37028. * (Default is true)
  37029. */
  37030. set fogEnabled(value: boolean);
  37031. get fogEnabled(): boolean;
  37032. private _fogMode;
  37033. /**
  37034. * Gets or sets the fog mode to use
  37035. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37036. * | mode | value |
  37037. * | --- | --- |
  37038. * | FOGMODE_NONE | 0 |
  37039. * | FOGMODE_EXP | 1 |
  37040. * | FOGMODE_EXP2 | 2 |
  37041. * | FOGMODE_LINEAR | 3 |
  37042. */
  37043. set fogMode(value: number);
  37044. get fogMode(): number;
  37045. /**
  37046. * Gets or sets the fog color to use
  37047. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37048. * (Default is Color3(0.2, 0.2, 0.3))
  37049. */
  37050. fogColor: Color3;
  37051. /**
  37052. * Gets or sets the fog density to use
  37053. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37054. * (Default is 0.1)
  37055. */
  37056. fogDensity: number;
  37057. /**
  37058. * Gets or sets the fog start distance to use
  37059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37060. * (Default is 0)
  37061. */
  37062. fogStart: number;
  37063. /**
  37064. * Gets or sets the fog end distance to use
  37065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37066. * (Default is 1000)
  37067. */
  37068. fogEnd: number;
  37069. private _shadowsEnabled;
  37070. /**
  37071. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37072. */
  37073. set shadowsEnabled(value: boolean);
  37074. get shadowsEnabled(): boolean;
  37075. private _lightsEnabled;
  37076. /**
  37077. * Gets or sets a boolean indicating if lights are enabled on this scene
  37078. */
  37079. set lightsEnabled(value: boolean);
  37080. get lightsEnabled(): boolean;
  37081. /** All of the active cameras added to this scene. */
  37082. activeCameras: Camera[];
  37083. /** @hidden */
  37084. _activeCamera: Nullable<Camera>;
  37085. /** Gets or sets the current active camera */
  37086. get activeCamera(): Nullable<Camera>;
  37087. set activeCamera(value: Nullable<Camera>);
  37088. private _defaultMaterial;
  37089. /** The default material used on meshes when no material is affected */
  37090. get defaultMaterial(): Material;
  37091. /** The default material used on meshes when no material is affected */
  37092. set defaultMaterial(value: Material);
  37093. private _texturesEnabled;
  37094. /**
  37095. * Gets or sets a boolean indicating if textures are enabled on this scene
  37096. */
  37097. set texturesEnabled(value: boolean);
  37098. get texturesEnabled(): boolean;
  37099. /**
  37100. * Gets or sets a boolean indicating if particles are enabled on this scene
  37101. */
  37102. particlesEnabled: boolean;
  37103. /**
  37104. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37105. */
  37106. spritesEnabled: boolean;
  37107. private _skeletonsEnabled;
  37108. /**
  37109. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37110. */
  37111. set skeletonsEnabled(value: boolean);
  37112. get skeletonsEnabled(): boolean;
  37113. /**
  37114. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37115. */
  37116. lensFlaresEnabled: boolean;
  37117. /**
  37118. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37120. */
  37121. collisionsEnabled: boolean;
  37122. private _collisionCoordinator;
  37123. /** @hidden */
  37124. get collisionCoordinator(): ICollisionCoordinator;
  37125. /**
  37126. * Defines the gravity applied to this scene (used only for collisions)
  37127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37128. */
  37129. gravity: Vector3;
  37130. /**
  37131. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37132. */
  37133. postProcessesEnabled: boolean;
  37134. /**
  37135. * The list of postprocesses added to the scene
  37136. */
  37137. postProcesses: PostProcess[];
  37138. /**
  37139. * Gets the current postprocess manager
  37140. */
  37141. postProcessManager: PostProcessManager;
  37142. /**
  37143. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37144. */
  37145. renderTargetsEnabled: boolean;
  37146. /**
  37147. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37148. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37149. */
  37150. dumpNextRenderTargets: boolean;
  37151. /**
  37152. * The list of user defined render targets added to the scene
  37153. */
  37154. customRenderTargets: RenderTargetTexture[];
  37155. /**
  37156. * Defines if texture loading must be delayed
  37157. * If true, textures will only be loaded when they need to be rendered
  37158. */
  37159. useDelayedTextureLoading: boolean;
  37160. /**
  37161. * Gets the list of meshes imported to the scene through SceneLoader
  37162. */
  37163. importedMeshesFiles: String[];
  37164. /**
  37165. * Gets or sets a boolean indicating if probes are enabled on this scene
  37166. */
  37167. probesEnabled: boolean;
  37168. /**
  37169. * Gets or sets the current offline provider to use to store scene data
  37170. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37171. */
  37172. offlineProvider: IOfflineProvider;
  37173. /**
  37174. * Gets or sets the action manager associated with the scene
  37175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37176. */
  37177. actionManager: AbstractActionManager;
  37178. private _meshesForIntersections;
  37179. /**
  37180. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37181. */
  37182. proceduralTexturesEnabled: boolean;
  37183. private _engine;
  37184. private _totalVertices;
  37185. /** @hidden */
  37186. _activeIndices: PerfCounter;
  37187. /** @hidden */
  37188. _activeParticles: PerfCounter;
  37189. /** @hidden */
  37190. _activeBones: PerfCounter;
  37191. private _animationRatio;
  37192. /** @hidden */
  37193. _animationTimeLast: number;
  37194. /** @hidden */
  37195. _animationTime: number;
  37196. /**
  37197. * Gets or sets a general scale for animation speed
  37198. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37199. */
  37200. animationTimeScale: number;
  37201. /** @hidden */
  37202. _cachedMaterial: Nullable<Material>;
  37203. /** @hidden */
  37204. _cachedEffect: Nullable<Effect>;
  37205. /** @hidden */
  37206. _cachedVisibility: Nullable<number>;
  37207. private _renderId;
  37208. private _frameId;
  37209. private _executeWhenReadyTimeoutId;
  37210. private _intermediateRendering;
  37211. private _viewUpdateFlag;
  37212. private _projectionUpdateFlag;
  37213. /** @hidden */
  37214. _toBeDisposed: Nullable<IDisposable>[];
  37215. private _activeRequests;
  37216. /** @hidden */
  37217. _pendingData: any[];
  37218. private _isDisposed;
  37219. /**
  37220. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37221. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37222. */
  37223. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37224. private _activeMeshes;
  37225. private _processedMaterials;
  37226. private _renderTargets;
  37227. /** @hidden */
  37228. _activeParticleSystems: SmartArray<IParticleSystem>;
  37229. private _activeSkeletons;
  37230. private _softwareSkinnedMeshes;
  37231. private _renderingManager;
  37232. /** @hidden */
  37233. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37234. private _transformMatrix;
  37235. private _sceneUbo;
  37236. /** @hidden */
  37237. _viewMatrix: Matrix;
  37238. private _projectionMatrix;
  37239. /** @hidden */
  37240. _forcedViewPosition: Nullable<Vector3>;
  37241. /** @hidden */
  37242. _frustumPlanes: Plane[];
  37243. /**
  37244. * Gets the list of frustum planes (built from the active camera)
  37245. */
  37246. get frustumPlanes(): Plane[];
  37247. /**
  37248. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37249. * This is useful if there are more lights that the maximum simulteanous authorized
  37250. */
  37251. requireLightSorting: boolean;
  37252. /** @hidden */
  37253. readonly useMaterialMeshMap: boolean;
  37254. /** @hidden */
  37255. readonly useClonedMeshMap: boolean;
  37256. private _externalData;
  37257. private _uid;
  37258. /**
  37259. * @hidden
  37260. * Backing store of defined scene components.
  37261. */
  37262. _components: ISceneComponent[];
  37263. /**
  37264. * @hidden
  37265. * Backing store of defined scene components.
  37266. */
  37267. _serializableComponents: ISceneSerializableComponent[];
  37268. /**
  37269. * List of components to register on the next registration step.
  37270. */
  37271. private _transientComponents;
  37272. /**
  37273. * Registers the transient components if needed.
  37274. */
  37275. private _registerTransientComponents;
  37276. /**
  37277. * @hidden
  37278. * Add a component to the scene.
  37279. * Note that the ccomponent could be registered on th next frame if this is called after
  37280. * the register component stage.
  37281. * @param component Defines the component to add to the scene
  37282. */
  37283. _addComponent(component: ISceneComponent): void;
  37284. /**
  37285. * @hidden
  37286. * Gets a component from the scene.
  37287. * @param name defines the name of the component to retrieve
  37288. * @returns the component or null if not present
  37289. */
  37290. _getComponent(name: string): Nullable<ISceneComponent>;
  37291. /**
  37292. * @hidden
  37293. * Defines the actions happening before camera updates.
  37294. */
  37295. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37296. /**
  37297. * @hidden
  37298. * Defines the actions happening before clear the canvas.
  37299. */
  37300. _beforeClearStage: Stage<SimpleStageAction>;
  37301. /**
  37302. * @hidden
  37303. * Defines the actions when collecting render targets for the frame.
  37304. */
  37305. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37306. /**
  37307. * @hidden
  37308. * Defines the actions happening for one camera in the frame.
  37309. */
  37310. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37311. /**
  37312. * @hidden
  37313. * Defines the actions happening during the per mesh ready checks.
  37314. */
  37315. _isReadyForMeshStage: Stage<MeshStageAction>;
  37316. /**
  37317. * @hidden
  37318. * Defines the actions happening before evaluate active mesh checks.
  37319. */
  37320. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37321. /**
  37322. * @hidden
  37323. * Defines the actions happening during the evaluate sub mesh checks.
  37324. */
  37325. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37326. /**
  37327. * @hidden
  37328. * Defines the actions happening during the active mesh stage.
  37329. */
  37330. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37331. /**
  37332. * @hidden
  37333. * Defines the actions happening during the per camera render target step.
  37334. */
  37335. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37336. /**
  37337. * @hidden
  37338. * Defines the actions happening just before the active camera is drawing.
  37339. */
  37340. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37341. /**
  37342. * @hidden
  37343. * Defines the actions happening just before a render target is drawing.
  37344. */
  37345. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37346. /**
  37347. * @hidden
  37348. * Defines the actions happening just before a rendering group is drawing.
  37349. */
  37350. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37351. /**
  37352. * @hidden
  37353. * Defines the actions happening just before a mesh is drawing.
  37354. */
  37355. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37356. /**
  37357. * @hidden
  37358. * Defines the actions happening just after a mesh has been drawn.
  37359. */
  37360. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37361. /**
  37362. * @hidden
  37363. * Defines the actions happening just after a rendering group has been drawn.
  37364. */
  37365. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37366. /**
  37367. * @hidden
  37368. * Defines the actions happening just after the active camera has been drawn.
  37369. */
  37370. _afterCameraDrawStage: Stage<CameraStageAction>;
  37371. /**
  37372. * @hidden
  37373. * Defines the actions happening just after a render target has been drawn.
  37374. */
  37375. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37376. /**
  37377. * @hidden
  37378. * Defines the actions happening just after rendering all cameras and computing intersections.
  37379. */
  37380. _afterRenderStage: Stage<SimpleStageAction>;
  37381. /**
  37382. * @hidden
  37383. * Defines the actions happening when a pointer move event happens.
  37384. */
  37385. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37386. /**
  37387. * @hidden
  37388. * Defines the actions happening when a pointer down event happens.
  37389. */
  37390. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37391. /**
  37392. * @hidden
  37393. * Defines the actions happening when a pointer up event happens.
  37394. */
  37395. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37396. /**
  37397. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37398. */
  37399. private geometriesByUniqueId;
  37400. /**
  37401. * Creates a new Scene
  37402. * @param engine defines the engine to use to render this scene
  37403. * @param options defines the scene options
  37404. */
  37405. constructor(engine: Engine, options?: SceneOptions);
  37406. /**
  37407. * Gets a string idenfifying the name of the class
  37408. * @returns "Scene" string
  37409. */
  37410. getClassName(): string;
  37411. private _defaultMeshCandidates;
  37412. /**
  37413. * @hidden
  37414. */
  37415. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37416. private _defaultSubMeshCandidates;
  37417. /**
  37418. * @hidden
  37419. */
  37420. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37421. /**
  37422. * Sets the default candidate providers for the scene.
  37423. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37424. * and getCollidingSubMeshCandidates to their default function
  37425. */
  37426. setDefaultCandidateProviders(): void;
  37427. /**
  37428. * Gets the mesh that is currently under the pointer
  37429. */
  37430. get meshUnderPointer(): Nullable<AbstractMesh>;
  37431. /**
  37432. * Gets or sets the current on-screen X position of the pointer
  37433. */
  37434. get pointerX(): number;
  37435. set pointerX(value: number);
  37436. /**
  37437. * Gets or sets the current on-screen Y position of the pointer
  37438. */
  37439. get pointerY(): number;
  37440. set pointerY(value: number);
  37441. /**
  37442. * Gets the cached material (ie. the latest rendered one)
  37443. * @returns the cached material
  37444. */
  37445. getCachedMaterial(): Nullable<Material>;
  37446. /**
  37447. * Gets the cached effect (ie. the latest rendered one)
  37448. * @returns the cached effect
  37449. */
  37450. getCachedEffect(): Nullable<Effect>;
  37451. /**
  37452. * Gets the cached visibility state (ie. the latest rendered one)
  37453. * @returns the cached visibility state
  37454. */
  37455. getCachedVisibility(): Nullable<number>;
  37456. /**
  37457. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37458. * @param material defines the current material
  37459. * @param effect defines the current effect
  37460. * @param visibility defines the current visibility state
  37461. * @returns true if one parameter is not cached
  37462. */
  37463. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37464. /**
  37465. * Gets the engine associated with the scene
  37466. * @returns an Engine
  37467. */
  37468. getEngine(): Engine;
  37469. /**
  37470. * Gets the total number of vertices rendered per frame
  37471. * @returns the total number of vertices rendered per frame
  37472. */
  37473. getTotalVertices(): number;
  37474. /**
  37475. * Gets the performance counter for total vertices
  37476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37477. */
  37478. get totalVerticesPerfCounter(): PerfCounter;
  37479. /**
  37480. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37481. * @returns the total number of active indices rendered per frame
  37482. */
  37483. getActiveIndices(): number;
  37484. /**
  37485. * Gets the performance counter for active indices
  37486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37487. */
  37488. get totalActiveIndicesPerfCounter(): PerfCounter;
  37489. /**
  37490. * Gets the total number of active particles rendered per frame
  37491. * @returns the total number of active particles rendered per frame
  37492. */
  37493. getActiveParticles(): number;
  37494. /**
  37495. * Gets the performance counter for active particles
  37496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37497. */
  37498. get activeParticlesPerfCounter(): PerfCounter;
  37499. /**
  37500. * Gets the total number of active bones rendered per frame
  37501. * @returns the total number of active bones rendered per frame
  37502. */
  37503. getActiveBones(): number;
  37504. /**
  37505. * Gets the performance counter for active bones
  37506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37507. */
  37508. get activeBonesPerfCounter(): PerfCounter;
  37509. /**
  37510. * Gets the array of active meshes
  37511. * @returns an array of AbstractMesh
  37512. */
  37513. getActiveMeshes(): SmartArray<AbstractMesh>;
  37514. /**
  37515. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37516. * @returns a number
  37517. */
  37518. getAnimationRatio(): number;
  37519. /**
  37520. * Gets an unique Id for the current render phase
  37521. * @returns a number
  37522. */
  37523. getRenderId(): number;
  37524. /**
  37525. * Gets an unique Id for the current frame
  37526. * @returns a number
  37527. */
  37528. getFrameId(): number;
  37529. /** Call this function if you want to manually increment the render Id*/
  37530. incrementRenderId(): void;
  37531. private _createUbo;
  37532. /**
  37533. * Use this method to simulate a pointer move 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. * @returns the current scene
  37538. */
  37539. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37540. /**
  37541. * Use this method to simulate a pointer down on a mesh
  37542. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37543. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37544. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37545. * @returns the current scene
  37546. */
  37547. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37548. /**
  37549. * Use this method to simulate a pointer up on a mesh
  37550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37553. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37554. * @returns the current scene
  37555. */
  37556. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37557. /**
  37558. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37559. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37560. * @returns true if the pointer was captured
  37561. */
  37562. isPointerCaptured(pointerId?: number): boolean;
  37563. /**
  37564. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37565. * @param attachUp defines if you want to attach events to pointerup
  37566. * @param attachDown defines if you want to attach events to pointerdown
  37567. * @param attachMove defines if you want to attach events to pointermove
  37568. */
  37569. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37570. /** Detaches all event handlers*/
  37571. detachControl(): void;
  37572. /**
  37573. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37574. * Delay loaded resources are not taking in account
  37575. * @return true if all required resources are ready
  37576. */
  37577. isReady(): boolean;
  37578. /** Resets all cached information relative to material (including effect and visibility) */
  37579. resetCachedMaterial(): void;
  37580. /**
  37581. * Registers a function to be called before every frame render
  37582. * @param func defines the function to register
  37583. */
  37584. registerBeforeRender(func: () => void): void;
  37585. /**
  37586. * Unregisters a function called before every frame render
  37587. * @param func defines the function to unregister
  37588. */
  37589. unregisterBeforeRender(func: () => void): void;
  37590. /**
  37591. * Registers a function to be called after every frame render
  37592. * @param func defines the function to register
  37593. */
  37594. registerAfterRender(func: () => void): void;
  37595. /**
  37596. * Unregisters a function called after every frame render
  37597. * @param func defines the function to unregister
  37598. */
  37599. unregisterAfterRender(func: () => void): void;
  37600. private _executeOnceBeforeRender;
  37601. /**
  37602. * The provided function will run before render once and will be disposed afterwards.
  37603. * A timeout delay can be provided so that the function will be executed in N ms.
  37604. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37605. * @param func The function to be executed.
  37606. * @param timeout optional delay in ms
  37607. */
  37608. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37609. /** @hidden */
  37610. _addPendingData(data: any): void;
  37611. /** @hidden */
  37612. _removePendingData(data: any): void;
  37613. /**
  37614. * Returns the number of items waiting to be loaded
  37615. * @returns the number of items waiting to be loaded
  37616. */
  37617. getWaitingItemsCount(): number;
  37618. /**
  37619. * Returns a boolean indicating if the scene is still loading data
  37620. */
  37621. get isLoading(): boolean;
  37622. /**
  37623. * Registers a function to be executed when the scene is ready
  37624. * @param {Function} func - the function to be executed
  37625. */
  37626. executeWhenReady(func: () => void): void;
  37627. /**
  37628. * Returns a promise that resolves when the scene is ready
  37629. * @returns A promise that resolves when the scene is ready
  37630. */
  37631. whenReadyAsync(): Promise<void>;
  37632. /** @hidden */
  37633. _checkIsReady(): void;
  37634. /**
  37635. * Gets all animatable attached to the scene
  37636. */
  37637. get animatables(): Animatable[];
  37638. /**
  37639. * Resets the last animation time frame.
  37640. * Useful to override when animations start running when loading a scene for the first time.
  37641. */
  37642. resetLastAnimationTimeFrame(): void;
  37643. /**
  37644. * Gets the current view matrix
  37645. * @returns a Matrix
  37646. */
  37647. getViewMatrix(): Matrix;
  37648. /**
  37649. * Gets the current projection matrix
  37650. * @returns a Matrix
  37651. */
  37652. getProjectionMatrix(): Matrix;
  37653. /**
  37654. * Gets the current transform matrix
  37655. * @returns a Matrix made of View * Projection
  37656. */
  37657. getTransformMatrix(): Matrix;
  37658. /**
  37659. * Sets the current transform matrix
  37660. * @param viewL defines the View matrix to use
  37661. * @param projectionL defines the Projection matrix to use
  37662. * @param viewR defines the right View matrix to use (if provided)
  37663. * @param projectionR defines the right Projection matrix to use (if provided)
  37664. */
  37665. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37666. /**
  37667. * Gets the uniform buffer used to store scene data
  37668. * @returns a UniformBuffer
  37669. */
  37670. getSceneUniformBuffer(): UniformBuffer;
  37671. /**
  37672. * Gets an unique (relatively to the current scene) Id
  37673. * @returns an unique number for the scene
  37674. */
  37675. getUniqueId(): number;
  37676. /**
  37677. * Add a mesh to the list of scene's meshes
  37678. * @param newMesh defines the mesh to add
  37679. * @param recursive if all child meshes should also be added to the scene
  37680. */
  37681. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37682. /**
  37683. * Remove a mesh for the list of scene's meshes
  37684. * @param toRemove defines the mesh to remove
  37685. * @param recursive if all child meshes should also be removed from the scene
  37686. * @returns the index where the mesh was in the mesh list
  37687. */
  37688. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37689. /**
  37690. * Add a transform node to the list of scene's transform nodes
  37691. * @param newTransformNode defines the transform node to add
  37692. */
  37693. addTransformNode(newTransformNode: TransformNode): void;
  37694. /**
  37695. * Remove a transform node for the list of scene's transform nodes
  37696. * @param toRemove defines the transform node to remove
  37697. * @returns the index where the transform node was in the transform node list
  37698. */
  37699. removeTransformNode(toRemove: TransformNode): number;
  37700. /**
  37701. * Remove a skeleton for the list of scene's skeletons
  37702. * @param toRemove defines the skeleton to remove
  37703. * @returns the index where the skeleton was in the skeleton list
  37704. */
  37705. removeSkeleton(toRemove: Skeleton): number;
  37706. /**
  37707. * Remove a morph target for the list of scene's morph targets
  37708. * @param toRemove defines the morph target to remove
  37709. * @returns the index where the morph target was in the morph target list
  37710. */
  37711. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37712. /**
  37713. * Remove a light for the list of scene's lights
  37714. * @param toRemove defines the light to remove
  37715. * @returns the index where the light was in the light list
  37716. */
  37717. removeLight(toRemove: Light): number;
  37718. /**
  37719. * Remove a camera for the list of scene's cameras
  37720. * @param toRemove defines the camera to remove
  37721. * @returns the index where the camera was in the camera list
  37722. */
  37723. removeCamera(toRemove: Camera): number;
  37724. /**
  37725. * Remove a particle system for the list of scene's particle systems
  37726. * @param toRemove defines the particle system to remove
  37727. * @returns the index where the particle system was in the particle system list
  37728. */
  37729. removeParticleSystem(toRemove: IParticleSystem): number;
  37730. /**
  37731. * Remove a animation for the list of scene's animations
  37732. * @param toRemove defines the animation to remove
  37733. * @returns the index where the animation was in the animation list
  37734. */
  37735. removeAnimation(toRemove: Animation): number;
  37736. /**
  37737. * Will stop the animation of the given target
  37738. * @param target - the target
  37739. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37740. * @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)
  37741. */
  37742. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37743. /**
  37744. * Removes the given animation group from this scene.
  37745. * @param toRemove The animation group to remove
  37746. * @returns The index of the removed animation group
  37747. */
  37748. removeAnimationGroup(toRemove: AnimationGroup): number;
  37749. /**
  37750. * Removes the given multi-material from this scene.
  37751. * @param toRemove The multi-material to remove
  37752. * @returns The index of the removed multi-material
  37753. */
  37754. removeMultiMaterial(toRemove: MultiMaterial): number;
  37755. /**
  37756. * Removes the given material from this scene.
  37757. * @param toRemove The material to remove
  37758. * @returns The index of the removed material
  37759. */
  37760. removeMaterial(toRemove: Material): number;
  37761. /**
  37762. * Removes the given action manager from this scene.
  37763. * @param toRemove The action manager to remove
  37764. * @returns The index of the removed action manager
  37765. */
  37766. removeActionManager(toRemove: AbstractActionManager): number;
  37767. /**
  37768. * Removes the given texture from this scene.
  37769. * @param toRemove The texture to remove
  37770. * @returns The index of the removed texture
  37771. */
  37772. removeTexture(toRemove: BaseTexture): number;
  37773. /**
  37774. * Adds the given light to this scene
  37775. * @param newLight The light to add
  37776. */
  37777. addLight(newLight: Light): void;
  37778. /**
  37779. * Sorts the list list based on light priorities
  37780. */
  37781. sortLightsByPriority(): void;
  37782. /**
  37783. * Adds the given camera to this scene
  37784. * @param newCamera The camera to add
  37785. */
  37786. addCamera(newCamera: Camera): void;
  37787. /**
  37788. * Adds the given skeleton to this scene
  37789. * @param newSkeleton The skeleton to add
  37790. */
  37791. addSkeleton(newSkeleton: Skeleton): void;
  37792. /**
  37793. * Adds the given particle system to this scene
  37794. * @param newParticleSystem The particle system to add
  37795. */
  37796. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37797. /**
  37798. * Adds the given animation to this scene
  37799. * @param newAnimation The animation to add
  37800. */
  37801. addAnimation(newAnimation: Animation): void;
  37802. /**
  37803. * Adds the given animation group to this scene.
  37804. * @param newAnimationGroup The animation group to add
  37805. */
  37806. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37807. /**
  37808. * Adds the given multi-material to this scene
  37809. * @param newMultiMaterial The multi-material to add
  37810. */
  37811. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37812. /**
  37813. * Adds the given material to this scene
  37814. * @param newMaterial The material to add
  37815. */
  37816. addMaterial(newMaterial: Material): void;
  37817. /**
  37818. * Adds the given morph target to this scene
  37819. * @param newMorphTargetManager The morph target to add
  37820. */
  37821. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37822. /**
  37823. * Adds the given geometry to this scene
  37824. * @param newGeometry The geometry to add
  37825. */
  37826. addGeometry(newGeometry: Geometry): void;
  37827. /**
  37828. * Adds the given action manager to this scene
  37829. * @param newActionManager The action manager to add
  37830. */
  37831. addActionManager(newActionManager: AbstractActionManager): void;
  37832. /**
  37833. * Adds the given texture to this scene.
  37834. * @param newTexture The texture to add
  37835. */
  37836. addTexture(newTexture: BaseTexture): void;
  37837. /**
  37838. * Switch active camera
  37839. * @param newCamera defines the new active camera
  37840. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37841. */
  37842. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37843. /**
  37844. * sets the active camera of the scene using its ID
  37845. * @param id defines the camera's ID
  37846. * @return the new active camera or null if none found.
  37847. */
  37848. setActiveCameraByID(id: string): Nullable<Camera>;
  37849. /**
  37850. * sets the active camera of the scene using its name
  37851. * @param name defines the camera's name
  37852. * @returns the new active camera or null if none found.
  37853. */
  37854. setActiveCameraByName(name: string): Nullable<Camera>;
  37855. /**
  37856. * get an animation group using its name
  37857. * @param name defines the material's name
  37858. * @return the animation group or null if none found.
  37859. */
  37860. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37861. /**
  37862. * Get a material using its unique id
  37863. * @param uniqueId defines the material's unique id
  37864. * @return the material or null if none found.
  37865. */
  37866. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37867. /**
  37868. * get a material using its id
  37869. * @param id defines the material's ID
  37870. * @return the material or null if none found.
  37871. */
  37872. getMaterialByID(id: string): Nullable<Material>;
  37873. /**
  37874. * Gets a the last added material using a given id
  37875. * @param id defines the material's ID
  37876. * @return the last material with the given id or null if none found.
  37877. */
  37878. getLastMaterialByID(id: string): Nullable<Material>;
  37879. /**
  37880. * Gets a material using its name
  37881. * @param name defines the material's name
  37882. * @return the material or null if none found.
  37883. */
  37884. getMaterialByName(name: string): Nullable<Material>;
  37885. /**
  37886. * Get a texture using its unique id
  37887. * @param uniqueId defines the texture's unique id
  37888. * @return the texture or null if none found.
  37889. */
  37890. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37891. /**
  37892. * Gets a camera using its id
  37893. * @param id defines the id to look for
  37894. * @returns the camera or null if not found
  37895. */
  37896. getCameraByID(id: string): Nullable<Camera>;
  37897. /**
  37898. * Gets a camera using its unique id
  37899. * @param uniqueId defines the unique id to look for
  37900. * @returns the camera or null if not found
  37901. */
  37902. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37903. /**
  37904. * Gets a camera using its name
  37905. * @param name defines the camera's name
  37906. * @return the camera or null if none found.
  37907. */
  37908. getCameraByName(name: string): Nullable<Camera>;
  37909. /**
  37910. * Gets a bone using its id
  37911. * @param id defines the bone's id
  37912. * @return the bone or null if not found
  37913. */
  37914. getBoneByID(id: string): Nullable<Bone>;
  37915. /**
  37916. * Gets a bone using its id
  37917. * @param name defines the bone's name
  37918. * @return the bone or null if not found
  37919. */
  37920. getBoneByName(name: string): Nullable<Bone>;
  37921. /**
  37922. * Gets a light node using its name
  37923. * @param name defines the the light's name
  37924. * @return the light or null if none found.
  37925. */
  37926. getLightByName(name: string): Nullable<Light>;
  37927. /**
  37928. * Gets a light node using its id
  37929. * @param id defines the light's id
  37930. * @return the light or null if none found.
  37931. */
  37932. getLightByID(id: string): Nullable<Light>;
  37933. /**
  37934. * Gets a light node using its scene-generated unique ID
  37935. * @param uniqueId defines the light's unique id
  37936. * @return the light or null if none found.
  37937. */
  37938. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37939. /**
  37940. * Gets a particle system by id
  37941. * @param id defines the particle system id
  37942. * @return the corresponding system or null if none found
  37943. */
  37944. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37945. /**
  37946. * Gets a geometry using its ID
  37947. * @param id defines the geometry's id
  37948. * @return the geometry or null if none found.
  37949. */
  37950. getGeometryByID(id: string): Nullable<Geometry>;
  37951. private _getGeometryByUniqueID;
  37952. /**
  37953. * Add a new geometry to this scene
  37954. * @param geometry defines the geometry to be added to the scene.
  37955. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37956. * @return a boolean defining if the geometry was added or not
  37957. */
  37958. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37959. /**
  37960. * Removes an existing geometry
  37961. * @param geometry defines the geometry to be removed from the scene
  37962. * @return a boolean defining if the geometry was removed or not
  37963. */
  37964. removeGeometry(geometry: Geometry): boolean;
  37965. /**
  37966. * Gets the list of geometries attached to the scene
  37967. * @returns an array of Geometry
  37968. */
  37969. getGeometries(): Geometry[];
  37970. /**
  37971. * Gets the first added mesh found of a given ID
  37972. * @param id defines the id to search for
  37973. * @return the mesh found or null if not found at all
  37974. */
  37975. getMeshByID(id: string): Nullable<AbstractMesh>;
  37976. /**
  37977. * Gets a list of meshes using their id
  37978. * @param id defines the id to search for
  37979. * @returns a list of meshes
  37980. */
  37981. getMeshesByID(id: string): Array<AbstractMesh>;
  37982. /**
  37983. * Gets the first added transform node found of a given ID
  37984. * @param id defines the id to search for
  37985. * @return the found transform node or null if not found at all.
  37986. */
  37987. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37988. /**
  37989. * Gets a transform node with its auto-generated unique id
  37990. * @param uniqueId efines the unique id to search for
  37991. * @return the found transform node or null if not found at all.
  37992. */
  37993. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37994. /**
  37995. * Gets a list of transform nodes using their id
  37996. * @param id defines the id to search for
  37997. * @returns a list of transform nodes
  37998. */
  37999. getTransformNodesByID(id: string): Array<TransformNode>;
  38000. /**
  38001. * Gets a mesh with its auto-generated unique id
  38002. * @param uniqueId defines the unique id to search for
  38003. * @return the found mesh or null if not found at all.
  38004. */
  38005. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38006. /**
  38007. * Gets a the last added mesh using a given id
  38008. * @param id defines the id to search for
  38009. * @return the found mesh or null if not found at all.
  38010. */
  38011. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38012. /**
  38013. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38014. * @param id defines the id to search for
  38015. * @return the found node or null if not found at all
  38016. */
  38017. getLastEntryByID(id: string): Nullable<Node>;
  38018. /**
  38019. * Gets a node (Mesh, Camera, Light) using a given id
  38020. * @param id defines the id to search for
  38021. * @return the found node or null if not found at all
  38022. */
  38023. getNodeByID(id: string): Nullable<Node>;
  38024. /**
  38025. * Gets a node (Mesh, Camera, Light) using a given name
  38026. * @param name defines the name to search for
  38027. * @return the found node or null if not found at all.
  38028. */
  38029. getNodeByName(name: string): Nullable<Node>;
  38030. /**
  38031. * Gets a mesh using a given name
  38032. * @param name defines the name to search for
  38033. * @return the found mesh or null if not found at all.
  38034. */
  38035. getMeshByName(name: string): Nullable<AbstractMesh>;
  38036. /**
  38037. * Gets a transform node using a given name
  38038. * @param name defines the name to search for
  38039. * @return the found transform node or null if not found at all.
  38040. */
  38041. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38042. /**
  38043. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38044. * @param id defines the id to search for
  38045. * @return the found skeleton or null if not found at all.
  38046. */
  38047. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38048. /**
  38049. * Gets a skeleton using a given auto generated unique id
  38050. * @param uniqueId defines the unique id to search for
  38051. * @return the found skeleton or null if not found at all.
  38052. */
  38053. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38054. /**
  38055. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38056. * @param id defines the id to search for
  38057. * @return the found skeleton or null if not found at all.
  38058. */
  38059. getSkeletonById(id: string): Nullable<Skeleton>;
  38060. /**
  38061. * Gets a skeleton using a given name
  38062. * @param name defines the name to search for
  38063. * @return the found skeleton or null if not found at all.
  38064. */
  38065. getSkeletonByName(name: string): Nullable<Skeleton>;
  38066. /**
  38067. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38068. * @param id defines the id to search for
  38069. * @return the found morph target manager or null if not found at all.
  38070. */
  38071. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38072. /**
  38073. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38074. * @param id defines the id to search for
  38075. * @return the found morph target or null if not found at all.
  38076. */
  38077. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38078. /**
  38079. * Gets a boolean indicating if the given mesh is active
  38080. * @param mesh defines the mesh to look for
  38081. * @returns true if the mesh is in the active list
  38082. */
  38083. isActiveMesh(mesh: AbstractMesh): boolean;
  38084. /**
  38085. * Return a unique id as a string which can serve as an identifier for the scene
  38086. */
  38087. get uid(): string;
  38088. /**
  38089. * Add an externaly attached data from its key.
  38090. * This method call will fail and return false, if such key already exists.
  38091. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38092. * @param key the unique key that identifies the data
  38093. * @param data the data object to associate to the key for this Engine instance
  38094. * @return true if no such key were already present and the data was added successfully, false otherwise
  38095. */
  38096. addExternalData<T>(key: string, data: T): boolean;
  38097. /**
  38098. * Get an externaly attached data from its key
  38099. * @param key the unique key that identifies the data
  38100. * @return the associated data, if present (can be null), or undefined if not present
  38101. */
  38102. getExternalData<T>(key: string): Nullable<T>;
  38103. /**
  38104. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38105. * @param key the unique key that identifies the data
  38106. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38107. * @return the associated data, can be null if the factory returned null.
  38108. */
  38109. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38110. /**
  38111. * Remove an externaly attached data from the Engine instance
  38112. * @param key the unique key that identifies the data
  38113. * @return true if the data was successfully removed, false if it doesn't exist
  38114. */
  38115. removeExternalData(key: string): boolean;
  38116. private _evaluateSubMesh;
  38117. /**
  38118. * Clear the processed materials smart array preventing retention point in material dispose.
  38119. */
  38120. freeProcessedMaterials(): void;
  38121. private _preventFreeActiveMeshesAndRenderingGroups;
  38122. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38123. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38124. * when disposing several meshes in a row or a hierarchy of meshes.
  38125. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38126. */
  38127. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38128. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38129. /**
  38130. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38131. */
  38132. freeActiveMeshes(): void;
  38133. /**
  38134. * Clear the info related to rendering groups preventing retention points during dispose.
  38135. */
  38136. freeRenderingGroups(): void;
  38137. /** @hidden */
  38138. _isInIntermediateRendering(): boolean;
  38139. /**
  38140. * Lambda returning the list of potentially active meshes.
  38141. */
  38142. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38143. /**
  38144. * Lambda returning the list of potentially active sub meshes.
  38145. */
  38146. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38147. /**
  38148. * Lambda returning the list of potentially intersecting sub meshes.
  38149. */
  38150. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38151. /**
  38152. * Lambda returning the list of potentially colliding sub meshes.
  38153. */
  38154. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38155. private _activeMeshesFrozen;
  38156. private _skipEvaluateActiveMeshesCompletely;
  38157. /**
  38158. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38159. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38160. * @returns the current scene
  38161. */
  38162. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38163. /**
  38164. * Use this function to restart evaluating active meshes on every frame
  38165. * @returns the current scene
  38166. */
  38167. unfreezeActiveMeshes(): Scene;
  38168. private _evaluateActiveMeshes;
  38169. private _activeMesh;
  38170. /**
  38171. * Update the transform matrix to update from the current active camera
  38172. * @param force defines a boolean used to force the update even if cache is up to date
  38173. */
  38174. updateTransformMatrix(force?: boolean): void;
  38175. private _bindFrameBuffer;
  38176. /** @hidden */
  38177. _allowPostProcessClearColor: boolean;
  38178. /** @hidden */
  38179. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38180. private _processSubCameras;
  38181. private _checkIntersections;
  38182. /** @hidden */
  38183. _advancePhysicsEngineStep(step: number): void;
  38184. /**
  38185. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38186. */
  38187. getDeterministicFrameTime: () => number;
  38188. /** @hidden */
  38189. _animate(): void;
  38190. /** Execute all animations (for a frame) */
  38191. animate(): void;
  38192. /**
  38193. * Render the scene
  38194. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38195. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38196. */
  38197. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38198. /**
  38199. * Freeze all materials
  38200. * A frozen material will not be updatable but should be faster to render
  38201. */
  38202. freezeMaterials(): void;
  38203. /**
  38204. * Unfreeze all materials
  38205. * A frozen material will not be updatable but should be faster to render
  38206. */
  38207. unfreezeMaterials(): void;
  38208. /**
  38209. * Releases all held ressources
  38210. */
  38211. dispose(): void;
  38212. /**
  38213. * Gets if the scene is already disposed
  38214. */
  38215. get isDisposed(): boolean;
  38216. /**
  38217. * Call this function to reduce memory footprint of the scene.
  38218. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38219. */
  38220. clearCachedVertexData(): void;
  38221. /**
  38222. * This function will remove the local cached buffer data from texture.
  38223. * It will save memory but will prevent the texture from being rebuilt
  38224. */
  38225. cleanCachedTextureBuffer(): void;
  38226. /**
  38227. * Get the world extend vectors with an optional filter
  38228. *
  38229. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38230. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38231. */
  38232. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38233. min: Vector3;
  38234. max: Vector3;
  38235. };
  38236. /**
  38237. * Creates a ray that can be used to pick in the scene
  38238. * @param x defines the x coordinate of the origin (on-screen)
  38239. * @param y defines the y coordinate of the origin (on-screen)
  38240. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38241. * @param camera defines the camera to use for the picking
  38242. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38243. * @returns a Ray
  38244. */
  38245. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38246. /**
  38247. * Creates a ray that can be used to pick in the scene
  38248. * @param x defines the x coordinate of the origin (on-screen)
  38249. * @param y defines the y coordinate of the origin (on-screen)
  38250. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38251. * @param result defines the ray where to store the picking ray
  38252. * @param camera defines the camera to use for the picking
  38253. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38254. * @returns the current scene
  38255. */
  38256. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38257. /**
  38258. * Creates a ray that can be used to pick in the scene
  38259. * @param x defines the x coordinate of the origin (on-screen)
  38260. * @param y defines the y coordinate of the origin (on-screen)
  38261. * @param camera defines the camera to use for the picking
  38262. * @returns a Ray
  38263. */
  38264. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38265. /**
  38266. * Creates a ray that can be used to pick in the scene
  38267. * @param x defines the x coordinate of the origin (on-screen)
  38268. * @param y defines the y coordinate of the origin (on-screen)
  38269. * @param result defines the ray where to store the picking ray
  38270. * @param camera defines the camera to use for the picking
  38271. * @returns the current scene
  38272. */
  38273. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38274. /** Launch a ray to try to pick a mesh in the scene
  38275. * @param x position on screen
  38276. * @param y position on screen
  38277. * @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
  38278. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38279. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38280. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38281. * @returns a PickingInfo
  38282. */
  38283. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38284. /** Use the given ray to pick a mesh in the scene
  38285. * @param ray The ray to use to pick meshes
  38286. * @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
  38287. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38288. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38289. * @returns a PickingInfo
  38290. */
  38291. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38292. /**
  38293. * Launch a ray to try to pick a mesh in the scene
  38294. * @param x X position on screen
  38295. * @param y Y position on screen
  38296. * @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
  38297. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38298. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38299. * @returns an array of PickingInfo
  38300. */
  38301. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38302. /**
  38303. * Launch a ray to try to pick a mesh in the scene
  38304. * @param ray Ray to use
  38305. * @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
  38306. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38307. * @returns an array of PickingInfo
  38308. */
  38309. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38310. /**
  38311. * Force the value of meshUnderPointer
  38312. * @param mesh defines the mesh to use
  38313. */
  38314. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38315. /**
  38316. * Gets the mesh under the pointer
  38317. * @returns a Mesh or null if no mesh is under the pointer
  38318. */
  38319. getPointerOverMesh(): Nullable<AbstractMesh>;
  38320. /** @hidden */
  38321. _rebuildGeometries(): void;
  38322. /** @hidden */
  38323. _rebuildTextures(): void;
  38324. private _getByTags;
  38325. /**
  38326. * Get a list of meshes by tags
  38327. * @param tagsQuery defines the tags query to use
  38328. * @param forEach defines a predicate used to filter results
  38329. * @returns an array of Mesh
  38330. */
  38331. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38332. /**
  38333. * Get a list of cameras by tags
  38334. * @param tagsQuery defines the tags query to use
  38335. * @param forEach defines a predicate used to filter results
  38336. * @returns an array of Camera
  38337. */
  38338. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38339. /**
  38340. * Get a list of lights by tags
  38341. * @param tagsQuery defines the tags query to use
  38342. * @param forEach defines a predicate used to filter results
  38343. * @returns an array of Light
  38344. */
  38345. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38346. /**
  38347. * Get a list of materials by tags
  38348. * @param tagsQuery defines the tags query to use
  38349. * @param forEach defines a predicate used to filter results
  38350. * @returns an array of Material
  38351. */
  38352. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38353. /**
  38354. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38355. * This allowed control for front to back rendering or reversly depending of the special needs.
  38356. *
  38357. * @param renderingGroupId The rendering group id corresponding to its index
  38358. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38359. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38360. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38361. */
  38362. 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;
  38363. /**
  38364. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38365. *
  38366. * @param renderingGroupId The rendering group id corresponding to its index
  38367. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38368. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38369. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38370. */
  38371. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38372. /**
  38373. * Gets the current auto clear configuration for one rendering group of the rendering
  38374. * manager.
  38375. * @param index the rendering group index to get the information for
  38376. * @returns The auto clear setup for the requested rendering group
  38377. */
  38378. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38379. private _blockMaterialDirtyMechanism;
  38380. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38381. get blockMaterialDirtyMechanism(): boolean;
  38382. set blockMaterialDirtyMechanism(value: boolean);
  38383. /**
  38384. * Will flag all materials as dirty to trigger new shader compilation
  38385. * @param flag defines the flag used to specify which material part must be marked as dirty
  38386. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38387. */
  38388. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38389. /** @hidden */
  38390. _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;
  38391. /** @hidden */
  38392. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38393. /** @hidden */
  38394. _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;
  38395. /** @hidden */
  38396. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38397. /** @hidden */
  38398. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38399. /** @hidden */
  38400. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38401. }
  38402. }
  38403. declare module "babylonjs/assetContainer" {
  38404. import { AbstractScene } from "babylonjs/abstractScene";
  38405. import { Scene } from "babylonjs/scene";
  38406. import { Mesh } from "babylonjs/Meshes/mesh";
  38407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38408. import { Skeleton } from "babylonjs/Bones/skeleton";
  38409. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38410. import { Animatable } from "babylonjs/Animations/animatable";
  38411. import { Nullable } from "babylonjs/types";
  38412. import { Node } from "babylonjs/node";
  38413. /**
  38414. * Set of assets to keep when moving a scene into an asset container.
  38415. */
  38416. export class KeepAssets extends AbstractScene {
  38417. }
  38418. /**
  38419. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38420. */
  38421. export class InstantiatedEntries {
  38422. /**
  38423. * List of new root nodes (eg. nodes with no parent)
  38424. */
  38425. rootNodes: TransformNode[];
  38426. /**
  38427. * List of new skeletons
  38428. */
  38429. skeletons: Skeleton[];
  38430. /**
  38431. * List of new animation groups
  38432. */
  38433. animationGroups: AnimationGroup[];
  38434. }
  38435. /**
  38436. * Container with a set of assets that can be added or removed from a scene.
  38437. */
  38438. export class AssetContainer extends AbstractScene {
  38439. private _wasAddedToScene;
  38440. /**
  38441. * The scene the AssetContainer belongs to.
  38442. */
  38443. scene: Scene;
  38444. /**
  38445. * Instantiates an AssetContainer.
  38446. * @param scene The scene the AssetContainer belongs to.
  38447. */
  38448. constructor(scene: Scene);
  38449. /**
  38450. * Instantiate or clone all meshes and add the new ones to the scene.
  38451. * Skeletons and animation groups will all be cloned
  38452. * @param nameFunction defines an optional function used to get new names for clones
  38453. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38454. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38455. */
  38456. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38457. /**
  38458. * Adds all the assets from the container to the scene.
  38459. */
  38460. addAllToScene(): void;
  38461. /**
  38462. * Removes all the assets in the container from the scene
  38463. */
  38464. removeAllFromScene(): void;
  38465. /**
  38466. * Disposes all the assets in the container
  38467. */
  38468. dispose(): void;
  38469. private _moveAssets;
  38470. /**
  38471. * Removes all the assets contained in the scene and adds them to the container.
  38472. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38473. */
  38474. moveAllFromScene(keepAssets?: KeepAssets): void;
  38475. /**
  38476. * 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.
  38477. * @returns the root mesh
  38478. */
  38479. createRootMesh(): Mesh;
  38480. /**
  38481. * Merge animations from this asset container into a scene
  38482. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38483. * @param animatables set of animatables to retarget to a node from the scene
  38484. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38485. */
  38486. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38487. }
  38488. }
  38489. declare module "babylonjs/abstractScene" {
  38490. import { Scene } from "babylonjs/scene";
  38491. import { Nullable } from "babylonjs/types";
  38492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38494. import { Geometry } from "babylonjs/Meshes/geometry";
  38495. import { Skeleton } from "babylonjs/Bones/skeleton";
  38496. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38497. import { AssetContainer } from "babylonjs/assetContainer";
  38498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38499. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38501. import { Material } from "babylonjs/Materials/material";
  38502. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38503. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38504. import { Camera } from "babylonjs/Cameras/camera";
  38505. import { Light } from "babylonjs/Lights/light";
  38506. import { Node } from "babylonjs/node";
  38507. import { Animation } from "babylonjs/Animations/animation";
  38508. /**
  38509. * Defines how the parser contract is defined.
  38510. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38511. */
  38512. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38513. /**
  38514. * Defines how the individual parser contract is defined.
  38515. * These parser can parse an individual asset
  38516. */
  38517. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38518. /**
  38519. * Base class of the scene acting as a container for the different elements composing a scene.
  38520. * This class is dynamically extended by the different components of the scene increasing
  38521. * flexibility and reducing coupling
  38522. */
  38523. export abstract class AbstractScene {
  38524. /**
  38525. * Stores the list of available parsers in the application.
  38526. */
  38527. private static _BabylonFileParsers;
  38528. /**
  38529. * Stores the list of available individual parsers in the application.
  38530. */
  38531. private static _IndividualBabylonFileParsers;
  38532. /**
  38533. * Adds a parser in the list of available ones
  38534. * @param name Defines the name of the parser
  38535. * @param parser Defines the parser to add
  38536. */
  38537. static AddParser(name: string, parser: BabylonFileParser): void;
  38538. /**
  38539. * Gets a general parser from the list of avaialble ones
  38540. * @param name Defines the name of the parser
  38541. * @returns the requested parser or null
  38542. */
  38543. static GetParser(name: string): Nullable<BabylonFileParser>;
  38544. /**
  38545. * Adds n individual parser in the list of available ones
  38546. * @param name Defines the name of the parser
  38547. * @param parser Defines the parser to add
  38548. */
  38549. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38550. /**
  38551. * Gets an individual parser from the list of avaialble ones
  38552. * @param name Defines the name of the parser
  38553. * @returns the requested parser or null
  38554. */
  38555. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38556. /**
  38557. * Parser json data and populate both a scene and its associated container object
  38558. * @param jsonData Defines the data to parse
  38559. * @param scene Defines the scene to parse the data for
  38560. * @param container Defines the container attached to the parsing sequence
  38561. * @param rootUrl Defines the root url of the data
  38562. */
  38563. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38564. /**
  38565. * Gets the list of root nodes (ie. nodes with no parent)
  38566. */
  38567. rootNodes: Node[];
  38568. /** All of the cameras added to this scene
  38569. * @see http://doc.babylonjs.com/babylon101/cameras
  38570. */
  38571. cameras: Camera[];
  38572. /**
  38573. * All of the lights added to this scene
  38574. * @see http://doc.babylonjs.com/babylon101/lights
  38575. */
  38576. lights: Light[];
  38577. /**
  38578. * All of the (abstract) meshes added to this scene
  38579. */
  38580. meshes: AbstractMesh[];
  38581. /**
  38582. * The list of skeletons added to the scene
  38583. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38584. */
  38585. skeletons: Skeleton[];
  38586. /**
  38587. * All of the particle systems added to this scene
  38588. * @see http://doc.babylonjs.com/babylon101/particles
  38589. */
  38590. particleSystems: IParticleSystem[];
  38591. /**
  38592. * Gets a list of Animations associated with the scene
  38593. */
  38594. animations: Animation[];
  38595. /**
  38596. * All of the animation groups added to this scene
  38597. * @see http://doc.babylonjs.com/how_to/group
  38598. */
  38599. animationGroups: AnimationGroup[];
  38600. /**
  38601. * All of the multi-materials added to this scene
  38602. * @see http://doc.babylonjs.com/how_to/multi_materials
  38603. */
  38604. multiMaterials: MultiMaterial[];
  38605. /**
  38606. * All of the materials added to this scene
  38607. * In the context of a Scene, it is not supposed to be modified manually.
  38608. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38609. * Note also that the order of the Material within the array is not significant and might change.
  38610. * @see http://doc.babylonjs.com/babylon101/materials
  38611. */
  38612. materials: Material[];
  38613. /**
  38614. * The list of morph target managers added to the scene
  38615. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38616. */
  38617. morphTargetManagers: MorphTargetManager[];
  38618. /**
  38619. * The list of geometries used in the scene.
  38620. */
  38621. geometries: Geometry[];
  38622. /**
  38623. * All of the tranform nodes added to this scene
  38624. * In the context of a Scene, it is not supposed to be modified manually.
  38625. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38626. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38627. * @see http://doc.babylonjs.com/how_to/transformnode
  38628. */
  38629. transformNodes: TransformNode[];
  38630. /**
  38631. * ActionManagers available on the scene.
  38632. */
  38633. actionManagers: AbstractActionManager[];
  38634. /**
  38635. * Textures to keep.
  38636. */
  38637. textures: BaseTexture[];
  38638. /**
  38639. * Environment texture for the scene
  38640. */
  38641. environmentTexture: Nullable<BaseTexture>;
  38642. /**
  38643. * @returns all meshes, lights, cameras, transformNodes and bones
  38644. */
  38645. getNodes(): Array<Node>;
  38646. }
  38647. }
  38648. declare module "babylonjs/Audio/sound" {
  38649. import { Observable } from "babylonjs/Misc/observable";
  38650. import { Vector3 } from "babylonjs/Maths/math.vector";
  38651. import { Nullable } from "babylonjs/types";
  38652. import { Scene } from "babylonjs/scene";
  38653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38654. /**
  38655. * Interface used to define options for Sound class
  38656. */
  38657. export interface ISoundOptions {
  38658. /**
  38659. * Does the sound autoplay once loaded.
  38660. */
  38661. autoplay?: boolean;
  38662. /**
  38663. * Does the sound loop after it finishes playing once.
  38664. */
  38665. loop?: boolean;
  38666. /**
  38667. * Sound's volume
  38668. */
  38669. volume?: number;
  38670. /**
  38671. * Is it a spatial sound?
  38672. */
  38673. spatialSound?: boolean;
  38674. /**
  38675. * Maximum distance to hear that sound
  38676. */
  38677. maxDistance?: number;
  38678. /**
  38679. * Uses user defined attenuation function
  38680. */
  38681. useCustomAttenuation?: boolean;
  38682. /**
  38683. * Define the roll off factor of spatial sounds.
  38684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38685. */
  38686. rolloffFactor?: number;
  38687. /**
  38688. * Define the reference distance the sound should be heard perfectly.
  38689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38690. */
  38691. refDistance?: number;
  38692. /**
  38693. * Define the distance attenuation model the sound will follow.
  38694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38695. */
  38696. distanceModel?: string;
  38697. /**
  38698. * Defines the playback speed (1 by default)
  38699. */
  38700. playbackRate?: number;
  38701. /**
  38702. * Defines if the sound is from a streaming source
  38703. */
  38704. streaming?: boolean;
  38705. /**
  38706. * Defines an optional length (in seconds) inside the sound file
  38707. */
  38708. length?: number;
  38709. /**
  38710. * Defines an optional offset (in seconds) inside the sound file
  38711. */
  38712. offset?: number;
  38713. /**
  38714. * If true, URLs will not be required to state the audio file codec to use.
  38715. */
  38716. skipCodecCheck?: boolean;
  38717. }
  38718. /**
  38719. * Defines a sound that can be played in the application.
  38720. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38722. */
  38723. export class Sound {
  38724. /**
  38725. * The name of the sound in the scene.
  38726. */
  38727. name: string;
  38728. /**
  38729. * Does the sound autoplay once loaded.
  38730. */
  38731. autoplay: boolean;
  38732. /**
  38733. * Does the sound loop after it finishes playing once.
  38734. */
  38735. loop: boolean;
  38736. /**
  38737. * Does the sound use a custom attenuation curve to simulate the falloff
  38738. * happening when the source gets further away from the camera.
  38739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38740. */
  38741. useCustomAttenuation: boolean;
  38742. /**
  38743. * The sound track id this sound belongs to.
  38744. */
  38745. soundTrackId: number;
  38746. /**
  38747. * Is this sound currently played.
  38748. */
  38749. isPlaying: boolean;
  38750. /**
  38751. * Is this sound currently paused.
  38752. */
  38753. isPaused: boolean;
  38754. /**
  38755. * Does this sound enables spatial sound.
  38756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38757. */
  38758. spatialSound: boolean;
  38759. /**
  38760. * Define the reference distance the sound should be heard perfectly.
  38761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38762. */
  38763. refDistance: number;
  38764. /**
  38765. * Define the roll off factor of spatial sounds.
  38766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38767. */
  38768. rolloffFactor: number;
  38769. /**
  38770. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38772. */
  38773. maxDistance: number;
  38774. /**
  38775. * Define the distance attenuation model the sound will follow.
  38776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38777. */
  38778. distanceModel: string;
  38779. /**
  38780. * @hidden
  38781. * Back Compat
  38782. **/
  38783. onended: () => any;
  38784. /**
  38785. * Observable event when the current playing sound finishes.
  38786. */
  38787. onEndedObservable: Observable<Sound>;
  38788. private _panningModel;
  38789. private _playbackRate;
  38790. private _streaming;
  38791. private _startTime;
  38792. private _startOffset;
  38793. private _position;
  38794. /** @hidden */
  38795. _positionInEmitterSpace: boolean;
  38796. private _localDirection;
  38797. private _volume;
  38798. private _isReadyToPlay;
  38799. private _isDirectional;
  38800. private _readyToPlayCallback;
  38801. private _audioBuffer;
  38802. private _soundSource;
  38803. private _streamingSource;
  38804. private _soundPanner;
  38805. private _soundGain;
  38806. private _inputAudioNode;
  38807. private _outputAudioNode;
  38808. private _coneInnerAngle;
  38809. private _coneOuterAngle;
  38810. private _coneOuterGain;
  38811. private _scene;
  38812. private _connectedTransformNode;
  38813. private _customAttenuationFunction;
  38814. private _registerFunc;
  38815. private _isOutputConnected;
  38816. private _htmlAudioElement;
  38817. private _urlType;
  38818. private _length?;
  38819. private _offset?;
  38820. /** @hidden */
  38821. static _SceneComponentInitialization: (scene: Scene) => void;
  38822. /**
  38823. * Create a sound and attach it to a scene
  38824. * @param name Name of your sound
  38825. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38826. * @param scene defines the scene the sound belongs to
  38827. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38828. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38829. */
  38830. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38831. /**
  38832. * Release the sound and its associated resources
  38833. */
  38834. dispose(): void;
  38835. /**
  38836. * Gets if the sounds is ready to be played or not.
  38837. * @returns true if ready, otherwise false
  38838. */
  38839. isReady(): boolean;
  38840. private _soundLoaded;
  38841. /**
  38842. * Sets the data of the sound from an audiobuffer
  38843. * @param audioBuffer The audioBuffer containing the data
  38844. */
  38845. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38846. /**
  38847. * Updates the current sounds options such as maxdistance, loop...
  38848. * @param options A JSON object containing values named as the object properties
  38849. */
  38850. updateOptions(options: ISoundOptions): void;
  38851. private _createSpatialParameters;
  38852. private _updateSpatialParameters;
  38853. /**
  38854. * Switch the panning model to HRTF:
  38855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38857. */
  38858. switchPanningModelToHRTF(): void;
  38859. /**
  38860. * Switch the panning model to Equal Power:
  38861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38863. */
  38864. switchPanningModelToEqualPower(): void;
  38865. private _switchPanningModel;
  38866. /**
  38867. * Connect this sound to a sound track audio node like gain...
  38868. * @param soundTrackAudioNode the sound track audio node to connect to
  38869. */
  38870. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38871. /**
  38872. * Transform this sound into a directional source
  38873. * @param coneInnerAngle Size of the inner cone in degree
  38874. * @param coneOuterAngle Size of the outer cone in degree
  38875. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38876. */
  38877. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38878. /**
  38879. * Gets or sets the inner angle for the directional cone.
  38880. */
  38881. get directionalConeInnerAngle(): number;
  38882. /**
  38883. * Gets or sets the inner angle for the directional cone.
  38884. */
  38885. set directionalConeInnerAngle(value: number);
  38886. /**
  38887. * Gets or sets the outer angle for the directional cone.
  38888. */
  38889. get directionalConeOuterAngle(): number;
  38890. /**
  38891. * Gets or sets the outer angle for the directional cone.
  38892. */
  38893. set directionalConeOuterAngle(value: number);
  38894. /**
  38895. * Sets the position of the emitter if spatial sound is enabled
  38896. * @param newPosition Defines the new posisiton
  38897. */
  38898. setPosition(newPosition: Vector3): void;
  38899. /**
  38900. * Sets the local direction of the emitter if spatial sound is enabled
  38901. * @param newLocalDirection Defines the new local direction
  38902. */
  38903. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38904. private _updateDirection;
  38905. /** @hidden */
  38906. updateDistanceFromListener(): void;
  38907. /**
  38908. * Sets a new custom attenuation function for the sound.
  38909. * @param callback Defines the function used for the attenuation
  38910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38911. */
  38912. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38913. /**
  38914. * Play the sound
  38915. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38916. * @param offset (optional) Start the sound at a specific time in seconds
  38917. * @param length (optional) Sound duration (in seconds)
  38918. */
  38919. play(time?: number, offset?: number, length?: number): void;
  38920. private _onended;
  38921. /**
  38922. * Stop the sound
  38923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38924. */
  38925. stop(time?: number): void;
  38926. /**
  38927. * Put the sound in pause
  38928. */
  38929. pause(): void;
  38930. /**
  38931. * Sets a dedicated volume for this sounds
  38932. * @param newVolume Define the new volume of the sound
  38933. * @param time Define time for gradual change to new volume
  38934. */
  38935. setVolume(newVolume: number, time?: number): void;
  38936. /**
  38937. * Set the sound play back rate
  38938. * @param newPlaybackRate Define the playback rate the sound should be played at
  38939. */
  38940. setPlaybackRate(newPlaybackRate: number): void;
  38941. /**
  38942. * Gets the volume of the sound.
  38943. * @returns the volume of the sound
  38944. */
  38945. getVolume(): number;
  38946. /**
  38947. * Attach the sound to a dedicated mesh
  38948. * @param transformNode The transform node to connect the sound with
  38949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38950. */
  38951. attachToMesh(transformNode: TransformNode): void;
  38952. /**
  38953. * Detach the sound from the previously attached mesh
  38954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38955. */
  38956. detachFromMesh(): void;
  38957. private _onRegisterAfterWorldMatrixUpdate;
  38958. /**
  38959. * Clone the current sound in the scene.
  38960. * @returns the new sound clone
  38961. */
  38962. clone(): Nullable<Sound>;
  38963. /**
  38964. * Gets the current underlying audio buffer containing the data
  38965. * @returns the audio buffer
  38966. */
  38967. getAudioBuffer(): Nullable<AudioBuffer>;
  38968. /**
  38969. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38970. * @returns the source node
  38971. */
  38972. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38973. /**
  38974. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38975. * @returns the gain node
  38976. */
  38977. getSoundGain(): Nullable<GainNode>;
  38978. /**
  38979. * Serializes the Sound in a JSON representation
  38980. * @returns the JSON representation of the sound
  38981. */
  38982. serialize(): any;
  38983. /**
  38984. * Parse a JSON representation of a sound to innstantiate in a given scene
  38985. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38986. * @param scene Define the scene the new parsed sound should be created in
  38987. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38988. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38989. * @returns the newly parsed sound
  38990. */
  38991. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38992. }
  38993. }
  38994. declare module "babylonjs/Actions/directAudioActions" {
  38995. import { Action } from "babylonjs/Actions/action";
  38996. import { Condition } from "babylonjs/Actions/condition";
  38997. import { Sound } from "babylonjs/Audio/sound";
  38998. /**
  38999. * This defines an action helpful to play a defined sound on a triggered action.
  39000. */
  39001. export class PlaySoundAction extends Action {
  39002. private _sound;
  39003. /**
  39004. * Instantiate the action
  39005. * @param triggerOptions defines the trigger options
  39006. * @param sound defines the sound to play
  39007. * @param condition defines the trigger related conditions
  39008. */
  39009. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39010. /** @hidden */
  39011. _prepare(): void;
  39012. /**
  39013. * Execute the action and play the sound.
  39014. */
  39015. execute(): void;
  39016. /**
  39017. * Serializes the actions and its related information.
  39018. * @param parent defines the object to serialize in
  39019. * @returns the serialized object
  39020. */
  39021. serialize(parent: any): any;
  39022. }
  39023. /**
  39024. * This defines an action helpful to stop a defined sound on a triggered action.
  39025. */
  39026. export class StopSoundAction extends Action {
  39027. private _sound;
  39028. /**
  39029. * Instantiate the action
  39030. * @param triggerOptions defines the trigger options
  39031. * @param sound defines the sound to stop
  39032. * @param condition defines the trigger related conditions
  39033. */
  39034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39035. /** @hidden */
  39036. _prepare(): void;
  39037. /**
  39038. * Execute the action and stop the sound.
  39039. */
  39040. execute(): void;
  39041. /**
  39042. * Serializes the actions and its related information.
  39043. * @param parent defines the object to serialize in
  39044. * @returns the serialized object
  39045. */
  39046. serialize(parent: any): any;
  39047. }
  39048. }
  39049. declare module "babylonjs/Actions/interpolateValueAction" {
  39050. import { Action } from "babylonjs/Actions/action";
  39051. import { Condition } from "babylonjs/Actions/condition";
  39052. import { Observable } from "babylonjs/Misc/observable";
  39053. /**
  39054. * This defines an action responsible to change the value of a property
  39055. * by interpolating between its current value and the newly set one once triggered.
  39056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39057. */
  39058. export class InterpolateValueAction extends Action {
  39059. /**
  39060. * Defines the path of the property where the value should be interpolated
  39061. */
  39062. propertyPath: string;
  39063. /**
  39064. * Defines the target value at the end of the interpolation.
  39065. */
  39066. value: any;
  39067. /**
  39068. * Defines the time it will take for the property to interpolate to the value.
  39069. */
  39070. duration: number;
  39071. /**
  39072. * Defines if the other scene animations should be stopped when the action has been triggered
  39073. */
  39074. stopOtherAnimations?: boolean;
  39075. /**
  39076. * Defines a callback raised once the interpolation animation has been done.
  39077. */
  39078. onInterpolationDone?: () => void;
  39079. /**
  39080. * Observable triggered once the interpolation animation has been done.
  39081. */
  39082. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39083. private _target;
  39084. private _effectiveTarget;
  39085. private _property;
  39086. /**
  39087. * Instantiate the action
  39088. * @param triggerOptions defines the trigger options
  39089. * @param target defines the object containing the value to interpolate
  39090. * @param propertyPath defines the path to the property in the target object
  39091. * @param value defines the target value at the end of the interpolation
  39092. * @param duration deines the time it will take for the property to interpolate to the value.
  39093. * @param condition defines the trigger related conditions
  39094. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39095. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39096. */
  39097. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39098. /** @hidden */
  39099. _prepare(): void;
  39100. /**
  39101. * Execute the action starts the value interpolation.
  39102. */
  39103. execute(): void;
  39104. /**
  39105. * Serializes the actions and its related information.
  39106. * @param parent defines the object to serialize in
  39107. * @returns the serialized object
  39108. */
  39109. serialize(parent: any): any;
  39110. }
  39111. }
  39112. declare module "babylonjs/Actions/index" {
  39113. export * from "babylonjs/Actions/abstractActionManager";
  39114. export * from "babylonjs/Actions/action";
  39115. export * from "babylonjs/Actions/actionEvent";
  39116. export * from "babylonjs/Actions/actionManager";
  39117. export * from "babylonjs/Actions/condition";
  39118. export * from "babylonjs/Actions/directActions";
  39119. export * from "babylonjs/Actions/directAudioActions";
  39120. export * from "babylonjs/Actions/interpolateValueAction";
  39121. }
  39122. declare module "babylonjs/Animations/index" {
  39123. export * from "babylonjs/Animations/animatable";
  39124. export * from "babylonjs/Animations/animation";
  39125. export * from "babylonjs/Animations/animationGroup";
  39126. export * from "babylonjs/Animations/animationPropertiesOverride";
  39127. export * from "babylonjs/Animations/easing";
  39128. export * from "babylonjs/Animations/runtimeAnimation";
  39129. export * from "babylonjs/Animations/animationEvent";
  39130. export * from "babylonjs/Animations/animationGroup";
  39131. export * from "babylonjs/Animations/animationKey";
  39132. export * from "babylonjs/Animations/animationRange";
  39133. export * from "babylonjs/Animations/animatable.interface";
  39134. }
  39135. declare module "babylonjs/Audio/soundTrack" {
  39136. import { Sound } from "babylonjs/Audio/sound";
  39137. import { Analyser } from "babylonjs/Audio/analyser";
  39138. import { Scene } from "babylonjs/scene";
  39139. /**
  39140. * Options allowed during the creation of a sound track.
  39141. */
  39142. export interface ISoundTrackOptions {
  39143. /**
  39144. * The volume the sound track should take during creation
  39145. */
  39146. volume?: number;
  39147. /**
  39148. * Define if the sound track is the main sound track of the scene
  39149. */
  39150. mainTrack?: boolean;
  39151. }
  39152. /**
  39153. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39154. * It will be also used in a future release to apply effects on a specific track.
  39155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39156. */
  39157. export class SoundTrack {
  39158. /**
  39159. * The unique identifier of the sound track in the scene.
  39160. */
  39161. id: number;
  39162. /**
  39163. * The list of sounds included in the sound track.
  39164. */
  39165. soundCollection: Array<Sound>;
  39166. private _outputAudioNode;
  39167. private _scene;
  39168. private _connectedAnalyser;
  39169. private _options;
  39170. private _isInitialized;
  39171. /**
  39172. * Creates a new sound track.
  39173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39174. * @param scene Define the scene the sound track belongs to
  39175. * @param options
  39176. */
  39177. constructor(scene: Scene, options?: ISoundTrackOptions);
  39178. private _initializeSoundTrackAudioGraph;
  39179. /**
  39180. * Release the sound track and its associated resources
  39181. */
  39182. dispose(): void;
  39183. /**
  39184. * Adds a sound to this sound track
  39185. * @param sound define the cound to add
  39186. * @ignoreNaming
  39187. */
  39188. AddSound(sound: Sound): void;
  39189. /**
  39190. * Removes a sound to this sound track
  39191. * @param sound define the cound to remove
  39192. * @ignoreNaming
  39193. */
  39194. RemoveSound(sound: Sound): void;
  39195. /**
  39196. * Set a global volume for the full sound track.
  39197. * @param newVolume Define the new volume of the sound track
  39198. */
  39199. setVolume(newVolume: number): void;
  39200. /**
  39201. * Switch the panning model to HRTF:
  39202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39204. */
  39205. switchPanningModelToHRTF(): void;
  39206. /**
  39207. * Switch the panning model to Equal Power:
  39208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39210. */
  39211. switchPanningModelToEqualPower(): void;
  39212. /**
  39213. * Connect the sound track to an audio analyser allowing some amazing
  39214. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39216. * @param analyser The analyser to connect to the engine
  39217. */
  39218. connectToAnalyser(analyser: Analyser): void;
  39219. }
  39220. }
  39221. declare module "babylonjs/Audio/audioSceneComponent" {
  39222. import { Sound } from "babylonjs/Audio/sound";
  39223. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39224. import { Nullable } from "babylonjs/types";
  39225. import { Vector3 } from "babylonjs/Maths/math.vector";
  39226. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39227. import { Scene } from "babylonjs/scene";
  39228. import { AbstractScene } from "babylonjs/abstractScene";
  39229. import "babylonjs/Audio/audioEngine";
  39230. module "babylonjs/abstractScene" {
  39231. interface AbstractScene {
  39232. /**
  39233. * The list of sounds used in the scene.
  39234. */
  39235. sounds: Nullable<Array<Sound>>;
  39236. }
  39237. }
  39238. module "babylonjs/scene" {
  39239. interface Scene {
  39240. /**
  39241. * @hidden
  39242. * Backing field
  39243. */
  39244. _mainSoundTrack: SoundTrack;
  39245. /**
  39246. * The main sound track played by the scene.
  39247. * It cotains your primary collection of sounds.
  39248. */
  39249. mainSoundTrack: SoundTrack;
  39250. /**
  39251. * The list of sound tracks added to the scene
  39252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39253. */
  39254. soundTracks: Nullable<Array<SoundTrack>>;
  39255. /**
  39256. * Gets a sound using a given name
  39257. * @param name defines the name to search for
  39258. * @return the found sound or null if not found at all.
  39259. */
  39260. getSoundByName(name: string): Nullable<Sound>;
  39261. /**
  39262. * Gets or sets if audio support is enabled
  39263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39264. */
  39265. audioEnabled: boolean;
  39266. /**
  39267. * Gets or sets if audio will be output to headphones
  39268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39269. */
  39270. headphone: boolean;
  39271. /**
  39272. * Gets or sets custom audio listener position provider
  39273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39274. */
  39275. audioListenerPositionProvider: Nullable<() => Vector3>;
  39276. /**
  39277. * Gets or sets a refresh rate when using 3D audio positioning
  39278. */
  39279. audioPositioningRefreshRate: number;
  39280. }
  39281. }
  39282. /**
  39283. * Defines the sound scene component responsible to manage any sounds
  39284. * in a given scene.
  39285. */
  39286. export class AudioSceneComponent implements ISceneSerializableComponent {
  39287. /**
  39288. * The component name helpfull to identify the component in the list of scene components.
  39289. */
  39290. readonly name: string;
  39291. /**
  39292. * The scene the component belongs to.
  39293. */
  39294. scene: Scene;
  39295. private _audioEnabled;
  39296. /**
  39297. * Gets whether audio is enabled or not.
  39298. * Please use related enable/disable method to switch state.
  39299. */
  39300. get audioEnabled(): boolean;
  39301. private _headphone;
  39302. /**
  39303. * Gets whether audio is outputing to headphone or not.
  39304. * Please use the according Switch methods to change output.
  39305. */
  39306. get headphone(): boolean;
  39307. /**
  39308. * Gets or sets a refresh rate when using 3D audio positioning
  39309. */
  39310. audioPositioningRefreshRate: number;
  39311. private _audioListenerPositionProvider;
  39312. /**
  39313. * Gets the current audio listener position provider
  39314. */
  39315. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39316. /**
  39317. * Sets a custom listener position for all sounds in the scene
  39318. * By default, this is the position of the first active camera
  39319. */
  39320. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39321. /**
  39322. * Creates a new instance of the component for the given scene
  39323. * @param scene Defines the scene to register the component in
  39324. */
  39325. constructor(scene: Scene);
  39326. /**
  39327. * Registers the component in a given scene
  39328. */
  39329. register(): void;
  39330. /**
  39331. * Rebuilds the elements related to this component in case of
  39332. * context lost for instance.
  39333. */
  39334. rebuild(): void;
  39335. /**
  39336. * Serializes the component data to the specified json object
  39337. * @param serializationObject The object to serialize to
  39338. */
  39339. serialize(serializationObject: any): void;
  39340. /**
  39341. * Adds all the elements from the container to the scene
  39342. * @param container the container holding the elements
  39343. */
  39344. addFromContainer(container: AbstractScene): void;
  39345. /**
  39346. * Removes all the elements in the container from the scene
  39347. * @param container contains the elements to remove
  39348. * @param dispose if the removed element should be disposed (default: false)
  39349. */
  39350. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39351. /**
  39352. * Disposes the component and the associated ressources.
  39353. */
  39354. dispose(): void;
  39355. /**
  39356. * Disables audio in the associated scene.
  39357. */
  39358. disableAudio(): void;
  39359. /**
  39360. * Enables audio in the associated scene.
  39361. */
  39362. enableAudio(): void;
  39363. /**
  39364. * Switch audio to headphone output.
  39365. */
  39366. switchAudioModeForHeadphones(): void;
  39367. /**
  39368. * Switch audio to normal speakers.
  39369. */
  39370. switchAudioModeForNormalSpeakers(): void;
  39371. private _cachedCameraDirection;
  39372. private _cachedCameraPosition;
  39373. private _lastCheck;
  39374. private _afterRender;
  39375. }
  39376. }
  39377. declare module "babylonjs/Audio/weightedsound" {
  39378. import { Sound } from "babylonjs/Audio/sound";
  39379. /**
  39380. * Wraps one or more Sound objects and selects one with random weight for playback.
  39381. */
  39382. export class WeightedSound {
  39383. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39384. loop: boolean;
  39385. private _coneInnerAngle;
  39386. private _coneOuterAngle;
  39387. private _volume;
  39388. /** A Sound is currently playing. */
  39389. isPlaying: boolean;
  39390. /** A Sound is currently paused. */
  39391. isPaused: boolean;
  39392. private _sounds;
  39393. private _weights;
  39394. private _currentIndex?;
  39395. /**
  39396. * Creates a new WeightedSound from the list of sounds given.
  39397. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39398. * @param sounds Array of Sounds that will be selected from.
  39399. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39400. */
  39401. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39402. /**
  39403. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39404. */
  39405. get directionalConeInnerAngle(): number;
  39406. /**
  39407. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39408. */
  39409. set directionalConeInnerAngle(value: number);
  39410. /**
  39411. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39412. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39413. */
  39414. get directionalConeOuterAngle(): number;
  39415. /**
  39416. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39417. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39418. */
  39419. set directionalConeOuterAngle(value: number);
  39420. /**
  39421. * Playback volume.
  39422. */
  39423. get volume(): number;
  39424. /**
  39425. * Playback volume.
  39426. */
  39427. set volume(value: number);
  39428. private _onended;
  39429. /**
  39430. * Suspend playback
  39431. */
  39432. pause(): void;
  39433. /**
  39434. * Stop playback
  39435. */
  39436. stop(): void;
  39437. /**
  39438. * Start playback.
  39439. * @param startOffset Position the clip head at a specific time in seconds.
  39440. */
  39441. play(startOffset?: number): void;
  39442. }
  39443. }
  39444. declare module "babylonjs/Audio/index" {
  39445. export * from "babylonjs/Audio/analyser";
  39446. export * from "babylonjs/Audio/audioEngine";
  39447. export * from "babylonjs/Audio/audioSceneComponent";
  39448. export * from "babylonjs/Audio/sound";
  39449. export * from "babylonjs/Audio/soundTrack";
  39450. export * from "babylonjs/Audio/weightedsound";
  39451. }
  39452. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39453. import { Behavior } from "babylonjs/Behaviors/behavior";
  39454. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39455. import { BackEase } from "babylonjs/Animations/easing";
  39456. /**
  39457. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39459. */
  39460. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39461. /**
  39462. * Gets the name of the behavior.
  39463. */
  39464. get name(): string;
  39465. /**
  39466. * The easing function used by animations
  39467. */
  39468. static EasingFunction: BackEase;
  39469. /**
  39470. * The easing mode used by animations
  39471. */
  39472. static EasingMode: number;
  39473. /**
  39474. * The duration of the animation, in milliseconds
  39475. */
  39476. transitionDuration: number;
  39477. /**
  39478. * Length of the distance animated by the transition when lower radius is reached
  39479. */
  39480. lowerRadiusTransitionRange: number;
  39481. /**
  39482. * Length of the distance animated by the transition when upper radius is reached
  39483. */
  39484. upperRadiusTransitionRange: number;
  39485. private _autoTransitionRange;
  39486. /**
  39487. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39488. */
  39489. get autoTransitionRange(): boolean;
  39490. /**
  39491. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39492. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39493. */
  39494. set autoTransitionRange(value: boolean);
  39495. private _attachedCamera;
  39496. private _onAfterCheckInputsObserver;
  39497. private _onMeshTargetChangedObserver;
  39498. /**
  39499. * Initializes the behavior.
  39500. */
  39501. init(): void;
  39502. /**
  39503. * Attaches the behavior to its arc rotate camera.
  39504. * @param camera Defines the camera to attach the behavior to
  39505. */
  39506. attach(camera: ArcRotateCamera): void;
  39507. /**
  39508. * Detaches the behavior from its current arc rotate camera.
  39509. */
  39510. detach(): void;
  39511. private _radiusIsAnimating;
  39512. private _radiusBounceTransition;
  39513. private _animatables;
  39514. private _cachedWheelPrecision;
  39515. /**
  39516. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39517. * @param radiusLimit The limit to check against.
  39518. * @return Bool to indicate if at limit.
  39519. */
  39520. private _isRadiusAtLimit;
  39521. /**
  39522. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39523. * @param radiusDelta The delta by which to animate to. Can be negative.
  39524. */
  39525. private _applyBoundRadiusAnimation;
  39526. /**
  39527. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39528. */
  39529. protected _clearAnimationLocks(): void;
  39530. /**
  39531. * Stops and removes all animations that have been applied to the camera
  39532. */
  39533. stopAllAnimations(): void;
  39534. }
  39535. }
  39536. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39537. import { Behavior } from "babylonjs/Behaviors/behavior";
  39538. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39539. import { ExponentialEase } from "babylonjs/Animations/easing";
  39540. import { Nullable } from "babylonjs/types";
  39541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39542. import { Vector3 } from "babylonjs/Maths/math.vector";
  39543. /**
  39544. * 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.
  39545. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39546. */
  39547. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39548. /**
  39549. * Gets the name of the behavior.
  39550. */
  39551. get name(): string;
  39552. private _mode;
  39553. private _radiusScale;
  39554. private _positionScale;
  39555. private _defaultElevation;
  39556. private _elevationReturnTime;
  39557. private _elevationReturnWaitTime;
  39558. private _zoomStopsAnimation;
  39559. private _framingTime;
  39560. /**
  39561. * The easing function used by animations
  39562. */
  39563. static EasingFunction: ExponentialEase;
  39564. /**
  39565. * The easing mode used by animations
  39566. */
  39567. static EasingMode: number;
  39568. /**
  39569. * Sets the current mode used by the behavior
  39570. */
  39571. set mode(mode: number);
  39572. /**
  39573. * Gets current mode used by the behavior.
  39574. */
  39575. get mode(): number;
  39576. /**
  39577. * Sets the scale applied to the radius (1 by default)
  39578. */
  39579. set radiusScale(radius: number);
  39580. /**
  39581. * Gets the scale applied to the radius
  39582. */
  39583. get radiusScale(): number;
  39584. /**
  39585. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39586. */
  39587. set positionScale(scale: number);
  39588. /**
  39589. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39590. */
  39591. get positionScale(): number;
  39592. /**
  39593. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39594. * behaviour is triggered, in radians.
  39595. */
  39596. set defaultElevation(elevation: number);
  39597. /**
  39598. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39599. * behaviour is triggered, in radians.
  39600. */
  39601. get defaultElevation(): number;
  39602. /**
  39603. * Sets the time (in milliseconds) taken to return to the default beta position.
  39604. * Negative value indicates camera should not return to default.
  39605. */
  39606. set elevationReturnTime(speed: number);
  39607. /**
  39608. * Gets the time (in milliseconds) taken to return to the default beta position.
  39609. * Negative value indicates camera should not return to default.
  39610. */
  39611. get elevationReturnTime(): number;
  39612. /**
  39613. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39614. */
  39615. set elevationReturnWaitTime(time: number);
  39616. /**
  39617. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39618. */
  39619. get elevationReturnWaitTime(): number;
  39620. /**
  39621. * Sets the flag that indicates if user zooming should stop animation.
  39622. */
  39623. set zoomStopsAnimation(flag: boolean);
  39624. /**
  39625. * Gets the flag that indicates if user zooming should stop animation.
  39626. */
  39627. get zoomStopsAnimation(): boolean;
  39628. /**
  39629. * Sets the transition time when framing the mesh, in milliseconds
  39630. */
  39631. set framingTime(time: number);
  39632. /**
  39633. * Gets the transition time when framing the mesh, in milliseconds
  39634. */
  39635. get framingTime(): number;
  39636. /**
  39637. * Define if the behavior should automatically change the configured
  39638. * camera limits and sensibilities.
  39639. */
  39640. autoCorrectCameraLimitsAndSensibility: boolean;
  39641. private _onPrePointerObservableObserver;
  39642. private _onAfterCheckInputsObserver;
  39643. private _onMeshTargetChangedObserver;
  39644. private _attachedCamera;
  39645. private _isPointerDown;
  39646. private _lastInteractionTime;
  39647. /**
  39648. * Initializes the behavior.
  39649. */
  39650. init(): void;
  39651. /**
  39652. * Attaches the behavior to its arc rotate camera.
  39653. * @param camera Defines the camera to attach the behavior to
  39654. */
  39655. attach(camera: ArcRotateCamera): void;
  39656. /**
  39657. * Detaches the behavior from its current arc rotate camera.
  39658. */
  39659. detach(): void;
  39660. private _animatables;
  39661. private _betaIsAnimating;
  39662. private _betaTransition;
  39663. private _radiusTransition;
  39664. private _vectorTransition;
  39665. /**
  39666. * Targets the given mesh and updates zoom level accordingly.
  39667. * @param mesh The mesh to target.
  39668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39670. */
  39671. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39672. /**
  39673. * Targets the given mesh with its children and updates zoom level accordingly.
  39674. * @param mesh The mesh to target.
  39675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39677. */
  39678. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39679. /**
  39680. * Targets the given meshes with their children and updates zoom level accordingly.
  39681. * @param meshes The mesh to target.
  39682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39684. */
  39685. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39686. /**
  39687. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39688. * @param minimumWorld Determines the smaller position of the bounding box extend
  39689. * @param maximumWorld Determines the bigger position of the bounding box extend
  39690. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39691. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39692. */
  39693. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39694. /**
  39695. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39696. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39697. * frustum width.
  39698. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39699. * to fully enclose the mesh in the viewing frustum.
  39700. */
  39701. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39702. /**
  39703. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39704. * is automatically returned to its default position (expected to be above ground plane).
  39705. */
  39706. private _maintainCameraAboveGround;
  39707. /**
  39708. * Returns the frustum slope based on the canvas ratio and camera FOV
  39709. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39710. */
  39711. private _getFrustumSlope;
  39712. /**
  39713. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39714. */
  39715. private _clearAnimationLocks;
  39716. /**
  39717. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39718. */
  39719. private _applyUserInteraction;
  39720. /**
  39721. * Stops and removes all animations that have been applied to the camera
  39722. */
  39723. stopAllAnimations(): void;
  39724. /**
  39725. * Gets a value indicating if the user is moving the camera
  39726. */
  39727. get isUserIsMoving(): boolean;
  39728. /**
  39729. * The camera can move all the way towards the mesh.
  39730. */
  39731. static IgnoreBoundsSizeMode: number;
  39732. /**
  39733. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39734. */
  39735. static FitFrustumSidesMode: number;
  39736. }
  39737. }
  39738. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39739. import { Nullable } from "babylonjs/types";
  39740. import { Camera } from "babylonjs/Cameras/camera";
  39741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39742. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39743. /**
  39744. * Base class for Camera Pointer Inputs.
  39745. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39746. * for example usage.
  39747. */
  39748. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39749. /**
  39750. * Defines the camera the input is attached to.
  39751. */
  39752. abstract camera: Camera;
  39753. /**
  39754. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39755. */
  39756. protected _altKey: boolean;
  39757. protected _ctrlKey: boolean;
  39758. protected _metaKey: boolean;
  39759. protected _shiftKey: boolean;
  39760. /**
  39761. * Which mouse buttons were pressed at time of last mouse event.
  39762. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39763. */
  39764. protected _buttonsPressed: number;
  39765. /**
  39766. * Defines the buttons associated with the input to handle camera move.
  39767. */
  39768. buttons: number[];
  39769. /**
  39770. * Attach the input controls to a specific dom element to get the input from.
  39771. * @param element Defines the element the controls should be listened from
  39772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39773. */
  39774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39775. /**
  39776. * Detach the current controls from the specified dom element.
  39777. * @param element Defines the element to stop listening the inputs from
  39778. */
  39779. detachControl(element: Nullable<HTMLElement>): void;
  39780. /**
  39781. * Gets the class name of the current input.
  39782. * @returns the class name
  39783. */
  39784. getClassName(): string;
  39785. /**
  39786. * Get the friendly name associated with the input class.
  39787. * @returns the input friendly name
  39788. */
  39789. getSimpleName(): string;
  39790. /**
  39791. * Called on pointer POINTERDOUBLETAP event.
  39792. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39793. */
  39794. protected onDoubleTap(type: string): void;
  39795. /**
  39796. * Called on pointer POINTERMOVE event if only a single touch is active.
  39797. * Override this method to provide functionality.
  39798. */
  39799. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39800. /**
  39801. * Called on pointer POINTERMOVE event if multiple touches are active.
  39802. * Override this method to provide functionality.
  39803. */
  39804. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39805. /**
  39806. * Called on JS contextmenu event.
  39807. * Override this method to provide functionality.
  39808. */
  39809. protected onContextMenu(evt: PointerEvent): void;
  39810. /**
  39811. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39812. * press.
  39813. * Override this method to provide functionality.
  39814. */
  39815. protected onButtonDown(evt: PointerEvent): void;
  39816. /**
  39817. * Called each time a new POINTERUP event occurs. Ie, for each button
  39818. * release.
  39819. * Override this method to provide functionality.
  39820. */
  39821. protected onButtonUp(evt: PointerEvent): void;
  39822. /**
  39823. * Called when window becomes inactive.
  39824. * Override this method to provide functionality.
  39825. */
  39826. protected onLostFocus(): void;
  39827. private _pointerInput;
  39828. private _observer;
  39829. private _onLostFocus;
  39830. private pointA;
  39831. private pointB;
  39832. }
  39833. }
  39834. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39835. import { Nullable } from "babylonjs/types";
  39836. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39837. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39838. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39839. /**
  39840. * Manage the pointers inputs to control an arc rotate camera.
  39841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39842. */
  39843. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39844. /**
  39845. * Defines the camera the input is attached to.
  39846. */
  39847. camera: ArcRotateCamera;
  39848. /**
  39849. * Gets the class name of the current input.
  39850. * @returns the class name
  39851. */
  39852. getClassName(): string;
  39853. /**
  39854. * Defines the buttons associated with the input to handle camera move.
  39855. */
  39856. buttons: number[];
  39857. /**
  39858. * Defines the pointer angular sensibility along the X axis or how fast is
  39859. * the camera rotating.
  39860. */
  39861. angularSensibilityX: number;
  39862. /**
  39863. * Defines the pointer angular sensibility along the Y axis or how fast is
  39864. * the camera rotating.
  39865. */
  39866. angularSensibilityY: number;
  39867. /**
  39868. * Defines the pointer pinch precision or how fast is the camera zooming.
  39869. */
  39870. pinchPrecision: number;
  39871. /**
  39872. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39873. * from 0.
  39874. * It defines the percentage of current camera.radius to use as delta when
  39875. * pinch zoom is used.
  39876. */
  39877. pinchDeltaPercentage: number;
  39878. /**
  39879. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39880. * that any object in the plane at the camera's target point will scale
  39881. * perfectly with finger motion.
  39882. * Overrides pinchDeltaPercentage and pinchPrecision.
  39883. */
  39884. useNaturalPinchZoom: boolean;
  39885. /**
  39886. * Defines the pointer panning sensibility or how fast is the camera moving.
  39887. */
  39888. panningSensibility: number;
  39889. /**
  39890. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39891. */
  39892. multiTouchPanning: boolean;
  39893. /**
  39894. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39895. * zoom (pinch) through multitouch.
  39896. */
  39897. multiTouchPanAndZoom: boolean;
  39898. /**
  39899. * Revers pinch action direction.
  39900. */
  39901. pinchInwards: boolean;
  39902. private _isPanClick;
  39903. private _twoFingerActivityCount;
  39904. private _isPinching;
  39905. /**
  39906. * Called on pointer POINTERMOVE event if only a single touch is active.
  39907. */
  39908. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39909. /**
  39910. * Called on pointer POINTERDOUBLETAP event.
  39911. */
  39912. protected onDoubleTap(type: string): void;
  39913. /**
  39914. * Called on pointer POINTERMOVE event if multiple touches are active.
  39915. */
  39916. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39917. /**
  39918. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39919. * press.
  39920. */
  39921. protected onButtonDown(evt: PointerEvent): void;
  39922. /**
  39923. * Called each time a new POINTERUP event occurs. Ie, for each button
  39924. * release.
  39925. */
  39926. protected onButtonUp(evt: PointerEvent): void;
  39927. /**
  39928. * Called when window becomes inactive.
  39929. */
  39930. protected onLostFocus(): void;
  39931. }
  39932. }
  39933. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39934. import { Nullable } from "babylonjs/types";
  39935. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39936. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39937. /**
  39938. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39940. */
  39941. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39942. /**
  39943. * Defines the camera the input is attached to.
  39944. */
  39945. camera: ArcRotateCamera;
  39946. /**
  39947. * Defines the list of key codes associated with the up action (increase alpha)
  39948. */
  39949. keysUp: number[];
  39950. /**
  39951. * Defines the list of key codes associated with the down action (decrease alpha)
  39952. */
  39953. keysDown: number[];
  39954. /**
  39955. * Defines the list of key codes associated with the left action (increase beta)
  39956. */
  39957. keysLeft: number[];
  39958. /**
  39959. * Defines the list of key codes associated with the right action (decrease beta)
  39960. */
  39961. keysRight: number[];
  39962. /**
  39963. * Defines the list of key codes associated with the reset action.
  39964. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39965. */
  39966. keysReset: number[];
  39967. /**
  39968. * Defines the panning sensibility of the inputs.
  39969. * (How fast is the camera panning)
  39970. */
  39971. panningSensibility: number;
  39972. /**
  39973. * Defines the zooming sensibility of the inputs.
  39974. * (How fast is the camera zooming)
  39975. */
  39976. zoomingSensibility: number;
  39977. /**
  39978. * Defines whether maintaining the alt key down switch the movement mode from
  39979. * orientation to zoom.
  39980. */
  39981. useAltToZoom: boolean;
  39982. /**
  39983. * Rotation speed of the camera
  39984. */
  39985. angularSpeed: number;
  39986. private _keys;
  39987. private _ctrlPressed;
  39988. private _altPressed;
  39989. private _onCanvasBlurObserver;
  39990. private _onKeyboardObserver;
  39991. private _engine;
  39992. private _scene;
  39993. /**
  39994. * Attach the input controls to a specific dom element to get the input from.
  39995. * @param element Defines the element the controls should be listened from
  39996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39997. */
  39998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39999. /**
  40000. * Detach the current controls from the specified dom element.
  40001. * @param element Defines the element to stop listening the inputs from
  40002. */
  40003. detachControl(element: Nullable<HTMLElement>): void;
  40004. /**
  40005. * Update the current camera state depending on the inputs that have been used this frame.
  40006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40007. */
  40008. checkInputs(): void;
  40009. /**
  40010. * Gets the class name of the current intput.
  40011. * @returns the class name
  40012. */
  40013. getClassName(): string;
  40014. /**
  40015. * Get the friendly name associated with the input class.
  40016. * @returns the input friendly name
  40017. */
  40018. getSimpleName(): string;
  40019. }
  40020. }
  40021. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40022. import { Nullable } from "babylonjs/types";
  40023. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40024. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40025. /**
  40026. * Manage the mouse wheel inputs to control an arc rotate camera.
  40027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40028. */
  40029. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40030. /**
  40031. * Defines the camera the input is attached to.
  40032. */
  40033. camera: ArcRotateCamera;
  40034. /**
  40035. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40036. */
  40037. wheelPrecision: number;
  40038. /**
  40039. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40040. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40041. */
  40042. wheelDeltaPercentage: number;
  40043. private _wheel;
  40044. private _observer;
  40045. private computeDeltaFromMouseWheelLegacyEvent;
  40046. /**
  40047. * Attach the input controls to a specific dom element to get the input from.
  40048. * @param element Defines the element the controls should be listened from
  40049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40050. */
  40051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40052. /**
  40053. * Detach the current controls from the specified dom element.
  40054. * @param element Defines the element to stop listening the inputs from
  40055. */
  40056. detachControl(element: Nullable<HTMLElement>): void;
  40057. /**
  40058. * Gets the class name of the current intput.
  40059. * @returns the class name
  40060. */
  40061. getClassName(): string;
  40062. /**
  40063. * Get the friendly name associated with the input class.
  40064. * @returns the input friendly name
  40065. */
  40066. getSimpleName(): string;
  40067. }
  40068. }
  40069. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40070. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40071. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40072. /**
  40073. * Default Inputs manager for the ArcRotateCamera.
  40074. * It groups all the default supported inputs for ease of use.
  40075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40076. */
  40077. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40078. /**
  40079. * Instantiates a new ArcRotateCameraInputsManager.
  40080. * @param camera Defines the camera the inputs belong to
  40081. */
  40082. constructor(camera: ArcRotateCamera);
  40083. /**
  40084. * Add mouse wheel input support to the input manager.
  40085. * @returns the current input manager
  40086. */
  40087. addMouseWheel(): ArcRotateCameraInputsManager;
  40088. /**
  40089. * Add pointers input support to the input manager.
  40090. * @returns the current input manager
  40091. */
  40092. addPointers(): ArcRotateCameraInputsManager;
  40093. /**
  40094. * Add keyboard input support to the input manager.
  40095. * @returns the current input manager
  40096. */
  40097. addKeyboard(): ArcRotateCameraInputsManager;
  40098. }
  40099. }
  40100. declare module "babylonjs/Cameras/arcRotateCamera" {
  40101. import { Observable } from "babylonjs/Misc/observable";
  40102. import { Nullable } from "babylonjs/types";
  40103. import { Scene } from "babylonjs/scene";
  40104. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40106. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40107. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40108. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40109. import { Camera } from "babylonjs/Cameras/camera";
  40110. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40111. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40112. import { Collider } from "babylonjs/Collisions/collider";
  40113. /**
  40114. * This represents an orbital type of camera.
  40115. *
  40116. * 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.
  40117. * 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.
  40118. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40119. */
  40120. export class ArcRotateCamera extends TargetCamera {
  40121. /**
  40122. * Defines the rotation angle of the camera along the longitudinal axis.
  40123. */
  40124. alpha: number;
  40125. /**
  40126. * Defines the rotation angle of the camera along the latitudinal axis.
  40127. */
  40128. beta: number;
  40129. /**
  40130. * Defines the radius of the camera from it s target point.
  40131. */
  40132. radius: number;
  40133. protected _target: Vector3;
  40134. protected _targetHost: Nullable<AbstractMesh>;
  40135. /**
  40136. * Defines the target point of the camera.
  40137. * The camera looks towards it form the radius distance.
  40138. */
  40139. get target(): Vector3;
  40140. set target(value: Vector3);
  40141. /**
  40142. * Define the current local position of the camera in the scene
  40143. */
  40144. get position(): Vector3;
  40145. set position(newPosition: Vector3);
  40146. protected _upVector: Vector3;
  40147. protected _upToYMatrix: Matrix;
  40148. protected _YToUpMatrix: Matrix;
  40149. /**
  40150. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40151. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40152. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40153. */
  40154. set upVector(vec: Vector3);
  40155. get upVector(): Vector3;
  40156. /**
  40157. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40158. */
  40159. setMatUp(): void;
  40160. /**
  40161. * Current inertia value on the longitudinal axis.
  40162. * The bigger this number the longer it will take for the camera to stop.
  40163. */
  40164. inertialAlphaOffset: number;
  40165. /**
  40166. * Current inertia value on the latitudinal axis.
  40167. * The bigger this number the longer it will take for the camera to stop.
  40168. */
  40169. inertialBetaOffset: number;
  40170. /**
  40171. * Current inertia value on the radius axis.
  40172. * The bigger this number the longer it will take for the camera to stop.
  40173. */
  40174. inertialRadiusOffset: number;
  40175. /**
  40176. * Minimum allowed angle on the longitudinal axis.
  40177. * This can help limiting how the Camera is able to move in the scene.
  40178. */
  40179. lowerAlphaLimit: Nullable<number>;
  40180. /**
  40181. * Maximum allowed angle on the longitudinal axis.
  40182. * This can help limiting how the Camera is able to move in the scene.
  40183. */
  40184. upperAlphaLimit: Nullable<number>;
  40185. /**
  40186. * Minimum allowed angle on the latitudinal axis.
  40187. * This can help limiting how the Camera is able to move in the scene.
  40188. */
  40189. lowerBetaLimit: number;
  40190. /**
  40191. * Maximum allowed angle on the latitudinal axis.
  40192. * This can help limiting how the Camera is able to move in the scene.
  40193. */
  40194. upperBetaLimit: number;
  40195. /**
  40196. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40197. * This can help limiting how the Camera is able to move in the scene.
  40198. */
  40199. lowerRadiusLimit: Nullable<number>;
  40200. /**
  40201. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40202. * This can help limiting how the Camera is able to move in the scene.
  40203. */
  40204. upperRadiusLimit: Nullable<number>;
  40205. /**
  40206. * Defines the current inertia value used during panning of the camera along the X axis.
  40207. */
  40208. inertialPanningX: number;
  40209. /**
  40210. * Defines the current inertia value used during panning of the camera along the Y axis.
  40211. */
  40212. inertialPanningY: number;
  40213. /**
  40214. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40215. * Basically if your fingers moves away from more than this distance you will be considered
  40216. * in pinch mode.
  40217. */
  40218. pinchToPanMaxDistance: number;
  40219. /**
  40220. * Defines the maximum distance the camera can pan.
  40221. * This could help keeping the cammera always in your scene.
  40222. */
  40223. panningDistanceLimit: Nullable<number>;
  40224. /**
  40225. * Defines the target of the camera before paning.
  40226. */
  40227. panningOriginTarget: Vector3;
  40228. /**
  40229. * Defines the value of the inertia used during panning.
  40230. * 0 would mean stop inertia and one would mean no decelleration at all.
  40231. */
  40232. panningInertia: number;
  40233. /**
  40234. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40235. */
  40236. get angularSensibilityX(): number;
  40237. set angularSensibilityX(value: number);
  40238. /**
  40239. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40240. */
  40241. get angularSensibilityY(): number;
  40242. set angularSensibilityY(value: number);
  40243. /**
  40244. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40245. */
  40246. get pinchPrecision(): number;
  40247. set pinchPrecision(value: number);
  40248. /**
  40249. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40250. * It will be used instead of pinchDeltaPrecision if different from 0.
  40251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40252. */
  40253. get pinchDeltaPercentage(): number;
  40254. set pinchDeltaPercentage(value: number);
  40255. /**
  40256. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40257. * and pinch delta percentage.
  40258. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40259. * that any object in the plane at the camera's target point will scale
  40260. * perfectly with finger motion.
  40261. */
  40262. get useNaturalPinchZoom(): boolean;
  40263. set useNaturalPinchZoom(value: boolean);
  40264. /**
  40265. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40266. */
  40267. get panningSensibility(): number;
  40268. set panningSensibility(value: number);
  40269. /**
  40270. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40271. */
  40272. get keysUp(): number[];
  40273. set keysUp(value: number[]);
  40274. /**
  40275. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40276. */
  40277. get keysDown(): number[];
  40278. set keysDown(value: number[]);
  40279. /**
  40280. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40281. */
  40282. get keysLeft(): number[];
  40283. set keysLeft(value: number[]);
  40284. /**
  40285. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40286. */
  40287. get keysRight(): number[];
  40288. set keysRight(value: number[]);
  40289. /**
  40290. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40291. */
  40292. get wheelPrecision(): number;
  40293. set wheelPrecision(value: number);
  40294. /**
  40295. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40296. * It will be used instead of pinchDeltaPrecision if different from 0.
  40297. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40298. */
  40299. get wheelDeltaPercentage(): number;
  40300. set wheelDeltaPercentage(value: number);
  40301. /**
  40302. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40303. */
  40304. zoomOnFactor: number;
  40305. /**
  40306. * Defines a screen offset for the camera position.
  40307. */
  40308. targetScreenOffset: Vector2;
  40309. /**
  40310. * Allows the camera to be completely reversed.
  40311. * If false the camera can not arrive upside down.
  40312. */
  40313. allowUpsideDown: boolean;
  40314. /**
  40315. * Define if double tap/click is used to restore the previously saved state of the camera.
  40316. */
  40317. useInputToRestoreState: boolean;
  40318. /** @hidden */
  40319. _viewMatrix: Matrix;
  40320. /** @hidden */
  40321. _useCtrlForPanning: boolean;
  40322. /** @hidden */
  40323. _panningMouseButton: number;
  40324. /**
  40325. * Defines the input associated to the camera.
  40326. */
  40327. inputs: ArcRotateCameraInputsManager;
  40328. /** @hidden */
  40329. _reset: () => void;
  40330. /**
  40331. * Defines the allowed panning axis.
  40332. */
  40333. panningAxis: Vector3;
  40334. protected _localDirection: Vector3;
  40335. protected _transformedDirection: Vector3;
  40336. private _bouncingBehavior;
  40337. /**
  40338. * Gets the bouncing behavior of the camera if it has been enabled.
  40339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40340. */
  40341. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40342. /**
  40343. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40345. */
  40346. get useBouncingBehavior(): boolean;
  40347. set useBouncingBehavior(value: boolean);
  40348. private _framingBehavior;
  40349. /**
  40350. * Gets the framing behavior of the camera if it has been enabled.
  40351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40352. */
  40353. get framingBehavior(): Nullable<FramingBehavior>;
  40354. /**
  40355. * Defines if the framing behavior of the camera is enabled on the camera.
  40356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40357. */
  40358. get useFramingBehavior(): boolean;
  40359. set useFramingBehavior(value: boolean);
  40360. private _autoRotationBehavior;
  40361. /**
  40362. * Gets the auto rotation behavior of the camera if it has been enabled.
  40363. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40364. */
  40365. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40366. /**
  40367. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40368. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40369. */
  40370. get useAutoRotationBehavior(): boolean;
  40371. set useAutoRotationBehavior(value: boolean);
  40372. /**
  40373. * Observable triggered when the mesh target has been changed on the camera.
  40374. */
  40375. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40376. /**
  40377. * Event raised when the camera is colliding with a mesh.
  40378. */
  40379. onCollide: (collidedMesh: AbstractMesh) => void;
  40380. /**
  40381. * Defines whether the camera should check collision with the objects oh the scene.
  40382. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40383. */
  40384. checkCollisions: boolean;
  40385. /**
  40386. * Defines the collision radius of the camera.
  40387. * This simulates a sphere around the camera.
  40388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40389. */
  40390. collisionRadius: Vector3;
  40391. protected _collider: Collider;
  40392. protected _previousPosition: Vector3;
  40393. protected _collisionVelocity: Vector3;
  40394. protected _newPosition: Vector3;
  40395. protected _previousAlpha: number;
  40396. protected _previousBeta: number;
  40397. protected _previousRadius: number;
  40398. protected _collisionTriggered: boolean;
  40399. protected _targetBoundingCenter: Nullable<Vector3>;
  40400. private _computationVector;
  40401. /**
  40402. * Instantiates a new ArcRotateCamera in a given scene
  40403. * @param name Defines the name of the camera
  40404. * @param alpha Defines the camera rotation along the logitudinal axis
  40405. * @param beta Defines the camera rotation along the latitudinal axis
  40406. * @param radius Defines the camera distance from its target
  40407. * @param target Defines the camera target
  40408. * @param scene Defines the scene the camera belongs to
  40409. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40410. */
  40411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40412. /** @hidden */
  40413. _initCache(): void;
  40414. /** @hidden */
  40415. _updateCache(ignoreParentClass?: boolean): void;
  40416. protected _getTargetPosition(): Vector3;
  40417. private _storedAlpha;
  40418. private _storedBeta;
  40419. private _storedRadius;
  40420. private _storedTarget;
  40421. private _storedTargetScreenOffset;
  40422. /**
  40423. * Stores the current state of the camera (alpha, beta, radius and target)
  40424. * @returns the camera itself
  40425. */
  40426. storeState(): Camera;
  40427. /**
  40428. * @hidden
  40429. * Restored camera state. You must call storeState() first
  40430. */
  40431. _restoreStateValues(): boolean;
  40432. /** @hidden */
  40433. _isSynchronizedViewMatrix(): boolean;
  40434. /**
  40435. * Attached controls to the current camera.
  40436. * @param element Defines the element the controls should be listened from
  40437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40438. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40439. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40440. */
  40441. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40442. /**
  40443. * Detach the current controls from the camera.
  40444. * The camera will stop reacting to inputs.
  40445. * @param element Defines the element to stop listening the inputs from
  40446. */
  40447. detachControl(element: HTMLElement): void;
  40448. /** @hidden */
  40449. _checkInputs(): void;
  40450. protected _checkLimits(): void;
  40451. /**
  40452. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40453. */
  40454. rebuildAnglesAndRadius(): void;
  40455. /**
  40456. * Use a position to define the current camera related information like alpha, beta and radius
  40457. * @param position Defines the position to set the camera at
  40458. */
  40459. setPosition(position: Vector3): void;
  40460. /**
  40461. * Defines the target the camera should look at.
  40462. * This will automatically adapt alpha beta and radius to fit within the new target.
  40463. * @param target Defines the new target as a Vector or a mesh
  40464. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40465. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40466. */
  40467. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40468. /** @hidden */
  40469. _getViewMatrix(): Matrix;
  40470. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40471. /**
  40472. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40473. * @param meshes Defines the mesh to zoom on
  40474. * @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)
  40475. */
  40476. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40477. /**
  40478. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40479. * The target will be changed but the radius
  40480. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40481. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  40482. */
  40483. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40484. min: Vector3;
  40485. max: Vector3;
  40486. distance: number;
  40487. }, doNotUpdateMaxZ?: boolean): void;
  40488. /**
  40489. * @override
  40490. * Override Camera.createRigCamera
  40491. */
  40492. createRigCamera(name: string, cameraIndex: number): Camera;
  40493. /**
  40494. * @hidden
  40495. * @override
  40496. * Override Camera._updateRigCameras
  40497. */
  40498. _updateRigCameras(): void;
  40499. /**
  40500. * Destroy the camera and release the current resources hold by it.
  40501. */
  40502. dispose(): void;
  40503. /**
  40504. * Gets the current object class name.
  40505. * @return the class name
  40506. */
  40507. getClassName(): string;
  40508. }
  40509. }
  40510. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40511. import { Behavior } from "babylonjs/Behaviors/behavior";
  40512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40513. /**
  40514. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40515. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40516. */
  40517. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40518. /**
  40519. * Gets the name of the behavior.
  40520. */
  40521. get name(): string;
  40522. private _zoomStopsAnimation;
  40523. private _idleRotationSpeed;
  40524. private _idleRotationWaitTime;
  40525. private _idleRotationSpinupTime;
  40526. /**
  40527. * Sets the flag that indicates if user zooming should stop animation.
  40528. */
  40529. set zoomStopsAnimation(flag: boolean);
  40530. /**
  40531. * Gets the flag that indicates if user zooming should stop animation.
  40532. */
  40533. get zoomStopsAnimation(): boolean;
  40534. /**
  40535. * Sets the default speed at which the camera rotates around the model.
  40536. */
  40537. set idleRotationSpeed(speed: number);
  40538. /**
  40539. * Gets the default speed at which the camera rotates around the model.
  40540. */
  40541. get idleRotationSpeed(): number;
  40542. /**
  40543. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40544. */
  40545. set idleRotationWaitTime(time: number);
  40546. /**
  40547. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40548. */
  40549. get idleRotationWaitTime(): number;
  40550. /**
  40551. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40552. */
  40553. set idleRotationSpinupTime(time: number);
  40554. /**
  40555. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40556. */
  40557. get idleRotationSpinupTime(): number;
  40558. /**
  40559. * Gets a value indicating if the camera is currently rotating because of this behavior
  40560. */
  40561. get rotationInProgress(): boolean;
  40562. private _onPrePointerObservableObserver;
  40563. private _onAfterCheckInputsObserver;
  40564. private _attachedCamera;
  40565. private _isPointerDown;
  40566. private _lastFrameTime;
  40567. private _lastInteractionTime;
  40568. private _cameraRotationSpeed;
  40569. /**
  40570. * Initializes the behavior.
  40571. */
  40572. init(): void;
  40573. /**
  40574. * Attaches the behavior to its arc rotate camera.
  40575. * @param camera Defines the camera to attach the behavior to
  40576. */
  40577. attach(camera: ArcRotateCamera): void;
  40578. /**
  40579. * Detaches the behavior from its current arc rotate camera.
  40580. */
  40581. detach(): void;
  40582. /**
  40583. * Returns true if user is scrolling.
  40584. * @return true if user is scrolling.
  40585. */
  40586. private _userIsZooming;
  40587. private _lastFrameRadius;
  40588. private _shouldAnimationStopForInteraction;
  40589. /**
  40590. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40591. */
  40592. private _applyUserInteraction;
  40593. private _userIsMoving;
  40594. }
  40595. }
  40596. declare module "babylonjs/Behaviors/Cameras/index" {
  40597. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40598. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40599. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40600. }
  40601. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40602. import { Mesh } from "babylonjs/Meshes/mesh";
  40603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40604. import { Behavior } from "babylonjs/Behaviors/behavior";
  40605. /**
  40606. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40607. */
  40608. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40609. private ui;
  40610. /**
  40611. * The name of the behavior
  40612. */
  40613. name: string;
  40614. /**
  40615. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40616. */
  40617. distanceAwayFromFace: number;
  40618. /**
  40619. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40620. */
  40621. distanceAwayFromBottomOfFace: number;
  40622. private _faceVectors;
  40623. private _target;
  40624. private _scene;
  40625. private _onRenderObserver;
  40626. private _tmpMatrix;
  40627. private _tmpVector;
  40628. /**
  40629. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40630. * @param ui The transform node that should be attched to the mesh
  40631. */
  40632. constructor(ui: TransformNode);
  40633. /**
  40634. * Initializes the behavior
  40635. */
  40636. init(): void;
  40637. private _closestFace;
  40638. private _zeroVector;
  40639. private _lookAtTmpMatrix;
  40640. private _lookAtToRef;
  40641. /**
  40642. * Attaches the AttachToBoxBehavior to the passed in mesh
  40643. * @param target The mesh that the specified node will be attached to
  40644. */
  40645. attach(target: Mesh): void;
  40646. /**
  40647. * Detaches the behavior from the mesh
  40648. */
  40649. detach(): void;
  40650. }
  40651. }
  40652. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40653. import { Behavior } from "babylonjs/Behaviors/behavior";
  40654. import { Mesh } from "babylonjs/Meshes/mesh";
  40655. /**
  40656. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40657. */
  40658. export class FadeInOutBehavior implements Behavior<Mesh> {
  40659. /**
  40660. * Time in milliseconds to delay before fading in (Default: 0)
  40661. */
  40662. delay: number;
  40663. /**
  40664. * Time in milliseconds for the mesh to fade in (Default: 300)
  40665. */
  40666. fadeInTime: number;
  40667. private _millisecondsPerFrame;
  40668. private _hovered;
  40669. private _hoverValue;
  40670. private _ownerNode;
  40671. /**
  40672. * Instatiates the FadeInOutBehavior
  40673. */
  40674. constructor();
  40675. /**
  40676. * The name of the behavior
  40677. */
  40678. get name(): string;
  40679. /**
  40680. * Initializes the behavior
  40681. */
  40682. init(): void;
  40683. /**
  40684. * Attaches the fade behavior on the passed in mesh
  40685. * @param ownerNode The mesh that will be faded in/out once attached
  40686. */
  40687. attach(ownerNode: Mesh): void;
  40688. /**
  40689. * Detaches the behavior from the mesh
  40690. */
  40691. detach(): void;
  40692. /**
  40693. * Triggers the mesh to begin fading in or out
  40694. * @param value if the object should fade in or out (true to fade in)
  40695. */
  40696. fadeIn(value: boolean): void;
  40697. private _update;
  40698. private _setAllVisibility;
  40699. }
  40700. }
  40701. declare module "babylonjs/Misc/pivotTools" {
  40702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40703. /**
  40704. * Class containing a set of static utilities functions for managing Pivots
  40705. * @hidden
  40706. */
  40707. export class PivotTools {
  40708. private static _PivotCached;
  40709. private static _OldPivotPoint;
  40710. private static _PivotTranslation;
  40711. private static _PivotTmpVector;
  40712. /** @hidden */
  40713. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40714. /** @hidden */
  40715. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40716. }
  40717. }
  40718. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40719. import { Scene } from "babylonjs/scene";
  40720. import { Vector4 } from "babylonjs/Maths/math.vector";
  40721. import { Mesh } from "babylonjs/Meshes/mesh";
  40722. import { Nullable } from "babylonjs/types";
  40723. import { Plane } from "babylonjs/Maths/math.plane";
  40724. /**
  40725. * Class containing static functions to help procedurally build meshes
  40726. */
  40727. export class PlaneBuilder {
  40728. /**
  40729. * Creates a plane mesh
  40730. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40731. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40732. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40736. * @param name defines the name of the mesh
  40737. * @param options defines the options used to create the mesh
  40738. * @param scene defines the hosting scene
  40739. * @returns the plane mesh
  40740. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40741. */
  40742. static CreatePlane(name: string, options: {
  40743. size?: number;
  40744. width?: number;
  40745. height?: number;
  40746. sideOrientation?: number;
  40747. frontUVs?: Vector4;
  40748. backUVs?: Vector4;
  40749. updatable?: boolean;
  40750. sourcePlane?: Plane;
  40751. }, scene?: Nullable<Scene>): Mesh;
  40752. }
  40753. }
  40754. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40755. import { Behavior } from "babylonjs/Behaviors/behavior";
  40756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40757. import { Observable } from "babylonjs/Misc/observable";
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import { Ray } from "babylonjs/Culling/ray";
  40760. import "babylonjs/Meshes/Builders/planeBuilder";
  40761. /**
  40762. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40763. */
  40764. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40765. private static _AnyMouseID;
  40766. /**
  40767. * Abstract mesh the behavior is set on
  40768. */
  40769. attachedNode: AbstractMesh;
  40770. private _dragPlane;
  40771. private _scene;
  40772. private _pointerObserver;
  40773. private _beforeRenderObserver;
  40774. private static _planeScene;
  40775. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40776. /**
  40777. * 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)
  40778. */
  40779. maxDragAngle: number;
  40780. /**
  40781. * @hidden
  40782. */
  40783. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40784. /**
  40785. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40786. */
  40787. currentDraggingPointerID: number;
  40788. /**
  40789. * The last position where the pointer hit the drag plane in world space
  40790. */
  40791. lastDragPosition: Vector3;
  40792. /**
  40793. * If the behavior is currently in a dragging state
  40794. */
  40795. dragging: boolean;
  40796. /**
  40797. * 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)
  40798. */
  40799. dragDeltaRatio: number;
  40800. /**
  40801. * If the drag plane orientation should be updated during the dragging (Default: true)
  40802. */
  40803. updateDragPlane: boolean;
  40804. private _debugMode;
  40805. private _moving;
  40806. /**
  40807. * Fires each time the attached mesh is dragged with the pointer
  40808. * * delta between last drag position and current drag position in world space
  40809. * * dragDistance along the drag axis
  40810. * * dragPlaneNormal normal of the current drag plane used during the drag
  40811. * * dragPlanePoint in world space where the drag intersects the drag plane
  40812. */
  40813. onDragObservable: Observable<{
  40814. delta: Vector3;
  40815. dragPlanePoint: Vector3;
  40816. dragPlaneNormal: Vector3;
  40817. dragDistance: number;
  40818. pointerId: number;
  40819. }>;
  40820. /**
  40821. * Fires each time a drag begins (eg. mouse down on mesh)
  40822. */
  40823. onDragStartObservable: Observable<{
  40824. dragPlanePoint: Vector3;
  40825. pointerId: number;
  40826. }>;
  40827. /**
  40828. * Fires each time a drag ends (eg. mouse release after drag)
  40829. */
  40830. onDragEndObservable: Observable<{
  40831. dragPlanePoint: Vector3;
  40832. pointerId: number;
  40833. }>;
  40834. /**
  40835. * If the attached mesh should be moved when dragged
  40836. */
  40837. moveAttached: boolean;
  40838. /**
  40839. * If the drag behavior will react to drag events (Default: true)
  40840. */
  40841. enabled: boolean;
  40842. /**
  40843. * If pointer events should start and release the drag (Default: true)
  40844. */
  40845. startAndReleaseDragOnPointerEvents: boolean;
  40846. /**
  40847. * If camera controls should be detached during the drag
  40848. */
  40849. detachCameraControls: boolean;
  40850. /**
  40851. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40852. */
  40853. useObjectOrientationForDragging: boolean;
  40854. private _options;
  40855. /**
  40856. * Gets the options used by the behavior
  40857. */
  40858. get options(): {
  40859. dragAxis?: Vector3;
  40860. dragPlaneNormal?: Vector3;
  40861. };
  40862. /**
  40863. * Sets the options used by the behavior
  40864. */
  40865. set options(options: {
  40866. dragAxis?: Vector3;
  40867. dragPlaneNormal?: Vector3;
  40868. });
  40869. /**
  40870. * Creates a pointer drag behavior that can be attached to a mesh
  40871. * @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)
  40872. */
  40873. constructor(options?: {
  40874. dragAxis?: Vector3;
  40875. dragPlaneNormal?: Vector3;
  40876. });
  40877. /**
  40878. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40879. */
  40880. validateDrag: (targetPosition: Vector3) => boolean;
  40881. /**
  40882. * The name of the behavior
  40883. */
  40884. get name(): string;
  40885. /**
  40886. * Initializes the behavior
  40887. */
  40888. init(): void;
  40889. private _tmpVector;
  40890. private _alternatePickedPoint;
  40891. private _worldDragAxis;
  40892. private _targetPosition;
  40893. private _attachedElement;
  40894. /**
  40895. * Attaches the drag behavior the passed in mesh
  40896. * @param ownerNode The mesh that will be dragged around once attached
  40897. * @param predicate Predicate to use for pick filtering
  40898. */
  40899. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40900. /**
  40901. * Force relase the drag action by code.
  40902. */
  40903. releaseDrag(): void;
  40904. private _startDragRay;
  40905. private _lastPointerRay;
  40906. /**
  40907. * Simulates the start of a pointer drag event on the behavior
  40908. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40909. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40910. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40911. */
  40912. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40913. private _startDrag;
  40914. private _dragDelta;
  40915. private _moveDrag;
  40916. private _pickWithRayOnDragPlane;
  40917. private _pointA;
  40918. private _pointB;
  40919. private _pointC;
  40920. private _lineA;
  40921. private _lineB;
  40922. private _localAxis;
  40923. private _lookAt;
  40924. private _updateDragPlanePosition;
  40925. /**
  40926. * Detaches the behavior from the mesh
  40927. */
  40928. detach(): void;
  40929. }
  40930. }
  40931. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40932. import { Mesh } from "babylonjs/Meshes/mesh";
  40933. import { Behavior } from "babylonjs/Behaviors/behavior";
  40934. /**
  40935. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40936. */
  40937. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40938. private _dragBehaviorA;
  40939. private _dragBehaviorB;
  40940. private _startDistance;
  40941. private _initialScale;
  40942. private _targetScale;
  40943. private _ownerNode;
  40944. private _sceneRenderObserver;
  40945. /**
  40946. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40947. */
  40948. constructor();
  40949. /**
  40950. * The name of the behavior
  40951. */
  40952. get name(): string;
  40953. /**
  40954. * Initializes the behavior
  40955. */
  40956. init(): void;
  40957. private _getCurrentDistance;
  40958. /**
  40959. * Attaches the scale behavior the passed in mesh
  40960. * @param ownerNode The mesh that will be scaled around once attached
  40961. */
  40962. attach(ownerNode: Mesh): void;
  40963. /**
  40964. * Detaches the behavior from the mesh
  40965. */
  40966. detach(): void;
  40967. }
  40968. }
  40969. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40970. import { Behavior } from "babylonjs/Behaviors/behavior";
  40971. import { Mesh } from "babylonjs/Meshes/mesh";
  40972. import { Observable } from "babylonjs/Misc/observable";
  40973. /**
  40974. * 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
  40975. */
  40976. export class SixDofDragBehavior implements Behavior<Mesh> {
  40977. private static _virtualScene;
  40978. private _ownerNode;
  40979. private _sceneRenderObserver;
  40980. private _scene;
  40981. private _targetPosition;
  40982. private _virtualOriginMesh;
  40983. private _virtualDragMesh;
  40984. private _pointerObserver;
  40985. private _moving;
  40986. private _startingOrientation;
  40987. private _attachedElement;
  40988. /**
  40989. * 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)
  40990. */
  40991. private zDragFactor;
  40992. /**
  40993. * If the object should rotate to face the drag origin
  40994. */
  40995. rotateDraggedObject: boolean;
  40996. /**
  40997. * If the behavior is currently in a dragging state
  40998. */
  40999. dragging: boolean;
  41000. /**
  41001. * 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)
  41002. */
  41003. dragDeltaRatio: number;
  41004. /**
  41005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41006. */
  41007. currentDraggingPointerID: number;
  41008. /**
  41009. * If camera controls should be detached during the drag
  41010. */
  41011. detachCameraControls: boolean;
  41012. /**
  41013. * Fires each time a drag starts
  41014. */
  41015. onDragStartObservable: Observable<{}>;
  41016. /**
  41017. * Fires each time a drag ends (eg. mouse release after drag)
  41018. */
  41019. onDragEndObservable: Observable<{}>;
  41020. /**
  41021. * 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
  41022. */
  41023. constructor();
  41024. /**
  41025. * The name of the behavior
  41026. */
  41027. get name(): string;
  41028. /**
  41029. * Initializes the behavior
  41030. */
  41031. init(): void;
  41032. /**
  41033. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41034. */
  41035. private get _pointerCamera();
  41036. /**
  41037. * Attaches the scale behavior the passed in mesh
  41038. * @param ownerNode The mesh that will be scaled around once attached
  41039. */
  41040. attach(ownerNode: Mesh): void;
  41041. /**
  41042. * Detaches the behavior from the mesh
  41043. */
  41044. detach(): void;
  41045. }
  41046. }
  41047. declare module "babylonjs/Behaviors/Meshes/index" {
  41048. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41049. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41050. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41051. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41052. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41053. }
  41054. declare module "babylonjs/Behaviors/index" {
  41055. export * from "babylonjs/Behaviors/behavior";
  41056. export * from "babylonjs/Behaviors/Cameras/index";
  41057. export * from "babylonjs/Behaviors/Meshes/index";
  41058. }
  41059. declare module "babylonjs/Bones/boneIKController" {
  41060. import { Bone } from "babylonjs/Bones/bone";
  41061. import { Vector3 } from "babylonjs/Maths/math.vector";
  41062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41063. import { Nullable } from "babylonjs/types";
  41064. /**
  41065. * Class used to apply inverse kinematics to bones
  41066. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41067. */
  41068. export class BoneIKController {
  41069. private static _tmpVecs;
  41070. private static _tmpQuat;
  41071. private static _tmpMats;
  41072. /**
  41073. * Gets or sets the target mesh
  41074. */
  41075. targetMesh: AbstractMesh;
  41076. /** Gets or sets the mesh used as pole */
  41077. poleTargetMesh: AbstractMesh;
  41078. /**
  41079. * Gets or sets the bone used as pole
  41080. */
  41081. poleTargetBone: Nullable<Bone>;
  41082. /**
  41083. * Gets or sets the target position
  41084. */
  41085. targetPosition: Vector3;
  41086. /**
  41087. * Gets or sets the pole target position
  41088. */
  41089. poleTargetPosition: Vector3;
  41090. /**
  41091. * Gets or sets the pole target local offset
  41092. */
  41093. poleTargetLocalOffset: Vector3;
  41094. /**
  41095. * Gets or sets the pole angle
  41096. */
  41097. poleAngle: number;
  41098. /**
  41099. * Gets or sets the mesh associated with the controller
  41100. */
  41101. mesh: AbstractMesh;
  41102. /**
  41103. * 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)
  41104. */
  41105. slerpAmount: number;
  41106. private _bone1Quat;
  41107. private _bone1Mat;
  41108. private _bone2Ang;
  41109. private _bone1;
  41110. private _bone2;
  41111. private _bone1Length;
  41112. private _bone2Length;
  41113. private _maxAngle;
  41114. private _maxReach;
  41115. private _rightHandedSystem;
  41116. private _bendAxis;
  41117. private _slerping;
  41118. private _adjustRoll;
  41119. /**
  41120. * Gets or sets maximum allowed angle
  41121. */
  41122. get maxAngle(): number;
  41123. set maxAngle(value: number);
  41124. /**
  41125. * Creates a new BoneIKController
  41126. * @param mesh defines the mesh to control
  41127. * @param bone defines the bone to control
  41128. * @param options defines options to set up the controller
  41129. */
  41130. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41131. targetMesh?: AbstractMesh;
  41132. poleTargetMesh?: AbstractMesh;
  41133. poleTargetBone?: Bone;
  41134. poleTargetLocalOffset?: Vector3;
  41135. poleAngle?: number;
  41136. bendAxis?: Vector3;
  41137. maxAngle?: number;
  41138. slerpAmount?: number;
  41139. });
  41140. private _setMaxAngle;
  41141. /**
  41142. * Force the controller to update the bones
  41143. */
  41144. update(): void;
  41145. }
  41146. }
  41147. declare module "babylonjs/Bones/boneLookController" {
  41148. import { Vector3 } from "babylonjs/Maths/math.vector";
  41149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41150. import { Bone } from "babylonjs/Bones/bone";
  41151. import { Space } from "babylonjs/Maths/math.axis";
  41152. /**
  41153. * Class used to make a bone look toward a point in space
  41154. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41155. */
  41156. export class BoneLookController {
  41157. private static _tmpVecs;
  41158. private static _tmpQuat;
  41159. private static _tmpMats;
  41160. /**
  41161. * The target Vector3 that the bone will look at
  41162. */
  41163. target: Vector3;
  41164. /**
  41165. * The mesh that the bone is attached to
  41166. */
  41167. mesh: AbstractMesh;
  41168. /**
  41169. * The bone that will be looking to the target
  41170. */
  41171. bone: Bone;
  41172. /**
  41173. * The up axis of the coordinate system that is used when the bone is rotated
  41174. */
  41175. upAxis: Vector3;
  41176. /**
  41177. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41178. */
  41179. upAxisSpace: Space;
  41180. /**
  41181. * Used to make an adjustment to the yaw of the bone
  41182. */
  41183. adjustYaw: number;
  41184. /**
  41185. * Used to make an adjustment to the pitch of the bone
  41186. */
  41187. adjustPitch: number;
  41188. /**
  41189. * Used to make an adjustment to the roll of the bone
  41190. */
  41191. adjustRoll: number;
  41192. /**
  41193. * 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)
  41194. */
  41195. slerpAmount: number;
  41196. private _minYaw;
  41197. private _maxYaw;
  41198. private _minPitch;
  41199. private _maxPitch;
  41200. private _minYawSin;
  41201. private _minYawCos;
  41202. private _maxYawSin;
  41203. private _maxYawCos;
  41204. private _midYawConstraint;
  41205. private _minPitchTan;
  41206. private _maxPitchTan;
  41207. private _boneQuat;
  41208. private _slerping;
  41209. private _transformYawPitch;
  41210. private _transformYawPitchInv;
  41211. private _firstFrameSkipped;
  41212. private _yawRange;
  41213. private _fowardAxis;
  41214. /**
  41215. * Gets or sets the minimum yaw angle that the bone can look to
  41216. */
  41217. get minYaw(): number;
  41218. set minYaw(value: number);
  41219. /**
  41220. * Gets or sets the maximum yaw angle that the bone can look to
  41221. */
  41222. get maxYaw(): number;
  41223. set maxYaw(value: number);
  41224. /**
  41225. * Gets or sets the minimum pitch angle that the bone can look to
  41226. */
  41227. get minPitch(): number;
  41228. set minPitch(value: number);
  41229. /**
  41230. * Gets or sets the maximum pitch angle that the bone can look to
  41231. */
  41232. get maxPitch(): number;
  41233. set maxPitch(value: number);
  41234. /**
  41235. * Create a BoneLookController
  41236. * @param mesh the mesh that the bone belongs to
  41237. * @param bone the bone that will be looking to the target
  41238. * @param target the target Vector3 to look at
  41239. * @param options optional settings:
  41240. * * maxYaw: the maximum angle the bone will yaw to
  41241. * * minYaw: the minimum angle the bone will yaw to
  41242. * * maxPitch: the maximum angle the bone will pitch to
  41243. * * minPitch: the minimum angle the bone will yaw to
  41244. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41245. * * upAxis: the up axis of the coordinate system
  41246. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41247. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41248. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41249. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41250. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41251. * * adjustRoll: used to make an adjustment to the roll of the bone
  41252. **/
  41253. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41254. maxYaw?: number;
  41255. minYaw?: number;
  41256. maxPitch?: number;
  41257. minPitch?: number;
  41258. slerpAmount?: number;
  41259. upAxis?: Vector3;
  41260. upAxisSpace?: Space;
  41261. yawAxis?: Vector3;
  41262. pitchAxis?: Vector3;
  41263. adjustYaw?: number;
  41264. adjustPitch?: number;
  41265. adjustRoll?: number;
  41266. });
  41267. /**
  41268. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41269. */
  41270. update(): void;
  41271. private _getAngleDiff;
  41272. private _getAngleBetween;
  41273. private _isAngleBetween;
  41274. }
  41275. }
  41276. declare module "babylonjs/Bones/index" {
  41277. export * from "babylonjs/Bones/bone";
  41278. export * from "babylonjs/Bones/boneIKController";
  41279. export * from "babylonjs/Bones/boneLookController";
  41280. export * from "babylonjs/Bones/skeleton";
  41281. }
  41282. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41283. import { Nullable } from "babylonjs/types";
  41284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41285. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41286. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41287. /**
  41288. * Manage the gamepad inputs to control an arc rotate camera.
  41289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41290. */
  41291. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41292. /**
  41293. * Defines the camera the input is attached to.
  41294. */
  41295. camera: ArcRotateCamera;
  41296. /**
  41297. * Defines the gamepad the input is gathering event from.
  41298. */
  41299. gamepad: Nullable<Gamepad>;
  41300. /**
  41301. * Defines the gamepad rotation sensiblity.
  41302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41303. */
  41304. gamepadRotationSensibility: number;
  41305. /**
  41306. * Defines the gamepad move sensiblity.
  41307. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41308. */
  41309. gamepadMoveSensibility: number;
  41310. private _yAxisScale;
  41311. /**
  41312. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41313. */
  41314. get invertYAxis(): boolean;
  41315. set invertYAxis(value: boolean);
  41316. private _onGamepadConnectedObserver;
  41317. private _onGamepadDisconnectedObserver;
  41318. /**
  41319. * Attach the input controls to a specific dom element to get the input from.
  41320. * @param element Defines the element the controls should be listened from
  41321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41322. */
  41323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41324. /**
  41325. * Detach the current controls from the specified dom element.
  41326. * @param element Defines the element to stop listening the inputs from
  41327. */
  41328. detachControl(element: Nullable<HTMLElement>): void;
  41329. /**
  41330. * Update the current camera state depending on the inputs that have been used this frame.
  41331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41332. */
  41333. checkInputs(): void;
  41334. /**
  41335. * Gets the class name of the current intput.
  41336. * @returns the class name
  41337. */
  41338. getClassName(): string;
  41339. /**
  41340. * Get the friendly name associated with the input class.
  41341. * @returns the input friendly name
  41342. */
  41343. getSimpleName(): string;
  41344. }
  41345. }
  41346. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41347. import { Nullable } from "babylonjs/types";
  41348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41349. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41350. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41351. interface ArcRotateCameraInputsManager {
  41352. /**
  41353. * Add orientation input support to the input manager.
  41354. * @returns the current input manager
  41355. */
  41356. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41357. }
  41358. }
  41359. /**
  41360. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41362. */
  41363. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41364. /**
  41365. * Defines the camera the input is attached to.
  41366. */
  41367. camera: ArcRotateCamera;
  41368. /**
  41369. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41370. */
  41371. alphaCorrection: number;
  41372. /**
  41373. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41374. */
  41375. gammaCorrection: number;
  41376. private _alpha;
  41377. private _gamma;
  41378. private _dirty;
  41379. private _deviceOrientationHandler;
  41380. /**
  41381. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41382. */
  41383. constructor();
  41384. /**
  41385. * Attach the input controls to a specific dom element to get the input from.
  41386. * @param element Defines the element the controls should be listened from
  41387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41388. */
  41389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41390. /** @hidden */
  41391. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41392. /**
  41393. * Update the current camera state depending on the inputs that have been used this frame.
  41394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41395. */
  41396. checkInputs(): void;
  41397. /**
  41398. * Detach the current controls from the specified dom element.
  41399. * @param element Defines the element to stop listening the inputs from
  41400. */
  41401. detachControl(element: Nullable<HTMLElement>): void;
  41402. /**
  41403. * Gets the class name of the current intput.
  41404. * @returns the class name
  41405. */
  41406. getClassName(): string;
  41407. /**
  41408. * Get the friendly name associated with the input class.
  41409. * @returns the input friendly name
  41410. */
  41411. getSimpleName(): string;
  41412. }
  41413. }
  41414. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41415. import { Nullable } from "babylonjs/types";
  41416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41417. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41418. /**
  41419. * Listen to mouse events to control the camera.
  41420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41421. */
  41422. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41423. /**
  41424. * Defines the camera the input is attached to.
  41425. */
  41426. camera: FlyCamera;
  41427. /**
  41428. * Defines if touch is enabled. (Default is true.)
  41429. */
  41430. touchEnabled: boolean;
  41431. /**
  41432. * Defines the buttons associated with the input to handle camera rotation.
  41433. */
  41434. buttons: number[];
  41435. /**
  41436. * Assign buttons for Yaw control.
  41437. */
  41438. buttonsYaw: number[];
  41439. /**
  41440. * Assign buttons for Pitch control.
  41441. */
  41442. buttonsPitch: number[];
  41443. /**
  41444. * Assign buttons for Roll control.
  41445. */
  41446. buttonsRoll: number[];
  41447. /**
  41448. * Detect if any button is being pressed while mouse is moved.
  41449. * -1 = Mouse locked.
  41450. * 0 = Left button.
  41451. * 1 = Middle Button.
  41452. * 2 = Right Button.
  41453. */
  41454. activeButton: number;
  41455. /**
  41456. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41457. * Higher values reduce its sensitivity.
  41458. */
  41459. angularSensibility: number;
  41460. private _mousemoveCallback;
  41461. private _observer;
  41462. private _rollObserver;
  41463. private previousPosition;
  41464. private noPreventDefault;
  41465. private element;
  41466. /**
  41467. * Listen to mouse events to control the camera.
  41468. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41470. */
  41471. constructor(touchEnabled?: boolean);
  41472. /**
  41473. * Attach the mouse control to the HTML DOM element.
  41474. * @param element Defines the element that listens to the input events.
  41475. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41476. */
  41477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41478. /**
  41479. * Detach the current controls from the specified dom element.
  41480. * @param element Defines the element to stop listening the inputs from
  41481. */
  41482. detachControl(element: Nullable<HTMLElement>): void;
  41483. /**
  41484. * Gets the class name of the current input.
  41485. * @returns the class name.
  41486. */
  41487. getClassName(): string;
  41488. /**
  41489. * Get the friendly name associated with the input class.
  41490. * @returns the input's friendly name.
  41491. */
  41492. getSimpleName(): string;
  41493. private _pointerInput;
  41494. private _onMouseMove;
  41495. /**
  41496. * Rotate camera by mouse offset.
  41497. */
  41498. private rotateCamera;
  41499. }
  41500. }
  41501. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41502. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41503. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41504. /**
  41505. * Default Inputs manager for the FlyCamera.
  41506. * It groups all the default supported inputs for ease of use.
  41507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41508. */
  41509. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41510. /**
  41511. * Instantiates a new FlyCameraInputsManager.
  41512. * @param camera Defines the camera the inputs belong to.
  41513. */
  41514. constructor(camera: FlyCamera);
  41515. /**
  41516. * Add keyboard input support to the input manager.
  41517. * @returns the new FlyCameraKeyboardMoveInput().
  41518. */
  41519. addKeyboard(): FlyCameraInputsManager;
  41520. /**
  41521. * Add mouse input support to the input manager.
  41522. * @param touchEnabled Enable touch screen support.
  41523. * @returns the new FlyCameraMouseInput().
  41524. */
  41525. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41526. }
  41527. }
  41528. declare module "babylonjs/Cameras/flyCamera" {
  41529. import { Scene } from "babylonjs/scene";
  41530. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41532. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41533. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41534. /**
  41535. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41536. * such as in a 3D Space Shooter or a Flight Simulator.
  41537. */
  41538. export class FlyCamera extends TargetCamera {
  41539. /**
  41540. * Define the collision ellipsoid of the camera.
  41541. * This is helpful for simulating a camera body, like a player's body.
  41542. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41543. */
  41544. ellipsoid: Vector3;
  41545. /**
  41546. * Define an offset for the position of the ellipsoid around the camera.
  41547. * This can be helpful if the camera is attached away from the player's body center,
  41548. * such as at its head.
  41549. */
  41550. ellipsoidOffset: Vector3;
  41551. /**
  41552. * Enable or disable collisions of the camera with the rest of the scene objects.
  41553. */
  41554. checkCollisions: boolean;
  41555. /**
  41556. * Enable or disable gravity on the camera.
  41557. */
  41558. applyGravity: boolean;
  41559. /**
  41560. * Define the current direction the camera is moving to.
  41561. */
  41562. cameraDirection: Vector3;
  41563. /**
  41564. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41565. * This overrides and empties cameraRotation.
  41566. */
  41567. rotationQuaternion: Quaternion;
  41568. /**
  41569. * Track Roll to maintain the wanted Rolling when looking around.
  41570. */
  41571. _trackRoll: number;
  41572. /**
  41573. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41574. */
  41575. rollCorrect: number;
  41576. /**
  41577. * Mimic a banked turn, Rolling the camera when Yawing.
  41578. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41579. */
  41580. bankedTurn: boolean;
  41581. /**
  41582. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41583. */
  41584. bankedTurnLimit: number;
  41585. /**
  41586. * Value of 0 disables the banked Roll.
  41587. * Value of 1 is equal to the Yaw angle in radians.
  41588. */
  41589. bankedTurnMultiplier: number;
  41590. /**
  41591. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41592. */
  41593. inputs: FlyCameraInputsManager;
  41594. /**
  41595. * Gets the input sensibility for mouse input.
  41596. * Higher values reduce sensitivity.
  41597. */
  41598. get angularSensibility(): number;
  41599. /**
  41600. * Sets the input sensibility for a mouse input.
  41601. * Higher values reduce sensitivity.
  41602. */
  41603. set angularSensibility(value: number);
  41604. /**
  41605. * Get the keys for camera movement forward.
  41606. */
  41607. get keysForward(): number[];
  41608. /**
  41609. * Set the keys for camera movement forward.
  41610. */
  41611. set keysForward(value: number[]);
  41612. /**
  41613. * Get the keys for camera movement backward.
  41614. */
  41615. get keysBackward(): number[];
  41616. set keysBackward(value: number[]);
  41617. /**
  41618. * Get the keys for camera movement up.
  41619. */
  41620. get keysUp(): number[];
  41621. /**
  41622. * Set the keys for camera movement up.
  41623. */
  41624. set keysUp(value: number[]);
  41625. /**
  41626. * Get the keys for camera movement down.
  41627. */
  41628. get keysDown(): number[];
  41629. /**
  41630. * Set the keys for camera movement down.
  41631. */
  41632. set keysDown(value: number[]);
  41633. /**
  41634. * Get the keys for camera movement left.
  41635. */
  41636. get keysLeft(): number[];
  41637. /**
  41638. * Set the keys for camera movement left.
  41639. */
  41640. set keysLeft(value: number[]);
  41641. /**
  41642. * Set the keys for camera movement right.
  41643. */
  41644. get keysRight(): number[];
  41645. /**
  41646. * Set the keys for camera movement right.
  41647. */
  41648. set keysRight(value: number[]);
  41649. /**
  41650. * Event raised when the camera collides with a mesh in the scene.
  41651. */
  41652. onCollide: (collidedMesh: AbstractMesh) => void;
  41653. private _collider;
  41654. private _needMoveForGravity;
  41655. private _oldPosition;
  41656. private _diffPosition;
  41657. private _newPosition;
  41658. /** @hidden */
  41659. _localDirection: Vector3;
  41660. /** @hidden */
  41661. _transformedDirection: Vector3;
  41662. /**
  41663. * Instantiates a FlyCamera.
  41664. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41665. * such as in a 3D Space Shooter or a Flight Simulator.
  41666. * @param name Define the name of the camera in the scene.
  41667. * @param position Define the starting position of the camera in the scene.
  41668. * @param scene Define the scene the camera belongs to.
  41669. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41670. */
  41671. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41672. /**
  41673. * Attach a control to the HTML DOM element.
  41674. * @param element Defines the element that listens to the input events.
  41675. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41676. */
  41677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41678. /**
  41679. * Detach a control from the HTML DOM element.
  41680. * The camera will stop reacting to that input.
  41681. * @param element Defines the element that listens to the input events.
  41682. */
  41683. detachControl(element: HTMLElement): void;
  41684. private _collisionMask;
  41685. /**
  41686. * Get the mask that the camera ignores in collision events.
  41687. */
  41688. get collisionMask(): number;
  41689. /**
  41690. * Set the mask that the camera ignores in collision events.
  41691. */
  41692. set collisionMask(mask: number);
  41693. /** @hidden */
  41694. _collideWithWorld(displacement: Vector3): void;
  41695. /** @hidden */
  41696. private _onCollisionPositionChange;
  41697. /** @hidden */
  41698. _checkInputs(): void;
  41699. /** @hidden */
  41700. _decideIfNeedsToMove(): boolean;
  41701. /** @hidden */
  41702. _updatePosition(): void;
  41703. /**
  41704. * Restore the Roll to its target value at the rate specified.
  41705. * @param rate - Higher means slower restoring.
  41706. * @hidden
  41707. */
  41708. restoreRoll(rate: number): void;
  41709. /**
  41710. * Destroy the camera and release the current resources held by it.
  41711. */
  41712. dispose(): void;
  41713. /**
  41714. * Get the current object class name.
  41715. * @returns the class name.
  41716. */
  41717. getClassName(): string;
  41718. }
  41719. }
  41720. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41721. import { Nullable } from "babylonjs/types";
  41722. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41723. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41724. /**
  41725. * Listen to keyboard events to control the camera.
  41726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41727. */
  41728. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41729. /**
  41730. * Defines the camera the input is attached to.
  41731. */
  41732. camera: FlyCamera;
  41733. /**
  41734. * The list of keyboard keys used to control the forward move of the camera.
  41735. */
  41736. keysForward: number[];
  41737. /**
  41738. * The list of keyboard keys used to control the backward move of the camera.
  41739. */
  41740. keysBackward: number[];
  41741. /**
  41742. * The list of keyboard keys used to control the forward move of the camera.
  41743. */
  41744. keysUp: number[];
  41745. /**
  41746. * The list of keyboard keys used to control the backward move of the camera.
  41747. */
  41748. keysDown: number[];
  41749. /**
  41750. * The list of keyboard keys used to control the right strafe move of the camera.
  41751. */
  41752. keysRight: number[];
  41753. /**
  41754. * The list of keyboard keys used to control the left strafe move of the camera.
  41755. */
  41756. keysLeft: number[];
  41757. private _keys;
  41758. private _onCanvasBlurObserver;
  41759. private _onKeyboardObserver;
  41760. private _engine;
  41761. private _scene;
  41762. /**
  41763. * Attach the input controls to a specific dom element to get the input from.
  41764. * @param element Defines the element the controls should be listened from
  41765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41766. */
  41767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41768. /**
  41769. * Detach the current controls from the specified dom element.
  41770. * @param element Defines the element to stop listening the inputs from
  41771. */
  41772. detachControl(element: Nullable<HTMLElement>): void;
  41773. /**
  41774. * Gets the class name of the current intput.
  41775. * @returns the class name
  41776. */
  41777. getClassName(): string;
  41778. /** @hidden */
  41779. _onLostFocus(e: FocusEvent): void;
  41780. /**
  41781. * Get the friendly name associated with the input class.
  41782. * @returns the input friendly name
  41783. */
  41784. getSimpleName(): string;
  41785. /**
  41786. * Update the current camera state depending on the inputs that have been used this frame.
  41787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41788. */
  41789. checkInputs(): void;
  41790. }
  41791. }
  41792. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41793. import { Nullable } from "babylonjs/types";
  41794. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41795. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41796. /**
  41797. * Manage the mouse wheel inputs to control a follow camera.
  41798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41799. */
  41800. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41801. /**
  41802. * Defines the camera the input is attached to.
  41803. */
  41804. camera: FollowCamera;
  41805. /**
  41806. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41807. */
  41808. axisControlRadius: boolean;
  41809. /**
  41810. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41811. */
  41812. axisControlHeight: boolean;
  41813. /**
  41814. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41815. */
  41816. axisControlRotation: boolean;
  41817. /**
  41818. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41819. * relation to mouseWheel events.
  41820. */
  41821. wheelPrecision: number;
  41822. /**
  41823. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41824. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41825. */
  41826. wheelDeltaPercentage: number;
  41827. private _wheel;
  41828. private _observer;
  41829. /**
  41830. * Attach the input controls to a specific dom element to get the input from.
  41831. * @param element Defines the element the controls should be listened from
  41832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41833. */
  41834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41835. /**
  41836. * Detach the current controls from the specified dom element.
  41837. * @param element Defines the element to stop listening the inputs from
  41838. */
  41839. detachControl(element: Nullable<HTMLElement>): void;
  41840. /**
  41841. * Gets the class name of the current intput.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. /**
  41846. * Get the friendly name associated with the input class.
  41847. * @returns the input friendly name
  41848. */
  41849. getSimpleName(): string;
  41850. }
  41851. }
  41852. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41853. import { Nullable } from "babylonjs/types";
  41854. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41855. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41856. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41857. /**
  41858. * Manage the pointers inputs to control an follow camera.
  41859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41860. */
  41861. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41862. /**
  41863. * Defines the camera the input is attached to.
  41864. */
  41865. camera: FollowCamera;
  41866. /**
  41867. * Gets the class name of the current input.
  41868. * @returns the class name
  41869. */
  41870. getClassName(): string;
  41871. /**
  41872. * Defines the pointer angular sensibility along the X axis or how fast is
  41873. * the camera rotating.
  41874. * A negative number will reverse the axis direction.
  41875. */
  41876. angularSensibilityX: number;
  41877. /**
  41878. * Defines the pointer angular sensibility along the Y axis or how fast is
  41879. * the camera rotating.
  41880. * A negative number will reverse the axis direction.
  41881. */
  41882. angularSensibilityY: number;
  41883. /**
  41884. * Defines the pointer pinch precision or how fast is the camera zooming.
  41885. * A negative number will reverse the axis direction.
  41886. */
  41887. pinchPrecision: number;
  41888. /**
  41889. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41890. * from 0.
  41891. * It defines the percentage of current camera.radius to use as delta when
  41892. * pinch zoom is used.
  41893. */
  41894. pinchDeltaPercentage: number;
  41895. /**
  41896. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41897. */
  41898. axisXControlRadius: boolean;
  41899. /**
  41900. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41901. */
  41902. axisXControlHeight: boolean;
  41903. /**
  41904. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41905. */
  41906. axisXControlRotation: boolean;
  41907. /**
  41908. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41909. */
  41910. axisYControlRadius: boolean;
  41911. /**
  41912. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41913. */
  41914. axisYControlHeight: boolean;
  41915. /**
  41916. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41917. */
  41918. axisYControlRotation: boolean;
  41919. /**
  41920. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41921. */
  41922. axisPinchControlRadius: boolean;
  41923. /**
  41924. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41925. */
  41926. axisPinchControlHeight: boolean;
  41927. /**
  41928. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41929. */
  41930. axisPinchControlRotation: boolean;
  41931. /**
  41932. * Log error messages if basic misconfiguration has occurred.
  41933. */
  41934. warningEnable: boolean;
  41935. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41936. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41937. private _warningCounter;
  41938. private _warning;
  41939. }
  41940. }
  41941. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41942. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41943. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41944. /**
  41945. * Default Inputs manager for the FollowCamera.
  41946. * It groups all the default supported inputs for ease of use.
  41947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41948. */
  41949. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41950. /**
  41951. * Instantiates a new FollowCameraInputsManager.
  41952. * @param camera Defines the camera the inputs belong to
  41953. */
  41954. constructor(camera: FollowCamera);
  41955. /**
  41956. * Add keyboard input support to the input manager.
  41957. * @returns the current input manager
  41958. */
  41959. addKeyboard(): FollowCameraInputsManager;
  41960. /**
  41961. * Add mouse wheel input support to the input manager.
  41962. * @returns the current input manager
  41963. */
  41964. addMouseWheel(): FollowCameraInputsManager;
  41965. /**
  41966. * Add pointers input support to the input manager.
  41967. * @returns the current input manager
  41968. */
  41969. addPointers(): FollowCameraInputsManager;
  41970. /**
  41971. * Add orientation input support to the input manager.
  41972. * @returns the current input manager
  41973. */
  41974. addVRDeviceOrientation(): FollowCameraInputsManager;
  41975. }
  41976. }
  41977. declare module "babylonjs/Cameras/followCamera" {
  41978. import { Nullable } from "babylonjs/types";
  41979. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41980. import { Scene } from "babylonjs/scene";
  41981. import { Vector3 } from "babylonjs/Maths/math.vector";
  41982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41983. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41984. /**
  41985. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41986. * an arc rotate version arcFollowCamera are available.
  41987. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41988. */
  41989. export class FollowCamera extends TargetCamera {
  41990. /**
  41991. * Distance the follow camera should follow an object at
  41992. */
  41993. radius: number;
  41994. /**
  41995. * Minimum allowed distance of the camera to the axis of rotation
  41996. * (The camera can not get closer).
  41997. * This can help limiting how the Camera is able to move in the scene.
  41998. */
  41999. lowerRadiusLimit: Nullable<number>;
  42000. /**
  42001. * Maximum allowed distance of the camera to the axis of rotation
  42002. * (The camera can not get further).
  42003. * This can help limiting how the Camera is able to move in the scene.
  42004. */
  42005. upperRadiusLimit: Nullable<number>;
  42006. /**
  42007. * Define a rotation offset between the camera and the object it follows
  42008. */
  42009. rotationOffset: number;
  42010. /**
  42011. * Minimum allowed angle to camera position relative to target object.
  42012. * This can help limiting how the Camera is able to move in the scene.
  42013. */
  42014. lowerRotationOffsetLimit: Nullable<number>;
  42015. /**
  42016. * Maximum allowed angle to camera position relative to target object.
  42017. * This can help limiting how the Camera is able to move in the scene.
  42018. */
  42019. upperRotationOffsetLimit: Nullable<number>;
  42020. /**
  42021. * Define a height offset between the camera and the object it follows.
  42022. * It can help following an object from the top (like a car chaing a plane)
  42023. */
  42024. heightOffset: number;
  42025. /**
  42026. * Minimum allowed height of camera position relative to target object.
  42027. * This can help limiting how the Camera is able to move in the scene.
  42028. */
  42029. lowerHeightOffsetLimit: Nullable<number>;
  42030. /**
  42031. * Maximum allowed height of camera position relative to target object.
  42032. * This can help limiting how the Camera is able to move in the scene.
  42033. */
  42034. upperHeightOffsetLimit: Nullable<number>;
  42035. /**
  42036. * Define how fast the camera can accelerate to follow it s target.
  42037. */
  42038. cameraAcceleration: number;
  42039. /**
  42040. * Define the speed limit of the camera following an object.
  42041. */
  42042. maxCameraSpeed: number;
  42043. /**
  42044. * Define the target of the camera.
  42045. */
  42046. lockedTarget: Nullable<AbstractMesh>;
  42047. /**
  42048. * Defines the input associated with the camera.
  42049. */
  42050. inputs: FollowCameraInputsManager;
  42051. /**
  42052. * Instantiates the follow camera.
  42053. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42054. * @param name Define the name of the camera in the scene
  42055. * @param position Define the position of the camera
  42056. * @param scene Define the scene the camera belong to
  42057. * @param lockedTarget Define the target of the camera
  42058. */
  42059. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42060. private _follow;
  42061. /**
  42062. * Attached controls to the current camera.
  42063. * @param element Defines the element the controls should be listened from
  42064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42065. */
  42066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42067. /**
  42068. * Detach the current controls from the camera.
  42069. * The camera will stop reacting to inputs.
  42070. * @param element Defines the element to stop listening the inputs from
  42071. */
  42072. detachControl(element: HTMLElement): void;
  42073. /** @hidden */
  42074. _checkInputs(): void;
  42075. private _checkLimits;
  42076. /**
  42077. * Gets the camera class name.
  42078. * @returns the class name
  42079. */
  42080. getClassName(): string;
  42081. }
  42082. /**
  42083. * Arc Rotate version of the follow camera.
  42084. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42085. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42086. */
  42087. export class ArcFollowCamera extends TargetCamera {
  42088. /** The longitudinal angle of the camera */
  42089. alpha: number;
  42090. /** The latitudinal angle of the camera */
  42091. beta: number;
  42092. /** The radius of the camera from its target */
  42093. radius: number;
  42094. /** Define the camera target (the messh it should follow) */
  42095. target: Nullable<AbstractMesh>;
  42096. private _cartesianCoordinates;
  42097. /**
  42098. * Instantiates a new ArcFollowCamera
  42099. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42100. * @param name Define the name of the camera
  42101. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42102. * @param beta Define the rotation angle of the camera around the elevation axis
  42103. * @param radius Define the radius of the camera from its target point
  42104. * @param target Define the target of the camera
  42105. * @param scene Define the scene the camera belongs to
  42106. */
  42107. constructor(name: string,
  42108. /** The longitudinal angle of the camera */
  42109. alpha: number,
  42110. /** The latitudinal angle of the camera */
  42111. beta: number,
  42112. /** The radius of the camera from its target */
  42113. radius: number,
  42114. /** Define the camera target (the messh it should follow) */
  42115. target: Nullable<AbstractMesh>, scene: Scene);
  42116. private _follow;
  42117. /** @hidden */
  42118. _checkInputs(): void;
  42119. /**
  42120. * Returns the class name of the object.
  42121. * It is mostly used internally for serialization purposes.
  42122. */
  42123. getClassName(): string;
  42124. }
  42125. }
  42126. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42127. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42129. import { Nullable } from "babylonjs/types";
  42130. /**
  42131. * Manage the keyboard inputs to control the movement of a follow camera.
  42132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42133. */
  42134. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42135. /**
  42136. * Defines the camera the input is attached to.
  42137. */
  42138. camera: FollowCamera;
  42139. /**
  42140. * Defines the list of key codes associated with the up action (increase heightOffset)
  42141. */
  42142. keysHeightOffsetIncr: number[];
  42143. /**
  42144. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42145. */
  42146. keysHeightOffsetDecr: number[];
  42147. /**
  42148. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42149. */
  42150. keysHeightOffsetModifierAlt: boolean;
  42151. /**
  42152. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42153. */
  42154. keysHeightOffsetModifierCtrl: boolean;
  42155. /**
  42156. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42157. */
  42158. keysHeightOffsetModifierShift: boolean;
  42159. /**
  42160. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42161. */
  42162. keysRotationOffsetIncr: number[];
  42163. /**
  42164. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42165. */
  42166. keysRotationOffsetDecr: number[];
  42167. /**
  42168. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42169. */
  42170. keysRotationOffsetModifierAlt: boolean;
  42171. /**
  42172. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42173. */
  42174. keysRotationOffsetModifierCtrl: boolean;
  42175. /**
  42176. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42177. */
  42178. keysRotationOffsetModifierShift: boolean;
  42179. /**
  42180. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42181. */
  42182. keysRadiusIncr: number[];
  42183. /**
  42184. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42185. */
  42186. keysRadiusDecr: number[];
  42187. /**
  42188. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42189. */
  42190. keysRadiusModifierAlt: boolean;
  42191. /**
  42192. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42193. */
  42194. keysRadiusModifierCtrl: boolean;
  42195. /**
  42196. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42197. */
  42198. keysRadiusModifierShift: boolean;
  42199. /**
  42200. * Defines the rate of change of heightOffset.
  42201. */
  42202. heightSensibility: number;
  42203. /**
  42204. * Defines the rate of change of rotationOffset.
  42205. */
  42206. rotationSensibility: number;
  42207. /**
  42208. * Defines the rate of change of radius.
  42209. */
  42210. radiusSensibility: number;
  42211. private _keys;
  42212. private _ctrlPressed;
  42213. private _altPressed;
  42214. private _shiftPressed;
  42215. private _onCanvasBlurObserver;
  42216. private _onKeyboardObserver;
  42217. private _engine;
  42218. private _scene;
  42219. /**
  42220. * Attach the input controls to a specific dom element to get the input from.
  42221. * @param element Defines the element the controls should be listened from
  42222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42223. */
  42224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42225. /**
  42226. * Detach the current controls from the specified dom element.
  42227. * @param element Defines the element to stop listening the inputs from
  42228. */
  42229. detachControl(element: Nullable<HTMLElement>): void;
  42230. /**
  42231. * Update the current camera state depending on the inputs that have been used this frame.
  42232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42233. */
  42234. checkInputs(): void;
  42235. /**
  42236. * Gets the class name of the current input.
  42237. * @returns the class name
  42238. */
  42239. getClassName(): string;
  42240. /**
  42241. * Get the friendly name associated with the input class.
  42242. * @returns the input friendly name
  42243. */
  42244. getSimpleName(): string;
  42245. /**
  42246. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42247. * allow modification of the heightOffset value.
  42248. */
  42249. private _modifierHeightOffset;
  42250. /**
  42251. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42252. * allow modification of the rotationOffset value.
  42253. */
  42254. private _modifierRotationOffset;
  42255. /**
  42256. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42257. * allow modification of the radius value.
  42258. */
  42259. private _modifierRadius;
  42260. }
  42261. }
  42262. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42263. import { Nullable } from "babylonjs/types";
  42264. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42265. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42266. import { Observable } from "babylonjs/Misc/observable";
  42267. module "babylonjs/Cameras/freeCameraInputsManager" {
  42268. interface FreeCameraInputsManager {
  42269. /**
  42270. * @hidden
  42271. */
  42272. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42273. /**
  42274. * Add orientation input support to the input manager.
  42275. * @returns the current input manager
  42276. */
  42277. addDeviceOrientation(): FreeCameraInputsManager;
  42278. }
  42279. }
  42280. /**
  42281. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42282. * Screen rotation is taken into account.
  42283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42284. */
  42285. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42286. private _camera;
  42287. private _screenOrientationAngle;
  42288. private _constantTranform;
  42289. private _screenQuaternion;
  42290. private _alpha;
  42291. private _beta;
  42292. private _gamma;
  42293. /**
  42294. * Can be used to detect if a device orientation sensor is available on a device
  42295. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42296. * @returns a promise that will resolve on orientation change
  42297. */
  42298. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42299. /**
  42300. * @hidden
  42301. */
  42302. _onDeviceOrientationChangedObservable: Observable<void>;
  42303. /**
  42304. * Instantiates a new input
  42305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42306. */
  42307. constructor();
  42308. /**
  42309. * Define the camera controlled by the input.
  42310. */
  42311. get camera(): FreeCamera;
  42312. set camera(camera: FreeCamera);
  42313. /**
  42314. * Attach the input controls to a specific dom element to get the input from.
  42315. * @param element Defines the element the controls should be listened from
  42316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42317. */
  42318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42319. private _orientationChanged;
  42320. private _deviceOrientation;
  42321. /**
  42322. * Detach the current controls from the specified dom element.
  42323. * @param element Defines the element to stop listening the inputs from
  42324. */
  42325. detachControl(element: Nullable<HTMLElement>): void;
  42326. /**
  42327. * Update the current camera state depending on the inputs that have been used this frame.
  42328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42329. */
  42330. checkInputs(): void;
  42331. /**
  42332. * Gets the class name of the current intput.
  42333. * @returns the class name
  42334. */
  42335. getClassName(): string;
  42336. /**
  42337. * Get the friendly name associated with the input class.
  42338. * @returns the input friendly name
  42339. */
  42340. getSimpleName(): string;
  42341. }
  42342. }
  42343. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42344. import { Nullable } from "babylonjs/types";
  42345. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42346. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42347. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42348. /**
  42349. * Manage the gamepad inputs to control a free camera.
  42350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42351. */
  42352. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42353. /**
  42354. * Define the camera the input is attached to.
  42355. */
  42356. camera: FreeCamera;
  42357. /**
  42358. * Define the Gamepad controlling the input
  42359. */
  42360. gamepad: Nullable<Gamepad>;
  42361. /**
  42362. * Defines the gamepad rotation sensiblity.
  42363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42364. */
  42365. gamepadAngularSensibility: number;
  42366. /**
  42367. * Defines the gamepad move sensiblity.
  42368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42369. */
  42370. gamepadMoveSensibility: number;
  42371. private _yAxisScale;
  42372. /**
  42373. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42374. */
  42375. get invertYAxis(): boolean;
  42376. set invertYAxis(value: boolean);
  42377. private _onGamepadConnectedObserver;
  42378. private _onGamepadDisconnectedObserver;
  42379. private _cameraTransform;
  42380. private _deltaTransform;
  42381. private _vector3;
  42382. private _vector2;
  42383. /**
  42384. * Attach the input controls to a specific dom element to get the input from.
  42385. * @param element Defines the element the controls should be listened from
  42386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42387. */
  42388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42389. /**
  42390. * Detach the current controls from the specified dom element.
  42391. * @param element Defines the element to stop listening the inputs from
  42392. */
  42393. detachControl(element: Nullable<HTMLElement>): void;
  42394. /**
  42395. * Update the current camera state depending on the inputs that have been used this frame.
  42396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42397. */
  42398. checkInputs(): void;
  42399. /**
  42400. * Gets the class name of the current intput.
  42401. * @returns the class name
  42402. */
  42403. getClassName(): string;
  42404. /**
  42405. * Get the friendly name associated with the input class.
  42406. * @returns the input friendly name
  42407. */
  42408. getSimpleName(): string;
  42409. }
  42410. }
  42411. declare module "babylonjs/Misc/virtualJoystick" {
  42412. import { Nullable } from "babylonjs/types";
  42413. import { Vector3 } from "babylonjs/Maths/math.vector";
  42414. /**
  42415. * Defines the potential axis of a Joystick
  42416. */
  42417. export enum JoystickAxis {
  42418. /** X axis */
  42419. X = 0,
  42420. /** Y axis */
  42421. Y = 1,
  42422. /** Z axis */
  42423. Z = 2
  42424. }
  42425. /**
  42426. * Class used to define virtual joystick (used in touch mode)
  42427. */
  42428. export class VirtualJoystick {
  42429. /**
  42430. * Gets or sets a boolean indicating that left and right values must be inverted
  42431. */
  42432. reverseLeftRight: boolean;
  42433. /**
  42434. * Gets or sets a boolean indicating that up and down values must be inverted
  42435. */
  42436. reverseUpDown: boolean;
  42437. /**
  42438. * Gets the offset value for the position (ie. the change of the position value)
  42439. */
  42440. deltaPosition: Vector3;
  42441. /**
  42442. * Gets a boolean indicating if the virtual joystick was pressed
  42443. */
  42444. pressed: boolean;
  42445. /**
  42446. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42447. */
  42448. static Canvas: Nullable<HTMLCanvasElement>;
  42449. private static _globalJoystickIndex;
  42450. private static vjCanvasContext;
  42451. private static vjCanvasWidth;
  42452. private static vjCanvasHeight;
  42453. private static halfWidth;
  42454. private _action;
  42455. private _axisTargetedByLeftAndRight;
  42456. private _axisTargetedByUpAndDown;
  42457. private _joystickSensibility;
  42458. private _inversedSensibility;
  42459. private _joystickPointerID;
  42460. private _joystickColor;
  42461. private _joystickPointerPos;
  42462. private _joystickPreviousPointerPos;
  42463. private _joystickPointerStartPos;
  42464. private _deltaJoystickVector;
  42465. private _leftJoystick;
  42466. private _touches;
  42467. private _onPointerDownHandlerRef;
  42468. private _onPointerMoveHandlerRef;
  42469. private _onPointerUpHandlerRef;
  42470. private _onResize;
  42471. /**
  42472. * Creates a new virtual joystick
  42473. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42474. */
  42475. constructor(leftJoystick?: boolean);
  42476. /**
  42477. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42478. * @param newJoystickSensibility defines the new sensibility
  42479. */
  42480. setJoystickSensibility(newJoystickSensibility: number): void;
  42481. private _onPointerDown;
  42482. private _onPointerMove;
  42483. private _onPointerUp;
  42484. /**
  42485. * Change the color of the virtual joystick
  42486. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42487. */
  42488. setJoystickColor(newColor: string): void;
  42489. /**
  42490. * Defines a callback to call when the joystick is touched
  42491. * @param action defines the callback
  42492. */
  42493. setActionOnTouch(action: () => any): void;
  42494. /**
  42495. * Defines which axis you'd like to control for left & right
  42496. * @param axis defines the axis to use
  42497. */
  42498. setAxisForLeftRight(axis: JoystickAxis): void;
  42499. /**
  42500. * Defines which axis you'd like to control for up & down
  42501. * @param axis defines the axis to use
  42502. */
  42503. setAxisForUpDown(axis: JoystickAxis): void;
  42504. private _drawVirtualJoystick;
  42505. /**
  42506. * Release internal HTML canvas
  42507. */
  42508. releaseCanvas(): void;
  42509. }
  42510. }
  42511. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42512. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42513. import { Nullable } from "babylonjs/types";
  42514. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42516. module "babylonjs/Cameras/freeCameraInputsManager" {
  42517. interface FreeCameraInputsManager {
  42518. /**
  42519. * Add virtual joystick input support to the input manager.
  42520. * @returns the current input manager
  42521. */
  42522. addVirtualJoystick(): FreeCameraInputsManager;
  42523. }
  42524. }
  42525. /**
  42526. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42528. */
  42529. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42530. /**
  42531. * Defines the camera the input is attached to.
  42532. */
  42533. camera: FreeCamera;
  42534. private _leftjoystick;
  42535. private _rightjoystick;
  42536. /**
  42537. * Gets the left stick of the virtual joystick.
  42538. * @returns The virtual Joystick
  42539. */
  42540. getLeftJoystick(): VirtualJoystick;
  42541. /**
  42542. * Gets the right stick of the virtual joystick.
  42543. * @returns The virtual Joystick
  42544. */
  42545. getRightJoystick(): VirtualJoystick;
  42546. /**
  42547. * Update the current camera state depending on the inputs that have been used this frame.
  42548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42549. */
  42550. checkInputs(): void;
  42551. /**
  42552. * Attach the input controls to a specific dom element to get the input from.
  42553. * @param element Defines the element the controls should be listened from
  42554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42555. */
  42556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42557. /**
  42558. * Detach the current controls from the specified dom element.
  42559. * @param element Defines the element to stop listening the inputs from
  42560. */
  42561. detachControl(element: Nullable<HTMLElement>): void;
  42562. /**
  42563. * Gets the class name of the current intput.
  42564. * @returns the class name
  42565. */
  42566. getClassName(): string;
  42567. /**
  42568. * Get the friendly name associated with the input class.
  42569. * @returns the input friendly name
  42570. */
  42571. getSimpleName(): string;
  42572. }
  42573. }
  42574. declare module "babylonjs/Cameras/Inputs/index" {
  42575. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42576. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42577. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42578. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42579. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42580. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42581. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42582. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42583. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42584. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42585. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42586. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42587. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42588. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42589. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42590. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42591. }
  42592. declare module "babylonjs/Cameras/touchCamera" {
  42593. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42594. import { Scene } from "babylonjs/scene";
  42595. import { Vector3 } from "babylonjs/Maths/math.vector";
  42596. /**
  42597. * This represents a FPS type of camera controlled by touch.
  42598. * This is like a universal camera minus the Gamepad controls.
  42599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42600. */
  42601. export class TouchCamera extends FreeCamera {
  42602. /**
  42603. * Defines the touch sensibility for rotation.
  42604. * The higher the faster.
  42605. */
  42606. get touchAngularSensibility(): number;
  42607. set touchAngularSensibility(value: number);
  42608. /**
  42609. * Defines the touch sensibility for move.
  42610. * The higher the faster.
  42611. */
  42612. get touchMoveSensibility(): number;
  42613. set touchMoveSensibility(value: number);
  42614. /**
  42615. * Instantiates a new touch camera.
  42616. * This represents a FPS type of camera controlled by touch.
  42617. * This is like a universal camera minus the Gamepad controls.
  42618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42619. * @param name Define the name of the camera in the scene
  42620. * @param position Define the start position of the camera in the scene
  42621. * @param scene Define the scene the camera belongs to
  42622. */
  42623. constructor(name: string, position: Vector3, scene: Scene);
  42624. /**
  42625. * Gets the current object class name.
  42626. * @return the class name
  42627. */
  42628. getClassName(): string;
  42629. /** @hidden */
  42630. _setupInputs(): void;
  42631. }
  42632. }
  42633. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42634. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42635. import { Scene } from "babylonjs/scene";
  42636. import { Vector3 } from "babylonjs/Maths/math.vector";
  42637. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42638. import { Axis } from "babylonjs/Maths/math.axis";
  42639. /**
  42640. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42641. * being tilted forward or back and left or right.
  42642. */
  42643. export class DeviceOrientationCamera extends FreeCamera {
  42644. private _initialQuaternion;
  42645. private _quaternionCache;
  42646. private _tmpDragQuaternion;
  42647. private _disablePointerInputWhenUsingDeviceOrientation;
  42648. /**
  42649. * Creates a new device orientation camera
  42650. * @param name The name of the camera
  42651. * @param position The start position camera
  42652. * @param scene The scene the camera belongs to
  42653. */
  42654. constructor(name: string, position: Vector3, scene: Scene);
  42655. /**
  42656. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42657. */
  42658. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42659. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42660. private _dragFactor;
  42661. /**
  42662. * Enabled turning on the y axis when the orientation sensor is active
  42663. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42664. */
  42665. enableHorizontalDragging(dragFactor?: number): void;
  42666. /**
  42667. * Gets the current instance class name ("DeviceOrientationCamera").
  42668. * This helps avoiding instanceof at run time.
  42669. * @returns the class name
  42670. */
  42671. getClassName(): string;
  42672. /**
  42673. * @hidden
  42674. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42675. */
  42676. _checkInputs(): void;
  42677. /**
  42678. * Reset the camera to its default orientation on the specified axis only.
  42679. * @param axis The axis to reset
  42680. */
  42681. resetToCurrentRotation(axis?: Axis): void;
  42682. }
  42683. }
  42684. declare module "babylonjs/Gamepads/xboxGamepad" {
  42685. import { Observable } from "babylonjs/Misc/observable";
  42686. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42687. /**
  42688. * Defines supported buttons for XBox360 compatible gamepads
  42689. */
  42690. export enum Xbox360Button {
  42691. /** A */
  42692. A = 0,
  42693. /** B */
  42694. B = 1,
  42695. /** X */
  42696. X = 2,
  42697. /** Y */
  42698. Y = 3,
  42699. /** Left button */
  42700. LB = 4,
  42701. /** Right button */
  42702. RB = 5,
  42703. /** Back */
  42704. Back = 8,
  42705. /** Start */
  42706. Start = 9,
  42707. /** Left stick */
  42708. LeftStick = 10,
  42709. /** Right stick */
  42710. RightStick = 11
  42711. }
  42712. /** Defines values for XBox360 DPad */
  42713. export enum Xbox360Dpad {
  42714. /** Up */
  42715. Up = 12,
  42716. /** Down */
  42717. Down = 13,
  42718. /** Left */
  42719. Left = 14,
  42720. /** Right */
  42721. Right = 15
  42722. }
  42723. /**
  42724. * Defines a XBox360 gamepad
  42725. */
  42726. export class Xbox360Pad extends Gamepad {
  42727. private _leftTrigger;
  42728. private _rightTrigger;
  42729. private _onlefttriggerchanged;
  42730. private _onrighttriggerchanged;
  42731. private _onbuttondown;
  42732. private _onbuttonup;
  42733. private _ondpaddown;
  42734. private _ondpadup;
  42735. /** Observable raised when a button is pressed */
  42736. onButtonDownObservable: Observable<Xbox360Button>;
  42737. /** Observable raised when a button is released */
  42738. onButtonUpObservable: Observable<Xbox360Button>;
  42739. /** Observable raised when a pad is pressed */
  42740. onPadDownObservable: Observable<Xbox360Dpad>;
  42741. /** Observable raised when a pad is released */
  42742. onPadUpObservable: Observable<Xbox360Dpad>;
  42743. private _buttonA;
  42744. private _buttonB;
  42745. private _buttonX;
  42746. private _buttonY;
  42747. private _buttonBack;
  42748. private _buttonStart;
  42749. private _buttonLB;
  42750. private _buttonRB;
  42751. private _buttonLeftStick;
  42752. private _buttonRightStick;
  42753. private _dPadUp;
  42754. private _dPadDown;
  42755. private _dPadLeft;
  42756. private _dPadRight;
  42757. private _isXboxOnePad;
  42758. /**
  42759. * Creates a new XBox360 gamepad object
  42760. * @param id defines the id of this gamepad
  42761. * @param index defines its index
  42762. * @param gamepad defines the internal HTML gamepad object
  42763. * @param xboxOne defines if it is a XBox One gamepad
  42764. */
  42765. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42766. /**
  42767. * Defines the callback to call when left trigger is pressed
  42768. * @param callback defines the callback to use
  42769. */
  42770. onlefttriggerchanged(callback: (value: number) => void): void;
  42771. /**
  42772. * Defines the callback to call when right trigger is pressed
  42773. * @param callback defines the callback to use
  42774. */
  42775. onrighttriggerchanged(callback: (value: number) => void): void;
  42776. /**
  42777. * Gets the left trigger value
  42778. */
  42779. get leftTrigger(): number;
  42780. /**
  42781. * Sets the left trigger value
  42782. */
  42783. set leftTrigger(newValue: number);
  42784. /**
  42785. * Gets the right trigger value
  42786. */
  42787. get rightTrigger(): number;
  42788. /**
  42789. * Sets the right trigger value
  42790. */
  42791. set rightTrigger(newValue: number);
  42792. /**
  42793. * Defines the callback to call when a button is pressed
  42794. * @param callback defines the callback to use
  42795. */
  42796. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42797. /**
  42798. * Defines the callback to call when a button is released
  42799. * @param callback defines the callback to use
  42800. */
  42801. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42802. /**
  42803. * Defines the callback to call when a pad is pressed
  42804. * @param callback defines the callback to use
  42805. */
  42806. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42807. /**
  42808. * Defines the callback to call when a pad is released
  42809. * @param callback defines the callback to use
  42810. */
  42811. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42812. private _setButtonValue;
  42813. private _setDPadValue;
  42814. /**
  42815. * Gets the value of the `A` button
  42816. */
  42817. get buttonA(): number;
  42818. /**
  42819. * Sets the value of the `A` button
  42820. */
  42821. set buttonA(value: number);
  42822. /**
  42823. * Gets the value of the `B` button
  42824. */
  42825. get buttonB(): number;
  42826. /**
  42827. * Sets the value of the `B` button
  42828. */
  42829. set buttonB(value: number);
  42830. /**
  42831. * Gets the value of the `X` button
  42832. */
  42833. get buttonX(): number;
  42834. /**
  42835. * Sets the value of the `X` button
  42836. */
  42837. set buttonX(value: number);
  42838. /**
  42839. * Gets the value of the `Y` button
  42840. */
  42841. get buttonY(): number;
  42842. /**
  42843. * Sets the value of the `Y` button
  42844. */
  42845. set buttonY(value: number);
  42846. /**
  42847. * Gets the value of the `Start` button
  42848. */
  42849. get buttonStart(): number;
  42850. /**
  42851. * Sets the value of the `Start` button
  42852. */
  42853. set buttonStart(value: number);
  42854. /**
  42855. * Gets the value of the `Back` button
  42856. */
  42857. get buttonBack(): number;
  42858. /**
  42859. * Sets the value of the `Back` button
  42860. */
  42861. set buttonBack(value: number);
  42862. /**
  42863. * Gets the value of the `Left` button
  42864. */
  42865. get buttonLB(): number;
  42866. /**
  42867. * Sets the value of the `Left` button
  42868. */
  42869. set buttonLB(value: number);
  42870. /**
  42871. * Gets the value of the `Right` button
  42872. */
  42873. get buttonRB(): number;
  42874. /**
  42875. * Sets the value of the `Right` button
  42876. */
  42877. set buttonRB(value: number);
  42878. /**
  42879. * Gets the value of the Left joystick
  42880. */
  42881. get buttonLeftStick(): number;
  42882. /**
  42883. * Sets the value of the Left joystick
  42884. */
  42885. set buttonLeftStick(value: number);
  42886. /**
  42887. * Gets the value of the Right joystick
  42888. */
  42889. get buttonRightStick(): number;
  42890. /**
  42891. * Sets the value of the Right joystick
  42892. */
  42893. set buttonRightStick(value: number);
  42894. /**
  42895. * Gets the value of D-pad up
  42896. */
  42897. get dPadUp(): number;
  42898. /**
  42899. * Sets the value of D-pad up
  42900. */
  42901. set dPadUp(value: number);
  42902. /**
  42903. * Gets the value of D-pad down
  42904. */
  42905. get dPadDown(): number;
  42906. /**
  42907. * Sets the value of D-pad down
  42908. */
  42909. set dPadDown(value: number);
  42910. /**
  42911. * Gets the value of D-pad left
  42912. */
  42913. get dPadLeft(): number;
  42914. /**
  42915. * Sets the value of D-pad left
  42916. */
  42917. set dPadLeft(value: number);
  42918. /**
  42919. * Gets the value of D-pad right
  42920. */
  42921. get dPadRight(): number;
  42922. /**
  42923. * Sets the value of D-pad right
  42924. */
  42925. set dPadRight(value: number);
  42926. /**
  42927. * Force the gamepad to synchronize with device values
  42928. */
  42929. update(): void;
  42930. /**
  42931. * Disposes the gamepad
  42932. */
  42933. dispose(): void;
  42934. }
  42935. }
  42936. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42937. import { Observable } from "babylonjs/Misc/observable";
  42938. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42939. /**
  42940. * Defines supported buttons for DualShock compatible gamepads
  42941. */
  42942. export enum DualShockButton {
  42943. /** Cross */
  42944. Cross = 0,
  42945. /** Circle */
  42946. Circle = 1,
  42947. /** Square */
  42948. Square = 2,
  42949. /** Triangle */
  42950. Triangle = 3,
  42951. /** L1 */
  42952. L1 = 4,
  42953. /** R1 */
  42954. R1 = 5,
  42955. /** Share */
  42956. Share = 8,
  42957. /** Options */
  42958. Options = 9,
  42959. /** Left stick */
  42960. LeftStick = 10,
  42961. /** Right stick */
  42962. RightStick = 11
  42963. }
  42964. /** Defines values for DualShock DPad */
  42965. export enum DualShockDpad {
  42966. /** Up */
  42967. Up = 12,
  42968. /** Down */
  42969. Down = 13,
  42970. /** Left */
  42971. Left = 14,
  42972. /** Right */
  42973. Right = 15
  42974. }
  42975. /**
  42976. * Defines a DualShock gamepad
  42977. */
  42978. export class DualShockPad extends Gamepad {
  42979. private _leftTrigger;
  42980. private _rightTrigger;
  42981. private _onlefttriggerchanged;
  42982. private _onrighttriggerchanged;
  42983. private _onbuttondown;
  42984. private _onbuttonup;
  42985. private _ondpaddown;
  42986. private _ondpadup;
  42987. /** Observable raised when a button is pressed */
  42988. onButtonDownObservable: Observable<DualShockButton>;
  42989. /** Observable raised when a button is released */
  42990. onButtonUpObservable: Observable<DualShockButton>;
  42991. /** Observable raised when a pad is pressed */
  42992. onPadDownObservable: Observable<DualShockDpad>;
  42993. /** Observable raised when a pad is released */
  42994. onPadUpObservable: Observable<DualShockDpad>;
  42995. private _buttonCross;
  42996. private _buttonCircle;
  42997. private _buttonSquare;
  42998. private _buttonTriangle;
  42999. private _buttonShare;
  43000. private _buttonOptions;
  43001. private _buttonL1;
  43002. private _buttonR1;
  43003. private _buttonLeftStick;
  43004. private _buttonRightStick;
  43005. private _dPadUp;
  43006. private _dPadDown;
  43007. private _dPadLeft;
  43008. private _dPadRight;
  43009. /**
  43010. * Creates a new DualShock gamepad object
  43011. * @param id defines the id of this gamepad
  43012. * @param index defines its index
  43013. * @param gamepad defines the internal HTML gamepad object
  43014. */
  43015. constructor(id: string, index: number, gamepad: any);
  43016. /**
  43017. * Defines the callback to call when left trigger is pressed
  43018. * @param callback defines the callback to use
  43019. */
  43020. onlefttriggerchanged(callback: (value: number) => void): void;
  43021. /**
  43022. * Defines the callback to call when right trigger is pressed
  43023. * @param callback defines the callback to use
  43024. */
  43025. onrighttriggerchanged(callback: (value: number) => void): void;
  43026. /**
  43027. * Gets the left trigger value
  43028. */
  43029. get leftTrigger(): number;
  43030. /**
  43031. * Sets the left trigger value
  43032. */
  43033. set leftTrigger(newValue: number);
  43034. /**
  43035. * Gets the right trigger value
  43036. */
  43037. get rightTrigger(): number;
  43038. /**
  43039. * Sets the right trigger value
  43040. */
  43041. set rightTrigger(newValue: number);
  43042. /**
  43043. * Defines the callback to call when a button is pressed
  43044. * @param callback defines the callback to use
  43045. */
  43046. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43047. /**
  43048. * Defines the callback to call when a button is released
  43049. * @param callback defines the callback to use
  43050. */
  43051. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43052. /**
  43053. * Defines the callback to call when a pad is pressed
  43054. * @param callback defines the callback to use
  43055. */
  43056. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43057. /**
  43058. * Defines the callback to call when a pad is released
  43059. * @param callback defines the callback to use
  43060. */
  43061. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43062. private _setButtonValue;
  43063. private _setDPadValue;
  43064. /**
  43065. * Gets the value of the `Cross` button
  43066. */
  43067. get buttonCross(): number;
  43068. /**
  43069. * Sets the value of the `Cross` button
  43070. */
  43071. set buttonCross(value: number);
  43072. /**
  43073. * Gets the value of the `Circle` button
  43074. */
  43075. get buttonCircle(): number;
  43076. /**
  43077. * Sets the value of the `Circle` button
  43078. */
  43079. set buttonCircle(value: number);
  43080. /**
  43081. * Gets the value of the `Square` button
  43082. */
  43083. get buttonSquare(): number;
  43084. /**
  43085. * Sets the value of the `Square` button
  43086. */
  43087. set buttonSquare(value: number);
  43088. /**
  43089. * Gets the value of the `Triangle` button
  43090. */
  43091. get buttonTriangle(): number;
  43092. /**
  43093. * Sets the value of the `Triangle` button
  43094. */
  43095. set buttonTriangle(value: number);
  43096. /**
  43097. * Gets the value of the `Options` button
  43098. */
  43099. get buttonOptions(): number;
  43100. /**
  43101. * Sets the value of the `Options` button
  43102. */
  43103. set buttonOptions(value: number);
  43104. /**
  43105. * Gets the value of the `Share` button
  43106. */
  43107. get buttonShare(): number;
  43108. /**
  43109. * Sets the value of the `Share` button
  43110. */
  43111. set buttonShare(value: number);
  43112. /**
  43113. * Gets the value of the `L1` button
  43114. */
  43115. get buttonL1(): number;
  43116. /**
  43117. * Sets the value of the `L1` button
  43118. */
  43119. set buttonL1(value: number);
  43120. /**
  43121. * Gets the value of the `R1` button
  43122. */
  43123. get buttonR1(): number;
  43124. /**
  43125. * Sets the value of the `R1` button
  43126. */
  43127. set buttonR1(value: number);
  43128. /**
  43129. * Gets the value of the Left joystick
  43130. */
  43131. get buttonLeftStick(): number;
  43132. /**
  43133. * Sets the value of the Left joystick
  43134. */
  43135. set buttonLeftStick(value: number);
  43136. /**
  43137. * Gets the value of the Right joystick
  43138. */
  43139. get buttonRightStick(): number;
  43140. /**
  43141. * Sets the value of the Right joystick
  43142. */
  43143. set buttonRightStick(value: number);
  43144. /**
  43145. * Gets the value of D-pad up
  43146. */
  43147. get dPadUp(): number;
  43148. /**
  43149. * Sets the value of D-pad up
  43150. */
  43151. set dPadUp(value: number);
  43152. /**
  43153. * Gets the value of D-pad down
  43154. */
  43155. get dPadDown(): number;
  43156. /**
  43157. * Sets the value of D-pad down
  43158. */
  43159. set dPadDown(value: number);
  43160. /**
  43161. * Gets the value of D-pad left
  43162. */
  43163. get dPadLeft(): number;
  43164. /**
  43165. * Sets the value of D-pad left
  43166. */
  43167. set dPadLeft(value: number);
  43168. /**
  43169. * Gets the value of D-pad right
  43170. */
  43171. get dPadRight(): number;
  43172. /**
  43173. * Sets the value of D-pad right
  43174. */
  43175. set dPadRight(value: number);
  43176. /**
  43177. * Force the gamepad to synchronize with device values
  43178. */
  43179. update(): void;
  43180. /**
  43181. * Disposes the gamepad
  43182. */
  43183. dispose(): void;
  43184. }
  43185. }
  43186. declare module "babylonjs/Gamepads/gamepadManager" {
  43187. import { Observable } from "babylonjs/Misc/observable";
  43188. import { Nullable } from "babylonjs/types";
  43189. import { Scene } from "babylonjs/scene";
  43190. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43191. /**
  43192. * Manager for handling gamepads
  43193. */
  43194. export class GamepadManager {
  43195. private _scene?;
  43196. private _babylonGamepads;
  43197. private _oneGamepadConnected;
  43198. /** @hidden */
  43199. _isMonitoring: boolean;
  43200. private _gamepadEventSupported;
  43201. private _gamepadSupport?;
  43202. /**
  43203. * observable to be triggered when the gamepad controller has been connected
  43204. */
  43205. onGamepadConnectedObservable: Observable<Gamepad>;
  43206. /**
  43207. * observable to be triggered when the gamepad controller has been disconnected
  43208. */
  43209. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43210. private _onGamepadConnectedEvent;
  43211. private _onGamepadDisconnectedEvent;
  43212. /**
  43213. * Initializes the gamepad manager
  43214. * @param _scene BabylonJS scene
  43215. */
  43216. constructor(_scene?: Scene | undefined);
  43217. /**
  43218. * The gamepads in the game pad manager
  43219. */
  43220. get gamepads(): Gamepad[];
  43221. /**
  43222. * Get the gamepad controllers based on type
  43223. * @param type The type of gamepad controller
  43224. * @returns Nullable gamepad
  43225. */
  43226. getGamepadByType(type?: number): Nullable<Gamepad>;
  43227. /**
  43228. * Disposes the gamepad manager
  43229. */
  43230. dispose(): void;
  43231. private _addNewGamepad;
  43232. private _startMonitoringGamepads;
  43233. private _stopMonitoringGamepads;
  43234. /** @hidden */
  43235. _checkGamepadsStatus(): void;
  43236. private _updateGamepadObjects;
  43237. }
  43238. }
  43239. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43240. import { Nullable } from "babylonjs/types";
  43241. import { Scene } from "babylonjs/scene";
  43242. import { ISceneComponent } from "babylonjs/sceneComponent";
  43243. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43244. module "babylonjs/scene" {
  43245. interface Scene {
  43246. /** @hidden */
  43247. _gamepadManager: Nullable<GamepadManager>;
  43248. /**
  43249. * Gets the gamepad manager associated with the scene
  43250. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43251. */
  43252. gamepadManager: GamepadManager;
  43253. }
  43254. }
  43255. module "babylonjs/Cameras/freeCameraInputsManager" {
  43256. /**
  43257. * Interface representing a free camera inputs manager
  43258. */
  43259. interface FreeCameraInputsManager {
  43260. /**
  43261. * Adds gamepad input support to the FreeCameraInputsManager.
  43262. * @returns the FreeCameraInputsManager
  43263. */
  43264. addGamepad(): FreeCameraInputsManager;
  43265. }
  43266. }
  43267. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43268. /**
  43269. * Interface representing an arc rotate camera inputs manager
  43270. */
  43271. interface ArcRotateCameraInputsManager {
  43272. /**
  43273. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43274. * @returns the camera inputs manager
  43275. */
  43276. addGamepad(): ArcRotateCameraInputsManager;
  43277. }
  43278. }
  43279. /**
  43280. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43281. */
  43282. export class GamepadSystemSceneComponent implements ISceneComponent {
  43283. /**
  43284. * The component name helpfull to identify the component in the list of scene components.
  43285. */
  43286. readonly name: string;
  43287. /**
  43288. * The scene the component belongs to.
  43289. */
  43290. scene: Scene;
  43291. /**
  43292. * Creates a new instance of the component for the given scene
  43293. * @param scene Defines the scene to register the component in
  43294. */
  43295. constructor(scene: Scene);
  43296. /**
  43297. * Registers the component in a given scene
  43298. */
  43299. register(): void;
  43300. /**
  43301. * Rebuilds the elements related to this component in case of
  43302. * context lost for instance.
  43303. */
  43304. rebuild(): void;
  43305. /**
  43306. * Disposes the component and the associated ressources
  43307. */
  43308. dispose(): void;
  43309. private _beforeCameraUpdate;
  43310. }
  43311. }
  43312. declare module "babylonjs/Cameras/universalCamera" {
  43313. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43314. import { Scene } from "babylonjs/scene";
  43315. import { Vector3 } from "babylonjs/Maths/math.vector";
  43316. import "babylonjs/Gamepads/gamepadSceneComponent";
  43317. /**
  43318. * 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,
  43319. * which still works and will still be found in many Playgrounds.
  43320. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43321. */
  43322. export class UniversalCamera extends TouchCamera {
  43323. /**
  43324. * Defines the gamepad rotation sensiblity.
  43325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43326. */
  43327. get gamepadAngularSensibility(): number;
  43328. set gamepadAngularSensibility(value: number);
  43329. /**
  43330. * Defines the gamepad move sensiblity.
  43331. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43332. */
  43333. get gamepadMoveSensibility(): number;
  43334. set gamepadMoveSensibility(value: number);
  43335. /**
  43336. * 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,
  43337. * which still works and will still be found in many Playgrounds.
  43338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43339. * @param name Define the name of the camera in the scene
  43340. * @param position Define the start position of the camera in the scene
  43341. * @param scene Define the scene the camera belongs to
  43342. */
  43343. constructor(name: string, position: Vector3, scene: Scene);
  43344. /**
  43345. * Gets the current object class name.
  43346. * @return the class name
  43347. */
  43348. getClassName(): string;
  43349. }
  43350. }
  43351. declare module "babylonjs/Cameras/gamepadCamera" {
  43352. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43353. import { Scene } from "babylonjs/scene";
  43354. import { Vector3 } from "babylonjs/Maths/math.vector";
  43355. /**
  43356. * This represents a FPS type of camera. This is only here for back compat purpose.
  43357. * Please use the UniversalCamera instead as both are identical.
  43358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43359. */
  43360. export class GamepadCamera extends UniversalCamera {
  43361. /**
  43362. * Instantiates a new Gamepad Camera
  43363. * This represents a FPS type of camera. This is only here for back compat purpose.
  43364. * Please use the UniversalCamera instead as both are identical.
  43365. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43366. * @param name Define the name of the camera in the scene
  43367. * @param position Define the start position of the camera in the scene
  43368. * @param scene Define the scene the camera belongs to
  43369. */
  43370. constructor(name: string, position: Vector3, scene: Scene);
  43371. /**
  43372. * Gets the current object class name.
  43373. * @return the class name
  43374. */
  43375. getClassName(): string;
  43376. }
  43377. }
  43378. declare module "babylonjs/Shaders/pass.fragment" {
  43379. /** @hidden */
  43380. export var passPixelShader: {
  43381. name: string;
  43382. shader: string;
  43383. };
  43384. }
  43385. declare module "babylonjs/Shaders/passCube.fragment" {
  43386. /** @hidden */
  43387. export var passCubePixelShader: {
  43388. name: string;
  43389. shader: string;
  43390. };
  43391. }
  43392. declare module "babylonjs/PostProcesses/passPostProcess" {
  43393. import { Nullable } from "babylonjs/types";
  43394. import { Camera } from "babylonjs/Cameras/camera";
  43395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43396. import { Engine } from "babylonjs/Engines/engine";
  43397. import "babylonjs/Shaders/pass.fragment";
  43398. import "babylonjs/Shaders/passCube.fragment";
  43399. /**
  43400. * PassPostProcess which produces an output the same as it's input
  43401. */
  43402. export class PassPostProcess extends PostProcess {
  43403. /**
  43404. * Creates the PassPostProcess
  43405. * @param name The name of the effect.
  43406. * @param options The required width/height ratio to downsize to before computing the render pass.
  43407. * @param camera The camera to apply the render pass to.
  43408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43409. * @param engine The engine which the post process will be applied. (default: current engine)
  43410. * @param reusable If the post process can be reused on the same frame. (default: false)
  43411. * @param textureType The type of texture to be used when performing the post processing.
  43412. * @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)
  43413. */
  43414. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43415. }
  43416. /**
  43417. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43418. */
  43419. export class PassCubePostProcess extends PostProcess {
  43420. private _face;
  43421. /**
  43422. * Gets or sets the cube face to display.
  43423. * * 0 is +X
  43424. * * 1 is -X
  43425. * * 2 is +Y
  43426. * * 3 is -Y
  43427. * * 4 is +Z
  43428. * * 5 is -Z
  43429. */
  43430. get face(): number;
  43431. set face(value: number);
  43432. /**
  43433. * Creates the PassCubePostProcess
  43434. * @param name The name of the effect.
  43435. * @param options The required width/height ratio to downsize to before computing the render pass.
  43436. * @param camera The camera to apply the render pass to.
  43437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43438. * @param engine The engine which the post process will be applied. (default: current engine)
  43439. * @param reusable If the post process can be reused on the same frame. (default: false)
  43440. * @param textureType The type of texture to be used when performing the post processing.
  43441. * @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)
  43442. */
  43443. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43444. }
  43445. }
  43446. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43447. /** @hidden */
  43448. export var anaglyphPixelShader: {
  43449. name: string;
  43450. shader: string;
  43451. };
  43452. }
  43453. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43454. import { Engine } from "babylonjs/Engines/engine";
  43455. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43456. import { Camera } from "babylonjs/Cameras/camera";
  43457. import "babylonjs/Shaders/anaglyph.fragment";
  43458. /**
  43459. * Postprocess used to generate anaglyphic rendering
  43460. */
  43461. export class AnaglyphPostProcess extends PostProcess {
  43462. private _passedProcess;
  43463. /**
  43464. * Creates a new AnaglyphPostProcess
  43465. * @param name defines postprocess name
  43466. * @param options defines creation options or target ratio scale
  43467. * @param rigCameras defines cameras using this postprocess
  43468. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43469. * @param engine defines hosting engine
  43470. * @param reusable defines if the postprocess will be reused multiple times per frame
  43471. */
  43472. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43473. }
  43474. }
  43475. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43477. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43478. import { Scene } from "babylonjs/scene";
  43479. import { Vector3 } from "babylonjs/Maths/math.vector";
  43480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43481. /**
  43482. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43484. */
  43485. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43486. /**
  43487. * Creates a new AnaglyphArcRotateCamera
  43488. * @param name defines camera name
  43489. * @param alpha defines alpha angle (in radians)
  43490. * @param beta defines beta angle (in radians)
  43491. * @param radius defines radius
  43492. * @param target defines camera target
  43493. * @param interaxialDistance defines distance between each color axis
  43494. * @param scene defines the hosting scene
  43495. */
  43496. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43497. /**
  43498. * Gets camera class name
  43499. * @returns AnaglyphArcRotateCamera
  43500. */
  43501. getClassName(): string;
  43502. }
  43503. }
  43504. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43505. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43506. import { Scene } from "babylonjs/scene";
  43507. import { Vector3 } from "babylonjs/Maths/math.vector";
  43508. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43509. /**
  43510. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43511. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43512. */
  43513. export class AnaglyphFreeCamera extends FreeCamera {
  43514. /**
  43515. * Creates a new AnaglyphFreeCamera
  43516. * @param name defines camera name
  43517. * @param position defines initial position
  43518. * @param interaxialDistance defines distance between each color axis
  43519. * @param scene defines the hosting scene
  43520. */
  43521. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43522. /**
  43523. * Gets camera class name
  43524. * @returns AnaglyphFreeCamera
  43525. */
  43526. getClassName(): string;
  43527. }
  43528. }
  43529. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43530. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43531. import { Scene } from "babylonjs/scene";
  43532. import { Vector3 } from "babylonjs/Maths/math.vector";
  43533. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43534. /**
  43535. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43536. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43537. */
  43538. export class AnaglyphGamepadCamera extends GamepadCamera {
  43539. /**
  43540. * Creates a new AnaglyphGamepadCamera
  43541. * @param name defines camera name
  43542. * @param position defines initial position
  43543. * @param interaxialDistance defines distance between each color axis
  43544. * @param scene defines the hosting scene
  43545. */
  43546. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43547. /**
  43548. * Gets camera class name
  43549. * @returns AnaglyphGamepadCamera
  43550. */
  43551. getClassName(): string;
  43552. }
  43553. }
  43554. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43555. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43556. import { Scene } from "babylonjs/scene";
  43557. import { Vector3 } from "babylonjs/Maths/math.vector";
  43558. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43559. /**
  43560. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43561. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43562. */
  43563. export class AnaglyphUniversalCamera extends UniversalCamera {
  43564. /**
  43565. * Creates a new AnaglyphUniversalCamera
  43566. * @param name defines camera name
  43567. * @param position defines initial position
  43568. * @param interaxialDistance defines distance between each color axis
  43569. * @param scene defines the hosting scene
  43570. */
  43571. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43572. /**
  43573. * Gets camera class name
  43574. * @returns AnaglyphUniversalCamera
  43575. */
  43576. getClassName(): string;
  43577. }
  43578. }
  43579. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43580. /** @hidden */
  43581. export var stereoscopicInterlacePixelShader: {
  43582. name: string;
  43583. shader: string;
  43584. };
  43585. }
  43586. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43587. import { Camera } from "babylonjs/Cameras/camera";
  43588. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43589. import { Engine } from "babylonjs/Engines/engine";
  43590. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43591. /**
  43592. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43593. */
  43594. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43595. private _stepSize;
  43596. private _passedProcess;
  43597. /**
  43598. * Initializes a StereoscopicInterlacePostProcessI
  43599. * @param name The name of the effect.
  43600. * @param rigCameras The rig cameras to be appled to the post process
  43601. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43602. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43604. * @param engine The engine which the post process will be applied. (default: current engine)
  43605. * @param reusable If the post process can be reused on the same frame. (default: false)
  43606. */
  43607. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43608. }
  43609. /**
  43610. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43611. */
  43612. export class StereoscopicInterlacePostProcess extends PostProcess {
  43613. private _stepSize;
  43614. private _passedProcess;
  43615. /**
  43616. * Initializes a StereoscopicInterlacePostProcess
  43617. * @param name The name of the effect.
  43618. * @param rigCameras The rig cameras to be appled to the post process
  43619. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43621. * @param engine The engine which the post process will be applied. (default: current engine)
  43622. * @param reusable If the post process can be reused on the same frame. (default: false)
  43623. */
  43624. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43625. }
  43626. }
  43627. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43628. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43629. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43630. import { Scene } from "babylonjs/scene";
  43631. import { Vector3 } from "babylonjs/Maths/math.vector";
  43632. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43633. /**
  43634. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43635. * @see http://doc.babylonjs.com/features/cameras
  43636. */
  43637. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43638. /**
  43639. * Creates a new StereoscopicArcRotateCamera
  43640. * @param name defines camera name
  43641. * @param alpha defines alpha angle (in radians)
  43642. * @param beta defines beta angle (in radians)
  43643. * @param radius defines radius
  43644. * @param target defines camera target
  43645. * @param interaxialDistance defines distance between each color axis
  43646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43647. * @param scene defines the hosting scene
  43648. */
  43649. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43650. /**
  43651. * Gets camera class name
  43652. * @returns StereoscopicArcRotateCamera
  43653. */
  43654. getClassName(): string;
  43655. }
  43656. }
  43657. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43658. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43659. import { Scene } from "babylonjs/scene";
  43660. import { Vector3 } from "babylonjs/Maths/math.vector";
  43661. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43662. /**
  43663. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43664. * @see http://doc.babylonjs.com/features/cameras
  43665. */
  43666. export class StereoscopicFreeCamera extends FreeCamera {
  43667. /**
  43668. * Creates a new StereoscopicFreeCamera
  43669. * @param name defines camera name
  43670. * @param position defines initial position
  43671. * @param interaxialDistance defines distance between each color axis
  43672. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43673. * @param scene defines the hosting scene
  43674. */
  43675. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43676. /**
  43677. * Gets camera class name
  43678. * @returns StereoscopicFreeCamera
  43679. */
  43680. getClassName(): string;
  43681. }
  43682. }
  43683. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43684. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43685. import { Scene } from "babylonjs/scene";
  43686. import { Vector3 } from "babylonjs/Maths/math.vector";
  43687. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43688. /**
  43689. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43690. * @see http://doc.babylonjs.com/features/cameras
  43691. */
  43692. export class StereoscopicGamepadCamera extends GamepadCamera {
  43693. /**
  43694. * Creates a new StereoscopicGamepadCamera
  43695. * @param name defines camera name
  43696. * @param position defines initial position
  43697. * @param interaxialDistance defines distance between each color axis
  43698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43699. * @param scene defines the hosting scene
  43700. */
  43701. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43702. /**
  43703. * Gets camera class name
  43704. * @returns StereoscopicGamepadCamera
  43705. */
  43706. getClassName(): string;
  43707. }
  43708. }
  43709. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43710. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43711. import { Scene } from "babylonjs/scene";
  43712. import { Vector3 } from "babylonjs/Maths/math.vector";
  43713. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43714. /**
  43715. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43716. * @see http://doc.babylonjs.com/features/cameras
  43717. */
  43718. export class StereoscopicUniversalCamera extends UniversalCamera {
  43719. /**
  43720. * Creates a new StereoscopicUniversalCamera
  43721. * @param name defines camera name
  43722. * @param position defines initial position
  43723. * @param interaxialDistance defines distance between each color axis
  43724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43725. * @param scene defines the hosting scene
  43726. */
  43727. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43728. /**
  43729. * Gets camera class name
  43730. * @returns StereoscopicUniversalCamera
  43731. */
  43732. getClassName(): string;
  43733. }
  43734. }
  43735. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43736. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43737. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43738. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43739. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43740. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43741. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43742. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43743. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43744. }
  43745. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43746. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43747. import { Scene } from "babylonjs/scene";
  43748. import { Vector3 } from "babylonjs/Maths/math.vector";
  43749. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43750. /**
  43751. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43752. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43753. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43754. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43755. */
  43756. export class VirtualJoysticksCamera extends FreeCamera {
  43757. /**
  43758. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43759. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43760. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43761. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43762. * @param name Define the name of the camera in the scene
  43763. * @param position Define the start position of the camera in the scene
  43764. * @param scene Define the scene the camera belongs to
  43765. */
  43766. constructor(name: string, position: Vector3, scene: Scene);
  43767. /**
  43768. * Gets the current object class name.
  43769. * @return the class name
  43770. */
  43771. getClassName(): string;
  43772. }
  43773. }
  43774. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43775. import { Matrix } from "babylonjs/Maths/math.vector";
  43776. /**
  43777. * This represents all the required metrics to create a VR camera.
  43778. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43779. */
  43780. export class VRCameraMetrics {
  43781. /**
  43782. * Define the horizontal resolution off the screen.
  43783. */
  43784. hResolution: number;
  43785. /**
  43786. * Define the vertical resolution off the screen.
  43787. */
  43788. vResolution: number;
  43789. /**
  43790. * Define the horizontal screen size.
  43791. */
  43792. hScreenSize: number;
  43793. /**
  43794. * Define the vertical screen size.
  43795. */
  43796. vScreenSize: number;
  43797. /**
  43798. * Define the vertical screen center position.
  43799. */
  43800. vScreenCenter: number;
  43801. /**
  43802. * Define the distance of the eyes to the screen.
  43803. */
  43804. eyeToScreenDistance: number;
  43805. /**
  43806. * Define the distance between both lenses
  43807. */
  43808. lensSeparationDistance: number;
  43809. /**
  43810. * Define the distance between both viewer's eyes.
  43811. */
  43812. interpupillaryDistance: number;
  43813. /**
  43814. * Define the distortion factor of the VR postprocess.
  43815. * Please, touch with care.
  43816. */
  43817. distortionK: number[];
  43818. /**
  43819. * Define the chromatic aberration correction factors for the VR post process.
  43820. */
  43821. chromaAbCorrection: number[];
  43822. /**
  43823. * Define the scale factor of the post process.
  43824. * The smaller the better but the slower.
  43825. */
  43826. postProcessScaleFactor: number;
  43827. /**
  43828. * Define an offset for the lens center.
  43829. */
  43830. lensCenterOffset: number;
  43831. /**
  43832. * Define if the current vr camera should compensate the distortion of the lense or not.
  43833. */
  43834. compensateDistortion: boolean;
  43835. /**
  43836. * Defines if multiview should be enabled when rendering (Default: false)
  43837. */
  43838. multiviewEnabled: boolean;
  43839. /**
  43840. * Gets the rendering aspect ratio based on the provided resolutions.
  43841. */
  43842. get aspectRatio(): number;
  43843. /**
  43844. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43845. */
  43846. get aspectRatioFov(): number;
  43847. /**
  43848. * @hidden
  43849. */
  43850. get leftHMatrix(): Matrix;
  43851. /**
  43852. * @hidden
  43853. */
  43854. get rightHMatrix(): Matrix;
  43855. /**
  43856. * @hidden
  43857. */
  43858. get leftPreViewMatrix(): Matrix;
  43859. /**
  43860. * @hidden
  43861. */
  43862. get rightPreViewMatrix(): Matrix;
  43863. /**
  43864. * Get the default VRMetrics based on the most generic setup.
  43865. * @returns the default vr metrics
  43866. */
  43867. static GetDefault(): VRCameraMetrics;
  43868. }
  43869. }
  43870. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43871. /** @hidden */
  43872. export var vrDistortionCorrectionPixelShader: {
  43873. name: string;
  43874. shader: string;
  43875. };
  43876. }
  43877. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43878. import { Camera } from "babylonjs/Cameras/camera";
  43879. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43880. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43881. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43882. /**
  43883. * VRDistortionCorrectionPostProcess used for mobile VR
  43884. */
  43885. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43886. private _isRightEye;
  43887. private _distortionFactors;
  43888. private _postProcessScaleFactor;
  43889. private _lensCenterOffset;
  43890. private _scaleIn;
  43891. private _scaleFactor;
  43892. private _lensCenter;
  43893. /**
  43894. * Initializes the VRDistortionCorrectionPostProcess
  43895. * @param name The name of the effect.
  43896. * @param camera The camera to apply the render pass to.
  43897. * @param isRightEye If this is for the right eye distortion
  43898. * @param vrMetrics All the required metrics for the VR camera
  43899. */
  43900. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43901. }
  43902. }
  43903. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43904. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43905. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43906. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43907. import { Scene } from "babylonjs/scene";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43910. import "babylonjs/Cameras/RigModes/vrRigMode";
  43911. /**
  43912. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43913. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43914. */
  43915. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43916. /**
  43917. * Creates a new VRDeviceOrientationArcRotateCamera
  43918. * @param name defines camera name
  43919. * @param alpha defines the camera rotation along the logitudinal axis
  43920. * @param beta defines the camera rotation along the latitudinal axis
  43921. * @param radius defines the camera distance from its target
  43922. * @param target defines the camera target
  43923. * @param scene defines the scene the camera belongs to
  43924. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43925. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43926. */
  43927. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43928. /**
  43929. * Gets camera class name
  43930. * @returns VRDeviceOrientationArcRotateCamera
  43931. */
  43932. getClassName(): string;
  43933. }
  43934. }
  43935. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43936. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43937. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43938. import { Scene } from "babylonjs/scene";
  43939. import { Vector3 } from "babylonjs/Maths/math.vector";
  43940. import "babylonjs/Cameras/RigModes/vrRigMode";
  43941. /**
  43942. * Camera used to simulate VR rendering (based on FreeCamera)
  43943. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43944. */
  43945. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43946. /**
  43947. * Creates a new VRDeviceOrientationFreeCamera
  43948. * @param name defines camera name
  43949. * @param position defines the start position of the camera
  43950. * @param scene defines the scene the camera belongs to
  43951. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43952. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43953. */
  43954. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43955. /**
  43956. * Gets camera class name
  43957. * @returns VRDeviceOrientationFreeCamera
  43958. */
  43959. getClassName(): string;
  43960. }
  43961. }
  43962. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43963. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43964. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43965. import { Scene } from "babylonjs/scene";
  43966. import { Vector3 } from "babylonjs/Maths/math.vector";
  43967. import "babylonjs/Gamepads/gamepadSceneComponent";
  43968. /**
  43969. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43970. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43971. */
  43972. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43973. /**
  43974. * Creates a new VRDeviceOrientationGamepadCamera
  43975. * @param name defines camera name
  43976. * @param position defines the start position of the camera
  43977. * @param scene defines the scene the camera belongs to
  43978. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43979. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43980. */
  43981. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43982. /**
  43983. * Gets camera class name
  43984. * @returns VRDeviceOrientationGamepadCamera
  43985. */
  43986. getClassName(): string;
  43987. }
  43988. }
  43989. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43992. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43993. /** @hidden */
  43994. export var imageProcessingPixelShader: {
  43995. name: string;
  43996. shader: string;
  43997. };
  43998. }
  43999. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44000. import { Nullable } from "babylonjs/types";
  44001. import { Color4 } from "babylonjs/Maths/math.color";
  44002. import { Camera } from "babylonjs/Cameras/camera";
  44003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44004. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44005. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44007. import { Engine } from "babylonjs/Engines/engine";
  44008. import "babylonjs/Shaders/imageProcessing.fragment";
  44009. import "babylonjs/Shaders/postprocess.vertex";
  44010. /**
  44011. * ImageProcessingPostProcess
  44012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44013. */
  44014. export class ImageProcessingPostProcess extends PostProcess {
  44015. /**
  44016. * Default configuration related to image processing available in the PBR Material.
  44017. */
  44018. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44019. /**
  44020. * Gets the image processing configuration used either in this material.
  44021. */
  44022. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44023. /**
  44024. * Sets the Default image processing configuration used either in the this material.
  44025. *
  44026. * If sets to null, the scene one is in use.
  44027. */
  44028. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44029. /**
  44030. * Keep track of the image processing observer to allow dispose and replace.
  44031. */
  44032. private _imageProcessingObserver;
  44033. /**
  44034. * Attaches a new image processing configuration to the PBR Material.
  44035. * @param configuration
  44036. */
  44037. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44038. /**
  44039. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44040. */
  44041. get colorCurves(): Nullable<ColorCurves>;
  44042. /**
  44043. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44044. */
  44045. set colorCurves(value: Nullable<ColorCurves>);
  44046. /**
  44047. * Gets wether the color curves effect is enabled.
  44048. */
  44049. get colorCurvesEnabled(): boolean;
  44050. /**
  44051. * Sets wether the color curves effect is enabled.
  44052. */
  44053. set colorCurvesEnabled(value: boolean);
  44054. /**
  44055. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44056. */
  44057. get colorGradingTexture(): Nullable<BaseTexture>;
  44058. /**
  44059. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44060. */
  44061. set colorGradingTexture(value: Nullable<BaseTexture>);
  44062. /**
  44063. * Gets wether the color grading effect is enabled.
  44064. */
  44065. get colorGradingEnabled(): boolean;
  44066. /**
  44067. * Gets wether the color grading effect is enabled.
  44068. */
  44069. set colorGradingEnabled(value: boolean);
  44070. /**
  44071. * Gets exposure used in the effect.
  44072. */
  44073. get exposure(): number;
  44074. /**
  44075. * Sets exposure used in the effect.
  44076. */
  44077. set exposure(value: number);
  44078. /**
  44079. * Gets wether tonemapping is enabled or not.
  44080. */
  44081. get toneMappingEnabled(): boolean;
  44082. /**
  44083. * Sets wether tonemapping is enabled or not
  44084. */
  44085. set toneMappingEnabled(value: boolean);
  44086. /**
  44087. * Gets the type of tone mapping effect.
  44088. */
  44089. get toneMappingType(): number;
  44090. /**
  44091. * Sets the type of tone mapping effect.
  44092. */
  44093. set toneMappingType(value: number);
  44094. /**
  44095. * Gets contrast used in the effect.
  44096. */
  44097. get contrast(): number;
  44098. /**
  44099. * Sets contrast used in the effect.
  44100. */
  44101. set contrast(value: number);
  44102. /**
  44103. * Gets Vignette stretch size.
  44104. */
  44105. get vignetteStretch(): number;
  44106. /**
  44107. * Sets Vignette stretch size.
  44108. */
  44109. set vignetteStretch(value: number);
  44110. /**
  44111. * Gets Vignette centre X Offset.
  44112. */
  44113. get vignetteCentreX(): number;
  44114. /**
  44115. * Sets Vignette centre X Offset.
  44116. */
  44117. set vignetteCentreX(value: number);
  44118. /**
  44119. * Gets Vignette centre Y Offset.
  44120. */
  44121. get vignetteCentreY(): number;
  44122. /**
  44123. * Sets Vignette centre Y Offset.
  44124. */
  44125. set vignetteCentreY(value: number);
  44126. /**
  44127. * Gets Vignette weight or intensity of the vignette effect.
  44128. */
  44129. get vignetteWeight(): number;
  44130. /**
  44131. * Sets Vignette weight or intensity of the vignette effect.
  44132. */
  44133. set vignetteWeight(value: number);
  44134. /**
  44135. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44136. * if vignetteEnabled is set to true.
  44137. */
  44138. get vignetteColor(): Color4;
  44139. /**
  44140. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44141. * if vignetteEnabled is set to true.
  44142. */
  44143. set vignetteColor(value: Color4);
  44144. /**
  44145. * Gets Camera field of view used by the Vignette effect.
  44146. */
  44147. get vignetteCameraFov(): number;
  44148. /**
  44149. * Sets Camera field of view used by the Vignette effect.
  44150. */
  44151. set vignetteCameraFov(value: number);
  44152. /**
  44153. * Gets the vignette blend mode allowing different kind of effect.
  44154. */
  44155. get vignetteBlendMode(): number;
  44156. /**
  44157. * Sets the vignette blend mode allowing different kind of effect.
  44158. */
  44159. set vignetteBlendMode(value: number);
  44160. /**
  44161. * Gets wether the vignette effect is enabled.
  44162. */
  44163. get vignetteEnabled(): boolean;
  44164. /**
  44165. * Sets wether the vignette effect is enabled.
  44166. */
  44167. set vignetteEnabled(value: boolean);
  44168. private _fromLinearSpace;
  44169. /**
  44170. * Gets wether the input of the processing is in Gamma or Linear Space.
  44171. */
  44172. get fromLinearSpace(): boolean;
  44173. /**
  44174. * Sets wether the input of the processing is in Gamma or Linear Space.
  44175. */
  44176. set fromLinearSpace(value: boolean);
  44177. /**
  44178. * Defines cache preventing GC.
  44179. */
  44180. private _defines;
  44181. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44182. /**
  44183. * "ImageProcessingPostProcess"
  44184. * @returns "ImageProcessingPostProcess"
  44185. */
  44186. getClassName(): string;
  44187. protected _updateParameters(): void;
  44188. dispose(camera?: Camera): void;
  44189. }
  44190. }
  44191. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44192. import { Scene } from "babylonjs/scene";
  44193. import { Color3 } from "babylonjs/Maths/math.color";
  44194. import { Mesh } from "babylonjs/Meshes/mesh";
  44195. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44196. import { Nullable } from "babylonjs/types";
  44197. /**
  44198. * Class containing static functions to help procedurally build meshes
  44199. */
  44200. export class GroundBuilder {
  44201. /**
  44202. * Creates a ground mesh
  44203. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44204. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44206. * @param name defines the name of the mesh
  44207. * @param options defines the options used to create the mesh
  44208. * @param scene defines the hosting scene
  44209. * @returns the ground mesh
  44210. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44211. */
  44212. static CreateGround(name: string, options: {
  44213. width?: number;
  44214. height?: number;
  44215. subdivisions?: number;
  44216. subdivisionsX?: number;
  44217. subdivisionsY?: number;
  44218. updatable?: boolean;
  44219. }, scene: any): Mesh;
  44220. /**
  44221. * Creates a tiled ground mesh
  44222. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44223. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44224. * * 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
  44225. * * 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
  44226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44227. * @param name defines the name of the mesh
  44228. * @param options defines the options used to create the mesh
  44229. * @param scene defines the hosting scene
  44230. * @returns the tiled ground mesh
  44231. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44232. */
  44233. static CreateTiledGround(name: string, options: {
  44234. xmin: number;
  44235. zmin: number;
  44236. xmax: number;
  44237. zmax: number;
  44238. subdivisions?: {
  44239. w: number;
  44240. h: number;
  44241. };
  44242. precision?: {
  44243. w: number;
  44244. h: number;
  44245. };
  44246. updatable?: boolean;
  44247. }, scene?: Nullable<Scene>): Mesh;
  44248. /**
  44249. * Creates a ground mesh from a height map
  44250. * * The parameter `url` sets the URL of the height map image resource.
  44251. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44252. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44253. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44254. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44255. * * 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.
  44256. * * 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).
  44257. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44259. * @param name defines the name of the mesh
  44260. * @param url defines the url to the height map
  44261. * @param options defines the options used to create the mesh
  44262. * @param scene defines the hosting scene
  44263. * @returns the ground mesh
  44264. * @see https://doc.babylonjs.com/babylon101/height_map
  44265. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44266. */
  44267. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44268. width?: number;
  44269. height?: number;
  44270. subdivisions?: number;
  44271. minHeight?: number;
  44272. maxHeight?: number;
  44273. colorFilter?: Color3;
  44274. alphaFilter?: number;
  44275. updatable?: boolean;
  44276. onReady?: (mesh: GroundMesh) => void;
  44277. }, scene?: Nullable<Scene>): GroundMesh;
  44278. }
  44279. }
  44280. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44281. import { Vector4 } from "babylonjs/Maths/math.vector";
  44282. import { Mesh } from "babylonjs/Meshes/mesh";
  44283. /**
  44284. * Class containing static functions to help procedurally build meshes
  44285. */
  44286. export class TorusBuilder {
  44287. /**
  44288. * Creates a torus mesh
  44289. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44290. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44291. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44295. * @param name defines the name of the mesh
  44296. * @param options defines the options used to create the mesh
  44297. * @param scene defines the hosting scene
  44298. * @returns the torus mesh
  44299. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44300. */
  44301. static CreateTorus(name: string, options: {
  44302. diameter?: number;
  44303. thickness?: number;
  44304. tessellation?: number;
  44305. updatable?: boolean;
  44306. sideOrientation?: number;
  44307. frontUVs?: Vector4;
  44308. backUVs?: Vector4;
  44309. }, scene: any): Mesh;
  44310. }
  44311. }
  44312. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44313. import { Vector4 } from "babylonjs/Maths/math.vector";
  44314. import { Color4 } from "babylonjs/Maths/math.color";
  44315. import { Mesh } from "babylonjs/Meshes/mesh";
  44316. /**
  44317. * Class containing static functions to help procedurally build meshes
  44318. */
  44319. export class CylinderBuilder {
  44320. /**
  44321. * Creates a cylinder or a cone mesh
  44322. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44323. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44324. * * 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.
  44325. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44326. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44327. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44328. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44329. * * 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).
  44330. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44331. * * 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).
  44332. * * 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
  44333. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44334. * * 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
  44335. * * 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.
  44336. * * If `enclose` is false, a ring surface is one element.
  44337. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44338. * * 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
  44339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44342. * @param name defines the name of the mesh
  44343. * @param options defines the options used to create the mesh
  44344. * @param scene defines the hosting scene
  44345. * @returns the cylinder mesh
  44346. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44347. */
  44348. static CreateCylinder(name: string, options: {
  44349. height?: number;
  44350. diameterTop?: number;
  44351. diameterBottom?: number;
  44352. diameter?: number;
  44353. tessellation?: number;
  44354. subdivisions?: number;
  44355. arc?: number;
  44356. faceColors?: Color4[];
  44357. faceUV?: Vector4[];
  44358. updatable?: boolean;
  44359. hasRings?: boolean;
  44360. enclose?: boolean;
  44361. cap?: number;
  44362. sideOrientation?: number;
  44363. frontUVs?: Vector4;
  44364. backUVs?: Vector4;
  44365. }, scene: any): Mesh;
  44366. }
  44367. }
  44368. declare module "babylonjs/XR/webXRTypes" {
  44369. import { Nullable } from "babylonjs/types";
  44370. import { IDisposable } from "babylonjs/scene";
  44371. /**
  44372. * States of the webXR experience
  44373. */
  44374. export enum WebXRState {
  44375. /**
  44376. * Transitioning to being in XR mode
  44377. */
  44378. ENTERING_XR = 0,
  44379. /**
  44380. * Transitioning to non XR mode
  44381. */
  44382. EXITING_XR = 1,
  44383. /**
  44384. * In XR mode and presenting
  44385. */
  44386. IN_XR = 2,
  44387. /**
  44388. * Not entered XR mode
  44389. */
  44390. NOT_IN_XR = 3
  44391. }
  44392. /**
  44393. * Abstraction of the XR render target
  44394. */
  44395. export interface WebXRRenderTarget extends IDisposable {
  44396. /**
  44397. * xrpresent context of the canvas which can be used to display/mirror xr content
  44398. */
  44399. canvasContext: WebGLRenderingContext;
  44400. /**
  44401. * xr layer for the canvas
  44402. */
  44403. xrLayer: Nullable<XRWebGLLayer>;
  44404. /**
  44405. * Initializes the xr layer for the session
  44406. * @param xrSession xr session
  44407. * @returns a promise that will resolve once the XR Layer has been created
  44408. */
  44409. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44410. }
  44411. }
  44412. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44413. import { Nullable } from "babylonjs/types";
  44414. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44415. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44416. /**
  44417. * COnfiguration object for WebXR output canvas
  44418. */
  44419. export class WebXRManagedOutputCanvasOptions {
  44420. /**
  44421. * An optional canvas in case you wish to create it yourself and provide it here.
  44422. * If not provided, a new canvas will be created
  44423. */
  44424. canvasElement?: HTMLCanvasElement;
  44425. /**
  44426. * Options for this XR Layer output
  44427. */
  44428. canvasOptions?: XRWebGLLayerOptions;
  44429. /**
  44430. * CSS styling for a newly created canvas (if not provided)
  44431. */
  44432. newCanvasCssStyle?: string;
  44433. /**
  44434. * Get the default values of the configuration object
  44435. * @returns default values of this configuration object
  44436. */
  44437. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44438. }
  44439. /**
  44440. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44441. */
  44442. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44443. private _options;
  44444. private _canvas;
  44445. private _engine;
  44446. /**
  44447. * Rendering context of the canvas which can be used to display/mirror xr content
  44448. */
  44449. canvasContext: WebGLRenderingContext;
  44450. /**
  44451. * xr layer for the canvas
  44452. */
  44453. xrLayer: Nullable<XRWebGLLayer>;
  44454. /**
  44455. * Initializes the canvas to be added/removed upon entering/exiting xr
  44456. * @param _xrSessionManager The XR Session manager
  44457. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44458. */
  44459. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44460. /**
  44461. * Disposes of the object
  44462. */
  44463. dispose(): void;
  44464. /**
  44465. * Initializes the xr layer for the session
  44466. * @param xrSession xr session
  44467. * @returns a promise that will resolve once the XR Layer has been created
  44468. */
  44469. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44470. private _addCanvas;
  44471. private _removeCanvas;
  44472. private _setManagedOutputCanvas;
  44473. }
  44474. }
  44475. declare module "babylonjs/XR/webXRSessionManager" {
  44476. import { Observable } from "babylonjs/Misc/observable";
  44477. import { Nullable } from "babylonjs/types";
  44478. import { IDisposable, Scene } from "babylonjs/scene";
  44479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44480. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44481. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44482. /**
  44483. * Manages an XRSession to work with Babylon's engine
  44484. * @see https://doc.babylonjs.com/how_to/webxr
  44485. */
  44486. export class WebXRSessionManager implements IDisposable {
  44487. /** The scene which the session should be created for */
  44488. scene: Scene;
  44489. private _referenceSpace;
  44490. private _rttProvider;
  44491. private _sessionEnded;
  44492. private _xrNavigator;
  44493. private baseLayer;
  44494. /**
  44495. * The base reference space from which the session started. good if you want to reset your
  44496. * reference space
  44497. */
  44498. baseReferenceSpace: XRReferenceSpace;
  44499. /**
  44500. * Current XR frame
  44501. */
  44502. currentFrame: Nullable<XRFrame>;
  44503. /** WebXR timestamp updated every frame */
  44504. currentTimestamp: number;
  44505. /**
  44506. * Used just in case of a failure to initialize an immersive session.
  44507. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44508. */
  44509. defaultHeightCompensation: number;
  44510. /**
  44511. * Fires every time a new xrFrame arrives which can be used to update the camera
  44512. */
  44513. onXRFrameObservable: Observable<XRFrame>;
  44514. /**
  44515. * Fires when the reference space changed
  44516. */
  44517. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44518. /**
  44519. * Fires when the xr session is ended either by the device or manually done
  44520. */
  44521. onXRSessionEnded: Observable<any>;
  44522. /**
  44523. * Fires when the xr session is ended either by the device or manually done
  44524. */
  44525. onXRSessionInit: Observable<XRSession>;
  44526. /**
  44527. * Underlying xr session
  44528. */
  44529. session: XRSession;
  44530. /**
  44531. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44532. * or get the offset the player is currently at.
  44533. */
  44534. viewerReferenceSpace: XRReferenceSpace;
  44535. /**
  44536. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44537. * @param scene The scene which the session should be created for
  44538. */
  44539. constructor(
  44540. /** The scene which the session should be created for */
  44541. scene: Scene);
  44542. /**
  44543. * The current reference space used in this session. This reference space can constantly change!
  44544. * It is mainly used to offset the camera's position.
  44545. */
  44546. get referenceSpace(): XRReferenceSpace;
  44547. /**
  44548. * Set a new reference space and triggers the observable
  44549. */
  44550. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44551. /**
  44552. * Disposes of the session manager
  44553. */
  44554. dispose(): void;
  44555. /**
  44556. * Stops the xrSession and restores the render loop
  44557. * @returns Promise which resolves after it exits XR
  44558. */
  44559. exitXRAsync(): Promise<void>;
  44560. /**
  44561. * Gets the correct render target texture to be rendered this frame for this eye
  44562. * @param eye the eye for which to get the render target
  44563. * @returns the render target for the specified eye
  44564. */
  44565. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44566. /**
  44567. * Creates a WebXRRenderTarget object for the XR session
  44568. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44569. * @param options optional options to provide when creating a new render target
  44570. * @returns a WebXR render target to which the session can render
  44571. */
  44572. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44573. /**
  44574. * Initializes the manager
  44575. * After initialization enterXR can be called to start an XR session
  44576. * @returns Promise which resolves after it is initialized
  44577. */
  44578. initializeAsync(): Promise<void>;
  44579. /**
  44580. * Initializes an xr session
  44581. * @param xrSessionMode mode to initialize
  44582. * @param xrSessionInit defines optional and required values to pass to the session builder
  44583. * @returns a promise which will resolve once the session has been initialized
  44584. */
  44585. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44586. /**
  44587. * Checks if a session would be supported for the creation options specified
  44588. * @param sessionMode session mode to check if supported eg. immersive-vr
  44589. * @returns A Promise that resolves to true if supported and false if not
  44590. */
  44591. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44592. /**
  44593. * Resets the reference space to the one started the session
  44594. */
  44595. resetReferenceSpace(): void;
  44596. /**
  44597. * Starts rendering to the xr layer
  44598. */
  44599. runXRRenderLoop(): void;
  44600. /**
  44601. * Sets the reference space on the xr session
  44602. * @param referenceSpaceType space to set
  44603. * @returns a promise that will resolve once the reference space has been set
  44604. */
  44605. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44606. /**
  44607. * Updates the render state of the session
  44608. * @param state state to set
  44609. * @returns a promise that resolves once the render state has been updated
  44610. */
  44611. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44612. /**
  44613. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44614. * @param sessionMode defines the session to test
  44615. * @returns a promise with boolean as final value
  44616. */
  44617. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44618. private _createRenderTargetTexture;
  44619. }
  44620. }
  44621. declare module "babylonjs/XR/webXRCamera" {
  44622. import { Scene } from "babylonjs/scene";
  44623. import { Camera } from "babylonjs/Cameras/camera";
  44624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44625. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44626. /**
  44627. * WebXR Camera which holds the views for the xrSession
  44628. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44629. */
  44630. export class WebXRCamera extends FreeCamera {
  44631. private _xrSessionManager;
  44632. private _firstFrame;
  44633. private _referenceQuaternion;
  44634. private _referencedPosition;
  44635. private _xrInvPositionCache;
  44636. private _xrInvQuaternionCache;
  44637. /**
  44638. * Should position compensation execute on first frame.
  44639. * This is used when copying the position from a native (non XR) camera
  44640. */
  44641. compensateOnFirstFrame: boolean;
  44642. /**
  44643. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44644. * @param name the name of the camera
  44645. * @param scene the scene to add the camera to
  44646. * @param _xrSessionManager a constructed xr session manager
  44647. */
  44648. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44649. /**
  44650. * Return the user's height, unrelated to the current ground.
  44651. * This will be the y position of this camera, when ground level is 0.
  44652. */
  44653. get realWorldHeight(): number;
  44654. /** @hidden */
  44655. _updateForDualEyeDebugging(): void;
  44656. /**
  44657. * Sets this camera's transformation based on a non-vr camera
  44658. * @param otherCamera the non-vr camera to copy the transformation from
  44659. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44660. */
  44661. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44662. /**
  44663. * Gets the current instance class name ("WebXRCamera").
  44664. * @returns the class name
  44665. */
  44666. getClassName(): string;
  44667. private _updateFromXRSession;
  44668. private _updateNumberOfRigCameras;
  44669. private _updateReferenceSpace;
  44670. private _updateReferenceSpaceOffset;
  44671. }
  44672. }
  44673. declare module "babylonjs/XR/webXRFeaturesManager" {
  44674. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44675. import { IDisposable } from "babylonjs/scene";
  44676. /**
  44677. * Defining the interface required for a (webxr) feature
  44678. */
  44679. export interface IWebXRFeature extends IDisposable {
  44680. /**
  44681. * Is this feature attached
  44682. */
  44683. attached: boolean;
  44684. /**
  44685. * Should auto-attach be disabled?
  44686. */
  44687. disableAutoAttach: boolean;
  44688. /**
  44689. * Attach the feature to the session
  44690. * Will usually be called by the features manager
  44691. *
  44692. * @param force should attachment be forced (even when already attached)
  44693. * @returns true if successful.
  44694. */
  44695. attach(force?: boolean): boolean;
  44696. /**
  44697. * Detach the feature from the session
  44698. * Will usually be called by the features manager
  44699. *
  44700. * @returns true if successful.
  44701. */
  44702. detach(): boolean;
  44703. }
  44704. /**
  44705. * A list of the currently available features without referencing them
  44706. */
  44707. export class WebXRFeatureName {
  44708. /**
  44709. * The name of the anchor system feature
  44710. */
  44711. static ANCHOR_SYSTEM: string;
  44712. /**
  44713. * The name of the background remover feature
  44714. */
  44715. static BACKGROUND_REMOVER: string;
  44716. /**
  44717. * The name of the hit test feature
  44718. */
  44719. static HIT_TEST: string;
  44720. /**
  44721. * physics impostors for xr controllers feature
  44722. */
  44723. static PHYSICS_CONTROLLERS: string;
  44724. /**
  44725. * The name of the plane detection feature
  44726. */
  44727. static PLANE_DETECTION: string;
  44728. /**
  44729. * The name of the pointer selection feature
  44730. */
  44731. static POINTER_SELECTION: string;
  44732. /**
  44733. * The name of the teleportation feature
  44734. */
  44735. static TELEPORTATION: string;
  44736. }
  44737. /**
  44738. * Defining the constructor of a feature. Used to register the modules.
  44739. */
  44740. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44741. /**
  44742. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44743. * It is mainly used in AR sessions.
  44744. *
  44745. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44746. */
  44747. export class WebXRFeaturesManager implements IDisposable {
  44748. private _xrSessionManager;
  44749. private static readonly _AvailableFeatures;
  44750. private _features;
  44751. /**
  44752. * constructs a new features manages.
  44753. *
  44754. * @param _xrSessionManager an instance of WebXRSessionManager
  44755. */
  44756. constructor(_xrSessionManager: WebXRSessionManager);
  44757. /**
  44758. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44759. * Mainly used internally.
  44760. *
  44761. * @param featureName the name of the feature to register
  44762. * @param constructorFunction the function used to construct the module
  44763. * @param version the (babylon) version of the module
  44764. * @param stable is that a stable version of this module
  44765. */
  44766. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44767. /**
  44768. * Returns a constructor of a specific feature.
  44769. *
  44770. * @param featureName the name of the feature to construct
  44771. * @param version the version of the feature to load
  44772. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44773. * @param options optional options provided to the module.
  44774. * @returns a function that, when called, will return a new instance of this feature
  44775. */
  44776. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44777. /**
  44778. * Can be used to return the list of features currently registered
  44779. *
  44780. * @returns an Array of available features
  44781. */
  44782. static GetAvailableFeatures(): string[];
  44783. /**
  44784. * Gets the versions available for a specific feature
  44785. * @param featureName the name of the feature
  44786. * @returns an array with the available versions
  44787. */
  44788. static GetAvailableVersions(featureName: string): string[];
  44789. /**
  44790. * Return the latest unstable version of this feature
  44791. * @param featureName the name of the feature to search
  44792. * @returns the version number. if not found will return -1
  44793. */
  44794. static GetLatestVersionOfFeature(featureName: string): number;
  44795. /**
  44796. * Return the latest stable version of this feature
  44797. * @param featureName the name of the feature to search
  44798. * @returns the version number. if not found will return -1
  44799. */
  44800. static GetStableVersionOfFeature(featureName: string): number;
  44801. /**
  44802. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44803. * Can be used during a session to start a feature
  44804. * @param featureName the name of feature to attach
  44805. */
  44806. attachFeature(featureName: string): void;
  44807. /**
  44808. * Can be used inside a session or when the session ends to detach a specific feature
  44809. * @param featureName the name of the feature to detach
  44810. */
  44811. detachFeature(featureName: string): void;
  44812. /**
  44813. * Used to disable an already-enabled feature
  44814. * The feature will be disposed and will be recreated once enabled.
  44815. * @param featureName the feature to disable
  44816. * @returns true if disable was successful
  44817. */
  44818. disableFeature(featureName: string | {
  44819. Name: string;
  44820. }): boolean;
  44821. /**
  44822. * dispose this features manager
  44823. */
  44824. dispose(): void;
  44825. /**
  44826. * 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.
  44827. * 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.
  44828. *
  44829. * @param featureName the name of the feature to load or the class of the feature
  44830. * @param version optional version to load. if not provided the latest version will be enabled
  44831. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44832. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44833. * @returns a new constructed feature or throws an error if feature not found.
  44834. */
  44835. enableFeature(featureName: string | {
  44836. Name: string;
  44837. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44838. /**
  44839. * get the implementation of an enabled feature.
  44840. * @param featureName the name of the feature to load
  44841. * @returns the feature class, if found
  44842. */
  44843. getEnabledFeature(featureName: string): IWebXRFeature;
  44844. /**
  44845. * Get the list of enabled features
  44846. * @returns an array of enabled features
  44847. */
  44848. getEnabledFeatures(): string[];
  44849. }
  44850. }
  44851. declare module "babylonjs/XR/webXRExperienceHelper" {
  44852. import { Observable } from "babylonjs/Misc/observable";
  44853. import { IDisposable, Scene } from "babylonjs/scene";
  44854. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44855. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44856. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44857. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44858. /**
  44859. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44860. * @see https://doc.babylonjs.com/how_to/webxr
  44861. */
  44862. export class WebXRExperienceHelper implements IDisposable {
  44863. private scene;
  44864. private _nonVRCamera;
  44865. private _originalSceneAutoClear;
  44866. private _supported;
  44867. /**
  44868. * Camera used to render xr content
  44869. */
  44870. camera: WebXRCamera;
  44871. /** A features manager for this xr session */
  44872. featuresManager: WebXRFeaturesManager;
  44873. /**
  44874. * Observers registered here will be triggered after the camera's initial transformation is set
  44875. * This can be used to set a different ground level or an extra rotation.
  44876. *
  44877. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44878. * to the position set after this observable is done executing.
  44879. */
  44880. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44881. /**
  44882. * Fires when the state of the experience helper has changed
  44883. */
  44884. onStateChangedObservable: Observable<WebXRState>;
  44885. /** Session manager used to keep track of xr session */
  44886. sessionManager: WebXRSessionManager;
  44887. /**
  44888. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44889. */
  44890. state: WebXRState;
  44891. /**
  44892. * Creates a WebXRExperienceHelper
  44893. * @param scene The scene the helper should be created in
  44894. */
  44895. private constructor();
  44896. /**
  44897. * Creates the experience helper
  44898. * @param scene the scene to attach the experience helper to
  44899. * @returns a promise for the experience helper
  44900. */
  44901. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44902. /**
  44903. * Disposes of the experience helper
  44904. */
  44905. dispose(): void;
  44906. /**
  44907. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44908. * @param sessionMode options for the XR session
  44909. * @param referenceSpaceType frame of reference of the XR session
  44910. * @param renderTarget the output canvas that will be used to enter XR mode
  44911. * @returns promise that resolves after xr mode has entered
  44912. */
  44913. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44914. /**
  44915. * Exits XR mode and returns the scene to its original state
  44916. * @returns promise that resolves after xr mode has exited
  44917. */
  44918. exitXRAsync(): Promise<void>;
  44919. private _nonXRToXRCamera;
  44920. private _setState;
  44921. }
  44922. }
  44923. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44924. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44925. import { Observable } from "babylonjs/Misc/observable";
  44926. import { IDisposable } from "babylonjs/scene";
  44927. /**
  44928. * X-Y values for axes in WebXR
  44929. */
  44930. export interface IWebXRMotionControllerAxesValue {
  44931. /**
  44932. * The value of the x axis
  44933. */
  44934. x: number;
  44935. /**
  44936. * The value of the y-axis
  44937. */
  44938. y: number;
  44939. }
  44940. /**
  44941. * changed / previous values for the values of this component
  44942. */
  44943. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44944. /**
  44945. * current (this frame) value
  44946. */
  44947. current: T;
  44948. /**
  44949. * previous (last change) value
  44950. */
  44951. previous: T;
  44952. }
  44953. /**
  44954. * Represents changes in the component between current frame and last values recorded
  44955. */
  44956. export interface IWebXRMotionControllerComponentChanges {
  44957. /**
  44958. * will be populated with previous and current values if axes changed
  44959. */
  44960. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44961. /**
  44962. * will be populated with previous and current values if pressed changed
  44963. */
  44964. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44965. /**
  44966. * will be populated with previous and current values if touched changed
  44967. */
  44968. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44969. /**
  44970. * will be populated with previous and current values if value changed
  44971. */
  44972. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44973. }
  44974. /**
  44975. * This class represents a single component (for example button or thumbstick) of a motion controller
  44976. */
  44977. export class WebXRControllerComponent implements IDisposable {
  44978. /**
  44979. * the id of this component
  44980. */
  44981. id: string;
  44982. /**
  44983. * the type of the component
  44984. */
  44985. type: MotionControllerComponentType;
  44986. private _buttonIndex;
  44987. private _axesIndices;
  44988. private _axes;
  44989. private _changes;
  44990. private _currentValue;
  44991. private _hasChanges;
  44992. private _pressed;
  44993. private _touched;
  44994. /**
  44995. * button component type
  44996. */
  44997. static BUTTON_TYPE: MotionControllerComponentType;
  44998. /**
  44999. * squeeze component type
  45000. */
  45001. static SQUEEZE_TYPE: MotionControllerComponentType;
  45002. /**
  45003. * Thumbstick component type
  45004. */
  45005. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45006. /**
  45007. * Touchpad component type
  45008. */
  45009. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45010. /**
  45011. * trigger component type
  45012. */
  45013. static TRIGGER_TYPE: MotionControllerComponentType;
  45014. /**
  45015. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45016. * the axes data changes
  45017. */
  45018. onAxisValueChangedObservable: Observable<{
  45019. x: number;
  45020. y: number;
  45021. }>;
  45022. /**
  45023. * Observers registered here will be triggered when the state of a button changes
  45024. * State change is either pressed / touched / value
  45025. */
  45026. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45027. /**
  45028. * Creates a new component for a motion controller.
  45029. * It is created by the motion controller itself
  45030. *
  45031. * @param id the id of this component
  45032. * @param type the type of the component
  45033. * @param _buttonIndex index in the buttons array of the gamepad
  45034. * @param _axesIndices indices of the values in the axes array of the gamepad
  45035. */
  45036. constructor(
  45037. /**
  45038. * the id of this component
  45039. */
  45040. id: string,
  45041. /**
  45042. * the type of the component
  45043. */
  45044. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45045. /**
  45046. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45047. */
  45048. get axes(): IWebXRMotionControllerAxesValue;
  45049. /**
  45050. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45051. */
  45052. get changes(): IWebXRMotionControllerComponentChanges;
  45053. /**
  45054. * Return whether or not the component changed the last frame
  45055. */
  45056. get hasChanges(): boolean;
  45057. /**
  45058. * is the button currently pressed
  45059. */
  45060. get pressed(): boolean;
  45061. /**
  45062. * is the button currently touched
  45063. */
  45064. get touched(): boolean;
  45065. /**
  45066. * Get the current value of this component
  45067. */
  45068. get value(): number;
  45069. /**
  45070. * Dispose this component
  45071. */
  45072. dispose(): void;
  45073. /**
  45074. * Are there axes correlating to this component
  45075. * @return true is axes data is available
  45076. */
  45077. isAxes(): boolean;
  45078. /**
  45079. * Is this component a button (hence - pressable)
  45080. * @returns true if can be pressed
  45081. */
  45082. isButton(): boolean;
  45083. /**
  45084. * update this component using the gamepad object it is in. Called on every frame
  45085. * @param nativeController the native gamepad controller object
  45086. */
  45087. update(nativeController: IMinimalMotionControllerObject): void;
  45088. }
  45089. }
  45090. declare module "babylonjs/Loading/sceneLoader" {
  45091. import { Observable } from "babylonjs/Misc/observable";
  45092. import { Nullable } from "babylonjs/types";
  45093. import { Scene } from "babylonjs/scene";
  45094. import { Engine } from "babylonjs/Engines/engine";
  45095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45096. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45097. import { AssetContainer } from "babylonjs/assetContainer";
  45098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45099. import { Skeleton } from "babylonjs/Bones/skeleton";
  45100. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45101. import { WebRequest } from "babylonjs/Misc/webRequest";
  45102. /**
  45103. * Class used to represent data loading progression
  45104. */
  45105. export class SceneLoaderProgressEvent {
  45106. /** defines if data length to load can be evaluated */
  45107. readonly lengthComputable: boolean;
  45108. /** defines the loaded data length */
  45109. readonly loaded: number;
  45110. /** defines the data length to load */
  45111. readonly total: number;
  45112. /**
  45113. * Create a new progress event
  45114. * @param lengthComputable defines if data length to load can be evaluated
  45115. * @param loaded defines the loaded data length
  45116. * @param total defines the data length to load
  45117. */
  45118. constructor(
  45119. /** defines if data length to load can be evaluated */
  45120. lengthComputable: boolean,
  45121. /** defines the loaded data length */
  45122. loaded: number,
  45123. /** defines the data length to load */
  45124. total: number);
  45125. /**
  45126. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45127. * @param event defines the source event
  45128. * @returns a new SceneLoaderProgressEvent
  45129. */
  45130. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45131. }
  45132. /**
  45133. * Interface used by SceneLoader plugins to define supported file extensions
  45134. */
  45135. export interface ISceneLoaderPluginExtensions {
  45136. /**
  45137. * Defines the list of supported extensions
  45138. */
  45139. [extension: string]: {
  45140. isBinary: boolean;
  45141. };
  45142. }
  45143. /**
  45144. * Interface used by SceneLoader plugin factory
  45145. */
  45146. export interface ISceneLoaderPluginFactory {
  45147. /**
  45148. * Defines the name of the factory
  45149. */
  45150. name: string;
  45151. /**
  45152. * Function called to create a new plugin
  45153. * @return the new plugin
  45154. */
  45155. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45156. /**
  45157. * The callback that returns true if the data can be directly loaded.
  45158. * @param data string containing the file data
  45159. * @returns if the data can be loaded directly
  45160. */
  45161. canDirectLoad?(data: string): boolean;
  45162. }
  45163. /**
  45164. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45165. */
  45166. export interface ISceneLoaderPluginBase {
  45167. /**
  45168. * The friendly name of this plugin.
  45169. */
  45170. name: string;
  45171. /**
  45172. * The file extensions supported by this plugin.
  45173. */
  45174. extensions: string | ISceneLoaderPluginExtensions;
  45175. /**
  45176. * The callback called when loading from a url.
  45177. * @param scene scene loading this url
  45178. * @param url url to load
  45179. * @param onSuccess callback called when the file successfully loads
  45180. * @param onProgress callback called while file is loading (if the server supports this mode)
  45181. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45182. * @param onError callback called when the file fails to load
  45183. * @returns a file request object
  45184. */
  45185. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45186. /**
  45187. * The callback called when loading from a file object.
  45188. * @param scene scene loading this file
  45189. * @param file defines the file to load
  45190. * @param onSuccess defines the callback to call when data is loaded
  45191. * @param onProgress defines the callback to call during loading process
  45192. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45193. * @param onError defines the callback to call when an error occurs
  45194. * @returns a file request object
  45195. */
  45196. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45197. /**
  45198. * The callback that returns true if the data can be directly loaded.
  45199. * @param data string containing the file data
  45200. * @returns if the data can be loaded directly
  45201. */
  45202. canDirectLoad?(data: string): boolean;
  45203. /**
  45204. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45205. * @param scene scene loading this data
  45206. * @param data string containing the data
  45207. * @returns data to pass to the plugin
  45208. */
  45209. directLoad?(scene: Scene, data: string): any;
  45210. /**
  45211. * The callback that allows custom handling of the root url based on the response url.
  45212. * @param rootUrl the original root url
  45213. * @param responseURL the response url if available
  45214. * @returns the new root url
  45215. */
  45216. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45217. }
  45218. /**
  45219. * Interface used to define a SceneLoader plugin
  45220. */
  45221. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45222. /**
  45223. * Import meshes into a scene.
  45224. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45225. * @param scene The scene to import into
  45226. * @param data The data to import
  45227. * @param rootUrl The root url for scene and resources
  45228. * @param meshes The meshes array to import into
  45229. * @param particleSystems The particle systems array to import into
  45230. * @param skeletons The skeletons array to import into
  45231. * @param onError The callback when import fails
  45232. * @returns True if successful or false otherwise
  45233. */
  45234. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45235. /**
  45236. * Load into a scene.
  45237. * @param scene The scene to load into
  45238. * @param data The data to import
  45239. * @param rootUrl The root url for scene and resources
  45240. * @param onError The callback when import fails
  45241. * @returns True if successful or false otherwise
  45242. */
  45243. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45244. /**
  45245. * Load into an asset container.
  45246. * @param scene The scene to load into
  45247. * @param data The data to import
  45248. * @param rootUrl The root url for scene and resources
  45249. * @param onError The callback when import fails
  45250. * @returns The loaded asset container
  45251. */
  45252. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45253. }
  45254. /**
  45255. * Interface used to define an async SceneLoader plugin
  45256. */
  45257. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45258. /**
  45259. * Import meshes into a scene.
  45260. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45261. * @param scene The scene to import into
  45262. * @param data The data to import
  45263. * @param rootUrl The root url for scene and resources
  45264. * @param onProgress The callback when the load progresses
  45265. * @param fileName Defines the name of the file to load
  45266. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45267. */
  45268. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45269. meshes: AbstractMesh[];
  45270. particleSystems: IParticleSystem[];
  45271. skeletons: Skeleton[];
  45272. animationGroups: AnimationGroup[];
  45273. }>;
  45274. /**
  45275. * Load into a scene.
  45276. * @param scene The scene to load into
  45277. * @param data The data to import
  45278. * @param rootUrl The root url for scene and resources
  45279. * @param onProgress The callback when the load progresses
  45280. * @param fileName Defines the name of the file to load
  45281. * @returns Nothing
  45282. */
  45283. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45284. /**
  45285. * Load into an asset container.
  45286. * @param scene The scene to load into
  45287. * @param data The data to import
  45288. * @param rootUrl The root url for scene and resources
  45289. * @param onProgress The callback when the load progresses
  45290. * @param fileName Defines the name of the file to load
  45291. * @returns The loaded asset container
  45292. */
  45293. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45294. }
  45295. /**
  45296. * Mode that determines how to handle old animation groups before loading new ones.
  45297. */
  45298. export enum SceneLoaderAnimationGroupLoadingMode {
  45299. /**
  45300. * Reset all old animations to initial state then dispose them.
  45301. */
  45302. Clean = 0,
  45303. /**
  45304. * Stop all old animations.
  45305. */
  45306. Stop = 1,
  45307. /**
  45308. * Restart old animations from first frame.
  45309. */
  45310. Sync = 2,
  45311. /**
  45312. * Old animations remains untouched.
  45313. */
  45314. NoSync = 3
  45315. }
  45316. /**
  45317. * Class used to load scene from various file formats using registered plugins
  45318. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45319. */
  45320. export class SceneLoader {
  45321. /**
  45322. * No logging while loading
  45323. */
  45324. static readonly NO_LOGGING: number;
  45325. /**
  45326. * Minimal logging while loading
  45327. */
  45328. static readonly MINIMAL_LOGGING: number;
  45329. /**
  45330. * Summary logging while loading
  45331. */
  45332. static readonly SUMMARY_LOGGING: number;
  45333. /**
  45334. * Detailled logging while loading
  45335. */
  45336. static readonly DETAILED_LOGGING: number;
  45337. /**
  45338. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45339. */
  45340. static get ForceFullSceneLoadingForIncremental(): boolean;
  45341. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45342. /**
  45343. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45344. */
  45345. static get ShowLoadingScreen(): boolean;
  45346. static set ShowLoadingScreen(value: boolean);
  45347. /**
  45348. * Defines the current logging level (while loading the scene)
  45349. * @ignorenaming
  45350. */
  45351. static get loggingLevel(): number;
  45352. static set loggingLevel(value: number);
  45353. /**
  45354. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45355. */
  45356. static get CleanBoneMatrixWeights(): boolean;
  45357. static set CleanBoneMatrixWeights(value: boolean);
  45358. /**
  45359. * Event raised when a plugin is used to load a scene
  45360. */
  45361. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45362. private static _registeredPlugins;
  45363. private static _getDefaultPlugin;
  45364. private static _getPluginForExtension;
  45365. private static _getPluginForDirectLoad;
  45366. private static _getPluginForFilename;
  45367. private static _getDirectLoad;
  45368. private static _loadData;
  45369. private static _getFileInfo;
  45370. /**
  45371. * Gets a plugin that can load the given extension
  45372. * @param extension defines the extension to load
  45373. * @returns a plugin or null if none works
  45374. */
  45375. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45376. /**
  45377. * Gets a boolean indicating that the given extension can be loaded
  45378. * @param extension defines the extension to load
  45379. * @returns true if the extension is supported
  45380. */
  45381. static IsPluginForExtensionAvailable(extension: string): boolean;
  45382. /**
  45383. * Adds a new plugin to the list of registered plugins
  45384. * @param plugin defines the plugin to add
  45385. */
  45386. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45387. /**
  45388. * Import meshes into a scene
  45389. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45390. * @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)
  45391. * @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)
  45392. * @param scene the instance of BABYLON.Scene to append to
  45393. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45394. * @param onProgress a callback with a progress event for each file being loaded
  45395. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45396. * @param pluginExtension the extension used to determine the plugin
  45397. * @returns The loaded plugin
  45398. */
  45399. 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>;
  45400. /**
  45401. * Import meshes into a scene
  45402. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45403. * @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)
  45404. * @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)
  45405. * @param scene the instance of BABYLON.Scene to append to
  45406. * @param onProgress a callback with a progress event for each file being loaded
  45407. * @param pluginExtension the extension used to determine the plugin
  45408. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45409. */
  45410. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45411. meshes: AbstractMesh[];
  45412. particleSystems: IParticleSystem[];
  45413. skeletons: Skeleton[];
  45414. animationGroups: AnimationGroup[];
  45415. }>;
  45416. /**
  45417. * Load a scene
  45418. * @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)
  45419. * @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)
  45420. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45421. * @param onSuccess a callback with the scene when import succeeds
  45422. * @param onProgress a callback with a progress event for each file being loaded
  45423. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45424. * @param pluginExtension the extension used to determine the plugin
  45425. * @returns The loaded plugin
  45426. */
  45427. 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>;
  45428. /**
  45429. * Load a scene
  45430. * @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)
  45431. * @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)
  45432. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45433. * @param onProgress a callback with a progress event for each file being loaded
  45434. * @param pluginExtension the extension used to determine the plugin
  45435. * @returns The loaded scene
  45436. */
  45437. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45438. /**
  45439. * Append a scene
  45440. * @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)
  45441. * @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)
  45442. * @param scene is the instance of BABYLON.Scene to append to
  45443. * @param onSuccess a callback with the scene when import succeeds
  45444. * @param onProgress a callback with a progress event for each file being loaded
  45445. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45446. * @param pluginExtension the extension used to determine the plugin
  45447. * @returns The loaded plugin
  45448. */
  45449. 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>;
  45450. /**
  45451. * Append a scene
  45452. * @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)
  45453. * @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)
  45454. * @param scene is the instance of BABYLON.Scene to append to
  45455. * @param onProgress a callback with a progress event for each file being loaded
  45456. * @param pluginExtension the extension used to determine the plugin
  45457. * @returns The given scene
  45458. */
  45459. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45460. /**
  45461. * Load a scene into an asset container
  45462. * @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)
  45463. * @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)
  45464. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45465. * @param onSuccess a callback with the scene when import succeeds
  45466. * @param onProgress a callback with a progress event for each file being loaded
  45467. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45468. * @param pluginExtension the extension used to determine the plugin
  45469. * @returns The loaded plugin
  45470. */
  45471. 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>;
  45472. /**
  45473. * Load a scene into an asset container
  45474. * @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)
  45475. * @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)
  45476. * @param scene is the instance of Scene to append to
  45477. * @param onProgress a callback with a progress event for each file being loaded
  45478. * @param pluginExtension the extension used to determine the plugin
  45479. * @returns The loaded asset container
  45480. */
  45481. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45482. /**
  45483. * Import animations from a file into a scene
  45484. * @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)
  45485. * @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)
  45486. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45487. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45488. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45489. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45490. * @param onSuccess a callback with the scene when import succeeds
  45491. * @param onProgress a callback with a progress event for each file being loaded
  45492. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45493. */
  45494. 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;
  45495. /**
  45496. * Import animations from a file into a scene
  45497. * @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)
  45498. * @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)
  45499. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45500. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45501. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45502. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45503. * @param onSuccess a callback with the scene when import succeeds
  45504. * @param onProgress a callback with a progress event for each file being loaded
  45505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45506. * @returns the updated scene with imported animations
  45507. */
  45508. 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>;
  45509. }
  45510. }
  45511. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45512. import { IDisposable, Scene } from "babylonjs/scene";
  45513. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45514. import { Observable } from "babylonjs/Misc/observable";
  45515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45516. import { Nullable } from "babylonjs/types";
  45517. /**
  45518. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45519. */
  45520. export type MotionControllerHandness = "none" | "left" | "right";
  45521. /**
  45522. * The type of components available in motion controllers.
  45523. * This is not the name of the component.
  45524. */
  45525. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45526. /**
  45527. * The state of a controller component
  45528. */
  45529. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45530. /**
  45531. * The schema of motion controller layout.
  45532. * No object will be initialized using this interface
  45533. * This is used just to define the profile.
  45534. */
  45535. export interface IMotionControllerLayout {
  45536. /**
  45537. * Path to load the assets. Usually relative to the base path
  45538. */
  45539. assetPath: string;
  45540. /**
  45541. * Available components (unsorted)
  45542. */
  45543. components: {
  45544. /**
  45545. * A map of component Ids
  45546. */
  45547. [componentId: string]: {
  45548. /**
  45549. * The type of input the component outputs
  45550. */
  45551. type: MotionControllerComponentType;
  45552. /**
  45553. * The indices of this component in the gamepad object
  45554. */
  45555. gamepadIndices: {
  45556. /**
  45557. * Index of button
  45558. */
  45559. button?: number;
  45560. /**
  45561. * If available, index of x-axis
  45562. */
  45563. xAxis?: number;
  45564. /**
  45565. * If available, index of y-axis
  45566. */
  45567. yAxis?: number;
  45568. };
  45569. /**
  45570. * The mesh's root node name
  45571. */
  45572. rootNodeName: string;
  45573. /**
  45574. * Animation definitions for this model
  45575. */
  45576. visualResponses: {
  45577. [stateKey: string]: {
  45578. /**
  45579. * What property will be animated
  45580. */
  45581. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45582. /**
  45583. * What states influence this visual response
  45584. */
  45585. states: MotionControllerComponentStateType[];
  45586. /**
  45587. * Type of animation - movement or visibility
  45588. */
  45589. valueNodeProperty: "transform" | "visibility";
  45590. /**
  45591. * Base node name to move. Its position will be calculated according to the min and max nodes
  45592. */
  45593. valueNodeName?: string;
  45594. /**
  45595. * Minimum movement node
  45596. */
  45597. minNodeName?: string;
  45598. /**
  45599. * Max movement node
  45600. */
  45601. maxNodeName?: string;
  45602. };
  45603. };
  45604. /**
  45605. * If touch enabled, what is the name of node to display user feedback
  45606. */
  45607. touchPointNodeName?: string;
  45608. };
  45609. };
  45610. /**
  45611. * Is it xr standard mapping or not
  45612. */
  45613. gamepadMapping: "" | "xr-standard";
  45614. /**
  45615. * Base root node of this entire model
  45616. */
  45617. rootNodeName: string;
  45618. /**
  45619. * Defines the main button component id
  45620. */
  45621. selectComponentId: string;
  45622. }
  45623. /**
  45624. * A definition for the layout map in the input profile
  45625. */
  45626. export interface IMotionControllerLayoutMap {
  45627. /**
  45628. * Layouts with handness type as a key
  45629. */
  45630. [handness: string]: IMotionControllerLayout;
  45631. }
  45632. /**
  45633. * The XR Input profile schema
  45634. * Profiles can be found here:
  45635. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45636. */
  45637. export interface IMotionControllerProfile {
  45638. /**
  45639. * fallback profiles for this profileId
  45640. */
  45641. fallbackProfileIds: string[];
  45642. /**
  45643. * The layout map, with handness as key
  45644. */
  45645. layouts: IMotionControllerLayoutMap;
  45646. /**
  45647. * The id of this profile
  45648. * correlates to the profile(s) in the xrInput.profiles array
  45649. */
  45650. profileId: string;
  45651. }
  45652. /**
  45653. * A helper-interface for the 3 meshes needed for controller button animation
  45654. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45655. */
  45656. export interface IMotionControllerButtonMeshMap {
  45657. /**
  45658. * the mesh that defines the pressed value mesh position.
  45659. * This is used to find the max-position of this button
  45660. */
  45661. pressedMesh: AbstractMesh;
  45662. /**
  45663. * the mesh that defines the unpressed value mesh position.
  45664. * This is used to find the min (or initial) position of this button
  45665. */
  45666. unpressedMesh: AbstractMesh;
  45667. /**
  45668. * The mesh that will be changed when value changes
  45669. */
  45670. valueMesh: AbstractMesh;
  45671. }
  45672. /**
  45673. * A helper-interface for the 3 meshes needed for controller axis animation.
  45674. * This will be expanded when touchpad animations are fully supported
  45675. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45676. */
  45677. export interface IMotionControllerMeshMap {
  45678. /**
  45679. * the mesh that defines the maximum value mesh position.
  45680. */
  45681. maxMesh?: AbstractMesh;
  45682. /**
  45683. * the mesh that defines the minimum value mesh position.
  45684. */
  45685. minMesh?: AbstractMesh;
  45686. /**
  45687. * The mesh that will be changed when axis value changes
  45688. */
  45689. valueMesh: AbstractMesh;
  45690. }
  45691. /**
  45692. * The elements needed for change-detection of the gamepad objects in motion controllers
  45693. */
  45694. export interface IMinimalMotionControllerObject {
  45695. /**
  45696. * Available axes of this controller
  45697. */
  45698. axes: number[];
  45699. /**
  45700. * An array of available buttons
  45701. */
  45702. buttons: Array<{
  45703. /**
  45704. * Value of the button/trigger
  45705. */
  45706. value: number;
  45707. /**
  45708. * If the button/trigger is currently touched
  45709. */
  45710. touched: boolean;
  45711. /**
  45712. * If the button/trigger is currently pressed
  45713. */
  45714. pressed: boolean;
  45715. }>;
  45716. }
  45717. /**
  45718. * An Abstract Motion controller
  45719. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45720. * Each component has an observable to check for changes in value and state
  45721. */
  45722. export abstract class WebXRAbstractMotionController implements IDisposable {
  45723. protected scene: Scene;
  45724. protected layout: IMotionControllerLayout;
  45725. /**
  45726. * The gamepad object correlating to this controller
  45727. */
  45728. gamepadObject: IMinimalMotionControllerObject;
  45729. /**
  45730. * handness (left/right/none) of this controller
  45731. */
  45732. handness: MotionControllerHandness;
  45733. private _initComponent;
  45734. private _modelReady;
  45735. /**
  45736. * A map of components (WebXRControllerComponent) in this motion controller
  45737. * Components have a ComponentType and can also have both button and axis definitions
  45738. */
  45739. readonly components: {
  45740. [id: string]: WebXRControllerComponent;
  45741. };
  45742. /**
  45743. * Disable the model's animation. Can be set at any time.
  45744. */
  45745. disableAnimation: boolean;
  45746. /**
  45747. * Observers registered here will be triggered when the model of this controller is done loading
  45748. */
  45749. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45750. /**
  45751. * The profile id of this motion controller
  45752. */
  45753. abstract profileId: string;
  45754. /**
  45755. * The root mesh of the model. It is null if the model was not yet initialized
  45756. */
  45757. rootMesh: Nullable<AbstractMesh>;
  45758. /**
  45759. * constructs a new abstract motion controller
  45760. * @param scene the scene to which the model of the controller will be added
  45761. * @param layout The profile layout to load
  45762. * @param gamepadObject The gamepad object correlating to this controller
  45763. * @param handness handness (left/right/none) of this controller
  45764. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45765. */
  45766. constructor(scene: Scene, layout: IMotionControllerLayout,
  45767. /**
  45768. * The gamepad object correlating to this controller
  45769. */
  45770. gamepadObject: IMinimalMotionControllerObject,
  45771. /**
  45772. * handness (left/right/none) of this controller
  45773. */
  45774. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45775. /**
  45776. * Dispose this controller, the model mesh and all its components
  45777. */
  45778. dispose(): void;
  45779. /**
  45780. * Returns all components of specific type
  45781. * @param type the type to search for
  45782. * @return an array of components with this type
  45783. */
  45784. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45785. /**
  45786. * get a component based an its component id as defined in layout.components
  45787. * @param id the id of the component
  45788. * @returns the component correlates to the id or undefined if not found
  45789. */
  45790. getComponent(id: string): WebXRControllerComponent;
  45791. /**
  45792. * Get the list of components available in this motion controller
  45793. * @returns an array of strings correlating to available components
  45794. */
  45795. getComponentIds(): string[];
  45796. /**
  45797. * Get the first component of specific type
  45798. * @param type type of component to find
  45799. * @return a controller component or null if not found
  45800. */
  45801. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45802. /**
  45803. * Get the main (Select) component of this controller as defined in the layout
  45804. * @returns the main component of this controller
  45805. */
  45806. getMainComponent(): WebXRControllerComponent;
  45807. /**
  45808. * Loads the model correlating to this controller
  45809. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45810. * @returns A promise fulfilled with the result of the model loading
  45811. */
  45812. loadModel(): Promise<boolean>;
  45813. /**
  45814. * Update this model using the current XRFrame
  45815. * @param xrFrame the current xr frame to use and update the model
  45816. */
  45817. updateFromXRFrame(xrFrame: XRFrame): void;
  45818. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45819. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45820. /**
  45821. * Moves the axis on the controller mesh based on its current state
  45822. * @param axis the index of the axis
  45823. * @param axisValue the value of the axis which determines the meshes new position
  45824. * @hidden
  45825. */
  45826. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45827. /**
  45828. * Update the model itself with the current frame data
  45829. * @param xrFrame the frame to use for updating the model mesh
  45830. */
  45831. protected updateModel(xrFrame: XRFrame): void;
  45832. /**
  45833. * Get the filename and path for this controller's model
  45834. * @returns a map of filename and path
  45835. */
  45836. protected abstract _getFilenameAndPath(): {
  45837. filename: string;
  45838. path: string;
  45839. };
  45840. /**
  45841. * This function is called before the mesh is loaded. It checks for loading constraints.
  45842. * For example, this function can check if the GLB loader is available
  45843. * If this function returns false, the generic controller will be loaded instead
  45844. * @returns Is the client ready to load the mesh
  45845. */
  45846. protected abstract _getModelLoadingConstraints(): boolean;
  45847. /**
  45848. * This function will be called after the model was successfully loaded and can be used
  45849. * for mesh transformations before it is available for the user
  45850. * @param meshes the loaded meshes
  45851. */
  45852. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45853. /**
  45854. * Set the root mesh for this controller. Important for the WebXR controller class
  45855. * @param meshes the loaded meshes
  45856. */
  45857. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45858. /**
  45859. * A function executed each frame that updates the mesh (if needed)
  45860. * @param xrFrame the current xrFrame
  45861. */
  45862. protected abstract _updateModel(xrFrame: XRFrame): void;
  45863. private _getGenericFilenameAndPath;
  45864. private _getGenericParentMesh;
  45865. }
  45866. }
  45867. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45868. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45870. import { Scene } from "babylonjs/scene";
  45871. /**
  45872. * A generic trigger-only motion controller for WebXR
  45873. */
  45874. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45875. /**
  45876. * Static version of the profile id of this controller
  45877. */
  45878. static ProfileId: string;
  45879. profileId: string;
  45880. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45881. protected _getFilenameAndPath(): {
  45882. filename: string;
  45883. path: string;
  45884. };
  45885. protected _getModelLoadingConstraints(): boolean;
  45886. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45887. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45888. protected _updateModel(): void;
  45889. }
  45890. }
  45891. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45892. import { Vector4 } from "babylonjs/Maths/math.vector";
  45893. import { Mesh } from "babylonjs/Meshes/mesh";
  45894. import { Scene } from "babylonjs/scene";
  45895. import { Nullable } from "babylonjs/types";
  45896. /**
  45897. * Class containing static functions to help procedurally build meshes
  45898. */
  45899. export class SphereBuilder {
  45900. /**
  45901. * Creates a sphere mesh
  45902. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45903. * * 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`)
  45904. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45905. * * 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
  45906. * * 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)
  45907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45910. * @param name defines the name of the mesh
  45911. * @param options defines the options used to create the mesh
  45912. * @param scene defines the hosting scene
  45913. * @returns the sphere mesh
  45914. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45915. */
  45916. static CreateSphere(name: string, options: {
  45917. segments?: number;
  45918. diameter?: number;
  45919. diameterX?: number;
  45920. diameterY?: number;
  45921. diameterZ?: number;
  45922. arc?: number;
  45923. slice?: number;
  45924. sideOrientation?: number;
  45925. frontUVs?: Vector4;
  45926. backUVs?: Vector4;
  45927. updatable?: boolean;
  45928. }, scene?: Nullable<Scene>): Mesh;
  45929. }
  45930. }
  45931. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45933. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45934. import { Scene } from "babylonjs/scene";
  45935. /**
  45936. * A profiled motion controller has its profile loaded from an online repository.
  45937. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45938. */
  45939. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45940. private _repositoryUrl;
  45941. private _buttonMeshMapping;
  45942. private _touchDots;
  45943. /**
  45944. * The profile ID of this controller. Will be populated when the controller initializes.
  45945. */
  45946. profileId: string;
  45947. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45948. dispose(): void;
  45949. protected _getFilenameAndPath(): {
  45950. filename: string;
  45951. path: string;
  45952. };
  45953. protected _getModelLoadingConstraints(): boolean;
  45954. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45955. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45956. protected _updateModel(_xrFrame: XRFrame): void;
  45957. }
  45958. }
  45959. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45960. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45961. import { Scene } from "babylonjs/scene";
  45962. /**
  45963. * A construction function type to create a new controller based on an xrInput object
  45964. */
  45965. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45966. /**
  45967. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45968. *
  45969. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45970. * it should be replaced with auto-loaded controllers.
  45971. *
  45972. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45973. */
  45974. export class WebXRMotionControllerManager {
  45975. private static _AvailableControllers;
  45976. private static _Fallbacks;
  45977. private static _ProfileLoadingPromises;
  45978. private static _ProfilesList;
  45979. /**
  45980. * The base URL of the online controller repository. Can be changed at any time.
  45981. */
  45982. static BaseRepositoryUrl: string;
  45983. /**
  45984. * Which repository gets priority - local or online
  45985. */
  45986. static PrioritizeOnlineRepository: boolean;
  45987. /**
  45988. * Use the online repository, or use only locally-defined controllers
  45989. */
  45990. static UseOnlineRepository: boolean;
  45991. /**
  45992. * Clear the cache used for profile loading and reload when requested again
  45993. */
  45994. static ClearProfilesCache(): void;
  45995. /**
  45996. * Register the default fallbacks.
  45997. * This function is called automatically when this file is imported.
  45998. */
  45999. static DefaultFallbacks(): void;
  46000. /**
  46001. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46002. * @param profileId the profile to which a fallback needs to be found
  46003. * @return an array with corresponding fallback profiles
  46004. */
  46005. static FindFallbackWithProfileId(profileId: string): string[];
  46006. /**
  46007. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46008. * The order of search:
  46009. *
  46010. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46011. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46012. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46013. * 4) return the generic trigger controller if none were found
  46014. *
  46015. * @param xrInput the xrInput to which a new controller is initialized
  46016. * @param scene the scene to which the model will be added
  46017. * @param forceProfile force a certain profile for this controller
  46018. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46019. */
  46020. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46021. /**
  46022. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46023. *
  46024. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46025. *
  46026. * @param type the profile type to register
  46027. * @param constructFunction the function to be called when loading this profile
  46028. */
  46029. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46030. /**
  46031. * Register a fallback to a specific profile.
  46032. * @param profileId the profileId that will receive the fallbacks
  46033. * @param fallbacks A list of fallback profiles
  46034. */
  46035. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46036. /**
  46037. * Will update the list of profiles available in the repository
  46038. * @return a promise that resolves to a map of profiles available online
  46039. */
  46040. static UpdateProfilesList(): Promise<{
  46041. [profile: string]: string;
  46042. }>;
  46043. private static _LoadProfileFromRepository;
  46044. private static _LoadProfilesFromAvailableControllers;
  46045. }
  46046. }
  46047. declare module "babylonjs/XR/webXRInputSource" {
  46048. import { Observable } from "babylonjs/Misc/observable";
  46049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46050. import { Ray } from "babylonjs/Culling/ray";
  46051. import { Scene } from "babylonjs/scene";
  46052. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46053. /**
  46054. * Configuration options for the WebXR controller creation
  46055. */
  46056. export interface IWebXRControllerOptions {
  46057. /**
  46058. * Should the controller mesh be animated when a user interacts with it
  46059. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46060. */
  46061. disableMotionControllerAnimation?: boolean;
  46062. /**
  46063. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46064. */
  46065. doNotLoadControllerMesh?: boolean;
  46066. /**
  46067. * Force a specific controller type for this controller.
  46068. * This can be used when creating your own profile or when testing different controllers
  46069. */
  46070. forceControllerProfile?: string;
  46071. }
  46072. /**
  46073. * Represents an XR controller
  46074. */
  46075. export class WebXRInputSource {
  46076. private _scene;
  46077. /** The underlying input source for the controller */
  46078. inputSource: XRInputSource;
  46079. private _options;
  46080. private _tmpQuaternion;
  46081. private _tmpVector;
  46082. private _uniqueId;
  46083. /**
  46084. * 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
  46085. */
  46086. grip?: AbstractMesh;
  46087. /**
  46088. * If available, this is the gamepad object related to this controller.
  46089. * Using this object it is possible to get click events and trackpad changes of the
  46090. * webxr controller that is currently being used.
  46091. */
  46092. motionController?: WebXRAbstractMotionController;
  46093. /**
  46094. * Event that fires when the controller is removed/disposed.
  46095. * The object provided as event data is this controller, after associated assets were disposed.
  46096. * uniqueId is still available.
  46097. */
  46098. onDisposeObservable: Observable<WebXRInputSource>;
  46099. /**
  46100. * Will be triggered when the mesh associated with the motion controller is done loading.
  46101. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46102. * A shortened version of controller -> motion controller -> on mesh loaded.
  46103. */
  46104. onMeshLoadedObservable: Observable<AbstractMesh>;
  46105. /**
  46106. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46107. */
  46108. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46109. /**
  46110. * Pointer which can be used to select objects or attach a visible laser to
  46111. */
  46112. pointer: AbstractMesh;
  46113. /**
  46114. * Creates the controller
  46115. * @see https://doc.babylonjs.com/how_to/webxr
  46116. * @param _scene the scene which the controller should be associated to
  46117. * @param inputSource the underlying input source for the controller
  46118. * @param _options options for this controller creation
  46119. */
  46120. constructor(_scene: Scene,
  46121. /** The underlying input source for the controller */
  46122. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46123. /**
  46124. * Get this controllers unique id
  46125. */
  46126. get uniqueId(): string;
  46127. /**
  46128. * Disposes of the object
  46129. */
  46130. dispose(): void;
  46131. /**
  46132. * Gets a world space ray coming from the pointer or grip
  46133. * @param result the resulting ray
  46134. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46135. */
  46136. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46137. /**
  46138. * Updates the controller pose based on the given XRFrame
  46139. * @param xrFrame xr frame to update the pose with
  46140. * @param referenceSpace reference space to use
  46141. */
  46142. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46143. }
  46144. }
  46145. declare module "babylonjs/XR/webXRInput" {
  46146. import { Observable } from "babylonjs/Misc/observable";
  46147. import { IDisposable } from "babylonjs/scene";
  46148. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46149. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46150. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46151. /**
  46152. * The schema for initialization options of the XR Input class
  46153. */
  46154. export interface IWebXRInputOptions {
  46155. /**
  46156. * If set to true no model will be automatically loaded
  46157. */
  46158. doNotLoadControllerMeshes?: boolean;
  46159. /**
  46160. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46161. * If not found, the xr input profile data will be used.
  46162. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46163. */
  46164. forceInputProfile?: string;
  46165. /**
  46166. * Do not send a request to the controller repository to load the profile.
  46167. *
  46168. * Instead, use the controllers available in babylon itself.
  46169. */
  46170. disableOnlineControllerRepository?: boolean;
  46171. /**
  46172. * A custom URL for the controllers repository
  46173. */
  46174. customControllersRepositoryURL?: string;
  46175. /**
  46176. * Should the controller model's components not move according to the user input
  46177. */
  46178. disableControllerAnimation?: boolean;
  46179. }
  46180. /**
  46181. * XR input used to track XR inputs such as controllers/rays
  46182. */
  46183. export class WebXRInput implements IDisposable {
  46184. /**
  46185. * the xr session manager for this session
  46186. */
  46187. xrSessionManager: WebXRSessionManager;
  46188. /**
  46189. * the WebXR camera for this session. Mainly used for teleportation
  46190. */
  46191. xrCamera: WebXRCamera;
  46192. private readonly options;
  46193. /**
  46194. * XR controllers being tracked
  46195. */
  46196. controllers: Array<WebXRInputSource>;
  46197. private _frameObserver;
  46198. private _sessionEndedObserver;
  46199. private _sessionInitObserver;
  46200. /**
  46201. * Event when a controller has been connected/added
  46202. */
  46203. onControllerAddedObservable: Observable<WebXRInputSource>;
  46204. /**
  46205. * Event when a controller has been removed/disconnected
  46206. */
  46207. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46208. /**
  46209. * Initializes the WebXRInput
  46210. * @param xrSessionManager the xr session manager for this session
  46211. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46212. * @param options = initialization options for this xr input
  46213. */
  46214. constructor(
  46215. /**
  46216. * the xr session manager for this session
  46217. */
  46218. xrSessionManager: WebXRSessionManager,
  46219. /**
  46220. * the WebXR camera for this session. Mainly used for teleportation
  46221. */
  46222. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46223. private _onInputSourcesChange;
  46224. private _addAndRemoveControllers;
  46225. /**
  46226. * Disposes of the object
  46227. */
  46228. dispose(): void;
  46229. }
  46230. }
  46231. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46232. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46233. import { Observable, EventState } from "babylonjs/Misc/observable";
  46234. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46235. /**
  46236. * This is the base class for all WebXR features.
  46237. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46238. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46239. */
  46240. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46241. protected _xrSessionManager: WebXRSessionManager;
  46242. private _attached;
  46243. private _removeOnDetach;
  46244. /**
  46245. * Should auto-attach be disabled?
  46246. */
  46247. disableAutoAttach: boolean;
  46248. /**
  46249. * Construct a new (abstract) WebXR feature
  46250. * @param _xrSessionManager the xr session manager for this feature
  46251. */
  46252. constructor(_xrSessionManager: WebXRSessionManager);
  46253. /**
  46254. * Is this feature attached
  46255. */
  46256. get attached(): boolean;
  46257. /**
  46258. * attach this feature
  46259. *
  46260. * @param force should attachment be forced (even when already attached)
  46261. * @returns true if successful, false is failed or already attached
  46262. */
  46263. attach(force?: boolean): boolean;
  46264. /**
  46265. * detach this feature.
  46266. *
  46267. * @returns true if successful, false if failed or already detached
  46268. */
  46269. detach(): boolean;
  46270. /**
  46271. * Dispose this feature and all of the resources attached
  46272. */
  46273. dispose(): void;
  46274. /**
  46275. * This is used to register callbacks that will automatically be removed when detach is called.
  46276. * @param observable the observable to which the observer will be attached
  46277. * @param callback the callback to register
  46278. */
  46279. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46280. /**
  46281. * Code in this function will be executed on each xrFrame received from the browser.
  46282. * This function will not execute after the feature is detached.
  46283. * @param _xrFrame the current frame
  46284. */
  46285. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46286. }
  46287. }
  46288. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46289. import { IDisposable, Scene } from "babylonjs/scene";
  46290. import { Nullable } from "babylonjs/types";
  46291. import { Observable } from "babylonjs/Misc/observable";
  46292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46293. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46294. import { Camera } from "babylonjs/Cameras/camera";
  46295. /**
  46296. * Renders a layer on top of an existing scene
  46297. */
  46298. export class UtilityLayerRenderer implements IDisposable {
  46299. /** the original scene that will be rendered on top of */
  46300. originalScene: Scene;
  46301. private _pointerCaptures;
  46302. private _lastPointerEvents;
  46303. private static _DefaultUtilityLayer;
  46304. private static _DefaultKeepDepthUtilityLayer;
  46305. private _sharedGizmoLight;
  46306. private _renderCamera;
  46307. /**
  46308. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46309. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46310. * @returns the camera that is used when rendering the utility layer
  46311. */
  46312. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46313. /**
  46314. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46315. * @param cam the camera that should be used when rendering the utility layer
  46316. */
  46317. setRenderCamera(cam: Nullable<Camera>): void;
  46318. /**
  46319. * @hidden
  46320. * Light which used by gizmos to get light shading
  46321. */
  46322. _getSharedGizmoLight(): HemisphericLight;
  46323. /**
  46324. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46325. */
  46326. pickUtilitySceneFirst: boolean;
  46327. /**
  46328. * 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)
  46329. */
  46330. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46331. /**
  46332. * 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)
  46333. */
  46334. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46335. /**
  46336. * The scene that is rendered on top of the original scene
  46337. */
  46338. utilityLayerScene: Scene;
  46339. /**
  46340. * If the utility layer should automatically be rendered on top of existing scene
  46341. */
  46342. shouldRender: boolean;
  46343. /**
  46344. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46345. */
  46346. onlyCheckPointerDownEvents: boolean;
  46347. /**
  46348. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46349. */
  46350. processAllEvents: boolean;
  46351. /**
  46352. * Observable raised when the pointer move from the utility layer scene to the main scene
  46353. */
  46354. onPointerOutObservable: Observable<number>;
  46355. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46356. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46357. private _afterRenderObserver;
  46358. private _sceneDisposeObserver;
  46359. private _originalPointerObserver;
  46360. /**
  46361. * Instantiates a UtilityLayerRenderer
  46362. * @param originalScene the original scene that will be rendered on top of
  46363. * @param handleEvents boolean indicating if the utility layer should handle events
  46364. */
  46365. constructor(
  46366. /** the original scene that will be rendered on top of */
  46367. originalScene: Scene, handleEvents?: boolean);
  46368. private _notifyObservers;
  46369. /**
  46370. * Renders the utility layers scene on top of the original scene
  46371. */
  46372. render(): void;
  46373. /**
  46374. * Disposes of the renderer
  46375. */
  46376. dispose(): void;
  46377. private _updateCamera;
  46378. }
  46379. }
  46380. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46381. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46383. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46384. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46385. import { Scene } from "babylonjs/scene";
  46386. import { Nullable } from "babylonjs/types";
  46387. import { Color3 } from "babylonjs/Maths/math.color";
  46388. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46389. /**
  46390. * Options interface for the pointer selection module
  46391. */
  46392. export interface IWebXRControllerPointerSelectionOptions {
  46393. /**
  46394. * if provided, this scene will be used to render meshes.
  46395. */
  46396. customUtilityLayerScene?: Scene;
  46397. /**
  46398. * 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)
  46399. * If not disabled, the last picked point will be used to execute a pointer up event
  46400. * If disabled, pointer up event will be triggered right after the pointer down event.
  46401. * Used in screen and gaze target ray mode only
  46402. */
  46403. disablePointerUpOnTouchOut: boolean;
  46404. /**
  46405. * For gaze mode (time to select instead of press)
  46406. */
  46407. forceGazeMode: boolean;
  46408. /**
  46409. * 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
  46410. * to start a new countdown to the pointer down event.
  46411. * Defaults to 1.
  46412. */
  46413. gazeModePointerMovedFactor?: number;
  46414. /**
  46415. * Different button type to use instead of the main component
  46416. */
  46417. overrideButtonId?: string;
  46418. /**
  46419. * use this rendering group id for the meshes (optional)
  46420. */
  46421. renderingGroupId?: number;
  46422. /**
  46423. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46424. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46425. * 3000 means 3 seconds between pointing at something and selecting it
  46426. */
  46427. timeToSelect?: number;
  46428. /**
  46429. * Should meshes created here be added to a utility layer or the main scene
  46430. */
  46431. useUtilityLayer?: boolean;
  46432. /**
  46433. * the xr input to use with this pointer selection
  46434. */
  46435. xrInput: WebXRInput;
  46436. }
  46437. /**
  46438. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46439. */
  46440. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46441. private readonly _options;
  46442. private static _idCounter;
  46443. private _attachController;
  46444. private _controllers;
  46445. private _scene;
  46446. private _tmpVectorForPickCompare;
  46447. /**
  46448. * The module's name
  46449. */
  46450. static readonly Name: string;
  46451. /**
  46452. * The (Babylon) version of this module.
  46453. * This is an integer representing the implementation version.
  46454. * This number does not correspond to the WebXR specs version
  46455. */
  46456. static readonly Version: number;
  46457. /**
  46458. * Disable lighting on the laser pointer (so it will always be visible)
  46459. */
  46460. disablePointerLighting: boolean;
  46461. /**
  46462. * Disable lighting on the selection mesh (so it will always be visible)
  46463. */
  46464. disableSelectionMeshLighting: boolean;
  46465. /**
  46466. * Should the laser pointer be displayed
  46467. */
  46468. displayLaserPointer: boolean;
  46469. /**
  46470. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46471. */
  46472. displaySelectionMesh: boolean;
  46473. /**
  46474. * This color will be set to the laser pointer when selection is triggered
  46475. */
  46476. laserPointerPickedColor: Color3;
  46477. /**
  46478. * Default color of the laser pointer
  46479. */
  46480. lasterPointerDefaultColor: Color3;
  46481. /**
  46482. * default color of the selection ring
  46483. */
  46484. selectionMeshDefaultColor: Color3;
  46485. /**
  46486. * This color will be applied to the selection ring when selection is triggered
  46487. */
  46488. selectionMeshPickedColor: Color3;
  46489. /**
  46490. * Optional filter to be used for ray selection. This predicate shares behavior with
  46491. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46492. */
  46493. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46494. /**
  46495. * constructs a new background remover module
  46496. * @param _xrSessionManager the session manager for this module
  46497. * @param _options read-only options to be used in this module
  46498. */
  46499. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46500. /**
  46501. * attach this feature
  46502. * Will usually be called by the features manager
  46503. *
  46504. * @returns true if successful.
  46505. */
  46506. attach(): boolean;
  46507. /**
  46508. * detach this feature.
  46509. * Will usually be called by the features manager
  46510. *
  46511. * @returns true if successful.
  46512. */
  46513. detach(): boolean;
  46514. /**
  46515. * Will get the mesh under a specific pointer.
  46516. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46517. * @param controllerId the controllerId to check
  46518. * @returns The mesh under pointer or null if no mesh is under the pointer
  46519. */
  46520. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46521. /**
  46522. * Get the xr controller that correlates to the pointer id in the pointer event
  46523. *
  46524. * @param id the pointer id to search for
  46525. * @returns the controller that correlates to this id or null if not found
  46526. */
  46527. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46528. protected _onXRFrame(_xrFrame: XRFrame): void;
  46529. private _attachGazeMode;
  46530. private _attachScreenRayMode;
  46531. private _attachTrackedPointerRayMode;
  46532. private _convertNormalToDirectionOfRay;
  46533. private _detachController;
  46534. private _generateNewMeshPair;
  46535. private _pickingMoved;
  46536. private _updatePointerDistance;
  46537. }
  46538. }
  46539. declare module "babylonjs/XR/webXREnterExitUI" {
  46540. import { Nullable } from "babylonjs/types";
  46541. import { Observable } from "babylonjs/Misc/observable";
  46542. import { IDisposable, Scene } from "babylonjs/scene";
  46543. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46544. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46545. /**
  46546. * Button which can be used to enter a different mode of XR
  46547. */
  46548. export class WebXREnterExitUIButton {
  46549. /** button element */
  46550. element: HTMLElement;
  46551. /** XR initialization options for the button */
  46552. sessionMode: XRSessionMode;
  46553. /** Reference space type */
  46554. referenceSpaceType: XRReferenceSpaceType;
  46555. /**
  46556. * Creates a WebXREnterExitUIButton
  46557. * @param element button element
  46558. * @param sessionMode XR initialization session mode
  46559. * @param referenceSpaceType the type of reference space to be used
  46560. */
  46561. constructor(
  46562. /** button element */
  46563. element: HTMLElement,
  46564. /** XR initialization options for the button */
  46565. sessionMode: XRSessionMode,
  46566. /** Reference space type */
  46567. referenceSpaceType: XRReferenceSpaceType);
  46568. /**
  46569. * Extendable function which can be used to update the button's visuals when the state changes
  46570. * @param activeButton the current active button in the UI
  46571. */
  46572. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46573. }
  46574. /**
  46575. * Options to create the webXR UI
  46576. */
  46577. export class WebXREnterExitUIOptions {
  46578. /**
  46579. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46580. */
  46581. customButtons?: Array<WebXREnterExitUIButton>;
  46582. /**
  46583. * A reference space type to use when creating the default button.
  46584. * Default is local-floor
  46585. */
  46586. referenceSpaceType?: XRReferenceSpaceType;
  46587. /**
  46588. * Context to enter xr with
  46589. */
  46590. renderTarget?: Nullable<WebXRRenderTarget>;
  46591. /**
  46592. * A session mode to use when creating the default button.
  46593. * Default is immersive-vr
  46594. */
  46595. sessionMode?: XRSessionMode;
  46596. }
  46597. /**
  46598. * UI to allow the user to enter/exit XR mode
  46599. */
  46600. export class WebXREnterExitUI implements IDisposable {
  46601. private scene;
  46602. /** version of the options passed to this UI */
  46603. options: WebXREnterExitUIOptions;
  46604. private _activeButton;
  46605. private _buttons;
  46606. private _overlay;
  46607. /**
  46608. * Fired every time the active button is changed.
  46609. *
  46610. * When xr is entered via a button that launches xr that button will be the callback parameter
  46611. *
  46612. * When exiting xr the callback parameter will be null)
  46613. */
  46614. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46615. /**
  46616. *
  46617. * @param scene babylon scene object to use
  46618. * @param options (read-only) version of the options passed to this UI
  46619. */
  46620. private constructor();
  46621. /**
  46622. * Creates UI to allow the user to enter/exit XR mode
  46623. * @param scene the scene to add the ui to
  46624. * @param helper the xr experience helper to enter/exit xr with
  46625. * @param options options to configure the UI
  46626. * @returns the created ui
  46627. */
  46628. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46629. /**
  46630. * Disposes of the XR UI component
  46631. */
  46632. dispose(): void;
  46633. private _updateButtons;
  46634. }
  46635. }
  46636. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46637. import { Vector3 } from "babylonjs/Maths/math.vector";
  46638. import { Color4 } from "babylonjs/Maths/math.color";
  46639. import { Nullable } from "babylonjs/types";
  46640. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46641. import { Scene } from "babylonjs/scene";
  46642. /**
  46643. * Class containing static functions to help procedurally build meshes
  46644. */
  46645. export class LinesBuilder {
  46646. /**
  46647. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46648. * * 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
  46649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46650. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46651. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46652. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46654. * * 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
  46655. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46658. * @param name defines the name of the new line system
  46659. * @param options defines the options used to create the line system
  46660. * @param scene defines the hosting scene
  46661. * @returns a new line system mesh
  46662. */
  46663. static CreateLineSystem(name: string, options: {
  46664. lines: Vector3[][];
  46665. updatable?: boolean;
  46666. instance?: Nullable<LinesMesh>;
  46667. colors?: Nullable<Color4[][]>;
  46668. useVertexAlpha?: boolean;
  46669. }, scene: Nullable<Scene>): LinesMesh;
  46670. /**
  46671. * Creates a line mesh
  46672. * 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
  46673. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46674. * * The parameter `points` is an array successive Vector3
  46675. * * 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
  46676. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46677. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46678. * * When updating an instance, remember that only point positions can change, not the number of points
  46679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46681. * @param name defines the name of the new line system
  46682. * @param options defines the options used to create the line system
  46683. * @param scene defines the hosting scene
  46684. * @returns a new line mesh
  46685. */
  46686. static CreateLines(name: string, options: {
  46687. points: Vector3[];
  46688. updatable?: boolean;
  46689. instance?: Nullable<LinesMesh>;
  46690. colors?: Color4[];
  46691. useVertexAlpha?: boolean;
  46692. }, scene?: Nullable<Scene>): LinesMesh;
  46693. /**
  46694. * Creates a dashed line mesh
  46695. * * 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
  46696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46697. * * The parameter `points` is an array successive Vector3
  46698. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46699. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46700. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46701. * * 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
  46702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46703. * * When updating an instance, remember that only point positions can change, not the number of points
  46704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46705. * @param name defines the name of the mesh
  46706. * @param options defines the options used to create the mesh
  46707. * @param scene defines the hosting scene
  46708. * @returns the dashed line mesh
  46709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46710. */
  46711. static CreateDashedLines(name: string, options: {
  46712. points: Vector3[];
  46713. dashSize?: number;
  46714. gapSize?: number;
  46715. dashNb?: number;
  46716. updatable?: boolean;
  46717. instance?: LinesMesh;
  46718. useVertexAlpha?: boolean;
  46719. }, scene?: Nullable<Scene>): LinesMesh;
  46720. }
  46721. }
  46722. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46723. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46724. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46725. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46727. import { Vector3 } from "babylonjs/Maths/math.vector";
  46728. import { Material } from "babylonjs/Materials/material";
  46729. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46730. import { Scene } from "babylonjs/scene";
  46731. /**
  46732. * The options container for the teleportation module
  46733. */
  46734. export interface IWebXRTeleportationOptions {
  46735. /**
  46736. * if provided, this scene will be used to render meshes.
  46737. */
  46738. customUtilityLayerScene?: Scene;
  46739. /**
  46740. * Values to configure the default target mesh
  46741. */
  46742. defaultTargetMeshOptions?: {
  46743. /**
  46744. * Fill color of the teleportation area
  46745. */
  46746. teleportationFillColor?: string;
  46747. /**
  46748. * Border color for the teleportation area
  46749. */
  46750. teleportationBorderColor?: string;
  46751. /**
  46752. * Disable the mesh's animation sequence
  46753. */
  46754. disableAnimation?: boolean;
  46755. /**
  46756. * Disable lighting on the material or the ring and arrow
  46757. */
  46758. disableLighting?: boolean;
  46759. /**
  46760. * Override the default material of the torus and arrow
  46761. */
  46762. torusArrowMaterial?: Material;
  46763. };
  46764. /**
  46765. * A list of meshes to use as floor meshes.
  46766. * Meshes can be added and removed after initializing the feature using the
  46767. * addFloorMesh and removeFloorMesh functions
  46768. * If empty, rotation will still work
  46769. */
  46770. floorMeshes?: AbstractMesh[];
  46771. /**
  46772. * use this rendering group id for the meshes (optional)
  46773. */
  46774. renderingGroupId?: number;
  46775. /**
  46776. * Should teleportation move only to snap points
  46777. */
  46778. snapPointsOnly?: boolean;
  46779. /**
  46780. * An array of points to which the teleportation will snap to.
  46781. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46782. */
  46783. snapPositions?: Vector3[];
  46784. /**
  46785. * How close should the teleportation ray be in order to snap to position.
  46786. * Default to 0.8 units (meters)
  46787. */
  46788. snapToPositionRadius?: number;
  46789. /**
  46790. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46791. * If you want to support rotation, make sure your mesh has a direction indicator.
  46792. *
  46793. * When left untouched, the default mesh will be initialized.
  46794. */
  46795. teleportationTargetMesh?: AbstractMesh;
  46796. /**
  46797. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46798. */
  46799. timeToTeleport?: number;
  46800. /**
  46801. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46802. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46803. */
  46804. useMainComponentOnly?: boolean;
  46805. /**
  46806. * Should meshes created here be added to a utility layer or the main scene
  46807. */
  46808. useUtilityLayer?: boolean;
  46809. /**
  46810. * Babylon XR Input class for controller
  46811. */
  46812. xrInput: WebXRInput;
  46813. }
  46814. /**
  46815. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46816. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46817. * the input of the attached controllers.
  46818. */
  46819. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46820. private _options;
  46821. private _controllers;
  46822. private _currentTeleportationControllerId;
  46823. private _floorMeshes;
  46824. private _quadraticBezierCurve;
  46825. private _selectionFeature;
  46826. private _snapToPositions;
  46827. private _snappedToPoint;
  46828. private _teleportationRingMaterial?;
  46829. private _tmpRay;
  46830. private _tmpVector;
  46831. /**
  46832. * The module's name
  46833. */
  46834. static readonly Name: string;
  46835. /**
  46836. * The (Babylon) version of this module.
  46837. * This is an integer representing the implementation version.
  46838. * This number does not correspond to the webxr specs version
  46839. */
  46840. static readonly Version: number;
  46841. /**
  46842. * Is movement backwards enabled
  46843. */
  46844. backwardsMovementEnabled: boolean;
  46845. /**
  46846. * Distance to travel when moving backwards
  46847. */
  46848. backwardsTeleportationDistance: number;
  46849. /**
  46850. * The distance from the user to the inspection point in the direction of the controller
  46851. * A higher number will allow the user to move further
  46852. * defaults to 5 (meters, in xr units)
  46853. */
  46854. parabolicCheckRadius: number;
  46855. /**
  46856. * Should the module support parabolic ray on top of direct ray
  46857. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46858. * Very helpful when moving between floors / different heights
  46859. */
  46860. parabolicRayEnabled: boolean;
  46861. /**
  46862. * How much rotation should be applied when rotating right and left
  46863. */
  46864. rotationAngle: number;
  46865. /**
  46866. * Is rotation enabled when moving forward?
  46867. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46868. */
  46869. rotationEnabled: boolean;
  46870. /**
  46871. * constructs a new anchor system
  46872. * @param _xrSessionManager an instance of WebXRSessionManager
  46873. * @param _options configuration object for this feature
  46874. */
  46875. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46876. /**
  46877. * Get the snapPointsOnly flag
  46878. */
  46879. get snapPointsOnly(): boolean;
  46880. /**
  46881. * Sets the snapPointsOnly flag
  46882. * @param snapToPoints should teleportation be exclusively to snap points
  46883. */
  46884. set snapPointsOnly(snapToPoints: boolean);
  46885. /**
  46886. * Add a new mesh to the floor meshes array
  46887. * @param mesh the mesh to use as floor mesh
  46888. */
  46889. addFloorMesh(mesh: AbstractMesh): void;
  46890. /**
  46891. * Add a new snap-to point to fix teleportation to this position
  46892. * @param newSnapPoint The new Snap-To point
  46893. */
  46894. addSnapPoint(newSnapPoint: Vector3): void;
  46895. attach(): boolean;
  46896. detach(): boolean;
  46897. dispose(): void;
  46898. /**
  46899. * Remove a mesh from the floor meshes array
  46900. * @param mesh the mesh to remove
  46901. */
  46902. removeFloorMesh(mesh: AbstractMesh): void;
  46903. /**
  46904. * Remove a mesh from the floor meshes array using its name
  46905. * @param name the mesh name to remove
  46906. */
  46907. removeFloorMeshByName(name: string): void;
  46908. /**
  46909. * 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
  46910. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46911. * @returns was the point found and removed or not
  46912. */
  46913. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46914. /**
  46915. * This function sets a selection feature that will be disabled when
  46916. * the forward ray is shown and will be reattached when hidden.
  46917. * This is used to remove the selection rays when moving.
  46918. * @param selectionFeature the feature to disable when forward movement is enabled
  46919. */
  46920. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46921. protected _onXRFrame(_xrFrame: XRFrame): void;
  46922. private _attachController;
  46923. private _createDefaultTargetMesh;
  46924. private _detachController;
  46925. private _findClosestSnapPointWithRadius;
  46926. private _setTargetMeshPosition;
  46927. private _setTargetMeshVisibility;
  46928. private _showParabolicPath;
  46929. private _teleportForward;
  46930. }
  46931. }
  46932. declare module "babylonjs/XR/webXRDefaultExperience" {
  46933. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46934. import { Scene } from "babylonjs/scene";
  46935. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46936. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46937. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46938. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46940. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46941. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46942. /**
  46943. * Options for the default xr helper
  46944. */
  46945. export class WebXRDefaultExperienceOptions {
  46946. /**
  46947. * Enable or disable default UI to enter XR
  46948. */
  46949. disableDefaultUI?: boolean;
  46950. /**
  46951. * Should teleportation not initialize. defaults to false.
  46952. */
  46953. disableTeleportation?: boolean;
  46954. /**
  46955. * Floor meshes that will be used for teleport
  46956. */
  46957. floorMeshes?: Array<AbstractMesh>;
  46958. /**
  46959. * If set to true, the first frame will not be used to reset position
  46960. * The first frame is mainly used when copying transformation from the old camera
  46961. * Mainly used in AR
  46962. */
  46963. ignoreNativeCameraTransformation?: boolean;
  46964. /**
  46965. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46966. */
  46967. inputOptions?: IWebXRInputOptions;
  46968. /**
  46969. * optional configuration for the output canvas
  46970. */
  46971. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46972. /**
  46973. * optional UI options. This can be used among other to change session mode and reference space type
  46974. */
  46975. uiOptions?: WebXREnterExitUIOptions;
  46976. /**
  46977. * When loading teleportation and pointer select, use stable versions instead of latest.
  46978. */
  46979. useStablePlugins?: boolean;
  46980. }
  46981. /**
  46982. * Default experience which provides a similar setup to the previous webVRExperience
  46983. */
  46984. export class WebXRDefaultExperience {
  46985. /**
  46986. * Base experience
  46987. */
  46988. baseExperience: WebXRExperienceHelper;
  46989. /**
  46990. * Enables ui for entering/exiting xr
  46991. */
  46992. enterExitUI: WebXREnterExitUI;
  46993. /**
  46994. * Input experience extension
  46995. */
  46996. input: WebXRInput;
  46997. /**
  46998. * Enables laser pointer and selection
  46999. */
  47000. pointerSelection: WebXRControllerPointerSelection;
  47001. /**
  47002. * Default target xr should render to
  47003. */
  47004. renderTarget: WebXRRenderTarget;
  47005. /**
  47006. * Enables teleportation
  47007. */
  47008. teleportation: WebXRMotionControllerTeleportation;
  47009. private constructor();
  47010. /**
  47011. * Creates the default xr experience
  47012. * @param scene scene
  47013. * @param options options for basic configuration
  47014. * @returns resulting WebXRDefaultExperience
  47015. */
  47016. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47017. /**
  47018. * DIsposes of the experience helper
  47019. */
  47020. dispose(): void;
  47021. }
  47022. }
  47023. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47024. import { Observable } from "babylonjs/Misc/observable";
  47025. import { Nullable } from "babylonjs/types";
  47026. import { Camera } from "babylonjs/Cameras/camera";
  47027. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47028. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47029. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47030. import { Scene } from "babylonjs/scene";
  47031. import { Vector3 } from "babylonjs/Maths/math.vector";
  47032. import { Color3 } from "babylonjs/Maths/math.color";
  47033. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47035. import { Mesh } from "babylonjs/Meshes/mesh";
  47036. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47037. import { EasingFunction } from "babylonjs/Animations/easing";
  47038. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47039. import "babylonjs/Meshes/Builders/groundBuilder";
  47040. import "babylonjs/Meshes/Builders/torusBuilder";
  47041. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47042. import "babylonjs/Gamepads/gamepadSceneComponent";
  47043. import "babylonjs/Animations/animatable";
  47044. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47045. /**
  47046. * Options to modify the vr teleportation behavior.
  47047. */
  47048. export interface VRTeleportationOptions {
  47049. /**
  47050. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47051. */
  47052. floorMeshName?: string;
  47053. /**
  47054. * A list of meshes to be used as the teleportation floor. (default: empty)
  47055. */
  47056. floorMeshes?: Mesh[];
  47057. /**
  47058. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47059. */
  47060. teleportationMode?: number;
  47061. /**
  47062. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47063. */
  47064. teleportationTime?: number;
  47065. /**
  47066. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47067. */
  47068. teleportationSpeed?: number;
  47069. /**
  47070. * The easing function used in the animation or null for Linear. (default CircleEase)
  47071. */
  47072. easingFunction?: EasingFunction;
  47073. }
  47074. /**
  47075. * Options to modify the vr experience helper's behavior.
  47076. */
  47077. export interface VRExperienceHelperOptions extends WebVROptions {
  47078. /**
  47079. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47080. */
  47081. createDeviceOrientationCamera?: boolean;
  47082. /**
  47083. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47084. */
  47085. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47086. /**
  47087. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47088. */
  47089. laserToggle?: boolean;
  47090. /**
  47091. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47092. */
  47093. floorMeshes?: Mesh[];
  47094. /**
  47095. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47096. */
  47097. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47098. /**
  47099. * Defines if WebXR should be used instead of WebVR (if available)
  47100. */
  47101. useXR?: boolean;
  47102. }
  47103. /**
  47104. * Event containing information after VR has been entered
  47105. */
  47106. export class OnAfterEnteringVRObservableEvent {
  47107. /**
  47108. * If entering vr was successful
  47109. */
  47110. success: boolean;
  47111. }
  47112. /**
  47113. * Helps to quickly add VR support to an existing scene.
  47114. * See http://doc.babylonjs.com/how_to/webvr_helper
  47115. */
  47116. export class VRExperienceHelper {
  47117. /** Options to modify the vr experience helper's behavior. */
  47118. webVROptions: VRExperienceHelperOptions;
  47119. private _scene;
  47120. private _position;
  47121. private _btnVR;
  47122. private _btnVRDisplayed;
  47123. private _webVRsupported;
  47124. private _webVRready;
  47125. private _webVRrequesting;
  47126. private _webVRpresenting;
  47127. private _hasEnteredVR;
  47128. private _fullscreenVRpresenting;
  47129. private _inputElement;
  47130. private _webVRCamera;
  47131. private _vrDeviceOrientationCamera;
  47132. private _deviceOrientationCamera;
  47133. private _existingCamera;
  47134. private _onKeyDown;
  47135. private _onVrDisplayPresentChange;
  47136. private _onVRDisplayChanged;
  47137. private _onVRRequestPresentStart;
  47138. private _onVRRequestPresentComplete;
  47139. /**
  47140. * 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)
  47141. */
  47142. enableGazeEvenWhenNoPointerLock: boolean;
  47143. /**
  47144. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47145. */
  47146. exitVROnDoubleTap: boolean;
  47147. /**
  47148. * Observable raised right before entering VR.
  47149. */
  47150. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47151. /**
  47152. * Observable raised when entering VR has completed.
  47153. */
  47154. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47155. /**
  47156. * Observable raised when exiting VR.
  47157. */
  47158. onExitingVRObservable: Observable<VRExperienceHelper>;
  47159. /**
  47160. * Observable raised when controller mesh is loaded.
  47161. */
  47162. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47163. /** Return this.onEnteringVRObservable
  47164. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47165. */
  47166. get onEnteringVR(): Observable<VRExperienceHelper>;
  47167. /** Return this.onExitingVRObservable
  47168. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47169. */
  47170. get onExitingVR(): Observable<VRExperienceHelper>;
  47171. /** Return this.onControllerMeshLoadedObservable
  47172. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47173. */
  47174. get onControllerMeshLoaded(): Observable<WebVRController>;
  47175. private _rayLength;
  47176. private _useCustomVRButton;
  47177. private _teleportationRequested;
  47178. private _teleportActive;
  47179. private _floorMeshName;
  47180. private _floorMeshesCollection;
  47181. private _teleportationMode;
  47182. private _teleportationTime;
  47183. private _teleportationSpeed;
  47184. private _teleportationEasing;
  47185. private _rotationAllowed;
  47186. private _teleportBackwardsVector;
  47187. private _teleportationTarget;
  47188. private _isDefaultTeleportationTarget;
  47189. private _postProcessMove;
  47190. private _teleportationFillColor;
  47191. private _teleportationBorderColor;
  47192. private _rotationAngle;
  47193. private _haloCenter;
  47194. private _cameraGazer;
  47195. private _padSensibilityUp;
  47196. private _padSensibilityDown;
  47197. private _leftController;
  47198. private _rightController;
  47199. private _gazeColor;
  47200. private _laserColor;
  47201. private _pickedLaserColor;
  47202. private _pickedGazeColor;
  47203. /**
  47204. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47205. */
  47206. onNewMeshSelected: Observable<AbstractMesh>;
  47207. /**
  47208. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47209. * This observable will provide the mesh and the controller used to select the mesh
  47210. */
  47211. onMeshSelectedWithController: Observable<{
  47212. mesh: AbstractMesh;
  47213. controller: WebVRController;
  47214. }>;
  47215. /**
  47216. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47217. */
  47218. onNewMeshPicked: Observable<PickingInfo>;
  47219. private _circleEase;
  47220. /**
  47221. * Observable raised before camera teleportation
  47222. */
  47223. onBeforeCameraTeleport: Observable<Vector3>;
  47224. /**
  47225. * Observable raised after camera teleportation
  47226. */
  47227. onAfterCameraTeleport: Observable<Vector3>;
  47228. /**
  47229. * Observable raised when current selected mesh gets unselected
  47230. */
  47231. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47232. private _raySelectionPredicate;
  47233. /**
  47234. * To be optionaly changed by user to define custom ray selection
  47235. */
  47236. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47237. /**
  47238. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47239. */
  47240. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47241. /**
  47242. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47243. */
  47244. teleportationEnabled: boolean;
  47245. private _defaultHeight;
  47246. private _teleportationInitialized;
  47247. private _interactionsEnabled;
  47248. private _interactionsRequested;
  47249. private _displayGaze;
  47250. private _displayLaserPointer;
  47251. /**
  47252. * The mesh used to display where the user is going to teleport.
  47253. */
  47254. get teleportationTarget(): Mesh;
  47255. /**
  47256. * Sets the mesh to be used to display where the user is going to teleport.
  47257. */
  47258. set teleportationTarget(value: Mesh);
  47259. /**
  47260. * 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
  47261. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47262. * See http://doc.babylonjs.com/resources/baking_transformations
  47263. */
  47264. get gazeTrackerMesh(): Mesh;
  47265. set gazeTrackerMesh(value: Mesh);
  47266. /**
  47267. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47268. */
  47269. updateGazeTrackerScale: boolean;
  47270. /**
  47271. * If the gaze trackers color should be updated when selecting meshes
  47272. */
  47273. updateGazeTrackerColor: boolean;
  47274. /**
  47275. * If the controller laser color should be updated when selecting meshes
  47276. */
  47277. updateControllerLaserColor: boolean;
  47278. /**
  47279. * The gaze tracking mesh corresponding to the left controller
  47280. */
  47281. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47282. /**
  47283. * The gaze tracking mesh corresponding to the right controller
  47284. */
  47285. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47286. /**
  47287. * If the ray of the gaze should be displayed.
  47288. */
  47289. get displayGaze(): boolean;
  47290. /**
  47291. * Sets if the ray of the gaze should be displayed.
  47292. */
  47293. set displayGaze(value: boolean);
  47294. /**
  47295. * If the ray of the LaserPointer should be displayed.
  47296. */
  47297. get displayLaserPointer(): boolean;
  47298. /**
  47299. * Sets if the ray of the LaserPointer should be displayed.
  47300. */
  47301. set displayLaserPointer(value: boolean);
  47302. /**
  47303. * The deviceOrientationCamera used as the camera when not in VR.
  47304. */
  47305. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47306. /**
  47307. * Based on the current WebVR support, returns the current VR camera used.
  47308. */
  47309. get currentVRCamera(): Nullable<Camera>;
  47310. /**
  47311. * The webVRCamera which is used when in VR.
  47312. */
  47313. get webVRCamera(): WebVRFreeCamera;
  47314. /**
  47315. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47316. */
  47317. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47318. /**
  47319. * The html button that is used to trigger entering into VR.
  47320. */
  47321. get vrButton(): Nullable<HTMLButtonElement>;
  47322. private get _teleportationRequestInitiated();
  47323. /**
  47324. * Defines whether or not Pointer lock should be requested when switching to
  47325. * full screen.
  47326. */
  47327. requestPointerLockOnFullScreen: boolean;
  47328. /**
  47329. * If asking to force XR, this will be populated with the default xr experience
  47330. */
  47331. xr: WebXRDefaultExperience;
  47332. /**
  47333. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47334. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47335. */
  47336. xrTestDone: boolean;
  47337. /**
  47338. * Instantiates a VRExperienceHelper.
  47339. * Helps to quickly add VR support to an existing scene.
  47340. * @param scene The scene the VRExperienceHelper belongs to.
  47341. * @param webVROptions Options to modify the vr experience helper's behavior.
  47342. */
  47343. constructor(scene: Scene,
  47344. /** Options to modify the vr experience helper's behavior. */
  47345. webVROptions?: VRExperienceHelperOptions);
  47346. private completeVRInit;
  47347. private _onDefaultMeshLoaded;
  47348. private _onResize;
  47349. private _onFullscreenChange;
  47350. /**
  47351. * Gets a value indicating if we are currently in VR mode.
  47352. */
  47353. get isInVRMode(): boolean;
  47354. private onVrDisplayPresentChange;
  47355. private onVRDisplayChanged;
  47356. private moveButtonToBottomRight;
  47357. private displayVRButton;
  47358. private updateButtonVisibility;
  47359. private _cachedAngularSensibility;
  47360. /**
  47361. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47362. * Otherwise, will use the fullscreen API.
  47363. */
  47364. enterVR(): void;
  47365. /**
  47366. * Attempt to exit VR, or fullscreen.
  47367. */
  47368. exitVR(): void;
  47369. /**
  47370. * The position of the vr experience helper.
  47371. */
  47372. get position(): Vector3;
  47373. /**
  47374. * Sets the position of the vr experience helper.
  47375. */
  47376. set position(value: Vector3);
  47377. /**
  47378. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47379. */
  47380. enableInteractions(): void;
  47381. private get _noControllerIsActive();
  47382. private beforeRender;
  47383. private _isTeleportationFloor;
  47384. /**
  47385. * Adds a floor mesh to be used for teleportation.
  47386. * @param floorMesh the mesh to be used for teleportation.
  47387. */
  47388. addFloorMesh(floorMesh: Mesh): void;
  47389. /**
  47390. * Removes a floor mesh from being used for teleportation.
  47391. * @param floorMesh the mesh to be removed.
  47392. */
  47393. removeFloorMesh(floorMesh: Mesh): void;
  47394. /**
  47395. * Enables interactions and teleportation using the VR controllers and gaze.
  47396. * @param vrTeleportationOptions options to modify teleportation behavior.
  47397. */
  47398. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47399. private _onNewGamepadConnected;
  47400. private _tryEnableInteractionOnController;
  47401. private _onNewGamepadDisconnected;
  47402. private _enableInteractionOnController;
  47403. private _checkTeleportWithRay;
  47404. private _checkRotate;
  47405. private _checkTeleportBackwards;
  47406. private _enableTeleportationOnController;
  47407. private _createTeleportationCircles;
  47408. private _displayTeleportationTarget;
  47409. private _hideTeleportationTarget;
  47410. private _rotateCamera;
  47411. private _moveTeleportationSelectorTo;
  47412. private _workingVector;
  47413. private _workingQuaternion;
  47414. private _workingMatrix;
  47415. /**
  47416. * Time Constant Teleportation Mode
  47417. */
  47418. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47419. /**
  47420. * Speed Constant Teleportation Mode
  47421. */
  47422. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47423. /**
  47424. * Teleports the users feet to the desired location
  47425. * @param location The location where the user's feet should be placed
  47426. */
  47427. teleportCamera(location: Vector3): void;
  47428. private _convertNormalToDirectionOfRay;
  47429. private _castRayAndSelectObject;
  47430. private _notifySelectedMeshUnselected;
  47431. /**
  47432. * Permanently set new colors for the laser pointer
  47433. * @param color the new laser color
  47434. * @param pickedColor the new laser color when picked mesh detected
  47435. */
  47436. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47437. /**
  47438. * Set lighting enabled / disabled on the laser pointer of both controllers
  47439. * @param enabled should the lighting be enabled on the laser pointer
  47440. */
  47441. setLaserLightingState(enabled?: boolean): void;
  47442. /**
  47443. * Permanently set new colors for the gaze pointer
  47444. * @param color the new gaze color
  47445. * @param pickedColor the new gaze color when picked mesh detected
  47446. */
  47447. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47448. /**
  47449. * Sets the color of the laser ray from the vr controllers.
  47450. * @param color new color for the ray.
  47451. */
  47452. changeLaserColor(color: Color3): void;
  47453. /**
  47454. * Sets the color of the ray from the vr headsets gaze.
  47455. * @param color new color for the ray.
  47456. */
  47457. changeGazeColor(color: Color3): void;
  47458. /**
  47459. * Exits VR and disposes of the vr experience helper
  47460. */
  47461. dispose(): void;
  47462. /**
  47463. * Gets the name of the VRExperienceHelper class
  47464. * @returns "VRExperienceHelper"
  47465. */
  47466. getClassName(): string;
  47467. }
  47468. }
  47469. declare module "babylonjs/Cameras/VR/index" {
  47470. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47471. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47472. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47473. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47474. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47475. export * from "babylonjs/Cameras/VR/webVRCamera";
  47476. }
  47477. declare module "babylonjs/Cameras/RigModes/index" {
  47478. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47479. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47480. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47481. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47482. }
  47483. declare module "babylonjs/Cameras/index" {
  47484. export * from "babylonjs/Cameras/Inputs/index";
  47485. export * from "babylonjs/Cameras/cameraInputsManager";
  47486. export * from "babylonjs/Cameras/camera";
  47487. export * from "babylonjs/Cameras/targetCamera";
  47488. export * from "babylonjs/Cameras/freeCamera";
  47489. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47490. export * from "babylonjs/Cameras/touchCamera";
  47491. export * from "babylonjs/Cameras/arcRotateCamera";
  47492. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47493. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47494. export * from "babylonjs/Cameras/flyCamera";
  47495. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47496. export * from "babylonjs/Cameras/followCamera";
  47497. export * from "babylonjs/Cameras/followCameraInputsManager";
  47498. export * from "babylonjs/Cameras/gamepadCamera";
  47499. export * from "babylonjs/Cameras/Stereoscopic/index";
  47500. export * from "babylonjs/Cameras/universalCamera";
  47501. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47502. export * from "babylonjs/Cameras/VR/index";
  47503. export * from "babylonjs/Cameras/RigModes/index";
  47504. }
  47505. declare module "babylonjs/Collisions/index" {
  47506. export * from "babylonjs/Collisions/collider";
  47507. export * from "babylonjs/Collisions/collisionCoordinator";
  47508. export * from "babylonjs/Collisions/pickingInfo";
  47509. export * from "babylonjs/Collisions/intersectionInfo";
  47510. export * from "babylonjs/Collisions/meshCollisionData";
  47511. }
  47512. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47513. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47514. import { Vector3 } from "babylonjs/Maths/math.vector";
  47515. import { Ray } from "babylonjs/Culling/ray";
  47516. import { Plane } from "babylonjs/Maths/math.plane";
  47517. /**
  47518. * Contains an array of blocks representing the octree
  47519. */
  47520. export interface IOctreeContainer<T> {
  47521. /**
  47522. * Blocks within the octree
  47523. */
  47524. blocks: Array<OctreeBlock<T>>;
  47525. }
  47526. /**
  47527. * Class used to store a cell in an octree
  47528. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47529. */
  47530. export class OctreeBlock<T> {
  47531. /**
  47532. * Gets the content of the current block
  47533. */
  47534. entries: T[];
  47535. /**
  47536. * Gets the list of block children
  47537. */
  47538. blocks: Array<OctreeBlock<T>>;
  47539. private _depth;
  47540. private _maxDepth;
  47541. private _capacity;
  47542. private _minPoint;
  47543. private _maxPoint;
  47544. private _boundingVectors;
  47545. private _creationFunc;
  47546. /**
  47547. * Creates a new block
  47548. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47549. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47550. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47551. * @param depth defines the current depth of this block in the octree
  47552. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47553. * @param creationFunc defines a callback to call when an element is added to the block
  47554. */
  47555. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47556. /**
  47557. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47558. */
  47559. get capacity(): number;
  47560. /**
  47561. * Gets the minimum vector (in world space) of the block's bounding box
  47562. */
  47563. get minPoint(): Vector3;
  47564. /**
  47565. * Gets the maximum vector (in world space) of the block's bounding box
  47566. */
  47567. get maxPoint(): Vector3;
  47568. /**
  47569. * Add a new element to this block
  47570. * @param entry defines the element to add
  47571. */
  47572. addEntry(entry: T): void;
  47573. /**
  47574. * Remove an element from this block
  47575. * @param entry defines the element to remove
  47576. */
  47577. removeEntry(entry: T): void;
  47578. /**
  47579. * Add an array of elements to this block
  47580. * @param entries defines the array of elements to add
  47581. */
  47582. addEntries(entries: T[]): void;
  47583. /**
  47584. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47585. * @param frustumPlanes defines the frustum planes to test
  47586. * @param selection defines the array to store current content if selection is positive
  47587. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47588. */
  47589. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47590. /**
  47591. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47592. * @param sphereCenter defines the bounding sphere center
  47593. * @param sphereRadius defines the bounding sphere radius
  47594. * @param selection defines the array to store current content if selection is positive
  47595. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47596. */
  47597. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47598. /**
  47599. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47600. * @param ray defines the ray to test with
  47601. * @param selection defines the array to store current content if selection is positive
  47602. */
  47603. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47604. /**
  47605. * Subdivide the content into child blocks (this block will then be empty)
  47606. */
  47607. createInnerBlocks(): void;
  47608. /**
  47609. * @hidden
  47610. */
  47611. 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;
  47612. }
  47613. }
  47614. declare module "babylonjs/Culling/Octrees/octree" {
  47615. import { SmartArray } from "babylonjs/Misc/smartArray";
  47616. import { Vector3 } from "babylonjs/Maths/math.vector";
  47617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47619. import { Ray } from "babylonjs/Culling/ray";
  47620. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47621. import { Plane } from "babylonjs/Maths/math.plane";
  47622. /**
  47623. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47624. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47625. */
  47626. export class Octree<T> {
  47627. /** 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.) */
  47628. maxDepth: number;
  47629. /**
  47630. * Blocks within the octree containing objects
  47631. */
  47632. blocks: Array<OctreeBlock<T>>;
  47633. /**
  47634. * Content stored in the octree
  47635. */
  47636. dynamicContent: T[];
  47637. private _maxBlockCapacity;
  47638. private _selectionContent;
  47639. private _creationFunc;
  47640. /**
  47641. * Creates a octree
  47642. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47643. * @param creationFunc function to be used to instatiate the octree
  47644. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47645. * @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.)
  47646. */
  47647. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47648. /** 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.) */
  47649. maxDepth?: number);
  47650. /**
  47651. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47652. * @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);
  47653. * @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);
  47654. * @param entries meshes to be added to the octree blocks
  47655. */
  47656. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47657. /**
  47658. * Adds a mesh to the octree
  47659. * @param entry Mesh to add to the octree
  47660. */
  47661. addMesh(entry: T): void;
  47662. /**
  47663. * Remove an element from the octree
  47664. * @param entry defines the element to remove
  47665. */
  47666. removeMesh(entry: T): void;
  47667. /**
  47668. * Selects an array of meshes within the frustum
  47669. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47670. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47671. * @returns array of meshes within the frustum
  47672. */
  47673. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47674. /**
  47675. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47676. * @param sphereCenter defines the bounding sphere center
  47677. * @param sphereRadius defines the bounding sphere radius
  47678. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47679. * @returns an array of objects that intersect the sphere
  47680. */
  47681. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47682. /**
  47683. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47684. * @param ray defines the ray to test with
  47685. * @returns array of intersected objects
  47686. */
  47687. intersectsRay(ray: Ray): SmartArray<T>;
  47688. /**
  47689. * Adds a mesh into the octree block if it intersects the block
  47690. */
  47691. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47692. /**
  47693. * Adds a submesh into the octree block if it intersects the block
  47694. */
  47695. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47696. }
  47697. }
  47698. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47699. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47700. import { Scene } from "babylonjs/scene";
  47701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47703. import { Ray } from "babylonjs/Culling/ray";
  47704. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47705. import { Collider } from "babylonjs/Collisions/collider";
  47706. module "babylonjs/scene" {
  47707. interface Scene {
  47708. /**
  47709. * @hidden
  47710. * Backing Filed
  47711. */
  47712. _selectionOctree: Octree<AbstractMesh>;
  47713. /**
  47714. * Gets the octree used to boost mesh selection (picking)
  47715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47716. */
  47717. selectionOctree: Octree<AbstractMesh>;
  47718. /**
  47719. * Creates or updates the octree used to boost selection (picking)
  47720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47721. * @param maxCapacity defines the maximum capacity per leaf
  47722. * @param maxDepth defines the maximum depth of the octree
  47723. * @returns an octree of AbstractMesh
  47724. */
  47725. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47726. }
  47727. }
  47728. module "babylonjs/Meshes/abstractMesh" {
  47729. interface AbstractMesh {
  47730. /**
  47731. * @hidden
  47732. * Backing Field
  47733. */
  47734. _submeshesOctree: Octree<SubMesh>;
  47735. /**
  47736. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47737. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47738. * @param maxCapacity defines the maximum size of each block (64 by default)
  47739. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47740. * @returns the new octree
  47741. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47743. */
  47744. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47745. }
  47746. }
  47747. /**
  47748. * Defines the octree scene component responsible to manage any octrees
  47749. * in a given scene.
  47750. */
  47751. export class OctreeSceneComponent {
  47752. /**
  47753. * The component name help to identify the component in the list of scene components.
  47754. */
  47755. readonly name: string;
  47756. /**
  47757. * The scene the component belongs to.
  47758. */
  47759. scene: Scene;
  47760. /**
  47761. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47762. */
  47763. readonly checksIsEnabled: boolean;
  47764. /**
  47765. * Creates a new instance of the component for the given scene
  47766. * @param scene Defines the scene to register the component in
  47767. */
  47768. constructor(scene: Scene);
  47769. /**
  47770. * Registers the component in a given scene
  47771. */
  47772. register(): void;
  47773. /**
  47774. * Return the list of active meshes
  47775. * @returns the list of active meshes
  47776. */
  47777. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47778. /**
  47779. * Return the list of active sub meshes
  47780. * @param mesh The mesh to get the candidates sub meshes from
  47781. * @returns the list of active sub meshes
  47782. */
  47783. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47784. private _tempRay;
  47785. /**
  47786. * Return the list of sub meshes intersecting with a given local ray
  47787. * @param mesh defines the mesh to find the submesh for
  47788. * @param localRay defines the ray in local space
  47789. * @returns the list of intersecting sub meshes
  47790. */
  47791. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47792. /**
  47793. * Return the list of sub meshes colliding with a collider
  47794. * @param mesh defines the mesh to find the submesh for
  47795. * @param collider defines the collider to evaluate the collision against
  47796. * @returns the list of colliding sub meshes
  47797. */
  47798. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47799. /**
  47800. * Rebuilds the elements related to this component in case of
  47801. * context lost for instance.
  47802. */
  47803. rebuild(): void;
  47804. /**
  47805. * Disposes the component and the associated ressources.
  47806. */
  47807. dispose(): void;
  47808. }
  47809. }
  47810. declare module "babylonjs/Culling/Octrees/index" {
  47811. export * from "babylonjs/Culling/Octrees/octree";
  47812. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47813. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47814. }
  47815. declare module "babylonjs/Culling/index" {
  47816. export * from "babylonjs/Culling/boundingBox";
  47817. export * from "babylonjs/Culling/boundingInfo";
  47818. export * from "babylonjs/Culling/boundingSphere";
  47819. export * from "babylonjs/Culling/Octrees/index";
  47820. export * from "babylonjs/Culling/ray";
  47821. }
  47822. declare module "babylonjs/Gizmos/gizmo" {
  47823. import { Nullable } from "babylonjs/types";
  47824. import { IDisposable } from "babylonjs/scene";
  47825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47826. import { Mesh } from "babylonjs/Meshes/mesh";
  47827. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47828. /**
  47829. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47830. */
  47831. export class Gizmo implements IDisposable {
  47832. /** The utility layer the gizmo will be added to */
  47833. gizmoLayer: UtilityLayerRenderer;
  47834. /**
  47835. * The root mesh of the gizmo
  47836. */
  47837. _rootMesh: Mesh;
  47838. private _attachedMesh;
  47839. /**
  47840. * Ratio for the scale of the gizmo (Default: 1)
  47841. */
  47842. scaleRatio: number;
  47843. /**
  47844. * If a custom mesh has been set (Default: false)
  47845. */
  47846. protected _customMeshSet: boolean;
  47847. /**
  47848. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47849. * * When set, interactions will be enabled
  47850. */
  47851. get attachedMesh(): Nullable<AbstractMesh>;
  47852. set attachedMesh(value: Nullable<AbstractMesh>);
  47853. /**
  47854. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47855. * @param mesh The mesh to replace the default mesh of the gizmo
  47856. */
  47857. setCustomMesh(mesh: Mesh): void;
  47858. /**
  47859. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47860. */
  47861. updateGizmoRotationToMatchAttachedMesh: boolean;
  47862. /**
  47863. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47864. */
  47865. updateGizmoPositionToMatchAttachedMesh: boolean;
  47866. /**
  47867. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47868. */
  47869. updateScale: boolean;
  47870. protected _interactionsEnabled: boolean;
  47871. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47872. private _beforeRenderObserver;
  47873. private _tempVector;
  47874. /**
  47875. * Creates a gizmo
  47876. * @param gizmoLayer The utility layer the gizmo will be added to
  47877. */
  47878. constructor(
  47879. /** The utility layer the gizmo will be added to */
  47880. gizmoLayer?: UtilityLayerRenderer);
  47881. /**
  47882. * Updates the gizmo to match the attached mesh's position/rotation
  47883. */
  47884. protected _update(): void;
  47885. /**
  47886. * Disposes of the gizmo
  47887. */
  47888. dispose(): void;
  47889. }
  47890. }
  47891. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47892. import { Observable } from "babylonjs/Misc/observable";
  47893. import { Nullable } from "babylonjs/types";
  47894. import { Vector3 } from "babylonjs/Maths/math.vector";
  47895. import { Color3 } from "babylonjs/Maths/math.color";
  47896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47898. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47901. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47902. import { Scene } from "babylonjs/scene";
  47903. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47904. /**
  47905. * Single plane drag gizmo
  47906. */
  47907. export class PlaneDragGizmo extends Gizmo {
  47908. /**
  47909. * Drag behavior responsible for the gizmos dragging interactions
  47910. */
  47911. dragBehavior: PointerDragBehavior;
  47912. private _pointerObserver;
  47913. /**
  47914. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47915. */
  47916. snapDistance: number;
  47917. /**
  47918. * Event that fires each time the gizmo snaps to a new location.
  47919. * * snapDistance is the the change in distance
  47920. */
  47921. onSnapObservable: Observable<{
  47922. snapDistance: number;
  47923. }>;
  47924. private _plane;
  47925. private _coloredMaterial;
  47926. private _hoverMaterial;
  47927. private _isEnabled;
  47928. private _parent;
  47929. /** @hidden */
  47930. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47931. /** @hidden */
  47932. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47933. /**
  47934. * Creates a PlaneDragGizmo
  47935. * @param gizmoLayer The utility layer the gizmo will be added to
  47936. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47937. * @param color The color of the gizmo
  47938. */
  47939. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47941. /**
  47942. * If the gizmo is enabled
  47943. */
  47944. set isEnabled(value: boolean);
  47945. get isEnabled(): boolean;
  47946. /**
  47947. * Disposes of the gizmo
  47948. */
  47949. dispose(): void;
  47950. }
  47951. }
  47952. declare module "babylonjs/Gizmos/positionGizmo" {
  47953. import { Observable } from "babylonjs/Misc/observable";
  47954. import { Nullable } from "babylonjs/types";
  47955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47956. import { Mesh } from "babylonjs/Meshes/mesh";
  47957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47958. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47959. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47961. /**
  47962. * Gizmo that enables dragging a mesh along 3 axis
  47963. */
  47964. export class PositionGizmo extends Gizmo {
  47965. /**
  47966. * Internal gizmo used for interactions on the x axis
  47967. */
  47968. xGizmo: AxisDragGizmo;
  47969. /**
  47970. * Internal gizmo used for interactions on the y axis
  47971. */
  47972. yGizmo: AxisDragGizmo;
  47973. /**
  47974. * Internal gizmo used for interactions on the z axis
  47975. */
  47976. zGizmo: AxisDragGizmo;
  47977. /**
  47978. * Internal gizmo used for interactions on the yz plane
  47979. */
  47980. xPlaneGizmo: PlaneDragGizmo;
  47981. /**
  47982. * Internal gizmo used for interactions on the xz plane
  47983. */
  47984. yPlaneGizmo: PlaneDragGizmo;
  47985. /**
  47986. * Internal gizmo used for interactions on the xy plane
  47987. */
  47988. zPlaneGizmo: PlaneDragGizmo;
  47989. /**
  47990. * private variables
  47991. */
  47992. private _meshAttached;
  47993. private _updateGizmoRotationToMatchAttachedMesh;
  47994. private _snapDistance;
  47995. private _scaleRatio;
  47996. /** Fires an event when any of it's sub gizmos are dragged */
  47997. onDragStartObservable: Observable<unknown>;
  47998. /** Fires an event when any of it's sub gizmos are released from dragging */
  47999. onDragEndObservable: Observable<unknown>;
  48000. /**
  48001. * If set to true, planar drag is enabled
  48002. */
  48003. private _planarGizmoEnabled;
  48004. get attachedMesh(): Nullable<AbstractMesh>;
  48005. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48006. /**
  48007. * Creates a PositionGizmo
  48008. * @param gizmoLayer The utility layer the gizmo will be added to
  48009. */
  48010. constructor(gizmoLayer?: UtilityLayerRenderer);
  48011. /**
  48012. * If the planar drag gizmo is enabled
  48013. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48014. */
  48015. set planarGizmoEnabled(value: boolean);
  48016. get planarGizmoEnabled(): boolean;
  48017. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48018. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48019. /**
  48020. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48021. */
  48022. set snapDistance(value: number);
  48023. get snapDistance(): number;
  48024. /**
  48025. * Ratio for the scale of the gizmo (Default: 1)
  48026. */
  48027. set scaleRatio(value: number);
  48028. get scaleRatio(): number;
  48029. /**
  48030. * Disposes of the gizmo
  48031. */
  48032. dispose(): void;
  48033. /**
  48034. * CustomMeshes are not supported by this gizmo
  48035. * @param mesh The mesh to replace the default mesh of the gizmo
  48036. */
  48037. setCustomMesh(mesh: Mesh): void;
  48038. }
  48039. }
  48040. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48041. import { Observable } from "babylonjs/Misc/observable";
  48042. import { Nullable } from "babylonjs/types";
  48043. import { Vector3 } from "babylonjs/Maths/math.vector";
  48044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48046. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48047. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48048. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48049. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48050. import { Scene } from "babylonjs/scene";
  48051. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48052. import { Color3 } from "babylonjs/Maths/math.color";
  48053. /**
  48054. * Single axis drag gizmo
  48055. */
  48056. export class AxisDragGizmo extends Gizmo {
  48057. /**
  48058. * Drag behavior responsible for the gizmos dragging interactions
  48059. */
  48060. dragBehavior: PointerDragBehavior;
  48061. private _pointerObserver;
  48062. /**
  48063. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48064. */
  48065. snapDistance: number;
  48066. /**
  48067. * Event that fires each time the gizmo snaps to a new location.
  48068. * * snapDistance is the the change in distance
  48069. */
  48070. onSnapObservable: Observable<{
  48071. snapDistance: number;
  48072. }>;
  48073. private _isEnabled;
  48074. private _parent;
  48075. private _arrow;
  48076. private _coloredMaterial;
  48077. private _hoverMaterial;
  48078. /** @hidden */
  48079. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48080. /** @hidden */
  48081. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48082. /**
  48083. * Creates an AxisDragGizmo
  48084. * @param gizmoLayer The utility layer the gizmo will be added to
  48085. * @param dragAxis The axis which the gizmo will be able to drag on
  48086. * @param color The color of the gizmo
  48087. */
  48088. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48090. /**
  48091. * If the gizmo is enabled
  48092. */
  48093. set isEnabled(value: boolean);
  48094. get isEnabled(): boolean;
  48095. /**
  48096. * Disposes of the gizmo
  48097. */
  48098. dispose(): void;
  48099. }
  48100. }
  48101. declare module "babylonjs/Debug/axesViewer" {
  48102. import { Vector3 } from "babylonjs/Maths/math.vector";
  48103. import { Nullable } from "babylonjs/types";
  48104. import { Scene } from "babylonjs/scene";
  48105. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48106. /**
  48107. * The Axes viewer will show 3 axes in a specific point in space
  48108. */
  48109. export class AxesViewer {
  48110. private _xAxis;
  48111. private _yAxis;
  48112. private _zAxis;
  48113. private _scaleLinesFactor;
  48114. private _instanced;
  48115. /**
  48116. * Gets the hosting scene
  48117. */
  48118. scene: Scene;
  48119. /**
  48120. * Gets or sets a number used to scale line length
  48121. */
  48122. scaleLines: number;
  48123. /** Gets the node hierarchy used to render x-axis */
  48124. get xAxis(): TransformNode;
  48125. /** Gets the node hierarchy used to render y-axis */
  48126. get yAxis(): TransformNode;
  48127. /** Gets the node hierarchy used to render z-axis */
  48128. get zAxis(): TransformNode;
  48129. /**
  48130. * Creates a new AxesViewer
  48131. * @param scene defines the hosting scene
  48132. * @param scaleLines defines a number used to scale line length (1 by default)
  48133. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48134. * @param xAxis defines the node hierarchy used to render the x-axis
  48135. * @param yAxis defines the node hierarchy used to render the y-axis
  48136. * @param zAxis defines the node hierarchy used to render the z-axis
  48137. */
  48138. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48139. /**
  48140. * Force the viewer to update
  48141. * @param position defines the position of the viewer
  48142. * @param xaxis defines the x axis of the viewer
  48143. * @param yaxis defines the y axis of the viewer
  48144. * @param zaxis defines the z axis of the viewer
  48145. */
  48146. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48147. /**
  48148. * Creates an instance of this axes viewer.
  48149. * @returns a new axes viewer with instanced meshes
  48150. */
  48151. createInstance(): AxesViewer;
  48152. /** Releases resources */
  48153. dispose(): void;
  48154. private static _SetRenderingGroupId;
  48155. }
  48156. }
  48157. declare module "babylonjs/Debug/boneAxesViewer" {
  48158. import { Nullable } from "babylonjs/types";
  48159. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48160. import { Vector3 } from "babylonjs/Maths/math.vector";
  48161. import { Mesh } from "babylonjs/Meshes/mesh";
  48162. import { Bone } from "babylonjs/Bones/bone";
  48163. import { Scene } from "babylonjs/scene";
  48164. /**
  48165. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48166. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48167. */
  48168. export class BoneAxesViewer extends AxesViewer {
  48169. /**
  48170. * Gets or sets the target mesh where to display the axes viewer
  48171. */
  48172. mesh: Nullable<Mesh>;
  48173. /**
  48174. * Gets or sets the target bone where to display the axes viewer
  48175. */
  48176. bone: Nullable<Bone>;
  48177. /** Gets current position */
  48178. pos: Vector3;
  48179. /** Gets direction of X axis */
  48180. xaxis: Vector3;
  48181. /** Gets direction of Y axis */
  48182. yaxis: Vector3;
  48183. /** Gets direction of Z axis */
  48184. zaxis: Vector3;
  48185. /**
  48186. * Creates a new BoneAxesViewer
  48187. * @param scene defines the hosting scene
  48188. * @param bone defines the target bone
  48189. * @param mesh defines the target mesh
  48190. * @param scaleLines defines a scaling factor for line length (1 by default)
  48191. */
  48192. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48193. /**
  48194. * Force the viewer to update
  48195. */
  48196. update(): void;
  48197. /** Releases resources */
  48198. dispose(): void;
  48199. }
  48200. }
  48201. declare module "babylonjs/Debug/debugLayer" {
  48202. import { Scene } from "babylonjs/scene";
  48203. /**
  48204. * Interface used to define scene explorer extensibility option
  48205. */
  48206. export interface IExplorerExtensibilityOption {
  48207. /**
  48208. * Define the option label
  48209. */
  48210. label: string;
  48211. /**
  48212. * Defines the action to execute on click
  48213. */
  48214. action: (entity: any) => void;
  48215. }
  48216. /**
  48217. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48218. */
  48219. export interface IExplorerExtensibilityGroup {
  48220. /**
  48221. * Defines a predicate to test if a given type mut be extended
  48222. */
  48223. predicate: (entity: any) => boolean;
  48224. /**
  48225. * Gets the list of options added to a type
  48226. */
  48227. entries: IExplorerExtensibilityOption[];
  48228. }
  48229. /**
  48230. * Interface used to define the options to use to create the Inspector
  48231. */
  48232. export interface IInspectorOptions {
  48233. /**
  48234. * Display in overlay mode (default: false)
  48235. */
  48236. overlay?: boolean;
  48237. /**
  48238. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48239. */
  48240. globalRoot?: HTMLElement;
  48241. /**
  48242. * Display the Scene explorer
  48243. */
  48244. showExplorer?: boolean;
  48245. /**
  48246. * Display the property inspector
  48247. */
  48248. showInspector?: boolean;
  48249. /**
  48250. * Display in embed mode (both panes on the right)
  48251. */
  48252. embedMode?: boolean;
  48253. /**
  48254. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48255. */
  48256. handleResize?: boolean;
  48257. /**
  48258. * Allow the panes to popup (default: true)
  48259. */
  48260. enablePopup?: boolean;
  48261. /**
  48262. * Allow the panes to be closed by users (default: true)
  48263. */
  48264. enableClose?: boolean;
  48265. /**
  48266. * Optional list of extensibility entries
  48267. */
  48268. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48269. /**
  48270. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48271. */
  48272. inspectorURL?: string;
  48273. /**
  48274. * Optional initial tab (default to DebugLayerTab.Properties)
  48275. */
  48276. initialTab?: DebugLayerTab;
  48277. }
  48278. module "babylonjs/scene" {
  48279. interface Scene {
  48280. /**
  48281. * @hidden
  48282. * Backing field
  48283. */
  48284. _debugLayer: DebugLayer;
  48285. /**
  48286. * Gets the debug layer (aka Inspector) associated with the scene
  48287. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48288. */
  48289. debugLayer: DebugLayer;
  48290. }
  48291. }
  48292. /**
  48293. * Enum of inspector action tab
  48294. */
  48295. export enum DebugLayerTab {
  48296. /**
  48297. * Properties tag (default)
  48298. */
  48299. Properties = 0,
  48300. /**
  48301. * Debug tab
  48302. */
  48303. Debug = 1,
  48304. /**
  48305. * Statistics tab
  48306. */
  48307. Statistics = 2,
  48308. /**
  48309. * Tools tab
  48310. */
  48311. Tools = 3,
  48312. /**
  48313. * Settings tab
  48314. */
  48315. Settings = 4
  48316. }
  48317. /**
  48318. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48319. * what is happening in your scene
  48320. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48321. */
  48322. export class DebugLayer {
  48323. /**
  48324. * Define the url to get the inspector script from.
  48325. * By default it uses the babylonjs CDN.
  48326. * @ignoreNaming
  48327. */
  48328. static InspectorURL: string;
  48329. private _scene;
  48330. private BJSINSPECTOR;
  48331. private _onPropertyChangedObservable?;
  48332. /**
  48333. * Observable triggered when a property is changed through the inspector.
  48334. */
  48335. get onPropertyChangedObservable(): any;
  48336. /**
  48337. * Instantiates a new debug layer.
  48338. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48339. * what is happening in your scene
  48340. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48341. * @param scene Defines the scene to inspect
  48342. */
  48343. constructor(scene: Scene);
  48344. /** Creates the inspector window. */
  48345. private _createInspector;
  48346. /**
  48347. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48348. * @param entity defines the entity to select
  48349. * @param lineContainerTitle defines the specific block to highlight
  48350. */
  48351. select(entity: any, lineContainerTitle?: string): void;
  48352. /** Get the inspector from bundle or global */
  48353. private _getGlobalInspector;
  48354. /**
  48355. * Get if the inspector is visible or not.
  48356. * @returns true if visible otherwise, false
  48357. */
  48358. isVisible(): boolean;
  48359. /**
  48360. * Hide the inspector and close its window.
  48361. */
  48362. hide(): void;
  48363. /**
  48364. * Launch the debugLayer.
  48365. * @param config Define the configuration of the inspector
  48366. * @return a promise fulfilled when the debug layer is visible
  48367. */
  48368. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48369. }
  48370. }
  48371. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48372. import { Nullable } from "babylonjs/types";
  48373. import { Scene } from "babylonjs/scene";
  48374. import { Vector4 } from "babylonjs/Maths/math.vector";
  48375. import { Color4 } from "babylonjs/Maths/math.color";
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. /**
  48378. * Class containing static functions to help procedurally build meshes
  48379. */
  48380. export class BoxBuilder {
  48381. /**
  48382. * Creates a box mesh
  48383. * * The parameter `size` sets the size (float) of each box side (default 1)
  48384. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48385. * * 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)
  48386. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48390. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48391. * @param name defines the name of the mesh
  48392. * @param options defines the options used to create the mesh
  48393. * @param scene defines the hosting scene
  48394. * @returns the box mesh
  48395. */
  48396. static CreateBox(name: string, options: {
  48397. size?: number;
  48398. width?: number;
  48399. height?: number;
  48400. depth?: number;
  48401. faceUV?: Vector4[];
  48402. faceColors?: Color4[];
  48403. sideOrientation?: number;
  48404. frontUVs?: Vector4;
  48405. backUVs?: Vector4;
  48406. wrap?: boolean;
  48407. topBaseAt?: number;
  48408. bottomBaseAt?: number;
  48409. updatable?: boolean;
  48410. }, scene?: Nullable<Scene>): Mesh;
  48411. }
  48412. }
  48413. declare module "babylonjs/Debug/physicsViewer" {
  48414. import { Nullable } from "babylonjs/types";
  48415. import { Scene } from "babylonjs/scene";
  48416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48417. import { Mesh } from "babylonjs/Meshes/mesh";
  48418. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48419. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48420. /**
  48421. * Used to show the physics impostor around the specific mesh
  48422. */
  48423. export class PhysicsViewer {
  48424. /** @hidden */
  48425. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48426. /** @hidden */
  48427. protected _meshes: Array<Nullable<AbstractMesh>>;
  48428. /** @hidden */
  48429. protected _scene: Nullable<Scene>;
  48430. /** @hidden */
  48431. protected _numMeshes: number;
  48432. /** @hidden */
  48433. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48434. private _renderFunction;
  48435. private _utilityLayer;
  48436. private _debugBoxMesh;
  48437. private _debugSphereMesh;
  48438. private _debugCylinderMesh;
  48439. private _debugMaterial;
  48440. private _debugMeshMeshes;
  48441. /**
  48442. * Creates a new PhysicsViewer
  48443. * @param scene defines the hosting scene
  48444. */
  48445. constructor(scene: Scene);
  48446. /** @hidden */
  48447. protected _updateDebugMeshes(): void;
  48448. /**
  48449. * Renders a specified physic impostor
  48450. * @param impostor defines the impostor to render
  48451. * @param targetMesh defines the mesh represented by the impostor
  48452. * @returns the new debug mesh used to render the impostor
  48453. */
  48454. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48455. /**
  48456. * Hides a specified physic impostor
  48457. * @param impostor defines the impostor to hide
  48458. */
  48459. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48460. private _getDebugMaterial;
  48461. private _getDebugBoxMesh;
  48462. private _getDebugSphereMesh;
  48463. private _getDebugCylinderMesh;
  48464. private _getDebugMeshMesh;
  48465. private _getDebugMesh;
  48466. /** Releases all resources */
  48467. dispose(): void;
  48468. }
  48469. }
  48470. declare module "babylonjs/Debug/rayHelper" {
  48471. import { Nullable } from "babylonjs/types";
  48472. import { Ray } from "babylonjs/Culling/ray";
  48473. import { Vector3 } from "babylonjs/Maths/math.vector";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { Scene } from "babylonjs/scene";
  48476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48477. import "babylonjs/Meshes/Builders/linesBuilder";
  48478. /**
  48479. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48480. * in order to better appreciate the issue one might have.
  48481. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48482. */
  48483. export class RayHelper {
  48484. /**
  48485. * Defines the ray we are currently tryin to visualize.
  48486. */
  48487. ray: Nullable<Ray>;
  48488. private _renderPoints;
  48489. private _renderLine;
  48490. private _renderFunction;
  48491. private _scene;
  48492. private _updateToMeshFunction;
  48493. private _attachedToMesh;
  48494. private _meshSpaceDirection;
  48495. private _meshSpaceOrigin;
  48496. /**
  48497. * Helper function to create a colored helper in a scene in one line.
  48498. * @param ray Defines the ray we are currently tryin to visualize
  48499. * @param scene Defines the scene the ray is used in
  48500. * @param color Defines the color we want to see the ray in
  48501. * @returns The newly created ray helper.
  48502. */
  48503. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48504. /**
  48505. * Instantiate a new ray helper.
  48506. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48507. * in order to better appreciate the issue one might have.
  48508. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48509. * @param ray Defines the ray we are currently tryin to visualize
  48510. */
  48511. constructor(ray: Ray);
  48512. /**
  48513. * Shows the ray we are willing to debug.
  48514. * @param scene Defines the scene the ray needs to be rendered in
  48515. * @param color Defines the color the ray needs to be rendered in
  48516. */
  48517. show(scene: Scene, color?: Color3): void;
  48518. /**
  48519. * Hides the ray we are debugging.
  48520. */
  48521. hide(): void;
  48522. private _render;
  48523. /**
  48524. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48525. * @param mesh Defines the mesh we want the helper attached to
  48526. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48527. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48528. * @param length Defines the length of the ray
  48529. */
  48530. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48531. /**
  48532. * Detach the ray helper from the mesh it has previously been attached to.
  48533. */
  48534. detachFromMesh(): void;
  48535. private _updateToMesh;
  48536. /**
  48537. * Dispose the helper and release its associated resources.
  48538. */
  48539. dispose(): void;
  48540. }
  48541. }
  48542. declare module "babylonjs/Debug/skeletonViewer" {
  48543. import { Color3 } from "babylonjs/Maths/math.color";
  48544. import { Scene } from "babylonjs/scene";
  48545. import { Nullable } from "babylonjs/types";
  48546. import { Skeleton } from "babylonjs/Bones/skeleton";
  48547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48548. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48549. /**
  48550. * Class used to render a debug view of a given skeleton
  48551. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48552. */
  48553. export class SkeletonViewer {
  48554. /** defines the skeleton to render */
  48555. skeleton: Skeleton;
  48556. /** defines the mesh attached to the skeleton */
  48557. mesh: AbstractMesh;
  48558. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48559. autoUpdateBonesMatrices: boolean;
  48560. /** defines the rendering group id to use with the viewer */
  48561. renderingGroupId: number;
  48562. /** Gets or sets the color used to render the skeleton */
  48563. color: Color3;
  48564. private _scene;
  48565. private _debugLines;
  48566. private _debugMesh;
  48567. private _isEnabled;
  48568. private _renderFunction;
  48569. private _utilityLayer;
  48570. /**
  48571. * Returns the mesh used to render the bones
  48572. */
  48573. get debugMesh(): Nullable<LinesMesh>;
  48574. /**
  48575. * Creates a new SkeletonViewer
  48576. * @param skeleton defines the skeleton to render
  48577. * @param mesh defines the mesh attached to the skeleton
  48578. * @param scene defines the hosting scene
  48579. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48580. * @param renderingGroupId defines the rendering group id to use with the viewer
  48581. */
  48582. constructor(
  48583. /** defines the skeleton to render */
  48584. skeleton: Skeleton,
  48585. /** defines the mesh attached to the skeleton */
  48586. mesh: AbstractMesh, scene: Scene,
  48587. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48588. autoUpdateBonesMatrices?: boolean,
  48589. /** defines the rendering group id to use with the viewer */
  48590. renderingGroupId?: number);
  48591. /** Gets or sets a boolean indicating if the viewer is enabled */
  48592. set isEnabled(value: boolean);
  48593. get isEnabled(): boolean;
  48594. private _getBonePosition;
  48595. private _getLinesForBonesWithLength;
  48596. private _getLinesForBonesNoLength;
  48597. /** Update the viewer to sync with current skeleton state */
  48598. update(): void;
  48599. /** Release associated resources */
  48600. dispose(): void;
  48601. }
  48602. }
  48603. declare module "babylonjs/Debug/index" {
  48604. export * from "babylonjs/Debug/axesViewer";
  48605. export * from "babylonjs/Debug/boneAxesViewer";
  48606. export * from "babylonjs/Debug/debugLayer";
  48607. export * from "babylonjs/Debug/physicsViewer";
  48608. export * from "babylonjs/Debug/rayHelper";
  48609. export * from "babylonjs/Debug/skeletonViewer";
  48610. }
  48611. declare module "babylonjs/Engines/nullEngine" {
  48612. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48613. import { Engine } from "babylonjs/Engines/engine";
  48614. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48615. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48616. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48617. import { Effect } from "babylonjs/Materials/effect";
  48618. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48619. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48620. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48621. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48622. /**
  48623. * Options to create the null engine
  48624. */
  48625. export class NullEngineOptions {
  48626. /**
  48627. * Render width (Default: 512)
  48628. */
  48629. renderWidth: number;
  48630. /**
  48631. * Render height (Default: 256)
  48632. */
  48633. renderHeight: number;
  48634. /**
  48635. * Texture size (Default: 512)
  48636. */
  48637. textureSize: number;
  48638. /**
  48639. * If delta time between frames should be constant
  48640. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48641. */
  48642. deterministicLockstep: boolean;
  48643. /**
  48644. * Maximum about of steps between frames (Default: 4)
  48645. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48646. */
  48647. lockstepMaxSteps: number;
  48648. }
  48649. /**
  48650. * The null engine class provides support for headless version of babylon.js.
  48651. * This can be used in server side scenario or for testing purposes
  48652. */
  48653. export class NullEngine extends Engine {
  48654. private _options;
  48655. /**
  48656. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48658. * @returns true if engine is in deterministic lock step mode
  48659. */
  48660. isDeterministicLockStep(): boolean;
  48661. /**
  48662. * Gets the max steps when engine is running in deterministic lock step
  48663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48664. * @returns the max steps
  48665. */
  48666. getLockstepMaxSteps(): number;
  48667. /**
  48668. * Gets the current hardware scaling level.
  48669. * By default the hardware scaling level is computed from the window device ratio.
  48670. * 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.
  48671. * @returns a number indicating the current hardware scaling level
  48672. */
  48673. getHardwareScalingLevel(): number;
  48674. constructor(options?: NullEngineOptions);
  48675. /**
  48676. * Creates a vertex buffer
  48677. * @param vertices the data for the vertex buffer
  48678. * @returns the new WebGL static buffer
  48679. */
  48680. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48681. /**
  48682. * Creates a new index buffer
  48683. * @param indices defines the content of the index buffer
  48684. * @param updatable defines if the index buffer must be updatable
  48685. * @returns a new webGL buffer
  48686. */
  48687. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48688. /**
  48689. * Clear the current render buffer or the current render target (if any is set up)
  48690. * @param color defines the color to use
  48691. * @param backBuffer defines if the back buffer must be cleared
  48692. * @param depth defines if the depth buffer must be cleared
  48693. * @param stencil defines if the stencil buffer must be cleared
  48694. */
  48695. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48696. /**
  48697. * Gets the current render width
  48698. * @param useScreen defines if screen size must be used (or the current render target if any)
  48699. * @returns a number defining the current render width
  48700. */
  48701. getRenderWidth(useScreen?: boolean): number;
  48702. /**
  48703. * Gets the current render height
  48704. * @param useScreen defines if screen size must be used (or the current render target if any)
  48705. * @returns a number defining the current render height
  48706. */
  48707. getRenderHeight(useScreen?: boolean): number;
  48708. /**
  48709. * Set the WebGL's viewport
  48710. * @param viewport defines the viewport element to be used
  48711. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48712. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48713. */
  48714. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48715. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48716. /**
  48717. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48718. * @param pipelineContext defines the pipeline context to use
  48719. * @param uniformsNames defines the list of uniform names
  48720. * @returns an array of webGL uniform locations
  48721. */
  48722. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48723. /**
  48724. * Gets the lsit of active attributes for a given webGL program
  48725. * @param pipelineContext defines the pipeline context to use
  48726. * @param attributesNames defines the list of attribute names to get
  48727. * @returns an array of indices indicating the offset of each attribute
  48728. */
  48729. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48730. /**
  48731. * Binds an effect to the webGL context
  48732. * @param effect defines the effect to bind
  48733. */
  48734. bindSamplers(effect: Effect): void;
  48735. /**
  48736. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48737. * @param effect defines the effect to activate
  48738. */
  48739. enableEffect(effect: Effect): void;
  48740. /**
  48741. * Set various states to the webGL context
  48742. * @param culling defines backface culling state
  48743. * @param zOffset defines the value to apply to zOffset (0 by default)
  48744. * @param force defines if states must be applied even if cache is up to date
  48745. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48746. */
  48747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48748. /**
  48749. * Set the value of an uniform to an array of int32
  48750. * @param uniform defines the webGL uniform location where to store the value
  48751. * @param array defines the array of int32 to store
  48752. */
  48753. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48754. /**
  48755. * Set the value of an uniform to an array of int32 (stored as vec2)
  48756. * @param uniform defines the webGL uniform location where to store the value
  48757. * @param array defines the array of int32 to store
  48758. */
  48759. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48760. /**
  48761. * Set the value of an uniform to an array of int32 (stored as vec3)
  48762. * @param uniform defines the webGL uniform location where to store the value
  48763. * @param array defines the array of int32 to store
  48764. */
  48765. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48766. /**
  48767. * Set the value of an uniform to an array of int32 (stored as vec4)
  48768. * @param uniform defines the webGL uniform location where to store the value
  48769. * @param array defines the array of int32 to store
  48770. */
  48771. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48772. /**
  48773. * Set the value of an uniform to an array of float32
  48774. * @param uniform defines the webGL uniform location where to store the value
  48775. * @param array defines the array of float32 to store
  48776. */
  48777. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48778. /**
  48779. * Set the value of an uniform to an array of float32 (stored as vec2)
  48780. * @param uniform defines the webGL uniform location where to store the value
  48781. * @param array defines the array of float32 to store
  48782. */
  48783. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48784. /**
  48785. * Set the value of an uniform to an array of float32 (stored as vec3)
  48786. * @param uniform defines the webGL uniform location where to store the value
  48787. * @param array defines the array of float32 to store
  48788. */
  48789. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48790. /**
  48791. * Set the value of an uniform to an array of float32 (stored as vec4)
  48792. * @param uniform defines the webGL uniform location where to store the value
  48793. * @param array defines the array of float32 to store
  48794. */
  48795. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48796. /**
  48797. * Set the value of an uniform to an array of number
  48798. * @param uniform defines the webGL uniform location where to store the value
  48799. * @param array defines the array of number to store
  48800. */
  48801. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48802. /**
  48803. * Set the value of an uniform to an array of number (stored as vec2)
  48804. * @param uniform defines the webGL uniform location where to store the value
  48805. * @param array defines the array of number to store
  48806. */
  48807. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48808. /**
  48809. * Set the value of an uniform to an array of number (stored as vec3)
  48810. * @param uniform defines the webGL uniform location where to store the value
  48811. * @param array defines the array of number to store
  48812. */
  48813. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48814. /**
  48815. * Set the value of an uniform to an array of number (stored as vec4)
  48816. * @param uniform defines the webGL uniform location where to store the value
  48817. * @param array defines the array of number to store
  48818. */
  48819. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48820. /**
  48821. * Set the value of an uniform to an array of float32 (stored as matrices)
  48822. * @param uniform defines the webGL uniform location where to store the value
  48823. * @param matrices defines the array of float32 to store
  48824. */
  48825. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48826. /**
  48827. * Set the value of an uniform to a matrix (3x3)
  48828. * @param uniform defines the webGL uniform location where to store the value
  48829. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48830. */
  48831. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48832. /**
  48833. * Set the value of an uniform to a matrix (2x2)
  48834. * @param uniform defines the webGL uniform location where to store the value
  48835. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48836. */
  48837. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48838. /**
  48839. * Set the value of an uniform to a number (float)
  48840. * @param uniform defines the webGL uniform location where to store the value
  48841. * @param value defines the float number to store
  48842. */
  48843. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48844. /**
  48845. * Set the value of an uniform to a vec2
  48846. * @param uniform defines the webGL uniform location where to store the value
  48847. * @param x defines the 1st component of the value
  48848. * @param y defines the 2nd component of the value
  48849. */
  48850. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48851. /**
  48852. * Set the value of an uniform to a vec3
  48853. * @param uniform defines the webGL uniform location where to store the value
  48854. * @param x defines the 1st component of the value
  48855. * @param y defines the 2nd component of the value
  48856. * @param z defines the 3rd component of the value
  48857. */
  48858. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48859. /**
  48860. * Set the value of an uniform to a boolean
  48861. * @param uniform defines the webGL uniform location where to store the value
  48862. * @param bool defines the boolean to store
  48863. */
  48864. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48865. /**
  48866. * Set the value of an uniform to a vec4
  48867. * @param uniform defines the webGL uniform location where to store the value
  48868. * @param x defines the 1st component of the value
  48869. * @param y defines the 2nd component of the value
  48870. * @param z defines the 3rd component of the value
  48871. * @param w defines the 4th component of the value
  48872. */
  48873. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48874. /**
  48875. * Sets the current alpha mode
  48876. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48877. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48878. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48879. */
  48880. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48881. /**
  48882. * Bind webGl buffers directly to the webGL context
  48883. * @param vertexBuffers defines the vertex buffer to bind
  48884. * @param indexBuffer defines the index buffer to bind
  48885. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48886. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48887. * @param effect defines the effect associated with the vertex buffer
  48888. */
  48889. bindBuffers(vertexBuffers: {
  48890. [key: string]: VertexBuffer;
  48891. }, indexBuffer: DataBuffer, effect: Effect): void;
  48892. /**
  48893. * Force the entire cache to be cleared
  48894. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48895. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48896. */
  48897. wipeCaches(bruteForce?: boolean): void;
  48898. /**
  48899. * Send a draw order
  48900. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48901. * @param indexStart defines the starting index
  48902. * @param indexCount defines the number of index to draw
  48903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48904. */
  48905. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48906. /**
  48907. * Draw a list of indexed primitives
  48908. * @param fillMode defines the primitive to use
  48909. * @param indexStart defines the starting index
  48910. * @param indexCount defines the number of index to draw
  48911. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48912. */
  48913. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48914. /**
  48915. * Draw a list of unindexed primitives
  48916. * @param fillMode defines the primitive to use
  48917. * @param verticesStart defines the index of first vertex to draw
  48918. * @param verticesCount defines the count of vertices to draw
  48919. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48920. */
  48921. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48922. /** @hidden */
  48923. _createTexture(): WebGLTexture;
  48924. /** @hidden */
  48925. _releaseTexture(texture: InternalTexture): void;
  48926. /**
  48927. * Usually called from Texture.ts.
  48928. * Passed information to create a WebGLTexture
  48929. * @param urlArg defines a value which contains one of the following:
  48930. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48931. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48932. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48933. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48934. * @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)
  48935. * @param scene needed for loading to the correct scene
  48936. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48937. * @param onLoad optional callback to be called upon successful completion
  48938. * @param onError optional callback to be called upon failure
  48939. * @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
  48940. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48941. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48942. * @param forcedExtension defines the extension to use to pick the right loader
  48943. * @param mimeType defines an optional mime type
  48944. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48945. */
  48946. 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;
  48947. /**
  48948. * Creates a new render target texture
  48949. * @param size defines the size of the texture
  48950. * @param options defines the options used to create the texture
  48951. * @returns a new render target texture stored in an InternalTexture
  48952. */
  48953. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48954. /**
  48955. * Update the sampling mode of a given texture
  48956. * @param samplingMode defines the required sampling mode
  48957. * @param texture defines the texture to update
  48958. */
  48959. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48960. /**
  48961. * Binds the frame buffer to the specified texture.
  48962. * @param texture The texture to render to or null for the default canvas
  48963. * @param faceIndex The face of the texture to render to in case of cube texture
  48964. * @param requiredWidth The width of the target to render to
  48965. * @param requiredHeight The height of the target to render to
  48966. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48967. * @param lodLevel defines le lod level to bind to the frame buffer
  48968. */
  48969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48970. /**
  48971. * Unbind the current render target texture from the webGL context
  48972. * @param texture defines the render target texture to unbind
  48973. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48974. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48975. */
  48976. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48977. /**
  48978. * Creates a dynamic vertex buffer
  48979. * @param vertices the data for the dynamic vertex buffer
  48980. * @returns the new WebGL dynamic buffer
  48981. */
  48982. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48983. /**
  48984. * Update the content of a dynamic texture
  48985. * @param texture defines the texture to update
  48986. * @param canvas defines the canvas containing the source
  48987. * @param invertY defines if data must be stored with Y axis inverted
  48988. * @param premulAlpha defines if alpha is stored as premultiplied
  48989. * @param format defines the format of the data
  48990. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48991. */
  48992. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48993. /**
  48994. * Gets a boolean indicating if all created effects are ready
  48995. * @returns true if all effects are ready
  48996. */
  48997. areAllEffectsReady(): boolean;
  48998. /**
  48999. * @hidden
  49000. * Get the current error code of the webGL context
  49001. * @returns the error code
  49002. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49003. */
  49004. getError(): number;
  49005. /** @hidden */
  49006. _getUnpackAlignement(): number;
  49007. /** @hidden */
  49008. _unpackFlipY(value: boolean): void;
  49009. /**
  49010. * Update a dynamic index buffer
  49011. * @param indexBuffer defines the target index buffer
  49012. * @param indices defines the data to update
  49013. * @param offset defines the offset in the target index buffer where update should start
  49014. */
  49015. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49016. /**
  49017. * Updates a dynamic vertex buffer.
  49018. * @param vertexBuffer the vertex buffer to update
  49019. * @param vertices the data used to update the vertex buffer
  49020. * @param byteOffset the byte offset of the data (optional)
  49021. * @param byteLength the byte length of the data (optional)
  49022. */
  49023. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49024. /** @hidden */
  49025. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49026. /** @hidden */
  49027. _bindTexture(channel: number, texture: InternalTexture): void;
  49028. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49029. /**
  49030. * 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
  49031. */
  49032. releaseEffects(): void;
  49033. displayLoadingUI(): void;
  49034. hideLoadingUI(): void;
  49035. /** @hidden */
  49036. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49037. /** @hidden */
  49038. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49039. /** @hidden */
  49040. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49041. /** @hidden */
  49042. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49043. }
  49044. }
  49045. declare module "babylonjs/Instrumentation/timeToken" {
  49046. import { Nullable } from "babylonjs/types";
  49047. /**
  49048. * @hidden
  49049. **/
  49050. export class _TimeToken {
  49051. _startTimeQuery: Nullable<WebGLQuery>;
  49052. _endTimeQuery: Nullable<WebGLQuery>;
  49053. _timeElapsedQuery: Nullable<WebGLQuery>;
  49054. _timeElapsedQueryEnded: boolean;
  49055. }
  49056. }
  49057. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49058. import { Nullable, int } from "babylonjs/types";
  49059. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49060. /** @hidden */
  49061. export class _OcclusionDataStorage {
  49062. /** @hidden */
  49063. occlusionInternalRetryCounter: number;
  49064. /** @hidden */
  49065. isOcclusionQueryInProgress: boolean;
  49066. /** @hidden */
  49067. isOccluded: boolean;
  49068. /** @hidden */
  49069. occlusionRetryCount: number;
  49070. /** @hidden */
  49071. occlusionType: number;
  49072. /** @hidden */
  49073. occlusionQueryAlgorithmType: number;
  49074. }
  49075. module "babylonjs/Engines/engine" {
  49076. interface Engine {
  49077. /**
  49078. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49079. * @return the new query
  49080. */
  49081. createQuery(): WebGLQuery;
  49082. /**
  49083. * Delete and release a webGL query
  49084. * @param query defines the query to delete
  49085. * @return the current engine
  49086. */
  49087. deleteQuery(query: WebGLQuery): Engine;
  49088. /**
  49089. * Check if a given query has resolved and got its value
  49090. * @param query defines the query to check
  49091. * @returns true if the query got its value
  49092. */
  49093. isQueryResultAvailable(query: WebGLQuery): boolean;
  49094. /**
  49095. * Gets the value of a given query
  49096. * @param query defines the query to check
  49097. * @returns the value of the query
  49098. */
  49099. getQueryResult(query: WebGLQuery): number;
  49100. /**
  49101. * Initiates an occlusion query
  49102. * @param algorithmType defines the algorithm to use
  49103. * @param query defines the query to use
  49104. * @returns the current engine
  49105. * @see http://doc.babylonjs.com/features/occlusionquery
  49106. */
  49107. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49108. /**
  49109. * Ends an occlusion query
  49110. * @see http://doc.babylonjs.com/features/occlusionquery
  49111. * @param algorithmType defines the algorithm to use
  49112. * @returns the current engine
  49113. */
  49114. endOcclusionQuery(algorithmType: number): Engine;
  49115. /**
  49116. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49117. * Please note that only one query can be issued at a time
  49118. * @returns a time token used to track the time span
  49119. */
  49120. startTimeQuery(): Nullable<_TimeToken>;
  49121. /**
  49122. * Ends a time query
  49123. * @param token defines the token used to measure the time span
  49124. * @returns the time spent (in ns)
  49125. */
  49126. endTimeQuery(token: _TimeToken): int;
  49127. /** @hidden */
  49128. _currentNonTimestampToken: Nullable<_TimeToken>;
  49129. /** @hidden */
  49130. _createTimeQuery(): WebGLQuery;
  49131. /** @hidden */
  49132. _deleteTimeQuery(query: WebGLQuery): void;
  49133. /** @hidden */
  49134. _getGlAlgorithmType(algorithmType: number): number;
  49135. /** @hidden */
  49136. _getTimeQueryResult(query: WebGLQuery): any;
  49137. /** @hidden */
  49138. _getTimeQueryAvailability(query: WebGLQuery): any;
  49139. }
  49140. }
  49141. module "babylonjs/Meshes/abstractMesh" {
  49142. interface AbstractMesh {
  49143. /**
  49144. * Backing filed
  49145. * @hidden
  49146. */
  49147. __occlusionDataStorage: _OcclusionDataStorage;
  49148. /**
  49149. * Access property
  49150. * @hidden
  49151. */
  49152. _occlusionDataStorage: _OcclusionDataStorage;
  49153. /**
  49154. * 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.
  49155. * The default value is -1 which means don't break the query and wait till the result
  49156. * @see http://doc.babylonjs.com/features/occlusionquery
  49157. */
  49158. occlusionRetryCount: number;
  49159. /**
  49160. * 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:
  49161. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49162. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49163. * * 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.
  49164. * @see http://doc.babylonjs.com/features/occlusionquery
  49165. */
  49166. occlusionType: number;
  49167. /**
  49168. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49169. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49170. * * 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.
  49171. * @see http://doc.babylonjs.com/features/occlusionquery
  49172. */
  49173. occlusionQueryAlgorithmType: number;
  49174. /**
  49175. * 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
  49176. * @see http://doc.babylonjs.com/features/occlusionquery
  49177. */
  49178. isOccluded: boolean;
  49179. /**
  49180. * Flag to check the progress status of the query
  49181. * @see http://doc.babylonjs.com/features/occlusionquery
  49182. */
  49183. isOcclusionQueryInProgress: boolean;
  49184. }
  49185. }
  49186. }
  49187. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49188. import { Nullable } from "babylonjs/types";
  49189. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49190. /** @hidden */
  49191. export var _forceTransformFeedbackToBundle: boolean;
  49192. module "babylonjs/Engines/engine" {
  49193. interface Engine {
  49194. /**
  49195. * Creates a webGL transform feedback object
  49196. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49197. * @returns the webGL transform feedback object
  49198. */
  49199. createTransformFeedback(): WebGLTransformFeedback;
  49200. /**
  49201. * Delete a webGL transform feedback object
  49202. * @param value defines the webGL transform feedback object to delete
  49203. */
  49204. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49205. /**
  49206. * Bind a webGL transform feedback object to the webgl context
  49207. * @param value defines the webGL transform feedback object to bind
  49208. */
  49209. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49210. /**
  49211. * Begins a transform feedback operation
  49212. * @param usePoints defines if points or triangles must be used
  49213. */
  49214. beginTransformFeedback(usePoints: boolean): void;
  49215. /**
  49216. * Ends a transform feedback operation
  49217. */
  49218. endTransformFeedback(): void;
  49219. /**
  49220. * Specify the varyings to use with transform feedback
  49221. * @param program defines the associated webGL program
  49222. * @param value defines the list of strings representing the varying names
  49223. */
  49224. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49225. /**
  49226. * Bind a webGL buffer for a transform feedback operation
  49227. * @param value defines the webGL buffer to bind
  49228. */
  49229. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49230. }
  49231. }
  49232. }
  49233. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49234. import { Scene } from "babylonjs/scene";
  49235. import { Engine } from "babylonjs/Engines/engine";
  49236. import { Texture } from "babylonjs/Materials/Textures/texture";
  49237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49238. import "babylonjs/Engines/Extensions/engine.multiRender";
  49239. /**
  49240. * Creation options of the multi render target texture.
  49241. */
  49242. export interface IMultiRenderTargetOptions {
  49243. /**
  49244. * Define if the texture needs to create mip maps after render.
  49245. */
  49246. generateMipMaps?: boolean;
  49247. /**
  49248. * Define the types of all the draw buffers we want to create
  49249. */
  49250. types?: number[];
  49251. /**
  49252. * Define the sampling modes of all the draw buffers we want to create
  49253. */
  49254. samplingModes?: number[];
  49255. /**
  49256. * Define if a depth buffer is required
  49257. */
  49258. generateDepthBuffer?: boolean;
  49259. /**
  49260. * Define if a stencil buffer is required
  49261. */
  49262. generateStencilBuffer?: boolean;
  49263. /**
  49264. * Define if a depth texture is required instead of a depth buffer
  49265. */
  49266. generateDepthTexture?: boolean;
  49267. /**
  49268. * Define the number of desired draw buffers
  49269. */
  49270. textureCount?: number;
  49271. /**
  49272. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49273. */
  49274. doNotChangeAspectRatio?: boolean;
  49275. /**
  49276. * Define the default type of the buffers we are creating
  49277. */
  49278. defaultType?: number;
  49279. }
  49280. /**
  49281. * A multi render target, like a render target provides the ability to render to a texture.
  49282. * Unlike the render target, it can render to several draw buffers in one draw.
  49283. * This is specially interesting in deferred rendering or for any effects requiring more than
  49284. * just one color from a single pass.
  49285. */
  49286. export class MultiRenderTarget extends RenderTargetTexture {
  49287. private _internalTextures;
  49288. private _textures;
  49289. private _multiRenderTargetOptions;
  49290. /**
  49291. * Get if draw buffers are currently supported by the used hardware and browser.
  49292. */
  49293. get isSupported(): boolean;
  49294. /**
  49295. * Get the list of textures generated by the multi render target.
  49296. */
  49297. get textures(): Texture[];
  49298. /**
  49299. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49300. */
  49301. get depthTexture(): Texture;
  49302. /**
  49303. * Set the wrapping mode on U of all the textures we are rendering to.
  49304. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49305. */
  49306. set wrapU(wrap: number);
  49307. /**
  49308. * Set the wrapping mode on V of all the textures we are rendering to.
  49309. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49310. */
  49311. set wrapV(wrap: number);
  49312. /**
  49313. * Instantiate a new multi render target texture.
  49314. * A multi render target, like a render target provides the ability to render to a texture.
  49315. * Unlike the render target, it can render to several draw buffers in one draw.
  49316. * This is specially interesting in deferred rendering or for any effects requiring more than
  49317. * just one color from a single pass.
  49318. * @param name Define the name of the texture
  49319. * @param size Define the size of the buffers to render to
  49320. * @param count Define the number of target we are rendering into
  49321. * @param scene Define the scene the texture belongs to
  49322. * @param options Define the options used to create the multi render target
  49323. */
  49324. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49325. /** @hidden */
  49326. _rebuild(): void;
  49327. private _createInternalTextures;
  49328. private _createTextures;
  49329. /**
  49330. * Define the number of samples used if MSAA is enabled.
  49331. */
  49332. get samples(): number;
  49333. set samples(value: number);
  49334. /**
  49335. * Resize all the textures in the multi render target.
  49336. * Be carrefull as it will recreate all the data in the new texture.
  49337. * @param size Define the new size
  49338. */
  49339. resize(size: any): void;
  49340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49341. /**
  49342. * Dispose the render targets and their associated resources
  49343. */
  49344. dispose(): void;
  49345. /**
  49346. * Release all the underlying texture used as draw buffers.
  49347. */
  49348. releaseInternalTextures(): void;
  49349. }
  49350. }
  49351. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49353. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49354. import { Nullable } from "babylonjs/types";
  49355. module "babylonjs/Engines/thinEngine" {
  49356. interface ThinEngine {
  49357. /**
  49358. * Unbind a list of render target textures from the webGL context
  49359. * This is used only when drawBuffer extension or webGL2 are active
  49360. * @param textures defines the render target textures to unbind
  49361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49363. */
  49364. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49365. /**
  49366. * Create a multi render target texture
  49367. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49368. * @param size defines the size of the texture
  49369. * @param options defines the creation options
  49370. * @returns the cube texture as an InternalTexture
  49371. */
  49372. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49373. /**
  49374. * Update the sample count for a given multiple render target texture
  49375. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49376. * @param textures defines the textures to update
  49377. * @param samples defines the sample count to set
  49378. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49379. */
  49380. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49381. }
  49382. }
  49383. }
  49384. declare module "babylonjs/Engines/Extensions/engine.views" {
  49385. import { Camera } from "babylonjs/Cameras/camera";
  49386. import { Nullable } from "babylonjs/types";
  49387. /**
  49388. * Class used to define an additional view for the engine
  49389. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49390. */
  49391. export class EngineView {
  49392. /** Defines the canvas where to render the view */
  49393. target: HTMLCanvasElement;
  49394. /** Defines an optional camera used to render the view (will use active camera else) */
  49395. camera?: Camera;
  49396. }
  49397. module "babylonjs/Engines/engine" {
  49398. interface Engine {
  49399. /**
  49400. * Gets or sets the HTML element to use for attaching events
  49401. */
  49402. inputElement: Nullable<HTMLElement>;
  49403. /**
  49404. * Gets the current engine view
  49405. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49406. */
  49407. activeView: Nullable<EngineView>;
  49408. /** Gets or sets the list of views */
  49409. views: EngineView[];
  49410. /**
  49411. * Register a new child canvas
  49412. * @param canvas defines the canvas to register
  49413. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49414. * @returns the associated view
  49415. */
  49416. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49417. /**
  49418. * Remove a registered child canvas
  49419. * @param canvas defines the canvas to remove
  49420. * @returns the current engine
  49421. */
  49422. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49423. }
  49424. }
  49425. }
  49426. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49427. import { Nullable } from "babylonjs/types";
  49428. module "babylonjs/Engines/engine" {
  49429. interface Engine {
  49430. /** @hidden */
  49431. _excludedCompressedTextures: string[];
  49432. /** @hidden */
  49433. _textureFormatInUse: string;
  49434. /**
  49435. * Gets the list of texture formats supported
  49436. */
  49437. readonly texturesSupported: Array<string>;
  49438. /**
  49439. * Gets the texture format in use
  49440. */
  49441. readonly textureFormatInUse: Nullable<string>;
  49442. /**
  49443. * Set the compressed texture extensions or file names to skip.
  49444. *
  49445. * @param skippedFiles defines the list of those texture files you want to skip
  49446. * Example: [".dds", ".env", "myfile.png"]
  49447. */
  49448. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49449. /**
  49450. * Set the compressed texture format to use, based on the formats you have, and the formats
  49451. * supported by the hardware / browser.
  49452. *
  49453. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49454. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49455. * to API arguments needed to compressed textures. This puts the burden on the container
  49456. * generator to house the arcane code for determining these for current & future formats.
  49457. *
  49458. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49459. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49460. *
  49461. * Note: The result of this call is not taken into account when a texture is base64.
  49462. *
  49463. * @param formatsAvailable defines the list of those format families you have created
  49464. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49465. *
  49466. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49467. * @returns The extension selected.
  49468. */
  49469. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49470. }
  49471. }
  49472. }
  49473. declare module "babylonjs/Engines/Extensions/index" {
  49474. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49475. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49476. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49477. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49478. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49479. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49480. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49481. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49482. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49483. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49484. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49485. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49486. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49487. export * from "babylonjs/Engines/Extensions/engine.views";
  49488. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49489. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49490. }
  49491. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49492. import { Nullable } from "babylonjs/types";
  49493. /**
  49494. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49495. */
  49496. export interface CubeMapInfo {
  49497. /**
  49498. * The pixel array for the front face.
  49499. * This is stored in format, left to right, up to down format.
  49500. */
  49501. front: Nullable<ArrayBufferView>;
  49502. /**
  49503. * The pixel array for the back face.
  49504. * This is stored in format, left to right, up to down format.
  49505. */
  49506. back: Nullable<ArrayBufferView>;
  49507. /**
  49508. * The pixel array for the left face.
  49509. * This is stored in format, left to right, up to down format.
  49510. */
  49511. left: Nullable<ArrayBufferView>;
  49512. /**
  49513. * The pixel array for the right face.
  49514. * This is stored in format, left to right, up to down format.
  49515. */
  49516. right: Nullable<ArrayBufferView>;
  49517. /**
  49518. * The pixel array for the up face.
  49519. * This is stored in format, left to right, up to down format.
  49520. */
  49521. up: Nullable<ArrayBufferView>;
  49522. /**
  49523. * The pixel array for the down face.
  49524. * This is stored in format, left to right, up to down format.
  49525. */
  49526. down: Nullable<ArrayBufferView>;
  49527. /**
  49528. * The size of the cubemap stored.
  49529. *
  49530. * Each faces will be size * size pixels.
  49531. */
  49532. size: number;
  49533. /**
  49534. * The format of the texture.
  49535. *
  49536. * RGBA, RGB.
  49537. */
  49538. format: number;
  49539. /**
  49540. * The type of the texture data.
  49541. *
  49542. * UNSIGNED_INT, FLOAT.
  49543. */
  49544. type: number;
  49545. /**
  49546. * Specifies whether the texture is in gamma space.
  49547. */
  49548. gammaSpace: boolean;
  49549. }
  49550. /**
  49551. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49552. */
  49553. export class PanoramaToCubeMapTools {
  49554. private static FACE_FRONT;
  49555. private static FACE_BACK;
  49556. private static FACE_RIGHT;
  49557. private static FACE_LEFT;
  49558. private static FACE_DOWN;
  49559. private static FACE_UP;
  49560. /**
  49561. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49562. *
  49563. * @param float32Array The source data.
  49564. * @param inputWidth The width of the input panorama.
  49565. * @param inputHeight The height of the input panorama.
  49566. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49567. * @return The cubemap data
  49568. */
  49569. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49570. private static CreateCubemapTexture;
  49571. private static CalcProjectionSpherical;
  49572. }
  49573. }
  49574. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49575. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49577. import { Nullable } from "babylonjs/types";
  49578. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49579. /**
  49580. * Helper class dealing with the extraction of spherical polynomial dataArray
  49581. * from a cube map.
  49582. */
  49583. export class CubeMapToSphericalPolynomialTools {
  49584. private static FileFaces;
  49585. /**
  49586. * Converts a texture to the according Spherical Polynomial data.
  49587. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49588. *
  49589. * @param texture The texture to extract the information from.
  49590. * @return The Spherical Polynomial data.
  49591. */
  49592. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49593. /**
  49594. * Converts a cubemap to the according Spherical Polynomial data.
  49595. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49596. *
  49597. * @param cubeInfo The Cube map to extract the information from.
  49598. * @return The Spherical Polynomial data.
  49599. */
  49600. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49601. }
  49602. }
  49603. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49604. import { Nullable } from "babylonjs/types";
  49605. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49606. module "babylonjs/Materials/Textures/baseTexture" {
  49607. interface BaseTexture {
  49608. /**
  49609. * Get the polynomial representation of the texture data.
  49610. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49611. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49612. */
  49613. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49614. }
  49615. }
  49616. }
  49617. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49619. /** @hidden */
  49620. export var rgbdEncodePixelShader: {
  49621. name: string;
  49622. shader: string;
  49623. };
  49624. }
  49625. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49627. /** @hidden */
  49628. export var rgbdDecodePixelShader: {
  49629. name: string;
  49630. shader: string;
  49631. };
  49632. }
  49633. declare module "babylonjs/Misc/environmentTextureTools" {
  49634. import { Nullable } from "babylonjs/types";
  49635. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49637. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49638. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49639. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49640. import "babylonjs/Shaders/rgbdEncode.fragment";
  49641. import "babylonjs/Shaders/rgbdDecode.fragment";
  49642. /**
  49643. * Raw texture data and descriptor sufficient for WebGL texture upload
  49644. */
  49645. export interface EnvironmentTextureInfo {
  49646. /**
  49647. * Version of the environment map
  49648. */
  49649. version: number;
  49650. /**
  49651. * Width of image
  49652. */
  49653. width: number;
  49654. /**
  49655. * Irradiance information stored in the file.
  49656. */
  49657. irradiance: any;
  49658. /**
  49659. * Specular information stored in the file.
  49660. */
  49661. specular: any;
  49662. }
  49663. /**
  49664. * Defines One Image in the file. It requires only the position in the file
  49665. * as well as the length.
  49666. */
  49667. interface BufferImageData {
  49668. /**
  49669. * Length of the image data.
  49670. */
  49671. length: number;
  49672. /**
  49673. * Position of the data from the null terminator delimiting the end of the JSON.
  49674. */
  49675. position: number;
  49676. }
  49677. /**
  49678. * Defines the specular data enclosed in the file.
  49679. * This corresponds to the version 1 of the data.
  49680. */
  49681. export interface EnvironmentTextureSpecularInfoV1 {
  49682. /**
  49683. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49684. */
  49685. specularDataPosition?: number;
  49686. /**
  49687. * This contains all the images data needed to reconstruct the cubemap.
  49688. */
  49689. mipmaps: Array<BufferImageData>;
  49690. /**
  49691. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49692. */
  49693. lodGenerationScale: number;
  49694. }
  49695. /**
  49696. * Sets of helpers addressing the serialization and deserialization of environment texture
  49697. * stored in a BabylonJS env file.
  49698. * Those files are usually stored as .env files.
  49699. */
  49700. export class EnvironmentTextureTools {
  49701. /**
  49702. * Magic number identifying the env file.
  49703. */
  49704. private static _MagicBytes;
  49705. /**
  49706. * Gets the environment info from an env file.
  49707. * @param data The array buffer containing the .env bytes.
  49708. * @returns the environment file info (the json header) if successfully parsed.
  49709. */
  49710. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49711. /**
  49712. * Creates an environment texture from a loaded cube texture.
  49713. * @param texture defines the cube texture to convert in env file
  49714. * @return a promise containing the environment data if succesfull.
  49715. */
  49716. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49717. /**
  49718. * Creates a JSON representation of the spherical data.
  49719. * @param texture defines the texture containing the polynomials
  49720. * @return the JSON representation of the spherical info
  49721. */
  49722. private static _CreateEnvTextureIrradiance;
  49723. /**
  49724. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49725. * @param data the image data
  49726. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49727. * @return the views described by info providing access to the underlying buffer
  49728. */
  49729. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49730. /**
  49731. * Uploads the texture info contained in the env file to the GPU.
  49732. * @param texture defines the internal texture to upload to
  49733. * @param data defines the data to load
  49734. * @param info defines the texture info retrieved through the GetEnvInfo method
  49735. * @returns a promise
  49736. */
  49737. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49738. private static _OnImageReadyAsync;
  49739. /**
  49740. * Uploads the levels of image data to the GPU.
  49741. * @param texture defines the internal texture to upload to
  49742. * @param imageData defines the array buffer views of image data [mipmap][face]
  49743. * @returns a promise
  49744. */
  49745. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49746. /**
  49747. * Uploads spherical polynomials information to the texture.
  49748. * @param texture defines the texture we are trying to upload the information to
  49749. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49750. */
  49751. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49752. /** @hidden */
  49753. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49754. }
  49755. }
  49756. declare module "babylonjs/Maths/math.vertexFormat" {
  49757. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49758. /**
  49759. * Contains position and normal vectors for a vertex
  49760. */
  49761. export class PositionNormalVertex {
  49762. /** the position of the vertex (defaut: 0,0,0) */
  49763. position: Vector3;
  49764. /** the normal of the vertex (defaut: 0,1,0) */
  49765. normal: Vector3;
  49766. /**
  49767. * Creates a PositionNormalVertex
  49768. * @param position the position of the vertex (defaut: 0,0,0)
  49769. * @param normal the normal of the vertex (defaut: 0,1,0)
  49770. */
  49771. constructor(
  49772. /** the position of the vertex (defaut: 0,0,0) */
  49773. position?: Vector3,
  49774. /** the normal of the vertex (defaut: 0,1,0) */
  49775. normal?: Vector3);
  49776. /**
  49777. * Clones the PositionNormalVertex
  49778. * @returns the cloned PositionNormalVertex
  49779. */
  49780. clone(): PositionNormalVertex;
  49781. }
  49782. /**
  49783. * Contains position, normal and uv vectors for a vertex
  49784. */
  49785. export class PositionNormalTextureVertex {
  49786. /** the position of the vertex (defaut: 0,0,0) */
  49787. position: Vector3;
  49788. /** the normal of the vertex (defaut: 0,1,0) */
  49789. normal: Vector3;
  49790. /** the uv of the vertex (default: 0,0) */
  49791. uv: Vector2;
  49792. /**
  49793. * Creates a PositionNormalTextureVertex
  49794. * @param position the position of the vertex (defaut: 0,0,0)
  49795. * @param normal the normal of the vertex (defaut: 0,1,0)
  49796. * @param uv the uv of the vertex (default: 0,0)
  49797. */
  49798. constructor(
  49799. /** the position of the vertex (defaut: 0,0,0) */
  49800. position?: Vector3,
  49801. /** the normal of the vertex (defaut: 0,1,0) */
  49802. normal?: Vector3,
  49803. /** the uv of the vertex (default: 0,0) */
  49804. uv?: Vector2);
  49805. /**
  49806. * Clones the PositionNormalTextureVertex
  49807. * @returns the cloned PositionNormalTextureVertex
  49808. */
  49809. clone(): PositionNormalTextureVertex;
  49810. }
  49811. }
  49812. declare module "babylonjs/Maths/math" {
  49813. export * from "babylonjs/Maths/math.axis";
  49814. export * from "babylonjs/Maths/math.color";
  49815. export * from "babylonjs/Maths/math.constants";
  49816. export * from "babylonjs/Maths/math.frustum";
  49817. export * from "babylonjs/Maths/math.path";
  49818. export * from "babylonjs/Maths/math.plane";
  49819. export * from "babylonjs/Maths/math.size";
  49820. export * from "babylonjs/Maths/math.vector";
  49821. export * from "babylonjs/Maths/math.vertexFormat";
  49822. export * from "babylonjs/Maths/math.viewport";
  49823. }
  49824. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49825. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49826. /** @hidden */
  49827. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49828. private _genericAttributeLocation;
  49829. private _varyingLocationCount;
  49830. private _varyingLocationMap;
  49831. private _replacements;
  49832. private _textureCount;
  49833. private _uniforms;
  49834. lineProcessor(line: string): string;
  49835. attributeProcessor(attribute: string): string;
  49836. varyingProcessor(varying: string, isFragment: boolean): string;
  49837. uniformProcessor(uniform: string): string;
  49838. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49839. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49840. }
  49841. }
  49842. declare module "babylonjs/Engines/nativeEngine" {
  49843. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49844. import { Engine } from "babylonjs/Engines/engine";
  49845. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49846. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49848. import { Effect } from "babylonjs/Materials/effect";
  49849. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49850. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49851. import { IColor4Like } from "babylonjs/Maths/math.like";
  49852. import { Scene } from "babylonjs/scene";
  49853. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49854. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49855. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49856. /**
  49857. * Container for accessors for natively-stored mesh data buffers.
  49858. */
  49859. class NativeDataBuffer extends DataBuffer {
  49860. /**
  49861. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49862. */
  49863. nativeIndexBuffer?: any;
  49864. /**
  49865. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49866. */
  49867. nativeVertexBuffer?: any;
  49868. }
  49869. /** @hidden */
  49870. class NativeTexture extends InternalTexture {
  49871. getInternalTexture(): InternalTexture;
  49872. getViewCount(): number;
  49873. }
  49874. /** @hidden */
  49875. export class NativeEngine extends Engine {
  49876. private readonly _native;
  49877. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49878. private readonly INVALID_HANDLE;
  49879. getHardwareScalingLevel(): number;
  49880. constructor();
  49881. /**
  49882. * Can be used to override the current requestAnimationFrame requester.
  49883. * @hidden
  49884. */
  49885. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49886. /**
  49887. * Override default engine behavior.
  49888. * @param color
  49889. * @param backBuffer
  49890. * @param depth
  49891. * @param stencil
  49892. */
  49893. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49894. /**
  49895. * Gets host document
  49896. * @returns the host document object
  49897. */
  49898. getHostDocument(): Nullable<Document>;
  49899. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49900. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49901. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49902. recordVertexArrayObject(vertexBuffers: {
  49903. [key: string]: VertexBuffer;
  49904. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49905. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49906. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49907. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49908. /**
  49909. * Draw a list of indexed primitives
  49910. * @param fillMode defines the primitive to use
  49911. * @param indexStart defines the starting index
  49912. * @param indexCount defines the number of index to draw
  49913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49914. */
  49915. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49916. /**
  49917. * Draw a list of unindexed primitives
  49918. * @param fillMode defines the primitive to use
  49919. * @param verticesStart defines the index of first vertex to draw
  49920. * @param verticesCount defines the count of vertices to draw
  49921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49922. */
  49923. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49924. createPipelineContext(): IPipelineContext;
  49925. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49926. /** @hidden */
  49927. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49928. /** @hidden */
  49929. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49930. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49931. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49932. protected _setProgram(program: WebGLProgram): void;
  49933. _releaseEffect(effect: Effect): void;
  49934. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49935. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49936. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49937. bindSamplers(effect: Effect): void;
  49938. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49939. getRenderWidth(useScreen?: boolean): number;
  49940. getRenderHeight(useScreen?: boolean): number;
  49941. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49942. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49943. /**
  49944. * Set the z offset to apply to current rendering
  49945. * @param value defines the offset to apply
  49946. */
  49947. setZOffset(value: number): void;
  49948. /**
  49949. * Gets the current value of the zOffset
  49950. * @returns the current zOffset state
  49951. */
  49952. getZOffset(): number;
  49953. /**
  49954. * Enable or disable depth buffering
  49955. * @param enable defines the state to set
  49956. */
  49957. setDepthBuffer(enable: boolean): void;
  49958. /**
  49959. * Gets a boolean indicating if depth writing is enabled
  49960. * @returns the current depth writing state
  49961. */
  49962. getDepthWrite(): boolean;
  49963. /**
  49964. * Enable or disable depth writing
  49965. * @param enable defines the state to set
  49966. */
  49967. setDepthWrite(enable: boolean): void;
  49968. /**
  49969. * Enable or disable color writing
  49970. * @param enable defines the state to set
  49971. */
  49972. setColorWrite(enable: boolean): void;
  49973. /**
  49974. * Gets a boolean indicating if color writing is enabled
  49975. * @returns the current color writing state
  49976. */
  49977. getColorWrite(): boolean;
  49978. /**
  49979. * Sets alpha constants used by some alpha blending modes
  49980. * @param r defines the red component
  49981. * @param g defines the green component
  49982. * @param b defines the blue component
  49983. * @param a defines the alpha component
  49984. */
  49985. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49986. /**
  49987. * Sets the current alpha mode
  49988. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49989. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49990. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49991. */
  49992. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49993. /**
  49994. * Gets the current alpha mode
  49995. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49996. * @returns the current alpha mode
  49997. */
  49998. getAlphaMode(): number;
  49999. setInt(uniform: WebGLUniformLocation, int: number): void;
  50000. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50001. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50002. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50003. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50004. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50005. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50006. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50007. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50008. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50009. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50010. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50011. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50012. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50013. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50014. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50015. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50016. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50017. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50018. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50019. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50020. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50021. wipeCaches(bruteForce?: boolean): void;
  50022. _createTexture(): WebGLTexture;
  50023. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50024. /**
  50025. * Usually called from Texture.ts.
  50026. * Passed information to create a WebGLTexture
  50027. * @param urlArg defines a value which contains one of the following:
  50028. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50029. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50030. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50031. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50032. * @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)
  50033. * @param scene needed for loading to the correct scene
  50034. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50035. * @param onLoad optional callback to be called upon successful completion
  50036. * @param onError optional callback to be called upon failure
  50037. * @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
  50038. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50039. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50040. * @param forcedExtension defines the extension to use to pick the right loader
  50041. * @param mimeType defines an optional mime type
  50042. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50043. */
  50044. 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;
  50045. /**
  50046. * Creates a cube texture
  50047. * @param rootUrl defines the url where the files to load is located
  50048. * @param scene defines the current scene
  50049. * @param files defines the list of files to load (1 per face)
  50050. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50051. * @param onLoad defines an optional callback raised when the texture is loaded
  50052. * @param onError defines an optional callback raised if there is an issue to load the texture
  50053. * @param format defines the format of the data
  50054. * @param forcedExtension defines the extension to use to pick the right loader
  50055. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50056. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50057. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50058. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50059. * @returns the cube texture as an InternalTexture
  50060. */
  50061. 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;
  50062. private _getSamplingFilter;
  50063. private static _GetNativeTextureFormat;
  50064. createRenderTargetTexture(size: number | {
  50065. width: number;
  50066. height: number;
  50067. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50068. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50069. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50070. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50071. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50072. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50073. /**
  50074. * Updates a dynamic vertex buffer.
  50075. * @param vertexBuffer the vertex buffer to update
  50076. * @param data the data used to update the vertex buffer
  50077. * @param byteOffset the byte offset of the data (optional)
  50078. * @param byteLength the byte length of the data (optional)
  50079. */
  50080. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50081. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50082. private _updateAnisotropicLevel;
  50083. private _getAddressMode;
  50084. /** @hidden */
  50085. _bindTexture(channel: number, texture: InternalTexture): void;
  50086. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50087. releaseEffects(): void;
  50088. /** @hidden */
  50089. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50090. /** @hidden */
  50091. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50092. /** @hidden */
  50093. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50094. /** @hidden */
  50095. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50096. }
  50097. }
  50098. declare module "babylonjs/Engines/index" {
  50099. export * from "babylonjs/Engines/constants";
  50100. export * from "babylonjs/Engines/engineCapabilities";
  50101. export * from "babylonjs/Engines/instancingAttributeInfo";
  50102. export * from "babylonjs/Engines/thinEngine";
  50103. export * from "babylonjs/Engines/engine";
  50104. export * from "babylonjs/Engines/engineStore";
  50105. export * from "babylonjs/Engines/nullEngine";
  50106. export * from "babylonjs/Engines/Extensions/index";
  50107. export * from "babylonjs/Engines/IPipelineContext";
  50108. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50109. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50110. export * from "babylonjs/Engines/nativeEngine";
  50111. }
  50112. declare module "babylonjs/Events/clipboardEvents" {
  50113. /**
  50114. * Gather the list of clipboard event types as constants.
  50115. */
  50116. export class ClipboardEventTypes {
  50117. /**
  50118. * The clipboard event is fired when a copy command is active (pressed).
  50119. */
  50120. static readonly COPY: number;
  50121. /**
  50122. * The clipboard event is fired when a cut command is active (pressed).
  50123. */
  50124. static readonly CUT: number;
  50125. /**
  50126. * The clipboard event is fired when a paste command is active (pressed).
  50127. */
  50128. static readonly PASTE: number;
  50129. }
  50130. /**
  50131. * This class is used to store clipboard related info for the onClipboardObservable event.
  50132. */
  50133. export class ClipboardInfo {
  50134. /**
  50135. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50136. */
  50137. type: number;
  50138. /**
  50139. * Defines the related dom event
  50140. */
  50141. event: ClipboardEvent;
  50142. /**
  50143. *Creates an instance of ClipboardInfo.
  50144. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50145. * @param event Defines the related dom event
  50146. */
  50147. constructor(
  50148. /**
  50149. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50150. */
  50151. type: number,
  50152. /**
  50153. * Defines the related dom event
  50154. */
  50155. event: ClipboardEvent);
  50156. /**
  50157. * Get the clipboard event's type from the keycode.
  50158. * @param keyCode Defines the keyCode for the current keyboard event.
  50159. * @return {number}
  50160. */
  50161. static GetTypeFromCharacter(keyCode: number): number;
  50162. }
  50163. }
  50164. declare module "babylonjs/Events/index" {
  50165. export * from "babylonjs/Events/keyboardEvents";
  50166. export * from "babylonjs/Events/pointerEvents";
  50167. export * from "babylonjs/Events/clipboardEvents";
  50168. }
  50169. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50170. import { Scene } from "babylonjs/scene";
  50171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50172. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50173. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50174. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50175. /**
  50176. * Google Daydream controller
  50177. */
  50178. export class DaydreamController extends WebVRController {
  50179. /**
  50180. * Base Url for the controller model.
  50181. */
  50182. static MODEL_BASE_URL: string;
  50183. /**
  50184. * File name for the controller model.
  50185. */
  50186. static MODEL_FILENAME: string;
  50187. /**
  50188. * Gamepad Id prefix used to identify Daydream Controller.
  50189. */
  50190. static readonly GAMEPAD_ID_PREFIX: string;
  50191. /**
  50192. * Creates a new DaydreamController from a gamepad
  50193. * @param vrGamepad the gamepad that the controller should be created from
  50194. */
  50195. constructor(vrGamepad: any);
  50196. /**
  50197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50198. * @param scene scene in which to add meshes
  50199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50200. */
  50201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50202. /**
  50203. * Called once for each button that changed state since the last frame
  50204. * @param buttonIdx Which button index changed
  50205. * @param state New state of the button
  50206. * @param changes Which properties on the state changed since last frame
  50207. */
  50208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50209. }
  50210. }
  50211. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50212. import { Scene } from "babylonjs/scene";
  50213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50214. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50215. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50216. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50217. /**
  50218. * Gear VR Controller
  50219. */
  50220. export class GearVRController extends WebVRController {
  50221. /**
  50222. * Base Url for the controller model.
  50223. */
  50224. static MODEL_BASE_URL: string;
  50225. /**
  50226. * File name for the controller model.
  50227. */
  50228. static MODEL_FILENAME: string;
  50229. /**
  50230. * Gamepad Id prefix used to identify this controller.
  50231. */
  50232. static readonly GAMEPAD_ID_PREFIX: string;
  50233. private readonly _buttonIndexToObservableNameMap;
  50234. /**
  50235. * Creates a new GearVRController from a gamepad
  50236. * @param vrGamepad the gamepad that the controller should be created from
  50237. */
  50238. constructor(vrGamepad: any);
  50239. /**
  50240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50241. * @param scene scene in which to add meshes
  50242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50243. */
  50244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50245. /**
  50246. * Called once for each button that changed state since the last frame
  50247. * @param buttonIdx Which button index changed
  50248. * @param state New state of the button
  50249. * @param changes Which properties on the state changed since last frame
  50250. */
  50251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50252. }
  50253. }
  50254. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50255. import { Scene } from "babylonjs/scene";
  50256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50257. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50258. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50259. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50260. /**
  50261. * Generic Controller
  50262. */
  50263. export class GenericController extends WebVRController {
  50264. /**
  50265. * Base Url for the controller model.
  50266. */
  50267. static readonly MODEL_BASE_URL: string;
  50268. /**
  50269. * File name for the controller model.
  50270. */
  50271. static readonly MODEL_FILENAME: string;
  50272. /**
  50273. * Creates a new GenericController from a gamepad
  50274. * @param vrGamepad the gamepad that the controller should be created from
  50275. */
  50276. constructor(vrGamepad: any);
  50277. /**
  50278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50279. * @param scene scene in which to add meshes
  50280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50281. */
  50282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50283. /**
  50284. * Called once for each button that changed state since the last frame
  50285. * @param buttonIdx Which button index changed
  50286. * @param state New state of the button
  50287. * @param changes Which properties on the state changed since last frame
  50288. */
  50289. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50290. }
  50291. }
  50292. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50293. import { Observable } from "babylonjs/Misc/observable";
  50294. import { Scene } from "babylonjs/scene";
  50295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50296. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50297. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50298. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50299. /**
  50300. * Oculus Touch Controller
  50301. */
  50302. export class OculusTouchController extends WebVRController {
  50303. /**
  50304. * Base Url for the controller model.
  50305. */
  50306. static MODEL_BASE_URL: string;
  50307. /**
  50308. * File name for the left controller model.
  50309. */
  50310. static MODEL_LEFT_FILENAME: string;
  50311. /**
  50312. * File name for the right controller model.
  50313. */
  50314. static MODEL_RIGHT_FILENAME: string;
  50315. /**
  50316. * Base Url for the Quest controller model.
  50317. */
  50318. static QUEST_MODEL_BASE_URL: string;
  50319. /**
  50320. * @hidden
  50321. * If the controllers are running on a device that needs the updated Quest controller models
  50322. */
  50323. static _IsQuest: boolean;
  50324. /**
  50325. * Fired when the secondary trigger on this controller is modified
  50326. */
  50327. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50328. /**
  50329. * Fired when the thumb rest on this controller is modified
  50330. */
  50331. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50332. /**
  50333. * Creates a new OculusTouchController from a gamepad
  50334. * @param vrGamepad the gamepad that the controller should be created from
  50335. */
  50336. constructor(vrGamepad: any);
  50337. /**
  50338. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50339. * @param scene scene in which to add meshes
  50340. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50341. */
  50342. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50343. /**
  50344. * Fired when the A button on this controller is modified
  50345. */
  50346. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50347. /**
  50348. * Fired when the B button on this controller is modified
  50349. */
  50350. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50351. /**
  50352. * Fired when the X button on this controller is modified
  50353. */
  50354. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50355. /**
  50356. * Fired when the Y button on this controller is modified
  50357. */
  50358. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50359. /**
  50360. * Called once for each button that changed state since the last frame
  50361. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50362. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50363. * 2) secondary trigger (same)
  50364. * 3) A (right) X (left), touch, pressed = value
  50365. * 4) B / Y
  50366. * 5) thumb rest
  50367. * @param buttonIdx Which button index changed
  50368. * @param state New state of the button
  50369. * @param changes Which properties on the state changed since last frame
  50370. */
  50371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50372. }
  50373. }
  50374. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50375. import { Scene } from "babylonjs/scene";
  50376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50377. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50378. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50379. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50380. import { Observable } from "babylonjs/Misc/observable";
  50381. /**
  50382. * Vive Controller
  50383. */
  50384. export class ViveController extends WebVRController {
  50385. /**
  50386. * Base Url for the controller model.
  50387. */
  50388. static MODEL_BASE_URL: string;
  50389. /**
  50390. * File name for the controller model.
  50391. */
  50392. static MODEL_FILENAME: string;
  50393. /**
  50394. * Creates a new ViveController from a gamepad
  50395. * @param vrGamepad the gamepad that the controller should be created from
  50396. */
  50397. constructor(vrGamepad: any);
  50398. /**
  50399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50400. * @param scene scene in which to add meshes
  50401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50402. */
  50403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50404. /**
  50405. * Fired when the left button on this controller is modified
  50406. */
  50407. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50408. /**
  50409. * Fired when the right button on this controller is modified
  50410. */
  50411. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50412. /**
  50413. * Fired when the menu button on this controller is modified
  50414. */
  50415. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50416. /**
  50417. * Called once for each button that changed state since the last frame
  50418. * Vive mapping:
  50419. * 0: touchpad
  50420. * 1: trigger
  50421. * 2: left AND right buttons
  50422. * 3: menu button
  50423. * @param buttonIdx Which button index changed
  50424. * @param state New state of the button
  50425. * @param changes Which properties on the state changed since last frame
  50426. */
  50427. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50428. }
  50429. }
  50430. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50431. import { Observable } from "babylonjs/Misc/observable";
  50432. import { Scene } from "babylonjs/scene";
  50433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50434. import { Ray } from "babylonjs/Culling/ray";
  50435. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50436. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50437. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50438. /**
  50439. * Defines the WindowsMotionController object that the state of the windows motion controller
  50440. */
  50441. export class WindowsMotionController extends WebVRController {
  50442. /**
  50443. * The base url used to load the left and right controller models
  50444. */
  50445. static MODEL_BASE_URL: string;
  50446. /**
  50447. * The name of the left controller model file
  50448. */
  50449. static MODEL_LEFT_FILENAME: string;
  50450. /**
  50451. * The name of the right controller model file
  50452. */
  50453. static MODEL_RIGHT_FILENAME: string;
  50454. /**
  50455. * The controller name prefix for this controller type
  50456. */
  50457. static readonly GAMEPAD_ID_PREFIX: string;
  50458. /**
  50459. * The controller id pattern for this controller type
  50460. */
  50461. private static readonly GAMEPAD_ID_PATTERN;
  50462. private _loadedMeshInfo;
  50463. protected readonly _mapping: {
  50464. buttons: string[];
  50465. buttonMeshNames: {
  50466. trigger: string;
  50467. menu: string;
  50468. grip: string;
  50469. thumbstick: string;
  50470. trackpad: string;
  50471. };
  50472. buttonObservableNames: {
  50473. trigger: string;
  50474. menu: string;
  50475. grip: string;
  50476. thumbstick: string;
  50477. trackpad: string;
  50478. };
  50479. axisMeshNames: string[];
  50480. pointingPoseMeshName: string;
  50481. };
  50482. /**
  50483. * Fired when the trackpad on this controller is clicked
  50484. */
  50485. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50486. /**
  50487. * Fired when the trackpad on this controller is modified
  50488. */
  50489. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50490. /**
  50491. * The current x and y values of this controller's trackpad
  50492. */
  50493. trackpad: StickValues;
  50494. /**
  50495. * Creates a new WindowsMotionController from a gamepad
  50496. * @param vrGamepad the gamepad that the controller should be created from
  50497. */
  50498. constructor(vrGamepad: any);
  50499. /**
  50500. * Fired when the trigger on this controller is modified
  50501. */
  50502. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50503. /**
  50504. * Fired when the menu button on this controller is modified
  50505. */
  50506. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50507. /**
  50508. * Fired when the grip button on this controller is modified
  50509. */
  50510. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50511. /**
  50512. * Fired when the thumbstick button on this controller is modified
  50513. */
  50514. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50515. /**
  50516. * Fired when the touchpad button on this controller is modified
  50517. */
  50518. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50519. /**
  50520. * Fired when the touchpad values on this controller are modified
  50521. */
  50522. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50523. protected _updateTrackpad(): void;
  50524. /**
  50525. * Called once per frame by the engine.
  50526. */
  50527. update(): void;
  50528. /**
  50529. * Called once for each button that changed state since the last frame
  50530. * @param buttonIdx Which button index changed
  50531. * @param state New state of the button
  50532. * @param changes Which properties on the state changed since last frame
  50533. */
  50534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50535. /**
  50536. * Moves the buttons on the controller mesh based on their current state
  50537. * @param buttonName the name of the button to move
  50538. * @param buttonValue the value of the button which determines the buttons new position
  50539. */
  50540. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50541. /**
  50542. * Moves the axis on the controller mesh based on its current state
  50543. * @param axis the index of the axis
  50544. * @param axisValue the value of the axis which determines the meshes new position
  50545. * @hidden
  50546. */
  50547. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50548. /**
  50549. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50550. * @param scene scene in which to add meshes
  50551. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50552. */
  50553. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50554. /**
  50555. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50556. * can be transformed by button presses and axes values, based on this._mapping.
  50557. *
  50558. * @param scene scene in which the meshes exist
  50559. * @param meshes list of meshes that make up the controller model to process
  50560. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50561. */
  50562. private processModel;
  50563. private createMeshInfo;
  50564. /**
  50565. * Gets the ray of the controller in the direction the controller is pointing
  50566. * @param length the length the resulting ray should be
  50567. * @returns a ray in the direction the controller is pointing
  50568. */
  50569. getForwardRay(length?: number): Ray;
  50570. /**
  50571. * Disposes of the controller
  50572. */
  50573. dispose(): void;
  50574. }
  50575. /**
  50576. * This class represents a new windows motion controller in XR.
  50577. */
  50578. export class XRWindowsMotionController extends WindowsMotionController {
  50579. /**
  50580. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50581. */
  50582. protected readonly _mapping: {
  50583. buttons: string[];
  50584. buttonMeshNames: {
  50585. trigger: string;
  50586. menu: string;
  50587. grip: string;
  50588. thumbstick: string;
  50589. trackpad: string;
  50590. };
  50591. buttonObservableNames: {
  50592. trigger: string;
  50593. menu: string;
  50594. grip: string;
  50595. thumbstick: string;
  50596. trackpad: string;
  50597. };
  50598. axisMeshNames: string[];
  50599. pointingPoseMeshName: string;
  50600. };
  50601. /**
  50602. * Construct a new XR-Based windows motion controller
  50603. *
  50604. * @param gamepadInfo the gamepad object from the browser
  50605. */
  50606. constructor(gamepadInfo: any);
  50607. /**
  50608. * holds the thumbstick values (X,Y)
  50609. */
  50610. thumbstickValues: StickValues;
  50611. /**
  50612. * Fired when the thumbstick on this controller is clicked
  50613. */
  50614. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50615. /**
  50616. * Fired when the thumbstick on this controller is modified
  50617. */
  50618. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50619. /**
  50620. * Fired when the touchpad button on this controller is modified
  50621. */
  50622. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50623. /**
  50624. * Fired when the touchpad values on this controller are modified
  50625. */
  50626. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50627. /**
  50628. * Fired when the thumbstick button on this controller is modified
  50629. * here to prevent breaking changes
  50630. */
  50631. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50632. /**
  50633. * updating the thumbstick(!) and not the trackpad.
  50634. * This is named this way due to the difference between WebVR and XR and to avoid
  50635. * changing the parent class.
  50636. */
  50637. protected _updateTrackpad(): void;
  50638. /**
  50639. * Disposes the class with joy
  50640. */
  50641. dispose(): void;
  50642. }
  50643. }
  50644. declare module "babylonjs/Gamepads/Controllers/index" {
  50645. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50646. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50647. export * from "babylonjs/Gamepads/Controllers/genericController";
  50648. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50649. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50650. export * from "babylonjs/Gamepads/Controllers/viveController";
  50651. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50652. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50653. }
  50654. declare module "babylonjs/Gamepads/index" {
  50655. export * from "babylonjs/Gamepads/Controllers/index";
  50656. export * from "babylonjs/Gamepads/gamepad";
  50657. export * from "babylonjs/Gamepads/gamepadManager";
  50658. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50659. export * from "babylonjs/Gamepads/xboxGamepad";
  50660. export * from "babylonjs/Gamepads/dualShockGamepad";
  50661. }
  50662. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50663. import { Scene } from "babylonjs/scene";
  50664. import { Vector4 } from "babylonjs/Maths/math.vector";
  50665. import { Color4 } from "babylonjs/Maths/math.color";
  50666. import { Mesh } from "babylonjs/Meshes/mesh";
  50667. import { Nullable } from "babylonjs/types";
  50668. /**
  50669. * Class containing static functions to help procedurally build meshes
  50670. */
  50671. export class PolyhedronBuilder {
  50672. /**
  50673. * Creates a polyhedron mesh
  50674. * * 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
  50675. * * The parameter `size` (positive float, default 1) sets the polygon size
  50676. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50677. * * 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`
  50678. * * 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
  50679. * * 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)`)
  50680. * * 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
  50681. * * 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
  50682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50685. * @param name defines the name of the mesh
  50686. * @param options defines the options used to create the mesh
  50687. * @param scene defines the hosting scene
  50688. * @returns the polyhedron mesh
  50689. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50690. */
  50691. static CreatePolyhedron(name: string, options: {
  50692. type?: number;
  50693. size?: number;
  50694. sizeX?: number;
  50695. sizeY?: number;
  50696. sizeZ?: number;
  50697. custom?: any;
  50698. faceUV?: Vector4[];
  50699. faceColors?: Color4[];
  50700. flat?: boolean;
  50701. updatable?: boolean;
  50702. sideOrientation?: number;
  50703. frontUVs?: Vector4;
  50704. backUVs?: Vector4;
  50705. }, scene?: Nullable<Scene>): Mesh;
  50706. }
  50707. }
  50708. declare module "babylonjs/Gizmos/scaleGizmo" {
  50709. import { Observable } from "babylonjs/Misc/observable";
  50710. import { Nullable } from "babylonjs/types";
  50711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50713. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50714. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50715. /**
  50716. * Gizmo that enables scaling a mesh along 3 axis
  50717. */
  50718. export class ScaleGizmo extends Gizmo {
  50719. /**
  50720. * Internal gizmo used for interactions on the x axis
  50721. */
  50722. xGizmo: AxisScaleGizmo;
  50723. /**
  50724. * Internal gizmo used for interactions on the y axis
  50725. */
  50726. yGizmo: AxisScaleGizmo;
  50727. /**
  50728. * Internal gizmo used for interactions on the z axis
  50729. */
  50730. zGizmo: AxisScaleGizmo;
  50731. /**
  50732. * Internal gizmo used to scale all axis equally
  50733. */
  50734. uniformScaleGizmo: AxisScaleGizmo;
  50735. private _meshAttached;
  50736. private _updateGizmoRotationToMatchAttachedMesh;
  50737. private _snapDistance;
  50738. private _scaleRatio;
  50739. private _uniformScalingMesh;
  50740. private _octahedron;
  50741. private _sensitivity;
  50742. /** Fires an event when any of it's sub gizmos are dragged */
  50743. onDragStartObservable: Observable<unknown>;
  50744. /** Fires an event when any of it's sub gizmos are released from dragging */
  50745. onDragEndObservable: Observable<unknown>;
  50746. get attachedMesh(): Nullable<AbstractMesh>;
  50747. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50748. /**
  50749. * Creates a ScaleGizmo
  50750. * @param gizmoLayer The utility layer the gizmo will be added to
  50751. */
  50752. constructor(gizmoLayer?: UtilityLayerRenderer);
  50753. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50754. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50755. /**
  50756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50757. */
  50758. set snapDistance(value: number);
  50759. get snapDistance(): number;
  50760. /**
  50761. * Ratio for the scale of the gizmo (Default: 1)
  50762. */
  50763. set scaleRatio(value: number);
  50764. get scaleRatio(): number;
  50765. /**
  50766. * Sensitivity factor for dragging (Default: 1)
  50767. */
  50768. set sensitivity(value: number);
  50769. get sensitivity(): number;
  50770. /**
  50771. * Disposes of the gizmo
  50772. */
  50773. dispose(): void;
  50774. }
  50775. }
  50776. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50777. import { Observable } from "babylonjs/Misc/observable";
  50778. import { Nullable } from "babylonjs/types";
  50779. import { Vector3 } from "babylonjs/Maths/math.vector";
  50780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50781. import { Mesh } from "babylonjs/Meshes/mesh";
  50782. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50783. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50784. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50785. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50786. import { Color3 } from "babylonjs/Maths/math.color";
  50787. /**
  50788. * Single axis scale gizmo
  50789. */
  50790. export class AxisScaleGizmo extends Gizmo {
  50791. /**
  50792. * Drag behavior responsible for the gizmos dragging interactions
  50793. */
  50794. dragBehavior: PointerDragBehavior;
  50795. private _pointerObserver;
  50796. /**
  50797. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50798. */
  50799. snapDistance: number;
  50800. /**
  50801. * Event that fires each time the gizmo snaps to a new location.
  50802. * * snapDistance is the the change in distance
  50803. */
  50804. onSnapObservable: Observable<{
  50805. snapDistance: number;
  50806. }>;
  50807. /**
  50808. * If the scaling operation should be done on all axis (default: false)
  50809. */
  50810. uniformScaling: boolean;
  50811. /**
  50812. * Custom sensitivity value for the drag strength
  50813. */
  50814. sensitivity: number;
  50815. private _isEnabled;
  50816. private _parent;
  50817. private _arrow;
  50818. private _coloredMaterial;
  50819. private _hoverMaterial;
  50820. /**
  50821. * Creates an AxisScaleGizmo
  50822. * @param gizmoLayer The utility layer the gizmo will be added to
  50823. * @param dragAxis The axis which the gizmo will be able to scale on
  50824. * @param color The color of the gizmo
  50825. */
  50826. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50827. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50828. /**
  50829. * If the gizmo is enabled
  50830. */
  50831. set isEnabled(value: boolean);
  50832. get isEnabled(): boolean;
  50833. /**
  50834. * Disposes of the gizmo
  50835. */
  50836. dispose(): void;
  50837. /**
  50838. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50839. * @param mesh The mesh to replace the default mesh of the gizmo
  50840. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50841. */
  50842. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50843. }
  50844. }
  50845. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50846. import { Observable } from "babylonjs/Misc/observable";
  50847. import { Nullable } from "babylonjs/types";
  50848. import { Vector3 } from "babylonjs/Maths/math.vector";
  50849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50850. import { Mesh } from "babylonjs/Meshes/mesh";
  50851. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50852. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50853. import { Color3 } from "babylonjs/Maths/math.color";
  50854. import "babylonjs/Meshes/Builders/boxBuilder";
  50855. /**
  50856. * Bounding box gizmo
  50857. */
  50858. export class BoundingBoxGizmo extends Gizmo {
  50859. private _lineBoundingBox;
  50860. private _rotateSpheresParent;
  50861. private _scaleBoxesParent;
  50862. private _boundingDimensions;
  50863. private _renderObserver;
  50864. private _pointerObserver;
  50865. private _scaleDragSpeed;
  50866. private _tmpQuaternion;
  50867. private _tmpVector;
  50868. private _tmpRotationMatrix;
  50869. /**
  50870. * 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)
  50871. */
  50872. ignoreChildren: boolean;
  50873. /**
  50874. * 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)
  50875. */
  50876. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50877. /**
  50878. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50879. */
  50880. rotationSphereSize: number;
  50881. /**
  50882. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50883. */
  50884. scaleBoxSize: number;
  50885. /**
  50886. * 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)
  50887. */
  50888. fixedDragMeshScreenSize: boolean;
  50889. /**
  50890. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50891. */
  50892. fixedDragMeshScreenSizeDistanceFactor: number;
  50893. /**
  50894. * Fired when a rotation sphere or scale box is dragged
  50895. */
  50896. onDragStartObservable: Observable<{}>;
  50897. /**
  50898. * Fired when a scale box is dragged
  50899. */
  50900. onScaleBoxDragObservable: Observable<{}>;
  50901. /**
  50902. * Fired when a scale box drag is ended
  50903. */
  50904. onScaleBoxDragEndObservable: Observable<{}>;
  50905. /**
  50906. * Fired when a rotation sphere is dragged
  50907. */
  50908. onRotationSphereDragObservable: Observable<{}>;
  50909. /**
  50910. * Fired when a rotation sphere drag is ended
  50911. */
  50912. onRotationSphereDragEndObservable: Observable<{}>;
  50913. /**
  50914. * 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)
  50915. */
  50916. scalePivot: Nullable<Vector3>;
  50917. /**
  50918. * Mesh used as a pivot to rotate the attached mesh
  50919. */
  50920. private _anchorMesh;
  50921. private _existingMeshScale;
  50922. private _dragMesh;
  50923. private pointerDragBehavior;
  50924. private coloredMaterial;
  50925. private hoverColoredMaterial;
  50926. /**
  50927. * Sets the color of the bounding box gizmo
  50928. * @param color the color to set
  50929. */
  50930. setColor(color: Color3): void;
  50931. /**
  50932. * Creates an BoundingBoxGizmo
  50933. * @param gizmoLayer The utility layer the gizmo will be added to
  50934. * @param color The color of the gizmo
  50935. */
  50936. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50937. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50938. private _selectNode;
  50939. /**
  50940. * Updates the bounding box information for the Gizmo
  50941. */
  50942. updateBoundingBox(): void;
  50943. private _updateRotationSpheres;
  50944. private _updateScaleBoxes;
  50945. /**
  50946. * Enables rotation on the specified axis and disables rotation on the others
  50947. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50948. */
  50949. setEnabledRotationAxis(axis: string): void;
  50950. /**
  50951. * Enables/disables scaling
  50952. * @param enable if scaling should be enabled
  50953. * @param homogeneousScaling defines if scaling should only be homogeneous
  50954. */
  50955. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50956. private _updateDummy;
  50957. /**
  50958. * Enables a pointer drag behavior on the bounding box of the gizmo
  50959. */
  50960. enableDragBehavior(): void;
  50961. /**
  50962. * Disposes of the gizmo
  50963. */
  50964. dispose(): void;
  50965. /**
  50966. * 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)
  50967. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50968. * @returns the bounding box mesh with the passed in mesh as a child
  50969. */
  50970. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50971. /**
  50972. * CustomMeshes are not supported by this gizmo
  50973. * @param mesh The mesh to replace the default mesh of the gizmo
  50974. */
  50975. setCustomMesh(mesh: Mesh): void;
  50976. }
  50977. }
  50978. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50979. import { Observable } from "babylonjs/Misc/observable";
  50980. import { Nullable } from "babylonjs/types";
  50981. import { Vector3 } from "babylonjs/Maths/math.vector";
  50982. import { Color3 } from "babylonjs/Maths/math.color";
  50983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50984. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50985. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50986. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50987. import "babylonjs/Meshes/Builders/linesBuilder";
  50988. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50989. /**
  50990. * Single plane rotation gizmo
  50991. */
  50992. export class PlaneRotationGizmo extends Gizmo {
  50993. /**
  50994. * Drag behavior responsible for the gizmos dragging interactions
  50995. */
  50996. dragBehavior: PointerDragBehavior;
  50997. private _pointerObserver;
  50998. /**
  50999. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51000. */
  51001. snapDistance: number;
  51002. /**
  51003. * Event that fires each time the gizmo snaps to a new location.
  51004. * * snapDistance is the the change in distance
  51005. */
  51006. onSnapObservable: Observable<{
  51007. snapDistance: number;
  51008. }>;
  51009. private _isEnabled;
  51010. private _parent;
  51011. /**
  51012. * Creates a PlaneRotationGizmo
  51013. * @param gizmoLayer The utility layer the gizmo will be added to
  51014. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51015. * @param color The color of the gizmo
  51016. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51017. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51018. */
  51019. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51021. /**
  51022. * If the gizmo is enabled
  51023. */
  51024. set isEnabled(value: boolean);
  51025. get isEnabled(): boolean;
  51026. /**
  51027. * Disposes of the gizmo
  51028. */
  51029. dispose(): void;
  51030. }
  51031. }
  51032. declare module "babylonjs/Gizmos/rotationGizmo" {
  51033. import { Observable } from "babylonjs/Misc/observable";
  51034. import { Nullable } from "babylonjs/types";
  51035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51036. import { Mesh } from "babylonjs/Meshes/mesh";
  51037. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51038. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51039. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51040. /**
  51041. * Gizmo that enables rotating a mesh along 3 axis
  51042. */
  51043. export class RotationGizmo extends Gizmo {
  51044. /**
  51045. * Internal gizmo used for interactions on the x axis
  51046. */
  51047. xGizmo: PlaneRotationGizmo;
  51048. /**
  51049. * Internal gizmo used for interactions on the y axis
  51050. */
  51051. yGizmo: PlaneRotationGizmo;
  51052. /**
  51053. * Internal gizmo used for interactions on the z axis
  51054. */
  51055. zGizmo: PlaneRotationGizmo;
  51056. /** Fires an event when any of it's sub gizmos are dragged */
  51057. onDragStartObservable: Observable<unknown>;
  51058. /** Fires an event when any of it's sub gizmos are released from dragging */
  51059. onDragEndObservable: Observable<unknown>;
  51060. private _meshAttached;
  51061. get attachedMesh(): Nullable<AbstractMesh>;
  51062. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51063. /**
  51064. * Creates a RotationGizmo
  51065. * @param gizmoLayer The utility layer the gizmo will be added to
  51066. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51067. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51068. */
  51069. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51070. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51071. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51072. /**
  51073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51074. */
  51075. set snapDistance(value: number);
  51076. get snapDistance(): number;
  51077. /**
  51078. * Ratio for the scale of the gizmo (Default: 1)
  51079. */
  51080. set scaleRatio(value: number);
  51081. get scaleRatio(): number;
  51082. /**
  51083. * Disposes of the gizmo
  51084. */
  51085. dispose(): void;
  51086. /**
  51087. * CustomMeshes are not supported by this gizmo
  51088. * @param mesh The mesh to replace the default mesh of the gizmo
  51089. */
  51090. setCustomMesh(mesh: Mesh): void;
  51091. }
  51092. }
  51093. declare module "babylonjs/Gizmos/gizmoManager" {
  51094. import { Observable } from "babylonjs/Misc/observable";
  51095. import { Nullable } from "babylonjs/types";
  51096. import { Scene, IDisposable } from "babylonjs/scene";
  51097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51098. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51099. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51100. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51101. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51102. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51103. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51104. /**
  51105. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51106. */
  51107. export class GizmoManager implements IDisposable {
  51108. private scene;
  51109. /**
  51110. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51111. */
  51112. gizmos: {
  51113. positionGizmo: Nullable<PositionGizmo>;
  51114. rotationGizmo: Nullable<RotationGizmo>;
  51115. scaleGizmo: Nullable<ScaleGizmo>;
  51116. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51117. };
  51118. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51119. clearGizmoOnEmptyPointerEvent: boolean;
  51120. /** Fires an event when the manager is attached to a mesh */
  51121. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51122. private _gizmosEnabled;
  51123. private _pointerObserver;
  51124. private _attachedMesh;
  51125. private _boundingBoxColor;
  51126. private _defaultUtilityLayer;
  51127. private _defaultKeepDepthUtilityLayer;
  51128. /**
  51129. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51130. */
  51131. boundingBoxDragBehavior: SixDofDragBehavior;
  51132. /**
  51133. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51134. */
  51135. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51136. /**
  51137. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51138. */
  51139. usePointerToAttachGizmos: boolean;
  51140. /**
  51141. * Utility layer that the bounding box gizmo belongs to
  51142. */
  51143. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51144. /**
  51145. * Utility layer that all gizmos besides bounding box belong to
  51146. */
  51147. get utilityLayer(): UtilityLayerRenderer;
  51148. /**
  51149. * Instatiates a gizmo manager
  51150. * @param scene the scene to overlay the gizmos on top of
  51151. */
  51152. constructor(scene: Scene);
  51153. /**
  51154. * Attaches a set of gizmos to the specified mesh
  51155. * @param mesh The mesh the gizmo's should be attached to
  51156. */
  51157. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51158. /**
  51159. * If the position gizmo is enabled
  51160. */
  51161. set positionGizmoEnabled(value: boolean);
  51162. get positionGizmoEnabled(): boolean;
  51163. /**
  51164. * If the rotation gizmo is enabled
  51165. */
  51166. set rotationGizmoEnabled(value: boolean);
  51167. get rotationGizmoEnabled(): boolean;
  51168. /**
  51169. * If the scale gizmo is enabled
  51170. */
  51171. set scaleGizmoEnabled(value: boolean);
  51172. get scaleGizmoEnabled(): boolean;
  51173. /**
  51174. * If the boundingBox gizmo is enabled
  51175. */
  51176. set boundingBoxGizmoEnabled(value: boolean);
  51177. get boundingBoxGizmoEnabled(): boolean;
  51178. /**
  51179. * Disposes of the gizmo manager
  51180. */
  51181. dispose(): void;
  51182. }
  51183. }
  51184. declare module "babylonjs/Lights/directionalLight" {
  51185. import { Camera } from "babylonjs/Cameras/camera";
  51186. import { Scene } from "babylonjs/scene";
  51187. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51189. import { Light } from "babylonjs/Lights/light";
  51190. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51191. import { Effect } from "babylonjs/Materials/effect";
  51192. /**
  51193. * A directional light is defined by a direction (what a surprise!).
  51194. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51195. * 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.
  51196. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51197. */
  51198. export class DirectionalLight extends ShadowLight {
  51199. private _shadowFrustumSize;
  51200. /**
  51201. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51202. */
  51203. get shadowFrustumSize(): number;
  51204. /**
  51205. * Specifies a fix frustum size for the shadow generation.
  51206. */
  51207. set shadowFrustumSize(value: number);
  51208. private _shadowOrthoScale;
  51209. /**
  51210. * Gets the shadow projection scale against the optimal computed one.
  51211. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51212. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51213. */
  51214. get shadowOrthoScale(): number;
  51215. /**
  51216. * Sets the shadow projection scale against the optimal computed one.
  51217. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51218. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51219. */
  51220. set shadowOrthoScale(value: number);
  51221. /**
  51222. * Automatically compute the projection matrix to best fit (including all the casters)
  51223. * on each frame.
  51224. */
  51225. autoUpdateExtends: boolean;
  51226. /**
  51227. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51228. * on each frame. autoUpdateExtends must be set to true for this to work
  51229. */
  51230. autoCalcShadowZBounds: boolean;
  51231. private _orthoLeft;
  51232. private _orthoRight;
  51233. private _orthoTop;
  51234. private _orthoBottom;
  51235. /**
  51236. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51237. * The directional light is emitted from everywhere in the given direction.
  51238. * It can cast shadows.
  51239. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51240. * @param name The friendly name of the light
  51241. * @param direction The direction of the light
  51242. * @param scene The scene the light belongs to
  51243. */
  51244. constructor(name: string, direction: Vector3, scene: Scene);
  51245. /**
  51246. * Returns the string "DirectionalLight".
  51247. * @return The class name
  51248. */
  51249. getClassName(): string;
  51250. /**
  51251. * Returns the integer 1.
  51252. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51253. */
  51254. getTypeID(): number;
  51255. /**
  51256. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51257. * Returns the DirectionalLight Shadow projection matrix.
  51258. */
  51259. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51260. /**
  51261. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51262. * Returns the DirectionalLight Shadow projection matrix.
  51263. */
  51264. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51265. /**
  51266. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51267. * Returns the DirectionalLight Shadow projection matrix.
  51268. */
  51269. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51270. protected _buildUniformLayout(): void;
  51271. /**
  51272. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51273. * @param effect The effect to update
  51274. * @param lightIndex The index of the light in the effect to update
  51275. * @returns The directional light
  51276. */
  51277. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51279. /**
  51280. * Gets the minZ used for shadow according to both the scene and the light.
  51281. *
  51282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51284. * @param activeCamera The camera we are returning the min for
  51285. * @returns the depth min z
  51286. */
  51287. getDepthMinZ(activeCamera: Camera): number;
  51288. /**
  51289. * Gets the maxZ used for shadow according to both the scene and the light.
  51290. *
  51291. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51292. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51293. * @param activeCamera The camera we are returning the max for
  51294. * @returns the depth max z
  51295. */
  51296. getDepthMaxZ(activeCamera: Camera): number;
  51297. /**
  51298. * Prepares the list of defines specific to the light type.
  51299. * @param defines the list of defines
  51300. * @param lightIndex defines the index of the light for the effect
  51301. */
  51302. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51303. }
  51304. }
  51305. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51306. import { Mesh } from "babylonjs/Meshes/mesh";
  51307. /**
  51308. * Class containing static functions to help procedurally build meshes
  51309. */
  51310. export class HemisphereBuilder {
  51311. /**
  51312. * Creates a hemisphere mesh
  51313. * @param name defines the name of the mesh
  51314. * @param options defines the options used to create the mesh
  51315. * @param scene defines the hosting scene
  51316. * @returns the hemisphere mesh
  51317. */
  51318. static CreateHemisphere(name: string, options: {
  51319. segments?: number;
  51320. diameter?: number;
  51321. sideOrientation?: number;
  51322. }, scene: any): Mesh;
  51323. }
  51324. }
  51325. declare module "babylonjs/Lights/spotLight" {
  51326. import { Nullable } from "babylonjs/types";
  51327. import { Scene } from "babylonjs/scene";
  51328. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51330. import { Effect } from "babylonjs/Materials/effect";
  51331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51332. import { Light } from "babylonjs/Lights/light";
  51333. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51334. /**
  51335. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51336. * These values define a cone of light starting from the position, emitting toward the direction.
  51337. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51338. * and the exponent defines the speed of the decay of the light with distance (reach).
  51339. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51340. */
  51341. export class SpotLight extends ShadowLight {
  51342. private _angle;
  51343. private _innerAngle;
  51344. private _cosHalfAngle;
  51345. private _lightAngleScale;
  51346. private _lightAngleOffset;
  51347. /**
  51348. * Gets the cone angle of the spot light in Radians.
  51349. */
  51350. get angle(): number;
  51351. /**
  51352. * Sets the cone angle of the spot light in Radians.
  51353. */
  51354. set angle(value: number);
  51355. /**
  51356. * Only used in gltf falloff mode, this defines the angle where
  51357. * the directional falloff will start before cutting at angle which could be seen
  51358. * as outer angle.
  51359. */
  51360. get innerAngle(): number;
  51361. /**
  51362. * Only used in gltf falloff mode, this defines the angle where
  51363. * the directional falloff will start before cutting at angle which could be seen
  51364. * as outer angle.
  51365. */
  51366. set innerAngle(value: number);
  51367. private _shadowAngleScale;
  51368. /**
  51369. * Allows scaling the angle of the light for shadow generation only.
  51370. */
  51371. get shadowAngleScale(): number;
  51372. /**
  51373. * Allows scaling the angle of the light for shadow generation only.
  51374. */
  51375. set shadowAngleScale(value: number);
  51376. /**
  51377. * The light decay speed with the distance from the emission spot.
  51378. */
  51379. exponent: number;
  51380. private _projectionTextureMatrix;
  51381. /**
  51382. * Allows reading the projecton texture
  51383. */
  51384. get projectionTextureMatrix(): Matrix;
  51385. protected _projectionTextureLightNear: number;
  51386. /**
  51387. * Gets the near clip of the Spotlight for texture projection.
  51388. */
  51389. get projectionTextureLightNear(): number;
  51390. /**
  51391. * Sets the near clip of the Spotlight for texture projection.
  51392. */
  51393. set projectionTextureLightNear(value: number);
  51394. protected _projectionTextureLightFar: number;
  51395. /**
  51396. * Gets the far clip of the Spotlight for texture projection.
  51397. */
  51398. get projectionTextureLightFar(): number;
  51399. /**
  51400. * Sets the far clip of the Spotlight for texture projection.
  51401. */
  51402. set projectionTextureLightFar(value: number);
  51403. protected _projectionTextureUpDirection: Vector3;
  51404. /**
  51405. * Gets the Up vector of the Spotlight for texture projection.
  51406. */
  51407. get projectionTextureUpDirection(): Vector3;
  51408. /**
  51409. * Sets the Up vector of the Spotlight for texture projection.
  51410. */
  51411. set projectionTextureUpDirection(value: Vector3);
  51412. private _projectionTexture;
  51413. /**
  51414. * Gets the projection texture of the light.
  51415. */
  51416. get projectionTexture(): Nullable<BaseTexture>;
  51417. /**
  51418. * Sets the projection texture of the light.
  51419. */
  51420. set projectionTexture(value: Nullable<BaseTexture>);
  51421. private _projectionTextureViewLightDirty;
  51422. private _projectionTextureProjectionLightDirty;
  51423. private _projectionTextureDirty;
  51424. private _projectionTextureViewTargetVector;
  51425. private _projectionTextureViewLightMatrix;
  51426. private _projectionTextureProjectionLightMatrix;
  51427. private _projectionTextureScalingMatrix;
  51428. /**
  51429. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51430. * It can cast shadows.
  51431. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51432. * @param name The light friendly name
  51433. * @param position The position of the spot light in the scene
  51434. * @param direction The direction of the light in the scene
  51435. * @param angle The cone angle of the light in Radians
  51436. * @param exponent The light decay speed with the distance from the emission spot
  51437. * @param scene The scene the lights belongs to
  51438. */
  51439. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51440. /**
  51441. * Returns the string "SpotLight".
  51442. * @returns the class name
  51443. */
  51444. getClassName(): string;
  51445. /**
  51446. * Returns the integer 2.
  51447. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51448. */
  51449. getTypeID(): number;
  51450. /**
  51451. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51452. */
  51453. protected _setDirection(value: Vector3): void;
  51454. /**
  51455. * Overrides the position setter to recompute the projection texture view light Matrix.
  51456. */
  51457. protected _setPosition(value: Vector3): void;
  51458. /**
  51459. * 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.
  51460. * Returns the SpotLight.
  51461. */
  51462. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51463. protected _computeProjectionTextureViewLightMatrix(): void;
  51464. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51465. /**
  51466. * Main function for light texture projection matrix computing.
  51467. */
  51468. protected _computeProjectionTextureMatrix(): void;
  51469. protected _buildUniformLayout(): void;
  51470. private _computeAngleValues;
  51471. /**
  51472. * Sets the passed Effect "effect" with the Light textures.
  51473. * @param effect The effect to update
  51474. * @param lightIndex The index of the light in the effect to update
  51475. * @returns The light
  51476. */
  51477. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51478. /**
  51479. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51480. * @param effect The effect to update
  51481. * @param lightIndex The index of the light in the effect to update
  51482. * @returns The spot light
  51483. */
  51484. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51485. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51486. /**
  51487. * Disposes the light and the associated resources.
  51488. */
  51489. dispose(): void;
  51490. /**
  51491. * Prepares the list of defines specific to the light type.
  51492. * @param defines the list of defines
  51493. * @param lightIndex defines the index of the light for the effect
  51494. */
  51495. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51496. }
  51497. }
  51498. declare module "babylonjs/Gizmos/lightGizmo" {
  51499. import { Nullable } from "babylonjs/types";
  51500. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51501. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51502. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51503. import { Light } from "babylonjs/Lights/light";
  51504. /**
  51505. * Gizmo that enables viewing a light
  51506. */
  51507. export class LightGizmo extends Gizmo {
  51508. private _lightMesh;
  51509. private _material;
  51510. private _cachedPosition;
  51511. private _cachedForward;
  51512. private _attachedMeshParent;
  51513. /**
  51514. * Creates a LightGizmo
  51515. * @param gizmoLayer The utility layer the gizmo will be added to
  51516. */
  51517. constructor(gizmoLayer?: UtilityLayerRenderer);
  51518. private _light;
  51519. /**
  51520. * The light that the gizmo is attached to
  51521. */
  51522. set light(light: Nullable<Light>);
  51523. get light(): Nullable<Light>;
  51524. /**
  51525. * Gets the material used to render the light gizmo
  51526. */
  51527. get material(): StandardMaterial;
  51528. /**
  51529. * @hidden
  51530. * Updates the gizmo to match the attached mesh's position/rotation
  51531. */
  51532. protected _update(): void;
  51533. private static _Scale;
  51534. /**
  51535. * Creates the lines for a light mesh
  51536. */
  51537. private static _CreateLightLines;
  51538. /**
  51539. * Disposes of the light gizmo
  51540. */
  51541. dispose(): void;
  51542. private static _CreateHemisphericLightMesh;
  51543. private static _CreatePointLightMesh;
  51544. private static _CreateSpotLightMesh;
  51545. private static _CreateDirectionalLightMesh;
  51546. }
  51547. }
  51548. declare module "babylonjs/Gizmos/index" {
  51549. export * from "babylonjs/Gizmos/axisDragGizmo";
  51550. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51551. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51552. export * from "babylonjs/Gizmos/gizmo";
  51553. export * from "babylonjs/Gizmos/gizmoManager";
  51554. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51555. export * from "babylonjs/Gizmos/positionGizmo";
  51556. export * from "babylonjs/Gizmos/rotationGizmo";
  51557. export * from "babylonjs/Gizmos/scaleGizmo";
  51558. export * from "babylonjs/Gizmos/lightGizmo";
  51559. export * from "babylonjs/Gizmos/planeDragGizmo";
  51560. }
  51561. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51562. /** @hidden */
  51563. export var backgroundFragmentDeclaration: {
  51564. name: string;
  51565. shader: string;
  51566. };
  51567. }
  51568. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51569. /** @hidden */
  51570. export var backgroundUboDeclaration: {
  51571. name: string;
  51572. shader: string;
  51573. };
  51574. }
  51575. declare module "babylonjs/Shaders/background.fragment" {
  51576. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51577. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51578. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51579. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51580. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51581. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51582. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51583. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51584. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51585. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51586. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51587. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51589. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51590. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51591. /** @hidden */
  51592. export var backgroundPixelShader: {
  51593. name: string;
  51594. shader: string;
  51595. };
  51596. }
  51597. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51598. /** @hidden */
  51599. export var backgroundVertexDeclaration: {
  51600. name: string;
  51601. shader: string;
  51602. };
  51603. }
  51604. declare module "babylonjs/Shaders/background.vertex" {
  51605. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51606. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51607. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51608. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51610. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51611. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51612. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51613. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51614. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51615. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51616. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51617. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51618. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51619. /** @hidden */
  51620. export var backgroundVertexShader: {
  51621. name: string;
  51622. shader: string;
  51623. };
  51624. }
  51625. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51626. import { Nullable, int, float } from "babylonjs/types";
  51627. import { Scene } from "babylonjs/scene";
  51628. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51631. import { Mesh } from "babylonjs/Meshes/mesh";
  51632. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51633. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51634. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51636. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51637. import { Color3 } from "babylonjs/Maths/math.color";
  51638. import "babylonjs/Shaders/background.fragment";
  51639. import "babylonjs/Shaders/background.vertex";
  51640. /**
  51641. * Background material used to create an efficient environement around your scene.
  51642. */
  51643. export class BackgroundMaterial extends PushMaterial {
  51644. /**
  51645. * Standard reflectance value at parallel view angle.
  51646. */
  51647. static StandardReflectance0: number;
  51648. /**
  51649. * Standard reflectance value at grazing angle.
  51650. */
  51651. static StandardReflectance90: number;
  51652. protected _primaryColor: Color3;
  51653. /**
  51654. * Key light Color (multiply against the environement texture)
  51655. */
  51656. primaryColor: Color3;
  51657. protected __perceptualColor: Nullable<Color3>;
  51658. /**
  51659. * Experimental Internal Use Only.
  51660. *
  51661. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51662. * This acts as a helper to set the primary color to a more "human friendly" value.
  51663. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51664. * output color as close as possible from the chosen value.
  51665. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51666. * part of lighting setup.)
  51667. */
  51668. get _perceptualColor(): Nullable<Color3>;
  51669. set _perceptualColor(value: Nullable<Color3>);
  51670. protected _primaryColorShadowLevel: float;
  51671. /**
  51672. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51673. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51674. */
  51675. get primaryColorShadowLevel(): float;
  51676. set primaryColorShadowLevel(value: float);
  51677. protected _primaryColorHighlightLevel: float;
  51678. /**
  51679. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51680. * The primary color is used at the level chosen to define what the white area would look.
  51681. */
  51682. get primaryColorHighlightLevel(): float;
  51683. set primaryColorHighlightLevel(value: float);
  51684. protected _reflectionTexture: Nullable<BaseTexture>;
  51685. /**
  51686. * Reflection Texture used in the material.
  51687. * Should be author in a specific way for the best result (refer to the documentation).
  51688. */
  51689. reflectionTexture: Nullable<BaseTexture>;
  51690. protected _reflectionBlur: float;
  51691. /**
  51692. * Reflection Texture level of blur.
  51693. *
  51694. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51695. * texture twice.
  51696. */
  51697. reflectionBlur: float;
  51698. protected _diffuseTexture: Nullable<BaseTexture>;
  51699. /**
  51700. * Diffuse Texture used in the material.
  51701. * Should be author in a specific way for the best result (refer to the documentation).
  51702. */
  51703. diffuseTexture: Nullable<BaseTexture>;
  51704. protected _shadowLights: Nullable<IShadowLight[]>;
  51705. /**
  51706. * Specify the list of lights casting shadow on the material.
  51707. * All scene shadow lights will be included if null.
  51708. */
  51709. shadowLights: Nullable<IShadowLight[]>;
  51710. protected _shadowLevel: float;
  51711. /**
  51712. * Helps adjusting the shadow to a softer level if required.
  51713. * 0 means black shadows and 1 means no shadows.
  51714. */
  51715. shadowLevel: float;
  51716. protected _sceneCenter: Vector3;
  51717. /**
  51718. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51719. * It is usually zero but might be interesting to modify according to your setup.
  51720. */
  51721. sceneCenter: Vector3;
  51722. protected _opacityFresnel: boolean;
  51723. /**
  51724. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51725. * This helps ensuring a nice transition when the camera goes under the ground.
  51726. */
  51727. opacityFresnel: boolean;
  51728. protected _reflectionFresnel: boolean;
  51729. /**
  51730. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51731. * This helps adding a mirror texture on the ground.
  51732. */
  51733. reflectionFresnel: boolean;
  51734. protected _reflectionFalloffDistance: number;
  51735. /**
  51736. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51737. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51738. */
  51739. reflectionFalloffDistance: number;
  51740. protected _reflectionAmount: number;
  51741. /**
  51742. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51743. */
  51744. reflectionAmount: number;
  51745. protected _reflectionReflectance0: number;
  51746. /**
  51747. * This specifies the weight of the reflection at grazing angle.
  51748. */
  51749. reflectionReflectance0: number;
  51750. protected _reflectionReflectance90: number;
  51751. /**
  51752. * This specifies the weight of the reflection at a perpendicular point of view.
  51753. */
  51754. reflectionReflectance90: number;
  51755. /**
  51756. * Sets the reflection reflectance fresnel values according to the default standard
  51757. * empirically know to work well :-)
  51758. */
  51759. set reflectionStandardFresnelWeight(value: number);
  51760. protected _useRGBColor: boolean;
  51761. /**
  51762. * Helps to directly use the maps channels instead of their level.
  51763. */
  51764. useRGBColor: boolean;
  51765. protected _enableNoise: boolean;
  51766. /**
  51767. * This helps reducing the banding effect that could occur on the background.
  51768. */
  51769. enableNoise: boolean;
  51770. /**
  51771. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51772. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51773. * Recommended to be keep at 1.0 except for special cases.
  51774. */
  51775. get fovMultiplier(): number;
  51776. set fovMultiplier(value: number);
  51777. private _fovMultiplier;
  51778. /**
  51779. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51780. */
  51781. useEquirectangularFOV: boolean;
  51782. private _maxSimultaneousLights;
  51783. /**
  51784. * Number of Simultaneous lights allowed on the material.
  51785. */
  51786. maxSimultaneousLights: int;
  51787. /**
  51788. * Default configuration related to image processing available in the Background Material.
  51789. */
  51790. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51791. /**
  51792. * Keep track of the image processing observer to allow dispose and replace.
  51793. */
  51794. private _imageProcessingObserver;
  51795. /**
  51796. * Attaches a new image processing configuration to the PBR Material.
  51797. * @param configuration (if null the scene configuration will be use)
  51798. */
  51799. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51800. /**
  51801. * Gets the image processing configuration used either in this material.
  51802. */
  51803. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51804. /**
  51805. * Sets the Default image processing configuration used either in the this material.
  51806. *
  51807. * If sets to null, the scene one is in use.
  51808. */
  51809. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51810. /**
  51811. * Gets wether the color curves effect is enabled.
  51812. */
  51813. get cameraColorCurvesEnabled(): boolean;
  51814. /**
  51815. * Sets wether the color curves effect is enabled.
  51816. */
  51817. set cameraColorCurvesEnabled(value: boolean);
  51818. /**
  51819. * Gets wether the color grading effect is enabled.
  51820. */
  51821. get cameraColorGradingEnabled(): boolean;
  51822. /**
  51823. * Gets wether the color grading effect is enabled.
  51824. */
  51825. set cameraColorGradingEnabled(value: boolean);
  51826. /**
  51827. * Gets wether tonemapping is enabled or not.
  51828. */
  51829. get cameraToneMappingEnabled(): boolean;
  51830. /**
  51831. * Sets wether tonemapping is enabled or not
  51832. */
  51833. set cameraToneMappingEnabled(value: boolean);
  51834. /**
  51835. * The camera exposure used on this material.
  51836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51837. * This corresponds to a photographic exposure.
  51838. */
  51839. get cameraExposure(): float;
  51840. /**
  51841. * The camera exposure used on this material.
  51842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51843. * This corresponds to a photographic exposure.
  51844. */
  51845. set cameraExposure(value: float);
  51846. /**
  51847. * Gets The camera contrast used on this material.
  51848. */
  51849. get cameraContrast(): float;
  51850. /**
  51851. * Sets The camera contrast used on this material.
  51852. */
  51853. set cameraContrast(value: float);
  51854. /**
  51855. * Gets the Color Grading 2D Lookup Texture.
  51856. */
  51857. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51858. /**
  51859. * Sets the Color Grading 2D Lookup Texture.
  51860. */
  51861. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51862. /**
  51863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51865. * 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;
  51866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51867. */
  51868. get cameraColorCurves(): Nullable<ColorCurves>;
  51869. /**
  51870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51872. * 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;
  51873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51874. */
  51875. set cameraColorCurves(value: Nullable<ColorCurves>);
  51876. /**
  51877. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51878. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51879. */
  51880. switchToBGR: boolean;
  51881. private _renderTargets;
  51882. private _reflectionControls;
  51883. private _white;
  51884. private _primaryShadowColor;
  51885. private _primaryHighlightColor;
  51886. /**
  51887. * Instantiates a Background Material in the given scene
  51888. * @param name The friendly name of the material
  51889. * @param scene The scene to add the material to
  51890. */
  51891. constructor(name: string, scene: Scene);
  51892. /**
  51893. * Gets a boolean indicating that current material needs to register RTT
  51894. */
  51895. get hasRenderTargetTextures(): boolean;
  51896. /**
  51897. * The entire material has been created in order to prevent overdraw.
  51898. * @returns false
  51899. */
  51900. needAlphaTesting(): boolean;
  51901. /**
  51902. * The entire material has been created in order to prevent overdraw.
  51903. * @returns true if blending is enable
  51904. */
  51905. needAlphaBlending(): boolean;
  51906. /**
  51907. * Checks wether the material is ready to be rendered for a given mesh.
  51908. * @param mesh The mesh to render
  51909. * @param subMesh The submesh to check against
  51910. * @param useInstances Specify wether or not the material is used with instances
  51911. * @returns true if all the dependencies are ready (Textures, Effects...)
  51912. */
  51913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51914. /**
  51915. * Compute the primary color according to the chosen perceptual color.
  51916. */
  51917. private _computePrimaryColorFromPerceptualColor;
  51918. /**
  51919. * Compute the highlights and shadow colors according to their chosen levels.
  51920. */
  51921. private _computePrimaryColors;
  51922. /**
  51923. * Build the uniform buffer used in the material.
  51924. */
  51925. buildUniformLayout(): void;
  51926. /**
  51927. * Unbind the material.
  51928. */
  51929. unbind(): void;
  51930. /**
  51931. * Bind only the world matrix to the material.
  51932. * @param world The world matrix to bind.
  51933. */
  51934. bindOnlyWorldMatrix(world: Matrix): void;
  51935. /**
  51936. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51937. * @param world The world matrix to bind.
  51938. * @param subMesh The submesh to bind for.
  51939. */
  51940. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51941. /**
  51942. * Checks to see if a texture is used in the material.
  51943. * @param texture - Base texture to use.
  51944. * @returns - Boolean specifying if a texture is used in the material.
  51945. */
  51946. hasTexture(texture: BaseTexture): boolean;
  51947. /**
  51948. * Dispose the material.
  51949. * @param forceDisposeEffect Force disposal of the associated effect.
  51950. * @param forceDisposeTextures Force disposal of the associated textures.
  51951. */
  51952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51953. /**
  51954. * Clones the material.
  51955. * @param name The cloned name.
  51956. * @returns The cloned material.
  51957. */
  51958. clone(name: string): BackgroundMaterial;
  51959. /**
  51960. * Serializes the current material to its JSON representation.
  51961. * @returns The JSON representation.
  51962. */
  51963. serialize(): any;
  51964. /**
  51965. * Gets the class name of the material
  51966. * @returns "BackgroundMaterial"
  51967. */
  51968. getClassName(): string;
  51969. /**
  51970. * Parse a JSON input to create back a background material.
  51971. * @param source The JSON data to parse
  51972. * @param scene The scene to create the parsed material in
  51973. * @param rootUrl The root url of the assets the material depends upon
  51974. * @returns the instantiated BackgroundMaterial.
  51975. */
  51976. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51977. }
  51978. }
  51979. declare module "babylonjs/Helpers/environmentHelper" {
  51980. import { Observable } from "babylonjs/Misc/observable";
  51981. import { Nullable } from "babylonjs/types";
  51982. import { Scene } from "babylonjs/scene";
  51983. import { Vector3 } from "babylonjs/Maths/math.vector";
  51984. import { Color3 } from "babylonjs/Maths/math.color";
  51985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51986. import { Mesh } from "babylonjs/Meshes/mesh";
  51987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51988. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51989. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51990. import "babylonjs/Meshes/Builders/planeBuilder";
  51991. import "babylonjs/Meshes/Builders/boxBuilder";
  51992. /**
  51993. * Represents the different options available during the creation of
  51994. * a Environment helper.
  51995. *
  51996. * This can control the default ground, skybox and image processing setup of your scene.
  51997. */
  51998. export interface IEnvironmentHelperOptions {
  51999. /**
  52000. * Specifies whether or not to create a ground.
  52001. * True by default.
  52002. */
  52003. createGround: boolean;
  52004. /**
  52005. * Specifies the ground size.
  52006. * 15 by default.
  52007. */
  52008. groundSize: number;
  52009. /**
  52010. * The texture used on the ground for the main color.
  52011. * Comes from the BabylonJS CDN by default.
  52012. *
  52013. * Remarks: Can be either a texture or a url.
  52014. */
  52015. groundTexture: string | BaseTexture;
  52016. /**
  52017. * The color mixed in the ground texture by default.
  52018. * BabylonJS clearColor by default.
  52019. */
  52020. groundColor: Color3;
  52021. /**
  52022. * Specifies the ground opacity.
  52023. * 1 by default.
  52024. */
  52025. groundOpacity: number;
  52026. /**
  52027. * Enables the ground to receive shadows.
  52028. * True by default.
  52029. */
  52030. enableGroundShadow: boolean;
  52031. /**
  52032. * Helps preventing the shadow to be fully black on the ground.
  52033. * 0.5 by default.
  52034. */
  52035. groundShadowLevel: number;
  52036. /**
  52037. * Creates a mirror texture attach to the ground.
  52038. * false by default.
  52039. */
  52040. enableGroundMirror: boolean;
  52041. /**
  52042. * Specifies the ground mirror size ratio.
  52043. * 0.3 by default as the default kernel is 64.
  52044. */
  52045. groundMirrorSizeRatio: number;
  52046. /**
  52047. * Specifies the ground mirror blur kernel size.
  52048. * 64 by default.
  52049. */
  52050. groundMirrorBlurKernel: number;
  52051. /**
  52052. * Specifies the ground mirror visibility amount.
  52053. * 1 by default
  52054. */
  52055. groundMirrorAmount: number;
  52056. /**
  52057. * Specifies the ground mirror reflectance weight.
  52058. * This uses the standard weight of the background material to setup the fresnel effect
  52059. * of the mirror.
  52060. * 1 by default.
  52061. */
  52062. groundMirrorFresnelWeight: number;
  52063. /**
  52064. * Specifies the ground mirror Falloff distance.
  52065. * This can helps reducing the size of the reflection.
  52066. * 0 by Default.
  52067. */
  52068. groundMirrorFallOffDistance: number;
  52069. /**
  52070. * Specifies the ground mirror texture type.
  52071. * Unsigned Int by Default.
  52072. */
  52073. groundMirrorTextureType: number;
  52074. /**
  52075. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52076. * the shown objects.
  52077. */
  52078. groundYBias: number;
  52079. /**
  52080. * Specifies whether or not to create a skybox.
  52081. * True by default.
  52082. */
  52083. createSkybox: boolean;
  52084. /**
  52085. * Specifies the skybox size.
  52086. * 20 by default.
  52087. */
  52088. skyboxSize: number;
  52089. /**
  52090. * The texture used on the skybox for the main color.
  52091. * Comes from the BabylonJS CDN by default.
  52092. *
  52093. * Remarks: Can be either a texture or a url.
  52094. */
  52095. skyboxTexture: string | BaseTexture;
  52096. /**
  52097. * The color mixed in the skybox texture by default.
  52098. * BabylonJS clearColor by default.
  52099. */
  52100. skyboxColor: Color3;
  52101. /**
  52102. * The background rotation around the Y axis of the scene.
  52103. * This helps aligning the key lights of your scene with the background.
  52104. * 0 by default.
  52105. */
  52106. backgroundYRotation: number;
  52107. /**
  52108. * Compute automatically the size of the elements to best fit with the scene.
  52109. */
  52110. sizeAuto: boolean;
  52111. /**
  52112. * Default position of the rootMesh if autoSize is not true.
  52113. */
  52114. rootPosition: Vector3;
  52115. /**
  52116. * Sets up the image processing in the scene.
  52117. * true by default.
  52118. */
  52119. setupImageProcessing: boolean;
  52120. /**
  52121. * The texture used as your environment texture in the scene.
  52122. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52123. *
  52124. * Remarks: Can be either a texture or a url.
  52125. */
  52126. environmentTexture: string | BaseTexture;
  52127. /**
  52128. * The value of the exposure to apply to the scene.
  52129. * 0.6 by default if setupImageProcessing is true.
  52130. */
  52131. cameraExposure: number;
  52132. /**
  52133. * The value of the contrast to apply to the scene.
  52134. * 1.6 by default if setupImageProcessing is true.
  52135. */
  52136. cameraContrast: number;
  52137. /**
  52138. * Specifies whether or not tonemapping should be enabled in the scene.
  52139. * true by default if setupImageProcessing is true.
  52140. */
  52141. toneMappingEnabled: boolean;
  52142. }
  52143. /**
  52144. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52145. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52146. * It also helps with the default setup of your imageProcessing configuration.
  52147. */
  52148. export class EnvironmentHelper {
  52149. /**
  52150. * Default ground texture URL.
  52151. */
  52152. private static _groundTextureCDNUrl;
  52153. /**
  52154. * Default skybox texture URL.
  52155. */
  52156. private static _skyboxTextureCDNUrl;
  52157. /**
  52158. * Default environment texture URL.
  52159. */
  52160. private static _environmentTextureCDNUrl;
  52161. /**
  52162. * Creates the default options for the helper.
  52163. */
  52164. private static _getDefaultOptions;
  52165. private _rootMesh;
  52166. /**
  52167. * Gets the root mesh created by the helper.
  52168. */
  52169. get rootMesh(): Mesh;
  52170. private _skybox;
  52171. /**
  52172. * Gets the skybox created by the helper.
  52173. */
  52174. get skybox(): Nullable<Mesh>;
  52175. private _skyboxTexture;
  52176. /**
  52177. * Gets the skybox texture created by the helper.
  52178. */
  52179. get skyboxTexture(): Nullable<BaseTexture>;
  52180. private _skyboxMaterial;
  52181. /**
  52182. * Gets the skybox material created by the helper.
  52183. */
  52184. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52185. private _ground;
  52186. /**
  52187. * Gets the ground mesh created by the helper.
  52188. */
  52189. get ground(): Nullable<Mesh>;
  52190. private _groundTexture;
  52191. /**
  52192. * Gets the ground texture created by the helper.
  52193. */
  52194. get groundTexture(): Nullable<BaseTexture>;
  52195. private _groundMirror;
  52196. /**
  52197. * Gets the ground mirror created by the helper.
  52198. */
  52199. get groundMirror(): Nullable<MirrorTexture>;
  52200. /**
  52201. * Gets the ground mirror render list to helps pushing the meshes
  52202. * you wish in the ground reflection.
  52203. */
  52204. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52205. private _groundMaterial;
  52206. /**
  52207. * Gets the ground material created by the helper.
  52208. */
  52209. get groundMaterial(): Nullable<BackgroundMaterial>;
  52210. /**
  52211. * Stores the creation options.
  52212. */
  52213. private readonly _scene;
  52214. private _options;
  52215. /**
  52216. * This observable will be notified with any error during the creation of the environment,
  52217. * mainly texture creation errors.
  52218. */
  52219. onErrorObservable: Observable<{
  52220. message?: string;
  52221. exception?: any;
  52222. }>;
  52223. /**
  52224. * constructor
  52225. * @param options Defines the options we want to customize the helper
  52226. * @param scene The scene to add the material to
  52227. */
  52228. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52229. /**
  52230. * Updates the background according to the new options
  52231. * @param options
  52232. */
  52233. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52234. /**
  52235. * Sets the primary color of all the available elements.
  52236. * @param color the main color to affect to the ground and the background
  52237. */
  52238. setMainColor(color: Color3): void;
  52239. /**
  52240. * Setup the image processing according to the specified options.
  52241. */
  52242. private _setupImageProcessing;
  52243. /**
  52244. * Setup the environment texture according to the specified options.
  52245. */
  52246. private _setupEnvironmentTexture;
  52247. /**
  52248. * Setup the background according to the specified options.
  52249. */
  52250. private _setupBackground;
  52251. /**
  52252. * Get the scene sizes according to the setup.
  52253. */
  52254. private _getSceneSize;
  52255. /**
  52256. * Setup the ground according to the specified options.
  52257. */
  52258. private _setupGround;
  52259. /**
  52260. * Setup the ground material according to the specified options.
  52261. */
  52262. private _setupGroundMaterial;
  52263. /**
  52264. * Setup the ground diffuse texture according to the specified options.
  52265. */
  52266. private _setupGroundDiffuseTexture;
  52267. /**
  52268. * Setup the ground mirror texture according to the specified options.
  52269. */
  52270. private _setupGroundMirrorTexture;
  52271. /**
  52272. * Setup the ground to receive the mirror texture.
  52273. */
  52274. private _setupMirrorInGroundMaterial;
  52275. /**
  52276. * Setup the skybox according to the specified options.
  52277. */
  52278. private _setupSkybox;
  52279. /**
  52280. * Setup the skybox material according to the specified options.
  52281. */
  52282. private _setupSkyboxMaterial;
  52283. /**
  52284. * Setup the skybox reflection texture according to the specified options.
  52285. */
  52286. private _setupSkyboxReflectionTexture;
  52287. private _errorHandler;
  52288. /**
  52289. * Dispose all the elements created by the Helper.
  52290. */
  52291. dispose(): void;
  52292. }
  52293. }
  52294. declare module "babylonjs/Helpers/photoDome" {
  52295. import { Observable } from "babylonjs/Misc/observable";
  52296. import { Nullable } from "babylonjs/types";
  52297. import { Scene } from "babylonjs/scene";
  52298. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52299. import { Mesh } from "babylonjs/Meshes/mesh";
  52300. import { Texture } from "babylonjs/Materials/Textures/texture";
  52301. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52302. import "babylonjs/Meshes/Builders/sphereBuilder";
  52303. /**
  52304. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52305. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52306. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52307. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52308. */
  52309. export class PhotoDome extends TransformNode {
  52310. /**
  52311. * Define the image as a Monoscopic panoramic 360 image.
  52312. */
  52313. static readonly MODE_MONOSCOPIC: number;
  52314. /**
  52315. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52316. */
  52317. static readonly MODE_TOPBOTTOM: number;
  52318. /**
  52319. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52320. */
  52321. static readonly MODE_SIDEBYSIDE: number;
  52322. private _useDirectMapping;
  52323. /**
  52324. * The texture being displayed on the sphere
  52325. */
  52326. protected _photoTexture: Texture;
  52327. /**
  52328. * Gets or sets the texture being displayed on the sphere
  52329. */
  52330. get photoTexture(): Texture;
  52331. set photoTexture(value: Texture);
  52332. /**
  52333. * Observable raised when an error occured while loading the 360 image
  52334. */
  52335. onLoadErrorObservable: Observable<string>;
  52336. /**
  52337. * The skybox material
  52338. */
  52339. protected _material: BackgroundMaterial;
  52340. /**
  52341. * The surface used for the skybox
  52342. */
  52343. protected _mesh: Mesh;
  52344. /**
  52345. * Gets the mesh used for the skybox.
  52346. */
  52347. get mesh(): Mesh;
  52348. /**
  52349. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52350. * Also see the options.resolution property.
  52351. */
  52352. get fovMultiplier(): number;
  52353. set fovMultiplier(value: number);
  52354. private _imageMode;
  52355. /**
  52356. * Gets or set the current video mode for the video. It can be:
  52357. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52358. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52359. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52360. */
  52361. get imageMode(): number;
  52362. set imageMode(value: number);
  52363. /**
  52364. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52365. * @param name Element's name, child elements will append suffixes for their own names.
  52366. * @param urlsOfPhoto defines the url of the photo to display
  52367. * @param options defines an object containing optional or exposed sub element properties
  52368. * @param onError defines a callback called when an error occured while loading the texture
  52369. */
  52370. constructor(name: string, urlOfPhoto: string, options: {
  52371. resolution?: number;
  52372. size?: number;
  52373. useDirectMapping?: boolean;
  52374. faceForward?: boolean;
  52375. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52376. private _onBeforeCameraRenderObserver;
  52377. private _changeImageMode;
  52378. /**
  52379. * Releases resources associated with this node.
  52380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52382. */
  52383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52384. }
  52385. }
  52386. declare module "babylonjs/Misc/rgbdTextureTools" {
  52387. import "babylonjs/Shaders/rgbdDecode.fragment";
  52388. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52389. import { Texture } from "babylonjs/Materials/Textures/texture";
  52390. /**
  52391. * Class used to host RGBD texture specific utilities
  52392. */
  52393. export class RGBDTextureTools {
  52394. /**
  52395. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52396. * @param texture the texture to expand.
  52397. */
  52398. static ExpandRGBDTexture(texture: Texture): void;
  52399. }
  52400. }
  52401. declare module "babylonjs/Misc/brdfTextureTools" {
  52402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52403. import { Scene } from "babylonjs/scene";
  52404. /**
  52405. * Class used to host texture specific utilities
  52406. */
  52407. export class BRDFTextureTools {
  52408. /**
  52409. * Prevents texture cache collision
  52410. */
  52411. private static _instanceNumber;
  52412. /**
  52413. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52414. * @param scene defines the hosting scene
  52415. * @returns the environment BRDF texture
  52416. */
  52417. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52418. private static _environmentBRDFBase64Texture;
  52419. }
  52420. }
  52421. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52422. import { Nullable } from "babylonjs/types";
  52423. import { Color3 } from "babylonjs/Maths/math.color";
  52424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52425. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52426. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52427. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52428. import { Engine } from "babylonjs/Engines/engine";
  52429. import { Scene } from "babylonjs/scene";
  52430. /**
  52431. * @hidden
  52432. */
  52433. export interface IMaterialClearCoatDefines {
  52434. CLEARCOAT: boolean;
  52435. CLEARCOAT_DEFAULTIOR: boolean;
  52436. CLEARCOAT_TEXTURE: boolean;
  52437. CLEARCOAT_TEXTUREDIRECTUV: number;
  52438. CLEARCOAT_BUMP: boolean;
  52439. CLEARCOAT_BUMPDIRECTUV: number;
  52440. CLEARCOAT_TINT: boolean;
  52441. CLEARCOAT_TINT_TEXTURE: boolean;
  52442. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52443. /** @hidden */
  52444. _areTexturesDirty: boolean;
  52445. }
  52446. /**
  52447. * Define the code related to the clear coat parameters of the pbr material.
  52448. */
  52449. export class PBRClearCoatConfiguration {
  52450. /**
  52451. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52452. * The default fits with a polyurethane material.
  52453. */
  52454. private static readonly _DefaultIndexOfRefraction;
  52455. private _isEnabled;
  52456. /**
  52457. * Defines if the clear coat is enabled in the material.
  52458. */
  52459. isEnabled: boolean;
  52460. /**
  52461. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52462. */
  52463. intensity: number;
  52464. /**
  52465. * Defines the clear coat layer roughness.
  52466. */
  52467. roughness: number;
  52468. private _indexOfRefraction;
  52469. /**
  52470. * Defines the index of refraction of the clear coat.
  52471. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52472. * The default fits with a polyurethane material.
  52473. * Changing the default value is more performance intensive.
  52474. */
  52475. indexOfRefraction: number;
  52476. private _texture;
  52477. /**
  52478. * Stores the clear coat values in a texture.
  52479. */
  52480. texture: Nullable<BaseTexture>;
  52481. private _bumpTexture;
  52482. /**
  52483. * Define the clear coat specific bump texture.
  52484. */
  52485. bumpTexture: Nullable<BaseTexture>;
  52486. private _isTintEnabled;
  52487. /**
  52488. * Defines if the clear coat tint is enabled in the material.
  52489. */
  52490. isTintEnabled: boolean;
  52491. /**
  52492. * Defines the clear coat tint of the material.
  52493. * This is only use if tint is enabled
  52494. */
  52495. tintColor: Color3;
  52496. /**
  52497. * Defines the distance at which the tint color should be found in the
  52498. * clear coat media.
  52499. * This is only use if tint is enabled
  52500. */
  52501. tintColorAtDistance: number;
  52502. /**
  52503. * Defines the clear coat layer thickness.
  52504. * This is only use if tint is enabled
  52505. */
  52506. tintThickness: number;
  52507. private _tintTexture;
  52508. /**
  52509. * Stores the clear tint values in a texture.
  52510. * rgb is tint
  52511. * a is a thickness factor
  52512. */
  52513. tintTexture: Nullable<BaseTexture>;
  52514. /** @hidden */
  52515. private _internalMarkAllSubMeshesAsTexturesDirty;
  52516. /** @hidden */
  52517. _markAllSubMeshesAsTexturesDirty(): void;
  52518. /**
  52519. * Instantiate a new istance of clear coat configuration.
  52520. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52521. */
  52522. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52523. /**
  52524. * Gets wehter the submesh is ready to be used or not.
  52525. * @param defines the list of "defines" to update.
  52526. * @param scene defines the scene the material belongs to.
  52527. * @param engine defines the engine the material belongs to.
  52528. * @param disableBumpMap defines wether the material disables bump or not.
  52529. * @returns - boolean indicating that the submesh is ready or not.
  52530. */
  52531. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52532. /**
  52533. * Checks to see if a texture is used in the material.
  52534. * @param defines the list of "defines" to update.
  52535. * @param scene defines the scene to the material belongs to.
  52536. */
  52537. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52538. /**
  52539. * Binds the material data.
  52540. * @param uniformBuffer defines the Uniform buffer to fill in.
  52541. * @param scene defines the scene the material belongs to.
  52542. * @param engine defines the engine the material belongs to.
  52543. * @param disableBumpMap defines wether the material disables bump or not.
  52544. * @param isFrozen defines wether the material is frozen or not.
  52545. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52546. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52547. */
  52548. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52549. /**
  52550. * Checks to see if a texture is used in the material.
  52551. * @param texture - Base texture to use.
  52552. * @returns - Boolean specifying if a texture is used in the material.
  52553. */
  52554. hasTexture(texture: BaseTexture): boolean;
  52555. /**
  52556. * Returns an array of the actively used textures.
  52557. * @param activeTextures Array of BaseTextures
  52558. */
  52559. getActiveTextures(activeTextures: BaseTexture[]): void;
  52560. /**
  52561. * Returns the animatable textures.
  52562. * @param animatables Array of animatable textures.
  52563. */
  52564. getAnimatables(animatables: IAnimatable[]): void;
  52565. /**
  52566. * Disposes the resources of the material.
  52567. * @param forceDisposeTextures - Forces the disposal of all textures.
  52568. */
  52569. dispose(forceDisposeTextures?: boolean): void;
  52570. /**
  52571. * Get the current class name of the texture useful for serialization or dynamic coding.
  52572. * @returns "PBRClearCoatConfiguration"
  52573. */
  52574. getClassName(): string;
  52575. /**
  52576. * Add fallbacks to the effect fallbacks list.
  52577. * @param defines defines the Base texture to use.
  52578. * @param fallbacks defines the current fallback list.
  52579. * @param currentRank defines the current fallback rank.
  52580. * @returns the new fallback rank.
  52581. */
  52582. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52583. /**
  52584. * Add the required uniforms to the current list.
  52585. * @param uniforms defines the current uniform list.
  52586. */
  52587. static AddUniforms(uniforms: string[]): void;
  52588. /**
  52589. * Add the required samplers to the current list.
  52590. * @param samplers defines the current sampler list.
  52591. */
  52592. static AddSamplers(samplers: string[]): void;
  52593. /**
  52594. * Add the required uniforms to the current buffer.
  52595. * @param uniformBuffer defines the current uniform buffer.
  52596. */
  52597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52598. /**
  52599. * Makes a duplicate of the current configuration into another one.
  52600. * @param clearCoatConfiguration define the config where to copy the info
  52601. */
  52602. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52603. /**
  52604. * Serializes this clear coat configuration.
  52605. * @returns - An object with the serialized config.
  52606. */
  52607. serialize(): any;
  52608. /**
  52609. * Parses a anisotropy Configuration from a serialized object.
  52610. * @param source - Serialized object.
  52611. * @param scene Defines the scene we are parsing for
  52612. * @param rootUrl Defines the rootUrl to load from
  52613. */
  52614. parse(source: any, scene: Scene, rootUrl: string): void;
  52615. }
  52616. }
  52617. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52618. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52620. import { Vector2 } from "babylonjs/Maths/math.vector";
  52621. import { Scene } from "babylonjs/scene";
  52622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52623. import { Nullable } from "babylonjs/types";
  52624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52625. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52626. /**
  52627. * @hidden
  52628. */
  52629. export interface IMaterialAnisotropicDefines {
  52630. ANISOTROPIC: boolean;
  52631. ANISOTROPIC_TEXTURE: boolean;
  52632. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52633. MAINUV1: boolean;
  52634. _areTexturesDirty: boolean;
  52635. _needUVs: boolean;
  52636. }
  52637. /**
  52638. * Define the code related to the anisotropic parameters of the pbr material.
  52639. */
  52640. export class PBRAnisotropicConfiguration {
  52641. private _isEnabled;
  52642. /**
  52643. * Defines if the anisotropy is enabled in the material.
  52644. */
  52645. isEnabled: boolean;
  52646. /**
  52647. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52648. */
  52649. intensity: number;
  52650. /**
  52651. * Defines if the effect is along the tangents, bitangents or in between.
  52652. * By default, the effect is "strectching" the highlights along the tangents.
  52653. */
  52654. direction: Vector2;
  52655. private _texture;
  52656. /**
  52657. * Stores the anisotropy values in a texture.
  52658. * rg is direction (like normal from -1 to 1)
  52659. * b is a intensity
  52660. */
  52661. texture: Nullable<BaseTexture>;
  52662. /** @hidden */
  52663. private _internalMarkAllSubMeshesAsTexturesDirty;
  52664. /** @hidden */
  52665. _markAllSubMeshesAsTexturesDirty(): void;
  52666. /**
  52667. * Instantiate a new istance of anisotropy configuration.
  52668. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52669. */
  52670. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52671. /**
  52672. * Specifies that the submesh is ready to be used.
  52673. * @param defines the list of "defines" to update.
  52674. * @param scene defines the scene the material belongs to.
  52675. * @returns - boolean indicating that the submesh is ready or not.
  52676. */
  52677. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52678. /**
  52679. * Checks to see if a texture is used in the material.
  52680. * @param defines the list of "defines" to update.
  52681. * @param mesh the mesh we are preparing the defines for.
  52682. * @param scene defines the scene the material belongs to.
  52683. */
  52684. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52685. /**
  52686. * Binds the material data.
  52687. * @param uniformBuffer defines the Uniform buffer to fill in.
  52688. * @param scene defines the scene the material belongs to.
  52689. * @param isFrozen defines wether the material is frozen or not.
  52690. */
  52691. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52692. /**
  52693. * Checks to see if a texture is used in the material.
  52694. * @param texture - Base texture to use.
  52695. * @returns - Boolean specifying if a texture is used in the material.
  52696. */
  52697. hasTexture(texture: BaseTexture): boolean;
  52698. /**
  52699. * Returns an array of the actively used textures.
  52700. * @param activeTextures Array of BaseTextures
  52701. */
  52702. getActiveTextures(activeTextures: BaseTexture[]): void;
  52703. /**
  52704. * Returns the animatable textures.
  52705. * @param animatables Array of animatable textures.
  52706. */
  52707. getAnimatables(animatables: IAnimatable[]): void;
  52708. /**
  52709. * Disposes the resources of the material.
  52710. * @param forceDisposeTextures - Forces the disposal of all textures.
  52711. */
  52712. dispose(forceDisposeTextures?: boolean): void;
  52713. /**
  52714. * Get the current class name of the texture useful for serialization or dynamic coding.
  52715. * @returns "PBRAnisotropicConfiguration"
  52716. */
  52717. getClassName(): string;
  52718. /**
  52719. * Add fallbacks to the effect fallbacks list.
  52720. * @param defines defines the Base texture to use.
  52721. * @param fallbacks defines the current fallback list.
  52722. * @param currentRank defines the current fallback rank.
  52723. * @returns the new fallback rank.
  52724. */
  52725. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52726. /**
  52727. * Add the required uniforms to the current list.
  52728. * @param uniforms defines the current uniform list.
  52729. */
  52730. static AddUniforms(uniforms: string[]): void;
  52731. /**
  52732. * Add the required uniforms to the current buffer.
  52733. * @param uniformBuffer defines the current uniform buffer.
  52734. */
  52735. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52736. /**
  52737. * Add the required samplers to the current list.
  52738. * @param samplers defines the current sampler list.
  52739. */
  52740. static AddSamplers(samplers: string[]): void;
  52741. /**
  52742. * Makes a duplicate of the current configuration into another one.
  52743. * @param anisotropicConfiguration define the config where to copy the info
  52744. */
  52745. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52746. /**
  52747. * Serializes this anisotropy configuration.
  52748. * @returns - An object with the serialized config.
  52749. */
  52750. serialize(): any;
  52751. /**
  52752. * Parses a anisotropy Configuration from a serialized object.
  52753. * @param source - Serialized object.
  52754. * @param scene Defines the scene we are parsing for
  52755. * @param rootUrl Defines the rootUrl to load from
  52756. */
  52757. parse(source: any, scene: Scene, rootUrl: string): void;
  52758. }
  52759. }
  52760. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52761. import { Scene } from "babylonjs/scene";
  52762. /**
  52763. * @hidden
  52764. */
  52765. export interface IMaterialBRDFDefines {
  52766. BRDF_V_HEIGHT_CORRELATED: boolean;
  52767. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52768. SPHERICAL_HARMONICS: boolean;
  52769. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52770. /** @hidden */
  52771. _areMiscDirty: boolean;
  52772. }
  52773. /**
  52774. * Define the code related to the BRDF parameters of the pbr material.
  52775. */
  52776. export class PBRBRDFConfiguration {
  52777. /**
  52778. * Default value used for the energy conservation.
  52779. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52780. */
  52781. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52782. /**
  52783. * Default value used for the Smith Visibility Height Correlated mode.
  52784. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52785. */
  52786. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52787. /**
  52788. * Default value used for the IBL diffuse part.
  52789. * This can help switching back to the polynomials mode globally which is a tiny bit
  52790. * less GPU intensive at the drawback of a lower quality.
  52791. */
  52792. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52793. /**
  52794. * Default value used for activating energy conservation for the specular workflow.
  52795. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52796. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52797. */
  52798. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52799. private _useEnergyConservation;
  52800. /**
  52801. * Defines if the material uses energy conservation.
  52802. */
  52803. useEnergyConservation: boolean;
  52804. private _useSmithVisibilityHeightCorrelated;
  52805. /**
  52806. * LEGACY Mode set to false
  52807. * Defines if the material uses height smith correlated visibility term.
  52808. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52809. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52810. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52811. * Not relying on height correlated will also disable energy conservation.
  52812. */
  52813. useSmithVisibilityHeightCorrelated: boolean;
  52814. private _useSphericalHarmonics;
  52815. /**
  52816. * LEGACY Mode set to false
  52817. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52818. * diffuse part of the IBL.
  52819. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52820. * to the ground truth.
  52821. */
  52822. useSphericalHarmonics: boolean;
  52823. private _useSpecularGlossinessInputEnergyConservation;
  52824. /**
  52825. * Defines if the material uses energy conservation, when the specular workflow is active.
  52826. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52827. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52828. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52829. */
  52830. useSpecularGlossinessInputEnergyConservation: boolean;
  52831. /** @hidden */
  52832. private _internalMarkAllSubMeshesAsMiscDirty;
  52833. /** @hidden */
  52834. _markAllSubMeshesAsMiscDirty(): void;
  52835. /**
  52836. * Instantiate a new istance of clear coat configuration.
  52837. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52838. */
  52839. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52840. /**
  52841. * Checks to see if a texture is used in the material.
  52842. * @param defines the list of "defines" to update.
  52843. */
  52844. prepareDefines(defines: IMaterialBRDFDefines): void;
  52845. /**
  52846. * Get the current class name of the texture useful for serialization or dynamic coding.
  52847. * @returns "PBRClearCoatConfiguration"
  52848. */
  52849. getClassName(): string;
  52850. /**
  52851. * Makes a duplicate of the current configuration into another one.
  52852. * @param brdfConfiguration define the config where to copy the info
  52853. */
  52854. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52855. /**
  52856. * Serializes this BRDF configuration.
  52857. * @returns - An object with the serialized config.
  52858. */
  52859. serialize(): any;
  52860. /**
  52861. * Parses a anisotropy Configuration from a serialized object.
  52862. * @param source - Serialized object.
  52863. * @param scene Defines the scene we are parsing for
  52864. * @param rootUrl Defines the rootUrl to load from
  52865. */
  52866. parse(source: any, scene: Scene, rootUrl: string): void;
  52867. }
  52868. }
  52869. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52870. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52871. import { Color3 } from "babylonjs/Maths/math.color";
  52872. import { Scene } from "babylonjs/scene";
  52873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52874. import { Nullable } from "babylonjs/types";
  52875. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52876. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52877. /**
  52878. * @hidden
  52879. */
  52880. export interface IMaterialSheenDefines {
  52881. SHEEN: boolean;
  52882. SHEEN_TEXTURE: boolean;
  52883. SHEEN_TEXTUREDIRECTUV: number;
  52884. SHEEN_LINKWITHALBEDO: boolean;
  52885. SHEEN_ROUGHNESS: boolean;
  52886. SHEEN_ALBEDOSCALING: boolean;
  52887. /** @hidden */
  52888. _areTexturesDirty: boolean;
  52889. }
  52890. /**
  52891. * Define the code related to the Sheen parameters of the pbr material.
  52892. */
  52893. export class PBRSheenConfiguration {
  52894. private _isEnabled;
  52895. /**
  52896. * Defines if the material uses sheen.
  52897. */
  52898. isEnabled: boolean;
  52899. private _linkSheenWithAlbedo;
  52900. /**
  52901. * Defines if the sheen is linked to the sheen color.
  52902. */
  52903. linkSheenWithAlbedo: boolean;
  52904. /**
  52905. * Defines the sheen intensity.
  52906. */
  52907. intensity: number;
  52908. /**
  52909. * Defines the sheen color.
  52910. */
  52911. color: Color3;
  52912. private _texture;
  52913. /**
  52914. * Stores the sheen tint values in a texture.
  52915. * rgb is tint
  52916. * a is a intensity
  52917. */
  52918. texture: Nullable<BaseTexture>;
  52919. private _roughness;
  52920. /**
  52921. * Defines the sheen roughness.
  52922. * It is not taken into account if linkSheenWithAlbedo is true.
  52923. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52924. */
  52925. roughness: Nullable<number>;
  52926. private _albedoScaling;
  52927. /**
  52928. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52929. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52930. * making it easier to setup and tweak the effect
  52931. */
  52932. albedoScaling: boolean;
  52933. /** @hidden */
  52934. private _internalMarkAllSubMeshesAsTexturesDirty;
  52935. /** @hidden */
  52936. _markAllSubMeshesAsTexturesDirty(): void;
  52937. /**
  52938. * Instantiate a new istance of clear coat configuration.
  52939. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52940. */
  52941. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52942. /**
  52943. * Specifies that the submesh is ready to be used.
  52944. * @param defines the list of "defines" to update.
  52945. * @param scene defines the scene the material belongs to.
  52946. * @returns - boolean indicating that the submesh is ready or not.
  52947. */
  52948. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52949. /**
  52950. * Checks to see if a texture is used in the material.
  52951. * @param defines the list of "defines" to update.
  52952. * @param scene defines the scene the material belongs to.
  52953. */
  52954. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52955. /**
  52956. * Binds the material data.
  52957. * @param uniformBuffer defines the Uniform buffer to fill in.
  52958. * @param scene defines the scene the material belongs to.
  52959. * @param isFrozen defines wether the material is frozen or not.
  52960. */
  52961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52962. /**
  52963. * Checks to see if a texture is used in the material.
  52964. * @param texture - Base texture to use.
  52965. * @returns - Boolean specifying if a texture is used in the material.
  52966. */
  52967. hasTexture(texture: BaseTexture): boolean;
  52968. /**
  52969. * Returns an array of the actively used textures.
  52970. * @param activeTextures Array of BaseTextures
  52971. */
  52972. getActiveTextures(activeTextures: BaseTexture[]): void;
  52973. /**
  52974. * Returns the animatable textures.
  52975. * @param animatables Array of animatable textures.
  52976. */
  52977. getAnimatables(animatables: IAnimatable[]): void;
  52978. /**
  52979. * Disposes the resources of the material.
  52980. * @param forceDisposeTextures - Forces the disposal of all textures.
  52981. */
  52982. dispose(forceDisposeTextures?: boolean): void;
  52983. /**
  52984. * Get the current class name of the texture useful for serialization or dynamic coding.
  52985. * @returns "PBRSheenConfiguration"
  52986. */
  52987. getClassName(): string;
  52988. /**
  52989. * Add fallbacks to the effect fallbacks list.
  52990. * @param defines defines the Base texture to use.
  52991. * @param fallbacks defines the current fallback list.
  52992. * @param currentRank defines the current fallback rank.
  52993. * @returns the new fallback rank.
  52994. */
  52995. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52996. /**
  52997. * Add the required uniforms to the current list.
  52998. * @param uniforms defines the current uniform list.
  52999. */
  53000. static AddUniforms(uniforms: string[]): void;
  53001. /**
  53002. * Add the required uniforms to the current buffer.
  53003. * @param uniformBuffer defines the current uniform buffer.
  53004. */
  53005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53006. /**
  53007. * Add the required samplers to the current list.
  53008. * @param samplers defines the current sampler list.
  53009. */
  53010. static AddSamplers(samplers: string[]): void;
  53011. /**
  53012. * Makes a duplicate of the current configuration into another one.
  53013. * @param sheenConfiguration define the config where to copy the info
  53014. */
  53015. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53016. /**
  53017. * Serializes this BRDF configuration.
  53018. * @returns - An object with the serialized config.
  53019. */
  53020. serialize(): any;
  53021. /**
  53022. * Parses a anisotropy Configuration from a serialized object.
  53023. * @param source - Serialized object.
  53024. * @param scene Defines the scene we are parsing for
  53025. * @param rootUrl Defines the rootUrl to load from
  53026. */
  53027. parse(source: any, scene: Scene, rootUrl: string): void;
  53028. }
  53029. }
  53030. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53031. import { Nullable } from "babylonjs/types";
  53032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53033. import { Color3 } from "babylonjs/Maths/math.color";
  53034. import { SmartArray } from "babylonjs/Misc/smartArray";
  53035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53037. import { Effect } from "babylonjs/Materials/effect";
  53038. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53039. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53040. import { Engine } from "babylonjs/Engines/engine";
  53041. import { Scene } from "babylonjs/scene";
  53042. /**
  53043. * @hidden
  53044. */
  53045. export interface IMaterialSubSurfaceDefines {
  53046. SUBSURFACE: boolean;
  53047. SS_REFRACTION: boolean;
  53048. SS_TRANSLUCENCY: boolean;
  53049. SS_SCATERRING: boolean;
  53050. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53051. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53052. SS_REFRACTIONMAP_3D: boolean;
  53053. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53054. SS_LODINREFRACTIONALPHA: boolean;
  53055. SS_GAMMAREFRACTION: boolean;
  53056. SS_RGBDREFRACTION: boolean;
  53057. SS_LINEARSPECULARREFRACTION: boolean;
  53058. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53059. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53060. /** @hidden */
  53061. _areTexturesDirty: boolean;
  53062. }
  53063. /**
  53064. * Define the code related to the sub surface parameters of the pbr material.
  53065. */
  53066. export class PBRSubSurfaceConfiguration {
  53067. private _isRefractionEnabled;
  53068. /**
  53069. * Defines if the refraction is enabled in the material.
  53070. */
  53071. isRefractionEnabled: boolean;
  53072. private _isTranslucencyEnabled;
  53073. /**
  53074. * Defines if the translucency is enabled in the material.
  53075. */
  53076. isTranslucencyEnabled: boolean;
  53077. private _isScatteringEnabled;
  53078. /**
  53079. * Defines the refraction intensity of the material.
  53080. * The refraction when enabled replaces the Diffuse part of the material.
  53081. * The intensity helps transitionning between diffuse and refraction.
  53082. */
  53083. refractionIntensity: number;
  53084. /**
  53085. * Defines the translucency intensity of the material.
  53086. * When translucency has been enabled, this defines how much of the "translucency"
  53087. * is addded to the diffuse part of the material.
  53088. */
  53089. translucencyIntensity: number;
  53090. /**
  53091. * Defines the scattering intensity of the material.
  53092. * When scattering has been enabled, this defines how much of the "scattered light"
  53093. * is addded to the diffuse part of the material.
  53094. */
  53095. scatteringIntensity: number;
  53096. private _thicknessTexture;
  53097. /**
  53098. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53099. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53100. * 0 would mean minimumThickness
  53101. * 1 would mean maximumThickness
  53102. * The other channels might be use as a mask to vary the different effects intensity.
  53103. */
  53104. thicknessTexture: Nullable<BaseTexture>;
  53105. private _refractionTexture;
  53106. /**
  53107. * Defines the texture to use for refraction.
  53108. */
  53109. refractionTexture: Nullable<BaseTexture>;
  53110. private _indexOfRefraction;
  53111. /**
  53112. * Defines the index of refraction used in the material.
  53113. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53114. */
  53115. indexOfRefraction: number;
  53116. private _invertRefractionY;
  53117. /**
  53118. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53119. */
  53120. invertRefractionY: boolean;
  53121. private _linkRefractionWithTransparency;
  53122. /**
  53123. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53124. * Materials half opaque for instance using refraction could benefit from this control.
  53125. */
  53126. linkRefractionWithTransparency: boolean;
  53127. /**
  53128. * Defines the minimum thickness stored in the thickness map.
  53129. * If no thickness map is defined, this value will be used to simulate thickness.
  53130. */
  53131. minimumThickness: number;
  53132. /**
  53133. * Defines the maximum thickness stored in the thickness map.
  53134. */
  53135. maximumThickness: number;
  53136. /**
  53137. * Defines the volume tint of the material.
  53138. * This is used for both translucency and scattering.
  53139. */
  53140. tintColor: Color3;
  53141. /**
  53142. * Defines the distance at which the tint color should be found in the media.
  53143. * This is used for refraction only.
  53144. */
  53145. tintColorAtDistance: number;
  53146. /**
  53147. * Defines how far each channel transmit through the media.
  53148. * It is defined as a color to simplify it selection.
  53149. */
  53150. diffusionDistance: Color3;
  53151. private _useMaskFromThicknessTexture;
  53152. /**
  53153. * Stores the intensity of the different subsurface effects in the thickness texture.
  53154. * * the green channel is the translucency intensity.
  53155. * * the blue channel is the scattering intensity.
  53156. * * the alpha channel is the refraction intensity.
  53157. */
  53158. useMaskFromThicknessTexture: boolean;
  53159. /** @hidden */
  53160. private _internalMarkAllSubMeshesAsTexturesDirty;
  53161. /** @hidden */
  53162. _markAllSubMeshesAsTexturesDirty(): void;
  53163. /**
  53164. * Instantiate a new istance of sub surface configuration.
  53165. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53166. */
  53167. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53168. /**
  53169. * Gets wehter the submesh is ready to be used or not.
  53170. * @param defines the list of "defines" to update.
  53171. * @param scene defines the scene the material belongs to.
  53172. * @returns - boolean indicating that the submesh is ready or not.
  53173. */
  53174. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53175. /**
  53176. * Checks to see if a texture is used in the material.
  53177. * @param defines the list of "defines" to update.
  53178. * @param scene defines the scene to the material belongs to.
  53179. */
  53180. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53181. /**
  53182. * Binds the material data.
  53183. * @param uniformBuffer defines the Uniform buffer to fill in.
  53184. * @param scene defines the scene the material belongs to.
  53185. * @param engine defines the engine the material belongs to.
  53186. * @param isFrozen defines wether the material is frozen or not.
  53187. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53188. */
  53189. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53190. /**
  53191. * Unbinds the material from the mesh.
  53192. * @param activeEffect defines the effect that should be unbound from.
  53193. * @returns true if unbound, otherwise false
  53194. */
  53195. unbind(activeEffect: Effect): boolean;
  53196. /**
  53197. * Returns the texture used for refraction or null if none is used.
  53198. * @param scene defines the scene the material belongs to.
  53199. * @returns - Refraction texture if present. If no refraction texture and refraction
  53200. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53201. */
  53202. private _getRefractionTexture;
  53203. /**
  53204. * Returns true if alpha blending should be disabled.
  53205. */
  53206. get disableAlphaBlending(): boolean;
  53207. /**
  53208. * Fills the list of render target textures.
  53209. * @param renderTargets the list of render targets to update
  53210. */
  53211. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53212. /**
  53213. * Checks to see if a texture is used in the material.
  53214. * @param texture - Base texture to use.
  53215. * @returns - Boolean specifying if a texture is used in the material.
  53216. */
  53217. hasTexture(texture: BaseTexture): boolean;
  53218. /**
  53219. * Gets a boolean indicating that current material needs to register RTT
  53220. * @returns true if this uses a render target otherwise false.
  53221. */
  53222. hasRenderTargetTextures(): boolean;
  53223. /**
  53224. * Returns an array of the actively used textures.
  53225. * @param activeTextures Array of BaseTextures
  53226. */
  53227. getActiveTextures(activeTextures: BaseTexture[]): void;
  53228. /**
  53229. * Returns the animatable textures.
  53230. * @param animatables Array of animatable textures.
  53231. */
  53232. getAnimatables(animatables: IAnimatable[]): void;
  53233. /**
  53234. * Disposes the resources of the material.
  53235. * @param forceDisposeTextures - Forces the disposal of all textures.
  53236. */
  53237. dispose(forceDisposeTextures?: boolean): void;
  53238. /**
  53239. * Get the current class name of the texture useful for serialization or dynamic coding.
  53240. * @returns "PBRSubSurfaceConfiguration"
  53241. */
  53242. getClassName(): string;
  53243. /**
  53244. * Add fallbacks to the effect fallbacks list.
  53245. * @param defines defines the Base texture to use.
  53246. * @param fallbacks defines the current fallback list.
  53247. * @param currentRank defines the current fallback rank.
  53248. * @returns the new fallback rank.
  53249. */
  53250. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53251. /**
  53252. * Add the required uniforms to the current list.
  53253. * @param uniforms defines the current uniform list.
  53254. */
  53255. static AddUniforms(uniforms: string[]): void;
  53256. /**
  53257. * Add the required samplers to the current list.
  53258. * @param samplers defines the current sampler list.
  53259. */
  53260. static AddSamplers(samplers: string[]): void;
  53261. /**
  53262. * Add the required uniforms to the current buffer.
  53263. * @param uniformBuffer defines the current uniform buffer.
  53264. */
  53265. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53266. /**
  53267. * Makes a duplicate of the current configuration into another one.
  53268. * @param configuration define the config where to copy the info
  53269. */
  53270. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53271. /**
  53272. * Serializes this Sub Surface configuration.
  53273. * @returns - An object with the serialized config.
  53274. */
  53275. serialize(): any;
  53276. /**
  53277. * Parses a anisotropy Configuration from a serialized object.
  53278. * @param source - Serialized object.
  53279. * @param scene Defines the scene we are parsing for
  53280. * @param rootUrl Defines the rootUrl to load from
  53281. */
  53282. parse(source: any, scene: Scene, rootUrl: string): void;
  53283. }
  53284. }
  53285. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53286. /** @hidden */
  53287. export var pbrFragmentDeclaration: {
  53288. name: string;
  53289. shader: string;
  53290. };
  53291. }
  53292. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53293. /** @hidden */
  53294. export var pbrUboDeclaration: {
  53295. name: string;
  53296. shader: string;
  53297. };
  53298. }
  53299. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53300. /** @hidden */
  53301. export var pbrFragmentExtraDeclaration: {
  53302. name: string;
  53303. shader: string;
  53304. };
  53305. }
  53306. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53307. /** @hidden */
  53308. export var pbrFragmentSamplersDeclaration: {
  53309. name: string;
  53310. shader: string;
  53311. };
  53312. }
  53313. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53314. /** @hidden */
  53315. export var pbrHelperFunctions: {
  53316. name: string;
  53317. shader: string;
  53318. };
  53319. }
  53320. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53321. /** @hidden */
  53322. export var harmonicsFunctions: {
  53323. name: string;
  53324. shader: string;
  53325. };
  53326. }
  53327. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53328. /** @hidden */
  53329. export var pbrDirectLightingSetupFunctions: {
  53330. name: string;
  53331. shader: string;
  53332. };
  53333. }
  53334. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53335. /** @hidden */
  53336. export var pbrDirectLightingFalloffFunctions: {
  53337. name: string;
  53338. shader: string;
  53339. };
  53340. }
  53341. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53342. /** @hidden */
  53343. export var pbrBRDFFunctions: {
  53344. name: string;
  53345. shader: string;
  53346. };
  53347. }
  53348. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53349. /** @hidden */
  53350. export var pbrDirectLightingFunctions: {
  53351. name: string;
  53352. shader: string;
  53353. };
  53354. }
  53355. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53356. /** @hidden */
  53357. export var pbrIBLFunctions: {
  53358. name: string;
  53359. shader: string;
  53360. };
  53361. }
  53362. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53363. /** @hidden */
  53364. export var pbrBlockAlbedoOpacity: {
  53365. name: string;
  53366. shader: string;
  53367. };
  53368. }
  53369. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53370. /** @hidden */
  53371. export var pbrBlockReflectivity: {
  53372. name: string;
  53373. shader: string;
  53374. };
  53375. }
  53376. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53377. /** @hidden */
  53378. export var pbrBlockAmbientOcclusion: {
  53379. name: string;
  53380. shader: string;
  53381. };
  53382. }
  53383. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53384. /** @hidden */
  53385. export var pbrBlockAlphaFresnel: {
  53386. name: string;
  53387. shader: string;
  53388. };
  53389. }
  53390. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53391. /** @hidden */
  53392. export var pbrBlockAnisotropic: {
  53393. name: string;
  53394. shader: string;
  53395. };
  53396. }
  53397. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53398. /** @hidden */
  53399. export var pbrBlockReflection: {
  53400. name: string;
  53401. shader: string;
  53402. };
  53403. }
  53404. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53405. /** @hidden */
  53406. export var pbrBlockSheen: {
  53407. name: string;
  53408. shader: string;
  53409. };
  53410. }
  53411. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53412. /** @hidden */
  53413. export var pbrBlockClearcoat: {
  53414. name: string;
  53415. shader: string;
  53416. };
  53417. }
  53418. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53419. /** @hidden */
  53420. export var pbrBlockSubSurface: {
  53421. name: string;
  53422. shader: string;
  53423. };
  53424. }
  53425. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53426. /** @hidden */
  53427. export var pbrBlockNormalGeometric: {
  53428. name: string;
  53429. shader: string;
  53430. };
  53431. }
  53432. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53433. /** @hidden */
  53434. export var pbrBlockNormalFinal: {
  53435. name: string;
  53436. shader: string;
  53437. };
  53438. }
  53439. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53440. /** @hidden */
  53441. export var pbrBlockGeometryInfo: {
  53442. name: string;
  53443. shader: string;
  53444. };
  53445. }
  53446. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53447. /** @hidden */
  53448. export var pbrBlockReflectance0: {
  53449. name: string;
  53450. shader: string;
  53451. };
  53452. }
  53453. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53454. /** @hidden */
  53455. export var pbrBlockReflectance: {
  53456. name: string;
  53457. shader: string;
  53458. };
  53459. }
  53460. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53461. /** @hidden */
  53462. export var pbrBlockDirectLighting: {
  53463. name: string;
  53464. shader: string;
  53465. };
  53466. }
  53467. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53468. /** @hidden */
  53469. export var pbrBlockFinalLitComponents: {
  53470. name: string;
  53471. shader: string;
  53472. };
  53473. }
  53474. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53475. /** @hidden */
  53476. export var pbrBlockFinalUnlitComponents: {
  53477. name: string;
  53478. shader: string;
  53479. };
  53480. }
  53481. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53482. /** @hidden */
  53483. export var pbrBlockFinalColorComposition: {
  53484. name: string;
  53485. shader: string;
  53486. };
  53487. }
  53488. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53489. /** @hidden */
  53490. export var pbrBlockImageProcessing: {
  53491. name: string;
  53492. shader: string;
  53493. };
  53494. }
  53495. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53496. /** @hidden */
  53497. export var pbrDebug: {
  53498. name: string;
  53499. shader: string;
  53500. };
  53501. }
  53502. declare module "babylonjs/Shaders/pbr.fragment" {
  53503. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53504. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53505. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53506. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53507. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53508. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53509. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53511. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53512. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53514. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53515. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53516. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53517. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53518. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53519. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53520. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53521. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53522. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53523. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53524. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53525. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53526. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53527. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53528. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53529. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53530. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53531. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53532. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53533. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53534. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53535. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53536. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53537. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53538. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53539. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53540. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53541. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53542. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53543. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53544. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53545. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53546. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53547. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53548. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53549. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53550. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53551. /** @hidden */
  53552. export var pbrPixelShader: {
  53553. name: string;
  53554. shader: string;
  53555. };
  53556. }
  53557. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53558. /** @hidden */
  53559. export var pbrVertexDeclaration: {
  53560. name: string;
  53561. shader: string;
  53562. };
  53563. }
  53564. declare module "babylonjs/Shaders/pbr.vertex" {
  53565. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53566. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53568. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53569. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53570. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53571. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53573. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53574. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53575. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53576. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53578. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53580. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53581. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53582. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53584. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53585. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53586. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53587. /** @hidden */
  53588. export var pbrVertexShader: {
  53589. name: string;
  53590. shader: string;
  53591. };
  53592. }
  53593. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53594. import { Nullable } from "babylonjs/types";
  53595. import { Scene } from "babylonjs/scene";
  53596. import { Matrix } from "babylonjs/Maths/math.vector";
  53597. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53599. import { Mesh } from "babylonjs/Meshes/mesh";
  53600. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53601. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53602. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53603. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53604. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53605. import { Color3 } from "babylonjs/Maths/math.color";
  53606. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53607. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53609. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53611. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53612. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53613. import "babylonjs/Shaders/pbr.fragment";
  53614. import "babylonjs/Shaders/pbr.vertex";
  53615. /**
  53616. * Manages the defines for the PBR Material.
  53617. * @hidden
  53618. */
  53619. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53620. PBR: boolean;
  53621. MAINUV1: boolean;
  53622. MAINUV2: boolean;
  53623. UV1: boolean;
  53624. UV2: boolean;
  53625. ALBEDO: boolean;
  53626. GAMMAALBEDO: boolean;
  53627. ALBEDODIRECTUV: number;
  53628. VERTEXCOLOR: boolean;
  53629. AMBIENT: boolean;
  53630. AMBIENTDIRECTUV: number;
  53631. AMBIENTINGRAYSCALE: boolean;
  53632. OPACITY: boolean;
  53633. VERTEXALPHA: boolean;
  53634. OPACITYDIRECTUV: number;
  53635. OPACITYRGB: boolean;
  53636. ALPHATEST: boolean;
  53637. DEPTHPREPASS: boolean;
  53638. ALPHABLEND: boolean;
  53639. ALPHAFROMALBEDO: boolean;
  53640. ALPHATESTVALUE: string;
  53641. SPECULAROVERALPHA: boolean;
  53642. RADIANCEOVERALPHA: boolean;
  53643. ALPHAFRESNEL: boolean;
  53644. LINEARALPHAFRESNEL: boolean;
  53645. PREMULTIPLYALPHA: boolean;
  53646. EMISSIVE: boolean;
  53647. EMISSIVEDIRECTUV: number;
  53648. REFLECTIVITY: boolean;
  53649. REFLECTIVITYDIRECTUV: number;
  53650. SPECULARTERM: boolean;
  53651. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53652. MICROSURFACEAUTOMATIC: boolean;
  53653. LODBASEDMICROSFURACE: boolean;
  53654. MICROSURFACEMAP: boolean;
  53655. MICROSURFACEMAPDIRECTUV: number;
  53656. METALLICWORKFLOW: boolean;
  53657. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53658. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53659. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53660. AOSTOREINMETALMAPRED: boolean;
  53661. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53662. ENVIRONMENTBRDF: boolean;
  53663. ENVIRONMENTBRDF_RGBD: boolean;
  53664. NORMAL: boolean;
  53665. TANGENT: boolean;
  53666. BUMP: boolean;
  53667. BUMPDIRECTUV: number;
  53668. OBJECTSPACE_NORMALMAP: boolean;
  53669. PARALLAX: boolean;
  53670. PARALLAXOCCLUSION: boolean;
  53671. NORMALXYSCALE: boolean;
  53672. LIGHTMAP: boolean;
  53673. LIGHTMAPDIRECTUV: number;
  53674. USELIGHTMAPASSHADOWMAP: boolean;
  53675. GAMMALIGHTMAP: boolean;
  53676. RGBDLIGHTMAP: boolean;
  53677. REFLECTION: boolean;
  53678. REFLECTIONMAP_3D: boolean;
  53679. REFLECTIONMAP_SPHERICAL: boolean;
  53680. REFLECTIONMAP_PLANAR: boolean;
  53681. REFLECTIONMAP_CUBIC: boolean;
  53682. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53683. REFLECTIONMAP_PROJECTION: boolean;
  53684. REFLECTIONMAP_SKYBOX: boolean;
  53685. REFLECTIONMAP_EXPLICIT: boolean;
  53686. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53687. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53688. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53689. INVERTCUBICMAP: boolean;
  53690. USESPHERICALFROMREFLECTIONMAP: boolean;
  53691. USEIRRADIANCEMAP: boolean;
  53692. SPHERICAL_HARMONICS: boolean;
  53693. USESPHERICALINVERTEX: boolean;
  53694. REFLECTIONMAP_OPPOSITEZ: boolean;
  53695. LODINREFLECTIONALPHA: boolean;
  53696. GAMMAREFLECTION: boolean;
  53697. RGBDREFLECTION: boolean;
  53698. LINEARSPECULARREFLECTION: boolean;
  53699. RADIANCEOCCLUSION: boolean;
  53700. HORIZONOCCLUSION: boolean;
  53701. INSTANCES: boolean;
  53702. NUM_BONE_INFLUENCERS: number;
  53703. BonesPerMesh: number;
  53704. BONETEXTURE: boolean;
  53705. NONUNIFORMSCALING: boolean;
  53706. MORPHTARGETS: boolean;
  53707. MORPHTARGETS_NORMAL: boolean;
  53708. MORPHTARGETS_TANGENT: boolean;
  53709. MORPHTARGETS_UV: boolean;
  53710. NUM_MORPH_INFLUENCERS: number;
  53711. IMAGEPROCESSING: boolean;
  53712. VIGNETTE: boolean;
  53713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53714. VIGNETTEBLENDMODEOPAQUE: boolean;
  53715. TONEMAPPING: boolean;
  53716. TONEMAPPING_ACES: boolean;
  53717. CONTRAST: boolean;
  53718. COLORCURVES: boolean;
  53719. COLORGRADING: boolean;
  53720. COLORGRADING3D: boolean;
  53721. SAMPLER3DGREENDEPTH: boolean;
  53722. SAMPLER3DBGRMAP: boolean;
  53723. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53724. EXPOSURE: boolean;
  53725. MULTIVIEW: boolean;
  53726. USEPHYSICALLIGHTFALLOFF: boolean;
  53727. USEGLTFLIGHTFALLOFF: boolean;
  53728. TWOSIDEDLIGHTING: boolean;
  53729. SHADOWFLOAT: boolean;
  53730. CLIPPLANE: boolean;
  53731. CLIPPLANE2: boolean;
  53732. CLIPPLANE3: boolean;
  53733. CLIPPLANE4: boolean;
  53734. CLIPPLANE5: boolean;
  53735. CLIPPLANE6: boolean;
  53736. POINTSIZE: boolean;
  53737. FOG: boolean;
  53738. LOGARITHMICDEPTH: boolean;
  53739. FORCENORMALFORWARD: boolean;
  53740. SPECULARAA: boolean;
  53741. CLEARCOAT: boolean;
  53742. CLEARCOAT_DEFAULTIOR: boolean;
  53743. CLEARCOAT_TEXTURE: boolean;
  53744. CLEARCOAT_TEXTUREDIRECTUV: number;
  53745. CLEARCOAT_BUMP: boolean;
  53746. CLEARCOAT_BUMPDIRECTUV: number;
  53747. CLEARCOAT_TINT: boolean;
  53748. CLEARCOAT_TINT_TEXTURE: boolean;
  53749. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53750. ANISOTROPIC: boolean;
  53751. ANISOTROPIC_TEXTURE: boolean;
  53752. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53753. BRDF_V_HEIGHT_CORRELATED: boolean;
  53754. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53755. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53756. SHEEN: boolean;
  53757. SHEEN_TEXTURE: boolean;
  53758. SHEEN_TEXTUREDIRECTUV: number;
  53759. SHEEN_LINKWITHALBEDO: boolean;
  53760. SHEEN_ROUGHNESS: boolean;
  53761. SHEEN_ALBEDOSCALING: boolean;
  53762. SUBSURFACE: boolean;
  53763. SS_REFRACTION: boolean;
  53764. SS_TRANSLUCENCY: boolean;
  53765. SS_SCATERRING: boolean;
  53766. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53767. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53768. SS_REFRACTIONMAP_3D: boolean;
  53769. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53770. SS_LODINREFRACTIONALPHA: boolean;
  53771. SS_GAMMAREFRACTION: boolean;
  53772. SS_RGBDREFRACTION: boolean;
  53773. SS_LINEARSPECULARREFRACTION: boolean;
  53774. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53775. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53776. UNLIT: boolean;
  53777. DEBUGMODE: number;
  53778. /**
  53779. * Initializes the PBR Material defines.
  53780. */
  53781. constructor();
  53782. /**
  53783. * Resets the PBR Material defines.
  53784. */
  53785. reset(): void;
  53786. }
  53787. /**
  53788. * The Physically based material base class of BJS.
  53789. *
  53790. * This offers the main features of a standard PBR material.
  53791. * For more information, please refer to the documentation :
  53792. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53793. */
  53794. export abstract class PBRBaseMaterial extends PushMaterial {
  53795. /**
  53796. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53797. */
  53798. static readonly PBRMATERIAL_OPAQUE: number;
  53799. /**
  53800. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53801. */
  53802. static readonly PBRMATERIAL_ALPHATEST: number;
  53803. /**
  53804. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53805. */
  53806. static readonly PBRMATERIAL_ALPHABLEND: number;
  53807. /**
  53808. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53809. * They are also discarded below the alpha cutoff threshold to improve performances.
  53810. */
  53811. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53812. /**
  53813. * Defines the default value of how much AO map is occluding the analytical lights
  53814. * (point spot...).
  53815. */
  53816. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53817. /**
  53818. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53819. */
  53820. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53821. /**
  53822. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53823. * to enhance interoperability with other engines.
  53824. */
  53825. static readonly LIGHTFALLOFF_GLTF: number;
  53826. /**
  53827. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53828. * to enhance interoperability with other materials.
  53829. */
  53830. static readonly LIGHTFALLOFF_STANDARD: number;
  53831. /**
  53832. * Intensity of the direct lights e.g. the four lights available in your scene.
  53833. * This impacts both the direct diffuse and specular highlights.
  53834. */
  53835. protected _directIntensity: number;
  53836. /**
  53837. * Intensity of the emissive part of the material.
  53838. * This helps controlling the emissive effect without modifying the emissive color.
  53839. */
  53840. protected _emissiveIntensity: number;
  53841. /**
  53842. * Intensity of the environment e.g. how much the environment will light the object
  53843. * either through harmonics for rough material or through the refelction for shiny ones.
  53844. */
  53845. protected _environmentIntensity: number;
  53846. /**
  53847. * This is a special control allowing the reduction of the specular highlights coming from the
  53848. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53849. */
  53850. protected _specularIntensity: number;
  53851. /**
  53852. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53853. */
  53854. private _lightingInfos;
  53855. /**
  53856. * Debug Control allowing disabling the bump map on this material.
  53857. */
  53858. protected _disableBumpMap: boolean;
  53859. /**
  53860. * AKA Diffuse Texture in standard nomenclature.
  53861. */
  53862. protected _albedoTexture: Nullable<BaseTexture>;
  53863. /**
  53864. * AKA Occlusion Texture in other nomenclature.
  53865. */
  53866. protected _ambientTexture: Nullable<BaseTexture>;
  53867. /**
  53868. * AKA Occlusion Texture Intensity in other nomenclature.
  53869. */
  53870. protected _ambientTextureStrength: number;
  53871. /**
  53872. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53873. * 1 means it completely occludes it
  53874. * 0 mean it has no impact
  53875. */
  53876. protected _ambientTextureImpactOnAnalyticalLights: number;
  53877. /**
  53878. * Stores the alpha values in a texture.
  53879. */
  53880. protected _opacityTexture: Nullable<BaseTexture>;
  53881. /**
  53882. * Stores the reflection values in a texture.
  53883. */
  53884. protected _reflectionTexture: Nullable<BaseTexture>;
  53885. /**
  53886. * Stores the emissive values in a texture.
  53887. */
  53888. protected _emissiveTexture: Nullable<BaseTexture>;
  53889. /**
  53890. * AKA Specular texture in other nomenclature.
  53891. */
  53892. protected _reflectivityTexture: Nullable<BaseTexture>;
  53893. /**
  53894. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53895. */
  53896. protected _metallicTexture: Nullable<BaseTexture>;
  53897. /**
  53898. * Specifies the metallic scalar of the metallic/roughness workflow.
  53899. * Can also be used to scale the metalness values of the metallic texture.
  53900. */
  53901. protected _metallic: Nullable<number>;
  53902. /**
  53903. * Specifies the roughness scalar of the metallic/roughness workflow.
  53904. * Can also be used to scale the roughness values of the metallic texture.
  53905. */
  53906. protected _roughness: Nullable<number>;
  53907. /**
  53908. * Specifies the an F0 factor to help configuring the material F0.
  53909. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53910. * to 0.5 the previously hard coded value stays the same.
  53911. * Can also be used to scale the F0 values of the metallic texture.
  53912. */
  53913. protected _metallicF0Factor: number;
  53914. /**
  53915. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53916. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53917. * your expectation as it multiplies with the texture data.
  53918. */
  53919. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53920. /**
  53921. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53922. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53923. */
  53924. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53925. /**
  53926. * Stores surface normal data used to displace a mesh in a texture.
  53927. */
  53928. protected _bumpTexture: Nullable<BaseTexture>;
  53929. /**
  53930. * Stores the pre-calculated light information of a mesh in a texture.
  53931. */
  53932. protected _lightmapTexture: Nullable<BaseTexture>;
  53933. /**
  53934. * The color of a material in ambient lighting.
  53935. */
  53936. protected _ambientColor: Color3;
  53937. /**
  53938. * AKA Diffuse Color in other nomenclature.
  53939. */
  53940. protected _albedoColor: Color3;
  53941. /**
  53942. * AKA Specular Color in other nomenclature.
  53943. */
  53944. protected _reflectivityColor: Color3;
  53945. /**
  53946. * The color applied when light is reflected from a material.
  53947. */
  53948. protected _reflectionColor: Color3;
  53949. /**
  53950. * The color applied when light is emitted from a material.
  53951. */
  53952. protected _emissiveColor: Color3;
  53953. /**
  53954. * AKA Glossiness in other nomenclature.
  53955. */
  53956. protected _microSurface: number;
  53957. /**
  53958. * Specifies that the material will use the light map as a show map.
  53959. */
  53960. protected _useLightmapAsShadowmap: boolean;
  53961. /**
  53962. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53963. * makes the reflect vector face the model (under horizon).
  53964. */
  53965. protected _useHorizonOcclusion: boolean;
  53966. /**
  53967. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53968. * too much the area relying on ambient texture to define their ambient occlusion.
  53969. */
  53970. protected _useRadianceOcclusion: boolean;
  53971. /**
  53972. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53973. */
  53974. protected _useAlphaFromAlbedoTexture: boolean;
  53975. /**
  53976. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53977. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53978. */
  53979. protected _useSpecularOverAlpha: boolean;
  53980. /**
  53981. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53982. */
  53983. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53984. /**
  53985. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53986. */
  53987. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53988. /**
  53989. * Specifies if the metallic texture contains the roughness information in its green channel.
  53990. */
  53991. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53992. /**
  53993. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53994. */
  53995. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53996. /**
  53997. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53998. */
  53999. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54000. /**
  54001. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54002. */
  54003. protected _useAmbientInGrayScale: boolean;
  54004. /**
  54005. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54006. * The material will try to infer what glossiness each pixel should be.
  54007. */
  54008. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54009. /**
  54010. * Defines the falloff type used in this material.
  54011. * It by default is Physical.
  54012. */
  54013. protected _lightFalloff: number;
  54014. /**
  54015. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54016. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54017. */
  54018. protected _useRadianceOverAlpha: boolean;
  54019. /**
  54020. * Allows using an object space normal map (instead of tangent space).
  54021. */
  54022. protected _useObjectSpaceNormalMap: boolean;
  54023. /**
  54024. * Allows using the bump map in parallax mode.
  54025. */
  54026. protected _useParallax: boolean;
  54027. /**
  54028. * Allows using the bump map in parallax occlusion mode.
  54029. */
  54030. protected _useParallaxOcclusion: boolean;
  54031. /**
  54032. * Controls the scale bias of the parallax mode.
  54033. */
  54034. protected _parallaxScaleBias: number;
  54035. /**
  54036. * If sets to true, disables all the lights affecting the material.
  54037. */
  54038. protected _disableLighting: boolean;
  54039. /**
  54040. * Number of Simultaneous lights allowed on the material.
  54041. */
  54042. protected _maxSimultaneousLights: number;
  54043. /**
  54044. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54045. */
  54046. protected _invertNormalMapX: boolean;
  54047. /**
  54048. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54049. */
  54050. protected _invertNormalMapY: boolean;
  54051. /**
  54052. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54053. */
  54054. protected _twoSidedLighting: boolean;
  54055. /**
  54056. * Defines the alpha limits in alpha test mode.
  54057. */
  54058. protected _alphaCutOff: number;
  54059. /**
  54060. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54061. */
  54062. protected _forceAlphaTest: boolean;
  54063. /**
  54064. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54065. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54066. */
  54067. protected _useAlphaFresnel: boolean;
  54068. /**
  54069. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54070. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54071. */
  54072. protected _useLinearAlphaFresnel: boolean;
  54073. /**
  54074. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54075. * from cos thetav and roughness:
  54076. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54077. */
  54078. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54079. /**
  54080. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54081. */
  54082. protected _forceIrradianceInFragment: boolean;
  54083. /**
  54084. * Force normal to face away from face.
  54085. */
  54086. protected _forceNormalForward: boolean;
  54087. /**
  54088. * Enables specular anti aliasing in the PBR shader.
  54089. * It will both interacts on the Geometry for analytical and IBL lighting.
  54090. * It also prefilter the roughness map based on the bump values.
  54091. */
  54092. protected _enableSpecularAntiAliasing: boolean;
  54093. /**
  54094. * Default configuration related to image processing available in the PBR Material.
  54095. */
  54096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54097. /**
  54098. * Keep track of the image processing observer to allow dispose and replace.
  54099. */
  54100. private _imageProcessingObserver;
  54101. /**
  54102. * Attaches a new image processing configuration to the PBR Material.
  54103. * @param configuration
  54104. */
  54105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54106. /**
  54107. * Stores the available render targets.
  54108. */
  54109. private _renderTargets;
  54110. /**
  54111. * Sets the global ambient color for the material used in lighting calculations.
  54112. */
  54113. private _globalAmbientColor;
  54114. /**
  54115. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54116. */
  54117. private _useLogarithmicDepth;
  54118. /**
  54119. * If set to true, no lighting calculations will be applied.
  54120. */
  54121. private _unlit;
  54122. private _debugMode;
  54123. /**
  54124. * @hidden
  54125. * This is reserved for the inspector.
  54126. * Defines the material debug mode.
  54127. * It helps seeing only some components of the material while troubleshooting.
  54128. */
  54129. debugMode: number;
  54130. /**
  54131. * @hidden
  54132. * This is reserved for the inspector.
  54133. * Specify from where on screen the debug mode should start.
  54134. * The value goes from -1 (full screen) to 1 (not visible)
  54135. * It helps with side by side comparison against the final render
  54136. * This defaults to -1
  54137. */
  54138. private debugLimit;
  54139. /**
  54140. * @hidden
  54141. * This is reserved for the inspector.
  54142. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54143. * You can use the factor to better multiply the final value.
  54144. */
  54145. private debugFactor;
  54146. /**
  54147. * Defines the clear coat layer parameters for the material.
  54148. */
  54149. readonly clearCoat: PBRClearCoatConfiguration;
  54150. /**
  54151. * Defines the anisotropic parameters for the material.
  54152. */
  54153. readonly anisotropy: PBRAnisotropicConfiguration;
  54154. /**
  54155. * Defines the BRDF parameters for the material.
  54156. */
  54157. readonly brdf: PBRBRDFConfiguration;
  54158. /**
  54159. * Defines the Sheen parameters for the material.
  54160. */
  54161. readonly sheen: PBRSheenConfiguration;
  54162. /**
  54163. * Defines the SubSurface parameters for the material.
  54164. */
  54165. readonly subSurface: PBRSubSurfaceConfiguration;
  54166. /**
  54167. * Custom callback helping to override the default shader used in the material.
  54168. */
  54169. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  54170. protected _rebuildInParallel: boolean;
  54171. /**
  54172. * Instantiates a new PBRMaterial instance.
  54173. *
  54174. * @param name The material name
  54175. * @param scene The scene the material will be use in.
  54176. */
  54177. constructor(name: string, scene: Scene);
  54178. /**
  54179. * Gets a boolean indicating that current material needs to register RTT
  54180. */
  54181. get hasRenderTargetTextures(): boolean;
  54182. /**
  54183. * Gets the name of the material class.
  54184. */
  54185. getClassName(): string;
  54186. /**
  54187. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54188. */
  54189. get useLogarithmicDepth(): boolean;
  54190. /**
  54191. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54192. */
  54193. set useLogarithmicDepth(value: boolean);
  54194. /**
  54195. * Returns true if alpha blending should be disabled.
  54196. */
  54197. protected get _disableAlphaBlending(): boolean;
  54198. /**
  54199. * Specifies whether or not this material should be rendered in alpha blend mode.
  54200. */
  54201. needAlphaBlending(): boolean;
  54202. /**
  54203. * Specifies whether or not this material should be rendered in alpha test mode.
  54204. */
  54205. needAlphaTesting(): boolean;
  54206. /**
  54207. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54208. */
  54209. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54210. /**
  54211. * Gets the texture used for the alpha test.
  54212. */
  54213. getAlphaTestTexture(): Nullable<BaseTexture>;
  54214. /**
  54215. * Specifies that the submesh is ready to be used.
  54216. * @param mesh - BJS mesh.
  54217. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54218. * @param useInstances - Specifies that instances should be used.
  54219. * @returns - boolean indicating that the submesh is ready or not.
  54220. */
  54221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54222. /**
  54223. * Specifies if the material uses metallic roughness workflow.
  54224. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54225. */
  54226. isMetallicWorkflow(): boolean;
  54227. private _prepareEffect;
  54228. private _prepareDefines;
  54229. /**
  54230. * Force shader compilation
  54231. */
  54232. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54233. /**
  54234. * Initializes the uniform buffer layout for the shader.
  54235. */
  54236. buildUniformLayout(): void;
  54237. /**
  54238. * Unbinds the material from the mesh
  54239. */
  54240. unbind(): void;
  54241. /**
  54242. * Binds the submesh data.
  54243. * @param world - The world matrix.
  54244. * @param mesh - The BJS mesh.
  54245. * @param subMesh - A submesh of the BJS mesh.
  54246. */
  54247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54248. /**
  54249. * Returns the animatable textures.
  54250. * @returns - Array of animatable textures.
  54251. */
  54252. getAnimatables(): IAnimatable[];
  54253. /**
  54254. * Returns the texture used for reflections.
  54255. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54256. */
  54257. private _getReflectionTexture;
  54258. /**
  54259. * Returns an array of the actively used textures.
  54260. * @returns - Array of BaseTextures
  54261. */
  54262. getActiveTextures(): BaseTexture[];
  54263. /**
  54264. * Checks to see if a texture is used in the material.
  54265. * @param texture - Base texture to use.
  54266. * @returns - Boolean specifying if a texture is used in the material.
  54267. */
  54268. hasTexture(texture: BaseTexture): boolean;
  54269. /**
  54270. * Disposes the resources of the material.
  54271. * @param forceDisposeEffect - Forces the disposal of effects.
  54272. * @param forceDisposeTextures - Forces the disposal of all textures.
  54273. */
  54274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54275. }
  54276. }
  54277. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54278. import { Nullable } from "babylonjs/types";
  54279. import { Scene } from "babylonjs/scene";
  54280. import { Color3 } from "babylonjs/Maths/math.color";
  54281. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54282. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54284. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54285. /**
  54286. * The Physically based material of BJS.
  54287. *
  54288. * This offers the main features of a standard PBR material.
  54289. * For more information, please refer to the documentation :
  54290. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54291. */
  54292. export class PBRMaterial extends PBRBaseMaterial {
  54293. /**
  54294. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54295. */
  54296. static readonly PBRMATERIAL_OPAQUE: number;
  54297. /**
  54298. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54299. */
  54300. static readonly PBRMATERIAL_ALPHATEST: number;
  54301. /**
  54302. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54303. */
  54304. static readonly PBRMATERIAL_ALPHABLEND: number;
  54305. /**
  54306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54307. * They are also discarded below the alpha cutoff threshold to improve performances.
  54308. */
  54309. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54310. /**
  54311. * Defines the default value of how much AO map is occluding the analytical lights
  54312. * (point spot...).
  54313. */
  54314. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54315. /**
  54316. * Intensity of the direct lights e.g. the four lights available in your scene.
  54317. * This impacts both the direct diffuse and specular highlights.
  54318. */
  54319. directIntensity: number;
  54320. /**
  54321. * Intensity of the emissive part of the material.
  54322. * This helps controlling the emissive effect without modifying the emissive color.
  54323. */
  54324. emissiveIntensity: number;
  54325. /**
  54326. * Intensity of the environment e.g. how much the environment will light the object
  54327. * either through harmonics for rough material or through the refelction for shiny ones.
  54328. */
  54329. environmentIntensity: number;
  54330. /**
  54331. * This is a special control allowing the reduction of the specular highlights coming from the
  54332. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54333. */
  54334. specularIntensity: number;
  54335. /**
  54336. * Debug Control allowing disabling the bump map on this material.
  54337. */
  54338. disableBumpMap: boolean;
  54339. /**
  54340. * AKA Diffuse Texture in standard nomenclature.
  54341. */
  54342. albedoTexture: BaseTexture;
  54343. /**
  54344. * AKA Occlusion Texture in other nomenclature.
  54345. */
  54346. ambientTexture: BaseTexture;
  54347. /**
  54348. * AKA Occlusion Texture Intensity in other nomenclature.
  54349. */
  54350. ambientTextureStrength: number;
  54351. /**
  54352. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54353. * 1 means it completely occludes it
  54354. * 0 mean it has no impact
  54355. */
  54356. ambientTextureImpactOnAnalyticalLights: number;
  54357. /**
  54358. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54359. */
  54360. opacityTexture: BaseTexture;
  54361. /**
  54362. * Stores the reflection values in a texture.
  54363. */
  54364. reflectionTexture: Nullable<BaseTexture>;
  54365. /**
  54366. * Stores the emissive values in a texture.
  54367. */
  54368. emissiveTexture: BaseTexture;
  54369. /**
  54370. * AKA Specular texture in other nomenclature.
  54371. */
  54372. reflectivityTexture: BaseTexture;
  54373. /**
  54374. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54375. */
  54376. metallicTexture: BaseTexture;
  54377. /**
  54378. * Specifies the metallic scalar of the metallic/roughness workflow.
  54379. * Can also be used to scale the metalness values of the metallic texture.
  54380. */
  54381. metallic: Nullable<number>;
  54382. /**
  54383. * Specifies the roughness scalar of the metallic/roughness workflow.
  54384. * Can also be used to scale the roughness values of the metallic texture.
  54385. */
  54386. roughness: Nullable<number>;
  54387. /**
  54388. * Specifies the an F0 factor to help configuring the material F0.
  54389. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54390. * to 0.5 the previously hard coded value stays the same.
  54391. * Can also be used to scale the F0 values of the metallic texture.
  54392. */
  54393. metallicF0Factor: number;
  54394. /**
  54395. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54396. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54397. * your expectation as it multiplies with the texture data.
  54398. */
  54399. useMetallicF0FactorFromMetallicTexture: boolean;
  54400. /**
  54401. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54402. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54403. */
  54404. microSurfaceTexture: BaseTexture;
  54405. /**
  54406. * Stores surface normal data used to displace a mesh in a texture.
  54407. */
  54408. bumpTexture: BaseTexture;
  54409. /**
  54410. * Stores the pre-calculated light information of a mesh in a texture.
  54411. */
  54412. lightmapTexture: BaseTexture;
  54413. /**
  54414. * Stores the refracted light information in a texture.
  54415. */
  54416. get refractionTexture(): Nullable<BaseTexture>;
  54417. set refractionTexture(value: Nullable<BaseTexture>);
  54418. /**
  54419. * The color of a material in ambient lighting.
  54420. */
  54421. ambientColor: Color3;
  54422. /**
  54423. * AKA Diffuse Color in other nomenclature.
  54424. */
  54425. albedoColor: Color3;
  54426. /**
  54427. * AKA Specular Color in other nomenclature.
  54428. */
  54429. reflectivityColor: Color3;
  54430. /**
  54431. * The color reflected from the material.
  54432. */
  54433. reflectionColor: Color3;
  54434. /**
  54435. * The color emitted from the material.
  54436. */
  54437. emissiveColor: Color3;
  54438. /**
  54439. * AKA Glossiness in other nomenclature.
  54440. */
  54441. microSurface: number;
  54442. /**
  54443. * source material index of refraction (IOR)' / 'destination material IOR.
  54444. */
  54445. get indexOfRefraction(): number;
  54446. set indexOfRefraction(value: number);
  54447. /**
  54448. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54449. */
  54450. get invertRefractionY(): boolean;
  54451. set invertRefractionY(value: boolean);
  54452. /**
  54453. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54454. * Materials half opaque for instance using refraction could benefit from this control.
  54455. */
  54456. get linkRefractionWithTransparency(): boolean;
  54457. set linkRefractionWithTransparency(value: boolean);
  54458. /**
  54459. * If true, the light map contains occlusion information instead of lighting info.
  54460. */
  54461. useLightmapAsShadowmap: boolean;
  54462. /**
  54463. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54464. */
  54465. useAlphaFromAlbedoTexture: boolean;
  54466. /**
  54467. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54468. */
  54469. forceAlphaTest: boolean;
  54470. /**
  54471. * Defines the alpha limits in alpha test mode.
  54472. */
  54473. alphaCutOff: number;
  54474. /**
  54475. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54476. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54477. */
  54478. useSpecularOverAlpha: boolean;
  54479. /**
  54480. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54481. */
  54482. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54483. /**
  54484. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54485. */
  54486. useRoughnessFromMetallicTextureAlpha: boolean;
  54487. /**
  54488. * Specifies if the metallic texture contains the roughness information in its green channel.
  54489. */
  54490. useRoughnessFromMetallicTextureGreen: boolean;
  54491. /**
  54492. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54493. */
  54494. useMetallnessFromMetallicTextureBlue: boolean;
  54495. /**
  54496. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54497. */
  54498. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54499. /**
  54500. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54501. */
  54502. useAmbientInGrayScale: boolean;
  54503. /**
  54504. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54505. * The material will try to infer what glossiness each pixel should be.
  54506. */
  54507. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54508. /**
  54509. * BJS is using an harcoded light falloff based on a manually sets up range.
  54510. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54511. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54512. */
  54513. get usePhysicalLightFalloff(): boolean;
  54514. /**
  54515. * BJS is using an harcoded light falloff based on a manually sets up range.
  54516. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54517. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54518. */
  54519. set usePhysicalLightFalloff(value: boolean);
  54520. /**
  54521. * In order to support the falloff compatibility with gltf, a special mode has been added
  54522. * to reproduce the gltf light falloff.
  54523. */
  54524. get useGLTFLightFalloff(): boolean;
  54525. /**
  54526. * In order to support the falloff compatibility with gltf, a special mode has been added
  54527. * to reproduce the gltf light falloff.
  54528. */
  54529. set useGLTFLightFalloff(value: boolean);
  54530. /**
  54531. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54532. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54533. */
  54534. useRadianceOverAlpha: boolean;
  54535. /**
  54536. * Allows using an object space normal map (instead of tangent space).
  54537. */
  54538. useObjectSpaceNormalMap: boolean;
  54539. /**
  54540. * Allows using the bump map in parallax mode.
  54541. */
  54542. useParallax: boolean;
  54543. /**
  54544. * Allows using the bump map in parallax occlusion mode.
  54545. */
  54546. useParallaxOcclusion: boolean;
  54547. /**
  54548. * Controls the scale bias of the parallax mode.
  54549. */
  54550. parallaxScaleBias: number;
  54551. /**
  54552. * If sets to true, disables all the lights affecting the material.
  54553. */
  54554. disableLighting: boolean;
  54555. /**
  54556. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54557. */
  54558. forceIrradianceInFragment: boolean;
  54559. /**
  54560. * Number of Simultaneous lights allowed on the material.
  54561. */
  54562. maxSimultaneousLights: number;
  54563. /**
  54564. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54565. */
  54566. invertNormalMapX: boolean;
  54567. /**
  54568. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54569. */
  54570. invertNormalMapY: boolean;
  54571. /**
  54572. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54573. */
  54574. twoSidedLighting: boolean;
  54575. /**
  54576. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54577. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54578. */
  54579. useAlphaFresnel: boolean;
  54580. /**
  54581. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54582. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54583. */
  54584. useLinearAlphaFresnel: boolean;
  54585. /**
  54586. * Let user defines the brdf lookup texture used for IBL.
  54587. * A default 8bit version is embedded but you could point at :
  54588. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54589. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54590. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54591. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54592. */
  54593. environmentBRDFTexture: Nullable<BaseTexture>;
  54594. /**
  54595. * Force normal to face away from face.
  54596. */
  54597. forceNormalForward: boolean;
  54598. /**
  54599. * Enables specular anti aliasing in the PBR shader.
  54600. * It will both interacts on the Geometry for analytical and IBL lighting.
  54601. * It also prefilter the roughness map based on the bump values.
  54602. */
  54603. enableSpecularAntiAliasing: boolean;
  54604. /**
  54605. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54606. * makes the reflect vector face the model (under horizon).
  54607. */
  54608. useHorizonOcclusion: boolean;
  54609. /**
  54610. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54611. * too much the area relying on ambient texture to define their ambient occlusion.
  54612. */
  54613. useRadianceOcclusion: boolean;
  54614. /**
  54615. * If set to true, no lighting calculations will be applied.
  54616. */
  54617. unlit: boolean;
  54618. /**
  54619. * Gets the image processing configuration used either in this material.
  54620. */
  54621. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54622. /**
  54623. * Sets the Default image processing configuration used either in the this material.
  54624. *
  54625. * If sets to null, the scene one is in use.
  54626. */
  54627. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54628. /**
  54629. * Gets wether the color curves effect is enabled.
  54630. */
  54631. get cameraColorCurvesEnabled(): boolean;
  54632. /**
  54633. * Sets wether the color curves effect is enabled.
  54634. */
  54635. set cameraColorCurvesEnabled(value: boolean);
  54636. /**
  54637. * Gets wether the color grading effect is enabled.
  54638. */
  54639. get cameraColorGradingEnabled(): boolean;
  54640. /**
  54641. * Gets wether the color grading effect is enabled.
  54642. */
  54643. set cameraColorGradingEnabled(value: boolean);
  54644. /**
  54645. * Gets wether tonemapping is enabled or not.
  54646. */
  54647. get cameraToneMappingEnabled(): boolean;
  54648. /**
  54649. * Sets wether tonemapping is enabled or not
  54650. */
  54651. set cameraToneMappingEnabled(value: boolean);
  54652. /**
  54653. * The camera exposure used on this material.
  54654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54655. * This corresponds to a photographic exposure.
  54656. */
  54657. get cameraExposure(): number;
  54658. /**
  54659. * The camera exposure used on this material.
  54660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54661. * This corresponds to a photographic exposure.
  54662. */
  54663. set cameraExposure(value: number);
  54664. /**
  54665. * Gets The camera contrast used on this material.
  54666. */
  54667. get cameraContrast(): number;
  54668. /**
  54669. * Sets The camera contrast used on this material.
  54670. */
  54671. set cameraContrast(value: number);
  54672. /**
  54673. * Gets the Color Grading 2D Lookup Texture.
  54674. */
  54675. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54676. /**
  54677. * Sets the Color Grading 2D Lookup Texture.
  54678. */
  54679. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54680. /**
  54681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54683. * 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;
  54684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54685. */
  54686. get cameraColorCurves(): Nullable<ColorCurves>;
  54687. /**
  54688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54690. * 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;
  54691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54692. */
  54693. set cameraColorCurves(value: Nullable<ColorCurves>);
  54694. /**
  54695. * Instantiates a new PBRMaterial instance.
  54696. *
  54697. * @param name The material name
  54698. * @param scene The scene the material will be use in.
  54699. */
  54700. constructor(name: string, scene: Scene);
  54701. /**
  54702. * Returns the name of this material class.
  54703. */
  54704. getClassName(): string;
  54705. /**
  54706. * Makes a duplicate of the current material.
  54707. * @param name - name to use for the new material.
  54708. */
  54709. clone(name: string): PBRMaterial;
  54710. /**
  54711. * Serializes this PBR Material.
  54712. * @returns - An object with the serialized material.
  54713. */
  54714. serialize(): any;
  54715. /**
  54716. * Parses a PBR Material from a serialized object.
  54717. * @param source - Serialized object.
  54718. * @param scene - BJS scene instance.
  54719. * @param rootUrl - url for the scene object
  54720. * @returns - PBRMaterial
  54721. */
  54722. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54723. }
  54724. }
  54725. declare module "babylonjs/Misc/dds" {
  54726. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54728. import { Nullable } from "babylonjs/types";
  54729. import { Scene } from "babylonjs/scene";
  54730. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54731. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54732. /**
  54733. * Direct draw surface info
  54734. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54735. */
  54736. export interface DDSInfo {
  54737. /**
  54738. * Width of the texture
  54739. */
  54740. width: number;
  54741. /**
  54742. * Width of the texture
  54743. */
  54744. height: number;
  54745. /**
  54746. * Number of Mipmaps for the texture
  54747. * @see https://en.wikipedia.org/wiki/Mipmap
  54748. */
  54749. mipmapCount: number;
  54750. /**
  54751. * If the textures format is a known fourCC format
  54752. * @see https://www.fourcc.org/
  54753. */
  54754. isFourCC: boolean;
  54755. /**
  54756. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54757. */
  54758. isRGB: boolean;
  54759. /**
  54760. * If the texture is a lumincance format
  54761. */
  54762. isLuminance: boolean;
  54763. /**
  54764. * If this is a cube texture
  54765. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54766. */
  54767. isCube: boolean;
  54768. /**
  54769. * If the texture is a compressed format eg. FOURCC_DXT1
  54770. */
  54771. isCompressed: boolean;
  54772. /**
  54773. * The dxgiFormat of the texture
  54774. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54775. */
  54776. dxgiFormat: number;
  54777. /**
  54778. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54779. */
  54780. textureType: number;
  54781. /**
  54782. * Sphericle polynomial created for the dds texture
  54783. */
  54784. sphericalPolynomial?: SphericalPolynomial;
  54785. }
  54786. /**
  54787. * Class used to provide DDS decompression tools
  54788. */
  54789. export class DDSTools {
  54790. /**
  54791. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54792. */
  54793. static StoreLODInAlphaChannel: boolean;
  54794. /**
  54795. * Gets DDS information from an array buffer
  54796. * @param data defines the array buffer view to read data from
  54797. * @returns the DDS information
  54798. */
  54799. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54800. private static _FloatView;
  54801. private static _Int32View;
  54802. private static _ToHalfFloat;
  54803. private static _FromHalfFloat;
  54804. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54805. private static _GetHalfFloatRGBAArrayBuffer;
  54806. private static _GetFloatRGBAArrayBuffer;
  54807. private static _GetFloatAsUIntRGBAArrayBuffer;
  54808. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54809. private static _GetRGBAArrayBuffer;
  54810. private static _ExtractLongWordOrder;
  54811. private static _GetRGBArrayBuffer;
  54812. private static _GetLuminanceArrayBuffer;
  54813. /**
  54814. * Uploads DDS Levels to a Babylon Texture
  54815. * @hidden
  54816. */
  54817. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54818. }
  54819. module "babylonjs/Engines/thinEngine" {
  54820. interface ThinEngine {
  54821. /**
  54822. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54823. * @param rootUrl defines the url where the file to load is located
  54824. * @param scene defines the current scene
  54825. * @param lodScale defines scale to apply to the mip map selection
  54826. * @param lodOffset defines offset to apply to the mip map selection
  54827. * @param onLoad defines an optional callback raised when the texture is loaded
  54828. * @param onError defines an optional callback raised if there is an issue to load the texture
  54829. * @param format defines the format of the data
  54830. * @param forcedExtension defines the extension to use to pick the right loader
  54831. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54832. * @returns the cube texture as an InternalTexture
  54833. */
  54834. 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;
  54835. }
  54836. }
  54837. }
  54838. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54839. import { Nullable } from "babylonjs/types";
  54840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54841. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54842. /**
  54843. * Implementation of the DDS Texture Loader.
  54844. * @hidden
  54845. */
  54846. export class _DDSTextureLoader implements IInternalTextureLoader {
  54847. /**
  54848. * Defines wether the loader supports cascade loading the different faces.
  54849. */
  54850. readonly supportCascades: boolean;
  54851. /**
  54852. * This returns if the loader support the current file information.
  54853. * @param extension defines the file extension of the file being loaded
  54854. * @returns true if the loader can load the specified file
  54855. */
  54856. canLoad(extension: string): boolean;
  54857. /**
  54858. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54859. * @param data contains the texture data
  54860. * @param texture defines the BabylonJS internal texture
  54861. * @param createPolynomials will be true if polynomials have been requested
  54862. * @param onLoad defines the callback to trigger once the texture is ready
  54863. * @param onError defines the callback to trigger in case of error
  54864. */
  54865. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54866. /**
  54867. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54868. * @param data contains the texture data
  54869. * @param texture defines the BabylonJS internal texture
  54870. * @param callback defines the method to call once ready to upload
  54871. */
  54872. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54873. }
  54874. }
  54875. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54876. import { Nullable } from "babylonjs/types";
  54877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54878. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54879. /**
  54880. * Implementation of the ENV Texture Loader.
  54881. * @hidden
  54882. */
  54883. export class _ENVTextureLoader implements IInternalTextureLoader {
  54884. /**
  54885. * Defines wether the loader supports cascade loading the different faces.
  54886. */
  54887. readonly supportCascades: boolean;
  54888. /**
  54889. * This returns if the loader support the current file information.
  54890. * @param extension defines the file extension of the file being loaded
  54891. * @returns true if the loader can load the specified file
  54892. */
  54893. canLoad(extension: string): boolean;
  54894. /**
  54895. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54896. * @param data contains the texture data
  54897. * @param texture defines the BabylonJS internal texture
  54898. * @param createPolynomials will be true if polynomials have been requested
  54899. * @param onLoad defines the callback to trigger once the texture is ready
  54900. * @param onError defines the callback to trigger in case of error
  54901. */
  54902. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54903. /**
  54904. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54905. * @param data contains the texture data
  54906. * @param texture defines the BabylonJS internal texture
  54907. * @param callback defines the method to call once ready to upload
  54908. */
  54909. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54910. }
  54911. }
  54912. declare module "babylonjs/Misc/khronosTextureContainer" {
  54913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54914. /**
  54915. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54916. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54917. */
  54918. export class KhronosTextureContainer {
  54919. /** contents of the KTX container file */
  54920. data: ArrayBufferView;
  54921. private static HEADER_LEN;
  54922. private static COMPRESSED_2D;
  54923. private static COMPRESSED_3D;
  54924. private static TEX_2D;
  54925. private static TEX_3D;
  54926. /**
  54927. * Gets the openGL type
  54928. */
  54929. glType: number;
  54930. /**
  54931. * Gets the openGL type size
  54932. */
  54933. glTypeSize: number;
  54934. /**
  54935. * Gets the openGL format
  54936. */
  54937. glFormat: number;
  54938. /**
  54939. * Gets the openGL internal format
  54940. */
  54941. glInternalFormat: number;
  54942. /**
  54943. * Gets the base internal format
  54944. */
  54945. glBaseInternalFormat: number;
  54946. /**
  54947. * Gets image width in pixel
  54948. */
  54949. pixelWidth: number;
  54950. /**
  54951. * Gets image height in pixel
  54952. */
  54953. pixelHeight: number;
  54954. /**
  54955. * Gets image depth in pixels
  54956. */
  54957. pixelDepth: number;
  54958. /**
  54959. * Gets the number of array elements
  54960. */
  54961. numberOfArrayElements: number;
  54962. /**
  54963. * Gets the number of faces
  54964. */
  54965. numberOfFaces: number;
  54966. /**
  54967. * Gets the number of mipmap levels
  54968. */
  54969. numberOfMipmapLevels: number;
  54970. /**
  54971. * Gets the bytes of key value data
  54972. */
  54973. bytesOfKeyValueData: number;
  54974. /**
  54975. * Gets the load type
  54976. */
  54977. loadType: number;
  54978. /**
  54979. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54980. */
  54981. isInvalid: boolean;
  54982. /**
  54983. * Creates a new KhronosTextureContainer
  54984. * @param data contents of the KTX container file
  54985. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54986. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54987. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54988. */
  54989. constructor(
  54990. /** contents of the KTX container file */
  54991. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54992. /**
  54993. * Uploads KTX content to a Babylon Texture.
  54994. * It is assumed that the texture has already been created & is currently bound
  54995. * @hidden
  54996. */
  54997. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54998. private _upload2DCompressedLevels;
  54999. /**
  55000. * Checks if the given data starts with a KTX file identifier.
  55001. * @param data the data to check
  55002. * @returns true if the data is a KTX file or false otherwise
  55003. */
  55004. static IsValid(data: ArrayBufferView): boolean;
  55005. }
  55006. }
  55007. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55008. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55010. /**
  55011. * Class for loading KTX2 files
  55012. * !!! Experimental Extension Subject to Changes !!!
  55013. * @hidden
  55014. */
  55015. export class KhronosTextureContainer2 {
  55016. private static _ModulePromise;
  55017. private static _TranscodeFormat;
  55018. constructor(engine: ThinEngine);
  55019. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55020. private _determineTranscodeFormat;
  55021. /**
  55022. * Checks if the given data starts with a KTX2 file identifier.
  55023. * @param data the data to check
  55024. * @returns true if the data is a KTX2 file or false otherwise
  55025. */
  55026. static IsValid(data: ArrayBufferView): boolean;
  55027. }
  55028. }
  55029. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55030. import { Nullable } from "babylonjs/types";
  55031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55032. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55033. /**
  55034. * Implementation of the KTX Texture Loader.
  55035. * @hidden
  55036. */
  55037. export class _KTXTextureLoader implements IInternalTextureLoader {
  55038. /**
  55039. * Defines wether the loader supports cascade loading the different faces.
  55040. */
  55041. readonly supportCascades: boolean;
  55042. /**
  55043. * This returns if the loader support the current file information.
  55044. * @param extension defines the file extension of the file being loaded
  55045. * @returns true if the loader can load the specified file
  55046. */
  55047. canLoad(extension: string): boolean;
  55048. /**
  55049. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55050. * @param data contains the texture data
  55051. * @param texture defines the BabylonJS internal texture
  55052. * @param createPolynomials will be true if polynomials have been requested
  55053. * @param onLoad defines the callback to trigger once the texture is ready
  55054. * @param onError defines the callback to trigger in case of error
  55055. */
  55056. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55057. /**
  55058. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55059. * @param data contains the texture data
  55060. * @param texture defines the BabylonJS internal texture
  55061. * @param callback defines the method to call once ready to upload
  55062. */
  55063. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55064. }
  55065. }
  55066. declare module "babylonjs/Helpers/sceneHelpers" {
  55067. import { Nullable } from "babylonjs/types";
  55068. import { Mesh } from "babylonjs/Meshes/mesh";
  55069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55070. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55071. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55072. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55073. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55074. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55075. import "babylonjs/Meshes/Builders/boxBuilder";
  55076. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55077. /** @hidden */
  55078. export var _forceSceneHelpersToBundle: boolean;
  55079. module "babylonjs/scene" {
  55080. interface Scene {
  55081. /**
  55082. * Creates a default light for the scene.
  55083. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55084. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55085. */
  55086. createDefaultLight(replace?: boolean): void;
  55087. /**
  55088. * Creates a default camera for the scene.
  55089. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55090. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55091. * @param replace has default false, when true replaces the active camera in the scene
  55092. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55093. */
  55094. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55095. /**
  55096. * Creates a default camera and a default light.
  55097. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55098. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55099. * @param replace has the default false, when true replaces the active camera/light in the scene
  55100. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55101. */
  55102. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55103. /**
  55104. * Creates a new sky box
  55105. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55106. * @param environmentTexture defines the texture to use as environment texture
  55107. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55108. * @param scale defines the overall scale of the skybox
  55109. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55110. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55111. * @returns a new mesh holding the sky box
  55112. */
  55113. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55114. /**
  55115. * Creates a new environment
  55116. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55117. * @param options defines the options you can use to configure the environment
  55118. * @returns the new EnvironmentHelper
  55119. */
  55120. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55121. /**
  55122. * Creates a new VREXperienceHelper
  55123. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55124. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55125. * @returns a new VREXperienceHelper
  55126. */
  55127. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55128. /**
  55129. * Creates a new WebXRDefaultExperience
  55130. * @see http://doc.babylonjs.com/how_to/webxr
  55131. * @param options experience options
  55132. * @returns a promise for a new WebXRDefaultExperience
  55133. */
  55134. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55135. }
  55136. }
  55137. }
  55138. declare module "babylonjs/Helpers/videoDome" {
  55139. import { Scene } from "babylonjs/scene";
  55140. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55141. import { Mesh } from "babylonjs/Meshes/mesh";
  55142. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55143. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55144. import "babylonjs/Meshes/Builders/sphereBuilder";
  55145. /**
  55146. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55147. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55148. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55149. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55150. */
  55151. export class VideoDome extends TransformNode {
  55152. /**
  55153. * Define the video source as a Monoscopic panoramic 360 video.
  55154. */
  55155. static readonly MODE_MONOSCOPIC: number;
  55156. /**
  55157. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55158. */
  55159. static readonly MODE_TOPBOTTOM: number;
  55160. /**
  55161. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55162. */
  55163. static readonly MODE_SIDEBYSIDE: number;
  55164. private _halfDome;
  55165. private _useDirectMapping;
  55166. /**
  55167. * The video texture being displayed on the sphere
  55168. */
  55169. protected _videoTexture: VideoTexture;
  55170. /**
  55171. * Gets the video texture being displayed on the sphere
  55172. */
  55173. get videoTexture(): VideoTexture;
  55174. /**
  55175. * The skybox material
  55176. */
  55177. protected _material: BackgroundMaterial;
  55178. /**
  55179. * The surface used for the skybox
  55180. */
  55181. protected _mesh: Mesh;
  55182. /**
  55183. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55184. */
  55185. private _halfDomeMask;
  55186. /**
  55187. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55188. * Also see the options.resolution property.
  55189. */
  55190. get fovMultiplier(): number;
  55191. set fovMultiplier(value: number);
  55192. private _videoMode;
  55193. /**
  55194. * Gets or set the current video mode for the video. It can be:
  55195. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55196. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55197. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55198. */
  55199. get videoMode(): number;
  55200. set videoMode(value: number);
  55201. /**
  55202. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55203. *
  55204. */
  55205. get halfDome(): boolean;
  55206. /**
  55207. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55208. */
  55209. set halfDome(enabled: boolean);
  55210. /**
  55211. * Oberserver used in Stereoscopic VR Mode.
  55212. */
  55213. private _onBeforeCameraRenderObserver;
  55214. /**
  55215. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55216. * @param name Element's name, child elements will append suffixes for their own names.
  55217. * @param urlsOrVideo defines the url(s) or the video element to use
  55218. * @param options An object containing optional or exposed sub element properties
  55219. */
  55220. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55221. resolution?: number;
  55222. clickToPlay?: boolean;
  55223. autoPlay?: boolean;
  55224. loop?: boolean;
  55225. size?: number;
  55226. poster?: string;
  55227. faceForward?: boolean;
  55228. useDirectMapping?: boolean;
  55229. halfDomeMode?: boolean;
  55230. }, scene: Scene);
  55231. private _changeVideoMode;
  55232. /**
  55233. * Releases resources associated with this node.
  55234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55236. */
  55237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55238. }
  55239. }
  55240. declare module "babylonjs/Helpers/index" {
  55241. export * from "babylonjs/Helpers/environmentHelper";
  55242. export * from "babylonjs/Helpers/photoDome";
  55243. export * from "babylonjs/Helpers/sceneHelpers";
  55244. export * from "babylonjs/Helpers/videoDome";
  55245. }
  55246. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55247. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55248. import { IDisposable } from "babylonjs/scene";
  55249. import { Engine } from "babylonjs/Engines/engine";
  55250. /**
  55251. * This class can be used to get instrumentation data from a Babylon engine
  55252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55253. */
  55254. export class EngineInstrumentation implements IDisposable {
  55255. /**
  55256. * Define the instrumented engine.
  55257. */
  55258. engine: Engine;
  55259. private _captureGPUFrameTime;
  55260. private _gpuFrameTimeToken;
  55261. private _gpuFrameTime;
  55262. private _captureShaderCompilationTime;
  55263. private _shaderCompilationTime;
  55264. private _onBeginFrameObserver;
  55265. private _onEndFrameObserver;
  55266. private _onBeforeShaderCompilationObserver;
  55267. private _onAfterShaderCompilationObserver;
  55268. /**
  55269. * Gets the perf counter used for GPU frame time
  55270. */
  55271. get gpuFrameTimeCounter(): PerfCounter;
  55272. /**
  55273. * Gets the GPU frame time capture status
  55274. */
  55275. get captureGPUFrameTime(): boolean;
  55276. /**
  55277. * Enable or disable the GPU frame time capture
  55278. */
  55279. set captureGPUFrameTime(value: boolean);
  55280. /**
  55281. * Gets the perf counter used for shader compilation time
  55282. */
  55283. get shaderCompilationTimeCounter(): PerfCounter;
  55284. /**
  55285. * Gets the shader compilation time capture status
  55286. */
  55287. get captureShaderCompilationTime(): boolean;
  55288. /**
  55289. * Enable or disable the shader compilation time capture
  55290. */
  55291. set captureShaderCompilationTime(value: boolean);
  55292. /**
  55293. * Instantiates a new engine instrumentation.
  55294. * This class can be used to get instrumentation data from a Babylon engine
  55295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55296. * @param engine Defines the engine to instrument
  55297. */
  55298. constructor(
  55299. /**
  55300. * Define the instrumented engine.
  55301. */
  55302. engine: Engine);
  55303. /**
  55304. * Dispose and release associated resources.
  55305. */
  55306. dispose(): void;
  55307. }
  55308. }
  55309. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55310. import { Scene, IDisposable } from "babylonjs/scene";
  55311. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55312. /**
  55313. * This class can be used to get instrumentation data from a Babylon engine
  55314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55315. */
  55316. export class SceneInstrumentation implements IDisposable {
  55317. /**
  55318. * Defines the scene to instrument
  55319. */
  55320. scene: Scene;
  55321. private _captureActiveMeshesEvaluationTime;
  55322. private _activeMeshesEvaluationTime;
  55323. private _captureRenderTargetsRenderTime;
  55324. private _renderTargetsRenderTime;
  55325. private _captureFrameTime;
  55326. private _frameTime;
  55327. private _captureRenderTime;
  55328. private _renderTime;
  55329. private _captureInterFrameTime;
  55330. private _interFrameTime;
  55331. private _captureParticlesRenderTime;
  55332. private _particlesRenderTime;
  55333. private _captureSpritesRenderTime;
  55334. private _spritesRenderTime;
  55335. private _capturePhysicsTime;
  55336. private _physicsTime;
  55337. private _captureAnimationsTime;
  55338. private _animationsTime;
  55339. private _captureCameraRenderTime;
  55340. private _cameraRenderTime;
  55341. private _onBeforeActiveMeshesEvaluationObserver;
  55342. private _onAfterActiveMeshesEvaluationObserver;
  55343. private _onBeforeRenderTargetsRenderObserver;
  55344. private _onAfterRenderTargetsRenderObserver;
  55345. private _onAfterRenderObserver;
  55346. private _onBeforeDrawPhaseObserver;
  55347. private _onAfterDrawPhaseObserver;
  55348. private _onBeforeAnimationsObserver;
  55349. private _onBeforeParticlesRenderingObserver;
  55350. private _onAfterParticlesRenderingObserver;
  55351. private _onBeforeSpritesRenderingObserver;
  55352. private _onAfterSpritesRenderingObserver;
  55353. private _onBeforePhysicsObserver;
  55354. private _onAfterPhysicsObserver;
  55355. private _onAfterAnimationsObserver;
  55356. private _onBeforeCameraRenderObserver;
  55357. private _onAfterCameraRenderObserver;
  55358. /**
  55359. * Gets the perf counter used for active meshes evaluation time
  55360. */
  55361. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55362. /**
  55363. * Gets the active meshes evaluation time capture status
  55364. */
  55365. get captureActiveMeshesEvaluationTime(): boolean;
  55366. /**
  55367. * Enable or disable the active meshes evaluation time capture
  55368. */
  55369. set captureActiveMeshesEvaluationTime(value: boolean);
  55370. /**
  55371. * Gets the perf counter used for render targets render time
  55372. */
  55373. get renderTargetsRenderTimeCounter(): PerfCounter;
  55374. /**
  55375. * Gets the render targets render time capture status
  55376. */
  55377. get captureRenderTargetsRenderTime(): boolean;
  55378. /**
  55379. * Enable or disable the render targets render time capture
  55380. */
  55381. set captureRenderTargetsRenderTime(value: boolean);
  55382. /**
  55383. * Gets the perf counter used for particles render time
  55384. */
  55385. get particlesRenderTimeCounter(): PerfCounter;
  55386. /**
  55387. * Gets the particles render time capture status
  55388. */
  55389. get captureParticlesRenderTime(): boolean;
  55390. /**
  55391. * Enable or disable the particles render time capture
  55392. */
  55393. set captureParticlesRenderTime(value: boolean);
  55394. /**
  55395. * Gets the perf counter used for sprites render time
  55396. */
  55397. get spritesRenderTimeCounter(): PerfCounter;
  55398. /**
  55399. * Gets the sprites render time capture status
  55400. */
  55401. get captureSpritesRenderTime(): boolean;
  55402. /**
  55403. * Enable or disable the sprites render time capture
  55404. */
  55405. set captureSpritesRenderTime(value: boolean);
  55406. /**
  55407. * Gets the perf counter used for physics time
  55408. */
  55409. get physicsTimeCounter(): PerfCounter;
  55410. /**
  55411. * Gets the physics time capture status
  55412. */
  55413. get capturePhysicsTime(): boolean;
  55414. /**
  55415. * Enable or disable the physics time capture
  55416. */
  55417. set capturePhysicsTime(value: boolean);
  55418. /**
  55419. * Gets the perf counter used for animations time
  55420. */
  55421. get animationsTimeCounter(): PerfCounter;
  55422. /**
  55423. * Gets the animations time capture status
  55424. */
  55425. get captureAnimationsTime(): boolean;
  55426. /**
  55427. * Enable or disable the animations time capture
  55428. */
  55429. set captureAnimationsTime(value: boolean);
  55430. /**
  55431. * Gets the perf counter used for frame time capture
  55432. */
  55433. get frameTimeCounter(): PerfCounter;
  55434. /**
  55435. * Gets the frame time capture status
  55436. */
  55437. get captureFrameTime(): boolean;
  55438. /**
  55439. * Enable or disable the frame time capture
  55440. */
  55441. set captureFrameTime(value: boolean);
  55442. /**
  55443. * Gets the perf counter used for inter-frames time capture
  55444. */
  55445. get interFrameTimeCounter(): PerfCounter;
  55446. /**
  55447. * Gets the inter-frames time capture status
  55448. */
  55449. get captureInterFrameTime(): boolean;
  55450. /**
  55451. * Enable or disable the inter-frames time capture
  55452. */
  55453. set captureInterFrameTime(value: boolean);
  55454. /**
  55455. * Gets the perf counter used for render time capture
  55456. */
  55457. get renderTimeCounter(): PerfCounter;
  55458. /**
  55459. * Gets the render time capture status
  55460. */
  55461. get captureRenderTime(): boolean;
  55462. /**
  55463. * Enable or disable the render time capture
  55464. */
  55465. set captureRenderTime(value: boolean);
  55466. /**
  55467. * Gets the perf counter used for camera render time capture
  55468. */
  55469. get cameraRenderTimeCounter(): PerfCounter;
  55470. /**
  55471. * Gets the camera render time capture status
  55472. */
  55473. get captureCameraRenderTime(): boolean;
  55474. /**
  55475. * Enable or disable the camera render time capture
  55476. */
  55477. set captureCameraRenderTime(value: boolean);
  55478. /**
  55479. * Gets the perf counter used for draw calls
  55480. */
  55481. get drawCallsCounter(): PerfCounter;
  55482. /**
  55483. * Instantiates a new scene instrumentation.
  55484. * This class can be used to get instrumentation data from a Babylon engine
  55485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55486. * @param scene Defines the scene to instrument
  55487. */
  55488. constructor(
  55489. /**
  55490. * Defines the scene to instrument
  55491. */
  55492. scene: Scene);
  55493. /**
  55494. * Dispose and release associated resources.
  55495. */
  55496. dispose(): void;
  55497. }
  55498. }
  55499. declare module "babylonjs/Instrumentation/index" {
  55500. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55501. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55502. export * from "babylonjs/Instrumentation/timeToken";
  55503. }
  55504. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55505. /** @hidden */
  55506. export var glowMapGenerationPixelShader: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55512. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55515. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55519. /** @hidden */
  55520. export var glowMapGenerationVertexShader: {
  55521. name: string;
  55522. shader: string;
  55523. };
  55524. }
  55525. declare module "babylonjs/Layers/effectLayer" {
  55526. import { Observable } from "babylonjs/Misc/observable";
  55527. import { Nullable } from "babylonjs/types";
  55528. import { Camera } from "babylonjs/Cameras/camera";
  55529. import { Scene } from "babylonjs/scene";
  55530. import { ISize } from "babylonjs/Maths/math.size";
  55531. import { Color4 } from "babylonjs/Maths/math.color";
  55532. import { Engine } from "babylonjs/Engines/engine";
  55533. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55535. import { Mesh } from "babylonjs/Meshes/mesh";
  55536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55538. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55539. import { Effect } from "babylonjs/Materials/effect";
  55540. import { Material } from "babylonjs/Materials/material";
  55541. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55542. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55543. /**
  55544. * Effect layer options. This helps customizing the behaviour
  55545. * of the effect layer.
  55546. */
  55547. export interface IEffectLayerOptions {
  55548. /**
  55549. * Multiplication factor apply to the canvas size to compute the render target size
  55550. * used to generated the objects (the smaller the faster).
  55551. */
  55552. mainTextureRatio: number;
  55553. /**
  55554. * Enforces a fixed size texture to ensure effect stability across devices.
  55555. */
  55556. mainTextureFixedSize?: number;
  55557. /**
  55558. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55559. */
  55560. alphaBlendingMode: number;
  55561. /**
  55562. * The camera attached to the layer.
  55563. */
  55564. camera: Nullable<Camera>;
  55565. /**
  55566. * The rendering group to draw the layer in.
  55567. */
  55568. renderingGroupId: number;
  55569. }
  55570. /**
  55571. * The effect layer Helps adding post process effect blended with the main pass.
  55572. *
  55573. * This can be for instance use to generate glow or higlight effects on the scene.
  55574. *
  55575. * The effect layer class can not be used directly and is intented to inherited from to be
  55576. * customized per effects.
  55577. */
  55578. export abstract class EffectLayer {
  55579. private _vertexBuffers;
  55580. private _indexBuffer;
  55581. private _cachedDefines;
  55582. private _effectLayerMapGenerationEffect;
  55583. private _effectLayerOptions;
  55584. private _mergeEffect;
  55585. protected _scene: Scene;
  55586. protected _engine: Engine;
  55587. protected _maxSize: number;
  55588. protected _mainTextureDesiredSize: ISize;
  55589. protected _mainTexture: RenderTargetTexture;
  55590. protected _shouldRender: boolean;
  55591. protected _postProcesses: PostProcess[];
  55592. protected _textures: BaseTexture[];
  55593. protected _emissiveTextureAndColor: {
  55594. texture: Nullable<BaseTexture>;
  55595. color: Color4;
  55596. };
  55597. /**
  55598. * The name of the layer
  55599. */
  55600. name: string;
  55601. /**
  55602. * The clear color of the texture used to generate the glow map.
  55603. */
  55604. neutralColor: Color4;
  55605. /**
  55606. * Specifies whether the highlight layer is enabled or not.
  55607. */
  55608. isEnabled: boolean;
  55609. /**
  55610. * Gets the camera attached to the layer.
  55611. */
  55612. get camera(): Nullable<Camera>;
  55613. /**
  55614. * Gets the rendering group id the layer should render in.
  55615. */
  55616. get renderingGroupId(): number;
  55617. set renderingGroupId(renderingGroupId: number);
  55618. /**
  55619. * An event triggered when the effect layer has been disposed.
  55620. */
  55621. onDisposeObservable: Observable<EffectLayer>;
  55622. /**
  55623. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55624. */
  55625. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55626. /**
  55627. * An event triggered when the generated texture is being merged in the scene.
  55628. */
  55629. onBeforeComposeObservable: Observable<EffectLayer>;
  55630. /**
  55631. * An event triggered when the mesh is rendered into the effect render target.
  55632. */
  55633. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55634. /**
  55635. * An event triggered after the mesh has been rendered into the effect render target.
  55636. */
  55637. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55638. /**
  55639. * An event triggered when the generated texture has been merged in the scene.
  55640. */
  55641. onAfterComposeObservable: Observable<EffectLayer>;
  55642. /**
  55643. * An event triggered when the efffect layer changes its size.
  55644. */
  55645. onSizeChangedObservable: Observable<EffectLayer>;
  55646. /** @hidden */
  55647. static _SceneComponentInitialization: (scene: Scene) => void;
  55648. /**
  55649. * Instantiates a new effect Layer and references it in the scene.
  55650. * @param name The name of the layer
  55651. * @param scene The scene to use the layer in
  55652. */
  55653. constructor(
  55654. /** The Friendly of the effect in the scene */
  55655. name: string, scene: Scene);
  55656. /**
  55657. * Get the effect name of the layer.
  55658. * @return The effect name
  55659. */
  55660. abstract getEffectName(): string;
  55661. /**
  55662. * Checks for the readiness of the element composing the layer.
  55663. * @param subMesh the mesh to check for
  55664. * @param useInstances specify whether or not to use instances to render the mesh
  55665. * @return true if ready otherwise, false
  55666. */
  55667. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55668. /**
  55669. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55670. * @returns true if the effect requires stencil during the main canvas render pass.
  55671. */
  55672. abstract needStencil(): boolean;
  55673. /**
  55674. * Create the merge effect. This is the shader use to blit the information back
  55675. * to the main canvas at the end of the scene rendering.
  55676. * @returns The effect containing the shader used to merge the effect on the main canvas
  55677. */
  55678. protected abstract _createMergeEffect(): Effect;
  55679. /**
  55680. * Creates the render target textures and post processes used in the effect layer.
  55681. */
  55682. protected abstract _createTextureAndPostProcesses(): void;
  55683. /**
  55684. * Implementation specific of rendering the generating effect on the main canvas.
  55685. * @param effect The effect used to render through
  55686. */
  55687. protected abstract _internalRender(effect: Effect): void;
  55688. /**
  55689. * Sets the required values for both the emissive texture and and the main color.
  55690. */
  55691. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55692. /**
  55693. * Free any resources and references associated to a mesh.
  55694. * Internal use
  55695. * @param mesh The mesh to free.
  55696. */
  55697. abstract _disposeMesh(mesh: Mesh): void;
  55698. /**
  55699. * Serializes this layer (Glow or Highlight for example)
  55700. * @returns a serialized layer object
  55701. */
  55702. abstract serialize?(): any;
  55703. /**
  55704. * Initializes the effect layer with the required options.
  55705. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55706. */
  55707. protected _init(options: Partial<IEffectLayerOptions>): void;
  55708. /**
  55709. * Generates the index buffer of the full screen quad blending to the main canvas.
  55710. */
  55711. private _generateIndexBuffer;
  55712. /**
  55713. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55714. */
  55715. private _generateVertexBuffer;
  55716. /**
  55717. * Sets the main texture desired size which is the closest power of two
  55718. * of the engine canvas size.
  55719. */
  55720. private _setMainTextureSize;
  55721. /**
  55722. * Creates the main texture for the effect layer.
  55723. */
  55724. protected _createMainTexture(): void;
  55725. /**
  55726. * Adds specific effects defines.
  55727. * @param defines The defines to add specifics to.
  55728. */
  55729. protected _addCustomEffectDefines(defines: string[]): void;
  55730. /**
  55731. * Checks for the readiness of the element composing the layer.
  55732. * @param subMesh the mesh to check for
  55733. * @param useInstances specify whether or not to use instances to render the mesh
  55734. * @param emissiveTexture the associated emissive texture used to generate the glow
  55735. * @return true if ready otherwise, false
  55736. */
  55737. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55738. /**
  55739. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55740. */
  55741. render(): void;
  55742. /**
  55743. * Determine if a given mesh will be used in the current effect.
  55744. * @param mesh mesh to test
  55745. * @returns true if the mesh will be used
  55746. */
  55747. hasMesh(mesh: AbstractMesh): boolean;
  55748. /**
  55749. * Returns true if the layer contains information to display, otherwise false.
  55750. * @returns true if the glow layer should be rendered
  55751. */
  55752. shouldRender(): boolean;
  55753. /**
  55754. * Returns true if the mesh should render, otherwise false.
  55755. * @param mesh The mesh to render
  55756. * @returns true if it should render otherwise false
  55757. */
  55758. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55759. /**
  55760. * Returns true if the mesh can be rendered, otherwise false.
  55761. * @param mesh The mesh to render
  55762. * @param material The material used on the mesh
  55763. * @returns true if it can be rendered otherwise false
  55764. */
  55765. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55766. /**
  55767. * Returns true if the mesh should render, otherwise false.
  55768. * @param mesh The mesh to render
  55769. * @returns true if it should render otherwise false
  55770. */
  55771. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55772. /**
  55773. * Renders the submesh passed in parameter to the generation map.
  55774. */
  55775. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55776. /**
  55777. * Defines whether the current material of the mesh should be use to render the effect.
  55778. * @param mesh defines the current mesh to render
  55779. */
  55780. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55781. /**
  55782. * Rebuild the required buffers.
  55783. * @hidden Internal use only.
  55784. */
  55785. _rebuild(): void;
  55786. /**
  55787. * Dispose only the render target textures and post process.
  55788. */
  55789. private _disposeTextureAndPostProcesses;
  55790. /**
  55791. * Dispose the highlight layer and free resources.
  55792. */
  55793. dispose(): void;
  55794. /**
  55795. * Gets the class name of the effect layer
  55796. * @returns the string with the class name of the effect layer
  55797. */
  55798. getClassName(): string;
  55799. /**
  55800. * Creates an effect layer from parsed effect layer data
  55801. * @param parsedEffectLayer defines effect layer data
  55802. * @param scene defines the current scene
  55803. * @param rootUrl defines the root URL containing the effect layer information
  55804. * @returns a parsed effect Layer
  55805. */
  55806. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55807. }
  55808. }
  55809. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55810. import { Scene } from "babylonjs/scene";
  55811. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55812. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55813. import { AbstractScene } from "babylonjs/abstractScene";
  55814. module "babylonjs/abstractScene" {
  55815. interface AbstractScene {
  55816. /**
  55817. * The list of effect layers (highlights/glow) added to the scene
  55818. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55819. * @see http://doc.babylonjs.com/how_to/glow_layer
  55820. */
  55821. effectLayers: Array<EffectLayer>;
  55822. /**
  55823. * Removes the given effect layer from this scene.
  55824. * @param toRemove defines the effect layer to remove
  55825. * @returns the index of the removed effect layer
  55826. */
  55827. removeEffectLayer(toRemove: EffectLayer): number;
  55828. /**
  55829. * Adds the given effect layer to this scene
  55830. * @param newEffectLayer defines the effect layer to add
  55831. */
  55832. addEffectLayer(newEffectLayer: EffectLayer): void;
  55833. }
  55834. }
  55835. /**
  55836. * Defines the layer scene component responsible to manage any effect layers
  55837. * in a given scene.
  55838. */
  55839. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55840. /**
  55841. * The component name helpfull to identify the component in the list of scene components.
  55842. */
  55843. readonly name: string;
  55844. /**
  55845. * The scene the component belongs to.
  55846. */
  55847. scene: Scene;
  55848. private _engine;
  55849. private _renderEffects;
  55850. private _needStencil;
  55851. private _previousStencilState;
  55852. /**
  55853. * Creates a new instance of the component for the given scene
  55854. * @param scene Defines the scene to register the component in
  55855. */
  55856. constructor(scene: Scene);
  55857. /**
  55858. * Registers the component in a given scene
  55859. */
  55860. register(): void;
  55861. /**
  55862. * Rebuilds the elements related to this component in case of
  55863. * context lost for instance.
  55864. */
  55865. rebuild(): void;
  55866. /**
  55867. * Serializes the component data to the specified json object
  55868. * @param serializationObject The object to serialize to
  55869. */
  55870. serialize(serializationObject: any): void;
  55871. /**
  55872. * Adds all the elements from the container to the scene
  55873. * @param container the container holding the elements
  55874. */
  55875. addFromContainer(container: AbstractScene): void;
  55876. /**
  55877. * Removes all the elements in the container from the scene
  55878. * @param container contains the elements to remove
  55879. * @param dispose if the removed element should be disposed (default: false)
  55880. */
  55881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55882. /**
  55883. * Disposes the component and the associated ressources.
  55884. */
  55885. dispose(): void;
  55886. private _isReadyForMesh;
  55887. private _renderMainTexture;
  55888. private _setStencil;
  55889. private _setStencilBack;
  55890. private _draw;
  55891. private _drawCamera;
  55892. private _drawRenderingGroup;
  55893. }
  55894. }
  55895. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55896. /** @hidden */
  55897. export var glowMapMergePixelShader: {
  55898. name: string;
  55899. shader: string;
  55900. };
  55901. }
  55902. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55903. /** @hidden */
  55904. export var glowMapMergeVertexShader: {
  55905. name: string;
  55906. shader: string;
  55907. };
  55908. }
  55909. declare module "babylonjs/Layers/glowLayer" {
  55910. import { Nullable } from "babylonjs/types";
  55911. import { Camera } from "babylonjs/Cameras/camera";
  55912. import { Scene } from "babylonjs/scene";
  55913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55915. import { Mesh } from "babylonjs/Meshes/mesh";
  55916. import { Texture } from "babylonjs/Materials/Textures/texture";
  55917. import { Effect } from "babylonjs/Materials/effect";
  55918. import { Material } from "babylonjs/Materials/material";
  55919. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55920. import { Color4 } from "babylonjs/Maths/math.color";
  55921. import "babylonjs/Shaders/glowMapMerge.fragment";
  55922. import "babylonjs/Shaders/glowMapMerge.vertex";
  55923. import "babylonjs/Layers/effectLayerSceneComponent";
  55924. module "babylonjs/abstractScene" {
  55925. interface AbstractScene {
  55926. /**
  55927. * Return a the first highlight layer of the scene with a given name.
  55928. * @param name The name of the highlight layer to look for.
  55929. * @return The highlight layer if found otherwise null.
  55930. */
  55931. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55932. }
  55933. }
  55934. /**
  55935. * Glow layer options. This helps customizing the behaviour
  55936. * of the glow layer.
  55937. */
  55938. export interface IGlowLayerOptions {
  55939. /**
  55940. * Multiplication factor apply to the canvas size to compute the render target size
  55941. * used to generated the glowing objects (the smaller the faster).
  55942. */
  55943. mainTextureRatio: number;
  55944. /**
  55945. * Enforces a fixed size texture to ensure resize independant blur.
  55946. */
  55947. mainTextureFixedSize?: number;
  55948. /**
  55949. * How big is the kernel of the blur texture.
  55950. */
  55951. blurKernelSize: number;
  55952. /**
  55953. * The camera attached to the layer.
  55954. */
  55955. camera: Nullable<Camera>;
  55956. /**
  55957. * Enable MSAA by chosing the number of samples.
  55958. */
  55959. mainTextureSamples?: number;
  55960. /**
  55961. * The rendering group to draw the layer in.
  55962. */
  55963. renderingGroupId: number;
  55964. }
  55965. /**
  55966. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55967. *
  55968. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55969. *
  55970. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55971. */
  55972. export class GlowLayer extends EffectLayer {
  55973. /**
  55974. * Effect Name of the layer.
  55975. */
  55976. static readonly EffectName: string;
  55977. /**
  55978. * The default blur kernel size used for the glow.
  55979. */
  55980. static DefaultBlurKernelSize: number;
  55981. /**
  55982. * The default texture size ratio used for the glow.
  55983. */
  55984. static DefaultTextureRatio: number;
  55985. /**
  55986. * Sets the kernel size of the blur.
  55987. */
  55988. set blurKernelSize(value: number);
  55989. /**
  55990. * Gets the kernel size of the blur.
  55991. */
  55992. get blurKernelSize(): number;
  55993. /**
  55994. * Sets the glow intensity.
  55995. */
  55996. set intensity(value: number);
  55997. /**
  55998. * Gets the glow intensity.
  55999. */
  56000. get intensity(): number;
  56001. private _options;
  56002. private _intensity;
  56003. private _horizontalBlurPostprocess1;
  56004. private _verticalBlurPostprocess1;
  56005. private _horizontalBlurPostprocess2;
  56006. private _verticalBlurPostprocess2;
  56007. private _blurTexture1;
  56008. private _blurTexture2;
  56009. private _postProcesses1;
  56010. private _postProcesses2;
  56011. private _includedOnlyMeshes;
  56012. private _excludedMeshes;
  56013. private _meshesUsingTheirOwnMaterials;
  56014. /**
  56015. * Callback used to let the user override the color selection on a per mesh basis
  56016. */
  56017. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56018. /**
  56019. * Callback used to let the user override the texture selection on a per mesh basis
  56020. */
  56021. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56022. /**
  56023. * Instantiates a new glow Layer and references it to the scene.
  56024. * @param name The name of the layer
  56025. * @param scene The scene to use the layer in
  56026. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56027. */
  56028. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56029. /**
  56030. * Get the effect name of the layer.
  56031. * @return The effect name
  56032. */
  56033. getEffectName(): string;
  56034. /**
  56035. * Create the merge effect. This is the shader use to blit the information back
  56036. * to the main canvas at the end of the scene rendering.
  56037. */
  56038. protected _createMergeEffect(): Effect;
  56039. /**
  56040. * Creates the render target textures and post processes used in the glow layer.
  56041. */
  56042. protected _createTextureAndPostProcesses(): void;
  56043. /**
  56044. * Checks for the readiness of the element composing the layer.
  56045. * @param subMesh the mesh to check for
  56046. * @param useInstances specify wether or not to use instances to render the mesh
  56047. * @param emissiveTexture the associated emissive texture used to generate the glow
  56048. * @return true if ready otherwise, false
  56049. */
  56050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56051. /**
  56052. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56053. */
  56054. needStencil(): boolean;
  56055. /**
  56056. * Returns true if the mesh can be rendered, otherwise false.
  56057. * @param mesh The mesh to render
  56058. * @param material The material used on the mesh
  56059. * @returns true if it can be rendered otherwise false
  56060. */
  56061. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56062. /**
  56063. * Implementation specific of rendering the generating effect on the main canvas.
  56064. * @param effect The effect used to render through
  56065. */
  56066. protected _internalRender(effect: Effect): void;
  56067. /**
  56068. * Sets the required values for both the emissive texture and and the main color.
  56069. */
  56070. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56071. /**
  56072. * Returns true if the mesh should render, otherwise false.
  56073. * @param mesh The mesh to render
  56074. * @returns true if it should render otherwise false
  56075. */
  56076. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56077. /**
  56078. * Adds specific effects defines.
  56079. * @param defines The defines to add specifics to.
  56080. */
  56081. protected _addCustomEffectDefines(defines: string[]): void;
  56082. /**
  56083. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56084. * @param mesh The mesh to exclude from the glow layer
  56085. */
  56086. addExcludedMesh(mesh: Mesh): void;
  56087. /**
  56088. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56089. * @param mesh The mesh to remove
  56090. */
  56091. removeExcludedMesh(mesh: Mesh): void;
  56092. /**
  56093. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56094. * @param mesh The mesh to include in the glow layer
  56095. */
  56096. addIncludedOnlyMesh(mesh: Mesh): void;
  56097. /**
  56098. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56099. * @param mesh The mesh to remove
  56100. */
  56101. removeIncludedOnlyMesh(mesh: Mesh): void;
  56102. /**
  56103. * Determine if a given mesh will be used in the glow layer
  56104. * @param mesh The mesh to test
  56105. * @returns true if the mesh will be highlighted by the current glow layer
  56106. */
  56107. hasMesh(mesh: AbstractMesh): boolean;
  56108. /**
  56109. * Defines whether the current material of the mesh should be use to render the effect.
  56110. * @param mesh defines the current mesh to render
  56111. */
  56112. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56113. /**
  56114. * Add a mesh to be rendered through its own material and not with emissive only.
  56115. * @param mesh The mesh for which we need to use its material
  56116. */
  56117. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56118. /**
  56119. * Remove a mesh from being rendered through its own material and not with emissive only.
  56120. * @param mesh The mesh for which we need to not use its material
  56121. */
  56122. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56123. /**
  56124. * Free any resources and references associated to a mesh.
  56125. * Internal use
  56126. * @param mesh The mesh to free.
  56127. * @hidden
  56128. */
  56129. _disposeMesh(mesh: Mesh): void;
  56130. /**
  56131. * Gets the class name of the effect layer
  56132. * @returns the string with the class name of the effect layer
  56133. */
  56134. getClassName(): string;
  56135. /**
  56136. * Serializes this glow layer
  56137. * @returns a serialized glow layer object
  56138. */
  56139. serialize(): any;
  56140. /**
  56141. * Creates a Glow Layer from parsed glow layer data
  56142. * @param parsedGlowLayer defines glow layer data
  56143. * @param scene defines the current scene
  56144. * @param rootUrl defines the root URL containing the glow layer information
  56145. * @returns a parsed Glow Layer
  56146. */
  56147. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56148. }
  56149. }
  56150. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56151. /** @hidden */
  56152. export var glowBlurPostProcessPixelShader: {
  56153. name: string;
  56154. shader: string;
  56155. };
  56156. }
  56157. declare module "babylonjs/Layers/highlightLayer" {
  56158. import { Observable } from "babylonjs/Misc/observable";
  56159. import { Nullable } from "babylonjs/types";
  56160. import { Camera } from "babylonjs/Cameras/camera";
  56161. import { Scene } from "babylonjs/scene";
  56162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56164. import { Mesh } from "babylonjs/Meshes/mesh";
  56165. import { Effect } from "babylonjs/Materials/effect";
  56166. import { Material } from "babylonjs/Materials/material";
  56167. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56168. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56169. import "babylonjs/Shaders/glowMapMerge.fragment";
  56170. import "babylonjs/Shaders/glowMapMerge.vertex";
  56171. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56172. module "babylonjs/abstractScene" {
  56173. interface AbstractScene {
  56174. /**
  56175. * Return a the first highlight layer of the scene with a given name.
  56176. * @param name The name of the highlight layer to look for.
  56177. * @return The highlight layer if found otherwise null.
  56178. */
  56179. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56180. }
  56181. }
  56182. /**
  56183. * Highlight layer options. This helps customizing the behaviour
  56184. * of the highlight layer.
  56185. */
  56186. export interface IHighlightLayerOptions {
  56187. /**
  56188. * Multiplication factor apply to the canvas size to compute the render target size
  56189. * used to generated the glowing objects (the smaller the faster).
  56190. */
  56191. mainTextureRatio: number;
  56192. /**
  56193. * Enforces a fixed size texture to ensure resize independant blur.
  56194. */
  56195. mainTextureFixedSize?: number;
  56196. /**
  56197. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56198. * of the picture to blur (the smaller the faster).
  56199. */
  56200. blurTextureSizeRatio: number;
  56201. /**
  56202. * How big in texel of the blur texture is the vertical blur.
  56203. */
  56204. blurVerticalSize: number;
  56205. /**
  56206. * How big in texel of the blur texture is the horizontal blur.
  56207. */
  56208. blurHorizontalSize: number;
  56209. /**
  56210. * Alpha blending mode used to apply the blur. Default is combine.
  56211. */
  56212. alphaBlendingMode: number;
  56213. /**
  56214. * The camera attached to the layer.
  56215. */
  56216. camera: Nullable<Camera>;
  56217. /**
  56218. * Should we display highlight as a solid stroke?
  56219. */
  56220. isStroke?: boolean;
  56221. /**
  56222. * The rendering group to draw the layer in.
  56223. */
  56224. renderingGroupId: number;
  56225. }
  56226. /**
  56227. * The highlight layer Helps adding a glow effect around a mesh.
  56228. *
  56229. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56230. * glowy meshes to your scene.
  56231. *
  56232. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56233. */
  56234. export class HighlightLayer extends EffectLayer {
  56235. name: string;
  56236. /**
  56237. * Effect Name of the highlight layer.
  56238. */
  56239. static readonly EffectName: string;
  56240. /**
  56241. * The neutral color used during the preparation of the glow effect.
  56242. * This is black by default as the blend operation is a blend operation.
  56243. */
  56244. static NeutralColor: Color4;
  56245. /**
  56246. * Stencil value used for glowing meshes.
  56247. */
  56248. static GlowingMeshStencilReference: number;
  56249. /**
  56250. * Stencil value used for the other meshes in the scene.
  56251. */
  56252. static NormalMeshStencilReference: number;
  56253. /**
  56254. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56255. */
  56256. innerGlow: boolean;
  56257. /**
  56258. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56259. */
  56260. outerGlow: boolean;
  56261. /**
  56262. * Specifies the horizontal size of the blur.
  56263. */
  56264. set blurHorizontalSize(value: number);
  56265. /**
  56266. * Specifies the vertical size of the blur.
  56267. */
  56268. set blurVerticalSize(value: number);
  56269. /**
  56270. * Gets the horizontal size of the blur.
  56271. */
  56272. get blurHorizontalSize(): number;
  56273. /**
  56274. * Gets the vertical size of the blur.
  56275. */
  56276. get blurVerticalSize(): number;
  56277. /**
  56278. * An event triggered when the highlight layer is being blurred.
  56279. */
  56280. onBeforeBlurObservable: Observable<HighlightLayer>;
  56281. /**
  56282. * An event triggered when the highlight layer has been blurred.
  56283. */
  56284. onAfterBlurObservable: Observable<HighlightLayer>;
  56285. private _instanceGlowingMeshStencilReference;
  56286. private _options;
  56287. private _downSamplePostprocess;
  56288. private _horizontalBlurPostprocess;
  56289. private _verticalBlurPostprocess;
  56290. private _blurTexture;
  56291. private _meshes;
  56292. private _excludedMeshes;
  56293. /**
  56294. * Instantiates a new highlight Layer and references it to the scene..
  56295. * @param name The name of the layer
  56296. * @param scene The scene to use the layer in
  56297. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56298. */
  56299. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56300. /**
  56301. * Get the effect name of the layer.
  56302. * @return The effect name
  56303. */
  56304. getEffectName(): string;
  56305. /**
  56306. * Create the merge effect. This is the shader use to blit the information back
  56307. * to the main canvas at the end of the scene rendering.
  56308. */
  56309. protected _createMergeEffect(): Effect;
  56310. /**
  56311. * Creates the render target textures and post processes used in the highlight layer.
  56312. */
  56313. protected _createTextureAndPostProcesses(): void;
  56314. /**
  56315. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56316. */
  56317. needStencil(): boolean;
  56318. /**
  56319. * Checks for the readiness of the element composing the layer.
  56320. * @param subMesh the mesh to check for
  56321. * @param useInstances specify wether or not to use instances to render the mesh
  56322. * @param emissiveTexture the associated emissive texture used to generate the glow
  56323. * @return true if ready otherwise, false
  56324. */
  56325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56326. /**
  56327. * Implementation specific of rendering the generating effect on the main canvas.
  56328. * @param effect The effect used to render through
  56329. */
  56330. protected _internalRender(effect: Effect): void;
  56331. /**
  56332. * Returns true if the layer contains information to display, otherwise false.
  56333. */
  56334. shouldRender(): boolean;
  56335. /**
  56336. * Returns true if the mesh should render, otherwise false.
  56337. * @param mesh The mesh to render
  56338. * @returns true if it should render otherwise false
  56339. */
  56340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56341. /**
  56342. * Adds specific effects defines.
  56343. * @param defines The defines to add specifics to.
  56344. */
  56345. protected _addCustomEffectDefines(defines: string[]): void;
  56346. /**
  56347. * Sets the required values for both the emissive texture and and the main color.
  56348. */
  56349. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56350. /**
  56351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56352. * @param mesh The mesh to exclude from the highlight layer
  56353. */
  56354. addExcludedMesh(mesh: Mesh): void;
  56355. /**
  56356. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56357. * @param mesh The mesh to highlight
  56358. */
  56359. removeExcludedMesh(mesh: Mesh): void;
  56360. /**
  56361. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56362. * @param mesh mesh to test
  56363. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56364. */
  56365. hasMesh(mesh: AbstractMesh): boolean;
  56366. /**
  56367. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56368. * @param mesh The mesh to highlight
  56369. * @param color The color of the highlight
  56370. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56371. */
  56372. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56373. /**
  56374. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56375. * @param mesh The mesh to highlight
  56376. */
  56377. removeMesh(mesh: Mesh): void;
  56378. /**
  56379. * Remove all the meshes currently referenced in the highlight layer
  56380. */
  56381. removeAllMeshes(): void;
  56382. /**
  56383. * Force the stencil to the normal expected value for none glowing parts
  56384. */
  56385. private _defaultStencilReference;
  56386. /**
  56387. * Free any resources and references associated to a mesh.
  56388. * Internal use
  56389. * @param mesh The mesh to free.
  56390. * @hidden
  56391. */
  56392. _disposeMesh(mesh: Mesh): void;
  56393. /**
  56394. * Dispose the highlight layer and free resources.
  56395. */
  56396. dispose(): void;
  56397. /**
  56398. * Gets the class name of the effect layer
  56399. * @returns the string with the class name of the effect layer
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Serializes this Highlight layer
  56404. * @returns a serialized Highlight layer object
  56405. */
  56406. serialize(): any;
  56407. /**
  56408. * Creates a Highlight layer from parsed Highlight layer data
  56409. * @param parsedHightlightLayer defines the Highlight layer data
  56410. * @param scene defines the current scene
  56411. * @param rootUrl defines the root URL containing the Highlight layer information
  56412. * @returns a parsed Highlight layer
  56413. */
  56414. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56415. }
  56416. }
  56417. declare module "babylonjs/Layers/layerSceneComponent" {
  56418. import { Scene } from "babylonjs/scene";
  56419. import { ISceneComponent } from "babylonjs/sceneComponent";
  56420. import { Layer } from "babylonjs/Layers/layer";
  56421. import { AbstractScene } from "babylonjs/abstractScene";
  56422. module "babylonjs/abstractScene" {
  56423. interface AbstractScene {
  56424. /**
  56425. * The list of layers (background and foreground) of the scene
  56426. */
  56427. layers: Array<Layer>;
  56428. }
  56429. }
  56430. /**
  56431. * Defines the layer scene component responsible to manage any layers
  56432. * in a given scene.
  56433. */
  56434. export class LayerSceneComponent implements ISceneComponent {
  56435. /**
  56436. * The component name helpfull to identify the component in the list of scene components.
  56437. */
  56438. readonly name: string;
  56439. /**
  56440. * The scene the component belongs to.
  56441. */
  56442. scene: Scene;
  56443. private _engine;
  56444. /**
  56445. * Creates a new instance of the component for the given scene
  56446. * @param scene Defines the scene to register the component in
  56447. */
  56448. constructor(scene: Scene);
  56449. /**
  56450. * Registers the component in a given scene
  56451. */
  56452. register(): void;
  56453. /**
  56454. * Rebuilds the elements related to this component in case of
  56455. * context lost for instance.
  56456. */
  56457. rebuild(): void;
  56458. /**
  56459. * Disposes the component and the associated ressources.
  56460. */
  56461. dispose(): void;
  56462. private _draw;
  56463. private _drawCameraPredicate;
  56464. private _drawCameraBackground;
  56465. private _drawCameraForeground;
  56466. private _drawRenderTargetPredicate;
  56467. private _drawRenderTargetBackground;
  56468. private _drawRenderTargetForeground;
  56469. /**
  56470. * Adds all the elements from the container to the scene
  56471. * @param container the container holding the elements
  56472. */
  56473. addFromContainer(container: AbstractScene): void;
  56474. /**
  56475. * Removes all the elements in the container from the scene
  56476. * @param container contains the elements to remove
  56477. * @param dispose if the removed element should be disposed (default: false)
  56478. */
  56479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56480. }
  56481. }
  56482. declare module "babylonjs/Shaders/layer.fragment" {
  56483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56484. /** @hidden */
  56485. export var layerPixelShader: {
  56486. name: string;
  56487. shader: string;
  56488. };
  56489. }
  56490. declare module "babylonjs/Shaders/layer.vertex" {
  56491. /** @hidden */
  56492. export var layerVertexShader: {
  56493. name: string;
  56494. shader: string;
  56495. };
  56496. }
  56497. declare module "babylonjs/Layers/layer" {
  56498. import { Observable } from "babylonjs/Misc/observable";
  56499. import { Nullable } from "babylonjs/types";
  56500. import { Scene } from "babylonjs/scene";
  56501. import { Vector2 } from "babylonjs/Maths/math.vector";
  56502. import { Color4 } from "babylonjs/Maths/math.color";
  56503. import { Texture } from "babylonjs/Materials/Textures/texture";
  56504. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56505. import "babylonjs/Shaders/layer.fragment";
  56506. import "babylonjs/Shaders/layer.vertex";
  56507. /**
  56508. * This represents a full screen 2d layer.
  56509. * This can be useful to display a picture in the background of your scene for instance.
  56510. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56511. */
  56512. export class Layer {
  56513. /**
  56514. * Define the name of the layer.
  56515. */
  56516. name: string;
  56517. /**
  56518. * Define the texture the layer should display.
  56519. */
  56520. texture: Nullable<Texture>;
  56521. /**
  56522. * Is the layer in background or foreground.
  56523. */
  56524. isBackground: boolean;
  56525. /**
  56526. * Define the color of the layer (instead of texture).
  56527. */
  56528. color: Color4;
  56529. /**
  56530. * Define the scale of the layer in order to zoom in out of the texture.
  56531. */
  56532. scale: Vector2;
  56533. /**
  56534. * Define an offset for the layer in order to shift the texture.
  56535. */
  56536. offset: Vector2;
  56537. /**
  56538. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56539. */
  56540. alphaBlendingMode: number;
  56541. /**
  56542. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56543. * Alpha test will not mix with the background color in case of transparency.
  56544. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56545. */
  56546. alphaTest: boolean;
  56547. /**
  56548. * Define a mask to restrict the layer to only some of the scene cameras.
  56549. */
  56550. layerMask: number;
  56551. /**
  56552. * Define the list of render target the layer is visible into.
  56553. */
  56554. renderTargetTextures: RenderTargetTexture[];
  56555. /**
  56556. * Define if the layer is only used in renderTarget or if it also
  56557. * renders in the main frame buffer of the canvas.
  56558. */
  56559. renderOnlyInRenderTargetTextures: boolean;
  56560. private _scene;
  56561. private _vertexBuffers;
  56562. private _indexBuffer;
  56563. private _effect;
  56564. private _previousDefines;
  56565. /**
  56566. * An event triggered when the layer is disposed.
  56567. */
  56568. onDisposeObservable: Observable<Layer>;
  56569. private _onDisposeObserver;
  56570. /**
  56571. * Back compatibility with callback before the onDisposeObservable existed.
  56572. * The set callback will be triggered when the layer has been disposed.
  56573. */
  56574. set onDispose(callback: () => void);
  56575. /**
  56576. * An event triggered before rendering the scene
  56577. */
  56578. onBeforeRenderObservable: Observable<Layer>;
  56579. private _onBeforeRenderObserver;
  56580. /**
  56581. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56582. * The set callback will be triggered just before rendering the layer.
  56583. */
  56584. set onBeforeRender(callback: () => void);
  56585. /**
  56586. * An event triggered after rendering the scene
  56587. */
  56588. onAfterRenderObservable: Observable<Layer>;
  56589. private _onAfterRenderObserver;
  56590. /**
  56591. * Back compatibility with callback before the onAfterRenderObservable existed.
  56592. * The set callback will be triggered just after rendering the layer.
  56593. */
  56594. set onAfterRender(callback: () => void);
  56595. /**
  56596. * Instantiates a new layer.
  56597. * This represents a full screen 2d layer.
  56598. * This can be useful to display a picture in the background of your scene for instance.
  56599. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56600. * @param name Define the name of the layer in the scene
  56601. * @param imgUrl Define the url of the texture to display in the layer
  56602. * @param scene Define the scene the layer belongs to
  56603. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56604. * @param color Defines a color for the layer
  56605. */
  56606. constructor(
  56607. /**
  56608. * Define the name of the layer.
  56609. */
  56610. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56611. private _createIndexBuffer;
  56612. /** @hidden */
  56613. _rebuild(): void;
  56614. /**
  56615. * Renders the layer in the scene.
  56616. */
  56617. render(): void;
  56618. /**
  56619. * Disposes and releases the associated ressources.
  56620. */
  56621. dispose(): void;
  56622. }
  56623. }
  56624. declare module "babylonjs/Layers/index" {
  56625. export * from "babylonjs/Layers/effectLayer";
  56626. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56627. export * from "babylonjs/Layers/glowLayer";
  56628. export * from "babylonjs/Layers/highlightLayer";
  56629. export * from "babylonjs/Layers/layer";
  56630. export * from "babylonjs/Layers/layerSceneComponent";
  56631. }
  56632. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56633. /** @hidden */
  56634. export var lensFlarePixelShader: {
  56635. name: string;
  56636. shader: string;
  56637. };
  56638. }
  56639. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56640. /** @hidden */
  56641. export var lensFlareVertexShader: {
  56642. name: string;
  56643. shader: string;
  56644. };
  56645. }
  56646. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56647. import { Scene } from "babylonjs/scene";
  56648. import { Vector3 } from "babylonjs/Maths/math.vector";
  56649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56650. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56651. import "babylonjs/Shaders/lensFlare.fragment";
  56652. import "babylonjs/Shaders/lensFlare.vertex";
  56653. import { Viewport } from "babylonjs/Maths/math.viewport";
  56654. /**
  56655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56656. * It is usually composed of several `lensFlare`.
  56657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56658. */
  56659. export class LensFlareSystem {
  56660. /**
  56661. * Define the name of the lens flare system
  56662. */
  56663. name: string;
  56664. /**
  56665. * List of lens flares used in this system.
  56666. */
  56667. lensFlares: LensFlare[];
  56668. /**
  56669. * Define a limit from the border the lens flare can be visible.
  56670. */
  56671. borderLimit: number;
  56672. /**
  56673. * Define a viewport border we do not want to see the lens flare in.
  56674. */
  56675. viewportBorder: number;
  56676. /**
  56677. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56678. */
  56679. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56680. /**
  56681. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56682. */
  56683. layerMask: number;
  56684. /**
  56685. * Define the id of the lens flare system in the scene.
  56686. * (equal to name by default)
  56687. */
  56688. id: string;
  56689. private _scene;
  56690. private _emitter;
  56691. private _vertexBuffers;
  56692. private _indexBuffer;
  56693. private _effect;
  56694. private _positionX;
  56695. private _positionY;
  56696. private _isEnabled;
  56697. /** @hidden */
  56698. static _SceneComponentInitialization: (scene: Scene) => void;
  56699. /**
  56700. * Instantiates a lens flare system.
  56701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56702. * It is usually composed of several `lensFlare`.
  56703. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56704. * @param name Define the name of the lens flare system in the scene
  56705. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56706. * @param scene Define the scene the lens flare system belongs to
  56707. */
  56708. constructor(
  56709. /**
  56710. * Define the name of the lens flare system
  56711. */
  56712. name: string, emitter: any, scene: Scene);
  56713. /**
  56714. * Define if the lens flare system is enabled.
  56715. */
  56716. get isEnabled(): boolean;
  56717. set isEnabled(value: boolean);
  56718. /**
  56719. * Get the scene the effects belongs to.
  56720. * @returns the scene holding the lens flare system
  56721. */
  56722. getScene(): Scene;
  56723. /**
  56724. * Get the emitter of the lens flare system.
  56725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56726. * @returns the emitter of the lens flare system
  56727. */
  56728. getEmitter(): any;
  56729. /**
  56730. * Set the emitter of the lens flare system.
  56731. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56732. * @param newEmitter Define the new emitter of the system
  56733. */
  56734. setEmitter(newEmitter: any): void;
  56735. /**
  56736. * Get the lens flare system emitter position.
  56737. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56738. * @returns the position
  56739. */
  56740. getEmitterPosition(): Vector3;
  56741. /**
  56742. * @hidden
  56743. */
  56744. computeEffectivePosition(globalViewport: Viewport): boolean;
  56745. /** @hidden */
  56746. _isVisible(): boolean;
  56747. /**
  56748. * @hidden
  56749. */
  56750. render(): boolean;
  56751. /**
  56752. * Dispose and release the lens flare with its associated resources.
  56753. */
  56754. dispose(): void;
  56755. /**
  56756. * Parse a lens flare system from a JSON repressentation
  56757. * @param parsedLensFlareSystem Define the JSON to parse
  56758. * @param scene Define the scene the parsed system should be instantiated in
  56759. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56760. * @returns the parsed system
  56761. */
  56762. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56763. /**
  56764. * Serialize the current Lens Flare System into a JSON representation.
  56765. * @returns the serialized JSON
  56766. */
  56767. serialize(): any;
  56768. }
  56769. }
  56770. declare module "babylonjs/LensFlares/lensFlare" {
  56771. import { Nullable } from "babylonjs/types";
  56772. import { Color3 } from "babylonjs/Maths/math.color";
  56773. import { Texture } from "babylonjs/Materials/Textures/texture";
  56774. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56775. /**
  56776. * This represents one of the lens effect in a `lensFlareSystem`.
  56777. * It controls one of the indiviual texture used in the effect.
  56778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56779. */
  56780. export class LensFlare {
  56781. /**
  56782. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56783. */
  56784. size: number;
  56785. /**
  56786. * 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.
  56787. */
  56788. position: number;
  56789. /**
  56790. * Define the lens color.
  56791. */
  56792. color: Color3;
  56793. /**
  56794. * Define the lens texture.
  56795. */
  56796. texture: Nullable<Texture>;
  56797. /**
  56798. * Define the alpha mode to render this particular lens.
  56799. */
  56800. alphaMode: number;
  56801. private _system;
  56802. /**
  56803. * Creates a new Lens Flare.
  56804. * This represents one of the lens effect in a `lensFlareSystem`.
  56805. * It controls one of the indiviual texture used in the effect.
  56806. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56807. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56808. * @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.
  56809. * @param color Define the lens color
  56810. * @param imgUrl Define the lens texture url
  56811. * @param system Define the `lensFlareSystem` this flare is part of
  56812. * @returns The newly created Lens Flare
  56813. */
  56814. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56815. /**
  56816. * Instantiates a new Lens Flare.
  56817. * This represents one of the lens effect in a `lensFlareSystem`.
  56818. * It controls one of the indiviual texture used in the effect.
  56819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56820. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56821. * @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.
  56822. * @param color Define the lens color
  56823. * @param imgUrl Define the lens texture url
  56824. * @param system Define the `lensFlareSystem` this flare is part of
  56825. */
  56826. constructor(
  56827. /**
  56828. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56829. */
  56830. size: number,
  56831. /**
  56832. * 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.
  56833. */
  56834. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56835. /**
  56836. * Dispose and release the lens flare with its associated resources.
  56837. */
  56838. dispose(): void;
  56839. }
  56840. }
  56841. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56842. import { Nullable } from "babylonjs/types";
  56843. import { Scene } from "babylonjs/scene";
  56844. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56845. import { AbstractScene } from "babylonjs/abstractScene";
  56846. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56847. module "babylonjs/abstractScene" {
  56848. interface AbstractScene {
  56849. /**
  56850. * The list of lens flare system added to the scene
  56851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56852. */
  56853. lensFlareSystems: Array<LensFlareSystem>;
  56854. /**
  56855. * Removes the given lens flare system from this scene.
  56856. * @param toRemove The lens flare system to remove
  56857. * @returns The index of the removed lens flare system
  56858. */
  56859. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56860. /**
  56861. * Adds the given lens flare system to this scene
  56862. * @param newLensFlareSystem The lens flare system to add
  56863. */
  56864. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56865. /**
  56866. * Gets a lens flare system using its name
  56867. * @param name defines the name to look for
  56868. * @returns the lens flare system or null if not found
  56869. */
  56870. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56871. /**
  56872. * Gets a lens flare system using its id
  56873. * @param id defines the id to look for
  56874. * @returns the lens flare system or null if not found
  56875. */
  56876. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56877. }
  56878. }
  56879. /**
  56880. * Defines the lens flare scene component responsible to manage any lens flares
  56881. * in a given scene.
  56882. */
  56883. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56884. /**
  56885. * The component name helpfull to identify the component in the list of scene components.
  56886. */
  56887. readonly name: string;
  56888. /**
  56889. * The scene the component belongs to.
  56890. */
  56891. scene: Scene;
  56892. /**
  56893. * Creates a new instance of the component for the given scene
  56894. * @param scene Defines the scene to register the component in
  56895. */
  56896. constructor(scene: Scene);
  56897. /**
  56898. * Registers the component in a given scene
  56899. */
  56900. register(): void;
  56901. /**
  56902. * Rebuilds the elements related to this component in case of
  56903. * context lost for instance.
  56904. */
  56905. rebuild(): void;
  56906. /**
  56907. * Adds all the elements from the container to the scene
  56908. * @param container the container holding the elements
  56909. */
  56910. addFromContainer(container: AbstractScene): void;
  56911. /**
  56912. * Removes all the elements in the container from the scene
  56913. * @param container contains the elements to remove
  56914. * @param dispose if the removed element should be disposed (default: false)
  56915. */
  56916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56917. /**
  56918. * Serializes the component data to the specified json object
  56919. * @param serializationObject The object to serialize to
  56920. */
  56921. serialize(serializationObject: any): void;
  56922. /**
  56923. * Disposes the component and the associated ressources.
  56924. */
  56925. dispose(): void;
  56926. private _draw;
  56927. }
  56928. }
  56929. declare module "babylonjs/LensFlares/index" {
  56930. export * from "babylonjs/LensFlares/lensFlare";
  56931. export * from "babylonjs/LensFlares/lensFlareSystem";
  56932. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56933. }
  56934. declare module "babylonjs/Shaders/depth.fragment" {
  56935. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56936. /** @hidden */
  56937. export var depthPixelShader: {
  56938. name: string;
  56939. shader: string;
  56940. };
  56941. }
  56942. declare module "babylonjs/Shaders/depth.vertex" {
  56943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56946. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56950. /** @hidden */
  56951. export var depthVertexShader: {
  56952. name: string;
  56953. shader: string;
  56954. };
  56955. }
  56956. declare module "babylonjs/Rendering/depthRenderer" {
  56957. import { Nullable } from "babylonjs/types";
  56958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56959. import { Scene } from "babylonjs/scene";
  56960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56961. import { Camera } from "babylonjs/Cameras/camera";
  56962. import "babylonjs/Shaders/depth.fragment";
  56963. import "babylonjs/Shaders/depth.vertex";
  56964. /**
  56965. * This represents a depth renderer in Babylon.
  56966. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56967. */
  56968. export class DepthRenderer {
  56969. private _scene;
  56970. private _depthMap;
  56971. private _effect;
  56972. private readonly _storeNonLinearDepth;
  56973. private readonly _clearColor;
  56974. /** Get if the depth renderer is using packed depth or not */
  56975. readonly isPacked: boolean;
  56976. private _cachedDefines;
  56977. private _camera;
  56978. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56979. enabled: boolean;
  56980. /**
  56981. * Specifiess that the depth renderer will only be used within
  56982. * the camera it is created for.
  56983. * This can help forcing its rendering during the camera processing.
  56984. */
  56985. useOnlyInActiveCamera: boolean;
  56986. /** @hidden */
  56987. static _SceneComponentInitialization: (scene: Scene) => void;
  56988. /**
  56989. * Instantiates a depth renderer
  56990. * @param scene The scene the renderer belongs to
  56991. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56992. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56994. */
  56995. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56996. /**
  56997. * Creates the depth rendering effect and checks if the effect is ready.
  56998. * @param subMesh The submesh to be used to render the depth map of
  56999. * @param useInstances If multiple world instances should be used
  57000. * @returns if the depth renderer is ready to render the depth map
  57001. */
  57002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57003. /**
  57004. * Gets the texture which the depth map will be written to.
  57005. * @returns The depth map texture
  57006. */
  57007. getDepthMap(): RenderTargetTexture;
  57008. /**
  57009. * Disposes of the depth renderer.
  57010. */
  57011. dispose(): void;
  57012. }
  57013. }
  57014. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57015. /** @hidden */
  57016. export var minmaxReduxPixelShader: {
  57017. name: string;
  57018. shader: string;
  57019. };
  57020. }
  57021. declare module "babylonjs/Misc/minMaxReducer" {
  57022. import { Nullable } from "babylonjs/types";
  57023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57024. import { Camera } from "babylonjs/Cameras/camera";
  57025. import { Observer } from "babylonjs/Misc/observable";
  57026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57027. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57028. import { Observable } from "babylonjs/Misc/observable";
  57029. import "babylonjs/Shaders/minmaxRedux.fragment";
  57030. /**
  57031. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57032. * and maximum values from all values of the texture.
  57033. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57034. * The source values are read from the red channel of the texture.
  57035. */
  57036. export class MinMaxReducer {
  57037. /**
  57038. * Observable triggered when the computation has been performed
  57039. */
  57040. onAfterReductionPerformed: Observable<{
  57041. min: number;
  57042. max: number;
  57043. }>;
  57044. protected _camera: Camera;
  57045. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57046. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57047. protected _postProcessManager: PostProcessManager;
  57048. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57049. protected _forceFullscreenViewport: boolean;
  57050. /**
  57051. * Creates a min/max reducer
  57052. * @param camera The camera to use for the post processes
  57053. */
  57054. constructor(camera: Camera);
  57055. /**
  57056. * Gets the texture used to read the values from.
  57057. */
  57058. get sourceTexture(): Nullable<RenderTargetTexture>;
  57059. /**
  57060. * Sets the source texture to read the values from.
  57061. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57062. * because in such textures '1' value must not be taken into account to compute the maximum
  57063. * as this value is used to clear the texture.
  57064. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57065. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57066. * @param depthRedux Indicates if the texture is a depth texture or not
  57067. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57068. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57069. */
  57070. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57071. /**
  57072. * Defines the refresh rate of the computation.
  57073. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57074. */
  57075. get refreshRate(): number;
  57076. set refreshRate(value: number);
  57077. protected _activated: boolean;
  57078. /**
  57079. * Gets the activation status of the reducer
  57080. */
  57081. get activated(): boolean;
  57082. /**
  57083. * Activates the reduction computation.
  57084. * When activated, the observers registered in onAfterReductionPerformed are
  57085. * called after the compuation is performed
  57086. */
  57087. activate(): void;
  57088. /**
  57089. * Deactivates the reduction computation.
  57090. */
  57091. deactivate(): void;
  57092. /**
  57093. * Disposes the min/max reducer
  57094. * @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.
  57095. */
  57096. dispose(disposeAll?: boolean): void;
  57097. }
  57098. }
  57099. declare module "babylonjs/Misc/depthReducer" {
  57100. import { Nullable } from "babylonjs/types";
  57101. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57102. import { Camera } from "babylonjs/Cameras/camera";
  57103. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57104. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57105. /**
  57106. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57107. */
  57108. export class DepthReducer extends MinMaxReducer {
  57109. private _depthRenderer;
  57110. private _depthRendererId;
  57111. /**
  57112. * Gets the depth renderer used for the computation.
  57113. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57114. */
  57115. get depthRenderer(): Nullable<DepthRenderer>;
  57116. /**
  57117. * Creates a depth reducer
  57118. * @param camera The camera used to render the depth texture
  57119. */
  57120. constructor(camera: Camera);
  57121. /**
  57122. * Sets the depth renderer to use to generate the depth map
  57123. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57124. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57125. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57126. */
  57127. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57128. /** @hidden */
  57129. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57130. /**
  57131. * Activates the reduction computation.
  57132. * When activated, the observers registered in onAfterReductionPerformed are
  57133. * called after the compuation is performed
  57134. */
  57135. activate(): void;
  57136. /**
  57137. * Deactivates the reduction computation.
  57138. */
  57139. deactivate(): void;
  57140. /**
  57141. * Disposes the depth reducer
  57142. * @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.
  57143. */
  57144. dispose(disposeAll?: boolean): void;
  57145. }
  57146. }
  57147. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57148. import { Nullable } from "babylonjs/types";
  57149. import { Scene } from "babylonjs/scene";
  57150. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57152. import { Effect } from "babylonjs/Materials/effect";
  57153. import "babylonjs/Shaders/shadowMap.fragment";
  57154. import "babylonjs/Shaders/shadowMap.vertex";
  57155. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57156. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57157. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57158. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57159. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57160. /**
  57161. * A CSM implementation allowing casting shadows on large scenes.
  57162. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57163. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57164. */
  57165. export class CascadedShadowGenerator extends ShadowGenerator {
  57166. private static readonly frustumCornersNDCSpace;
  57167. /**
  57168. * Name of the CSM class
  57169. */
  57170. static CLASSNAME: string;
  57171. /**
  57172. * Defines the default number of cascades used by the CSM.
  57173. */
  57174. static readonly DEFAULT_CASCADES_COUNT: number;
  57175. /**
  57176. * Defines the minimum number of cascades used by the CSM.
  57177. */
  57178. static readonly MIN_CASCADES_COUNT: number;
  57179. /**
  57180. * Defines the maximum number of cascades used by the CSM.
  57181. */
  57182. static readonly MAX_CASCADES_COUNT: number;
  57183. protected _validateFilter(filter: number): number;
  57184. /**
  57185. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57186. */
  57187. penumbraDarkness: number;
  57188. private _numCascades;
  57189. /**
  57190. * Gets or set the number of cascades used by the CSM.
  57191. */
  57192. get numCascades(): number;
  57193. set numCascades(value: number);
  57194. /**
  57195. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57196. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57197. */
  57198. stabilizeCascades: boolean;
  57199. private _freezeShadowCastersBoundingInfo;
  57200. private _freezeShadowCastersBoundingInfoObservable;
  57201. /**
  57202. * Enables or disables the shadow casters bounding info computation.
  57203. * If your shadow casters don't move, you can disable this feature.
  57204. * If it is enabled, the bounding box computation is done every frame.
  57205. */
  57206. get freezeShadowCastersBoundingInfo(): boolean;
  57207. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57208. private _scbiMin;
  57209. private _scbiMax;
  57210. protected _computeShadowCastersBoundingInfo(): void;
  57211. protected _shadowCastersBoundingInfo: BoundingInfo;
  57212. /**
  57213. * Gets or sets the shadow casters bounding info.
  57214. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57215. * so that the system won't overwrite the bounds you provide
  57216. */
  57217. get shadowCastersBoundingInfo(): BoundingInfo;
  57218. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57219. protected _breaksAreDirty: boolean;
  57220. protected _minDistance: number;
  57221. protected _maxDistance: number;
  57222. /**
  57223. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57224. *
  57225. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57226. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57227. * @param min minimal distance for the breaks (default to 0.)
  57228. * @param max maximal distance for the breaks (default to 1.)
  57229. */
  57230. setMinMaxDistance(min: number, max: number): void;
  57231. /** Gets the minimal distance used in the cascade break computation */
  57232. get minDistance(): number;
  57233. /** Gets the maximal distance used in the cascade break computation */
  57234. get maxDistance(): number;
  57235. /**
  57236. * Gets the class name of that object
  57237. * @returns "CascadedShadowGenerator"
  57238. */
  57239. getClassName(): string;
  57240. private _cascadeMinExtents;
  57241. private _cascadeMaxExtents;
  57242. /**
  57243. * Gets a cascade minimum extents
  57244. * @param cascadeIndex index of the cascade
  57245. * @returns the minimum cascade extents
  57246. */
  57247. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57248. /**
  57249. * Gets a cascade maximum extents
  57250. * @param cascadeIndex index of the cascade
  57251. * @returns the maximum cascade extents
  57252. */
  57253. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57254. private _cascades;
  57255. private _currentLayer;
  57256. private _viewSpaceFrustumsZ;
  57257. private _viewMatrices;
  57258. private _projectionMatrices;
  57259. private _transformMatrices;
  57260. private _transformMatricesAsArray;
  57261. private _frustumLengths;
  57262. private _lightSizeUVCorrection;
  57263. private _depthCorrection;
  57264. private _frustumCornersWorldSpace;
  57265. private _frustumCenter;
  57266. private _shadowCameraPos;
  57267. private _shadowMaxZ;
  57268. /**
  57269. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57270. * It defaults to camera.maxZ
  57271. */
  57272. get shadowMaxZ(): number;
  57273. /**
  57274. * Sets the shadow max z distance.
  57275. */
  57276. set shadowMaxZ(value: number);
  57277. protected _debug: boolean;
  57278. /**
  57279. * Gets or sets the debug flag.
  57280. * When enabled, the cascades are materialized by different colors on the screen.
  57281. */
  57282. get debug(): boolean;
  57283. set debug(dbg: boolean);
  57284. private _depthClamp;
  57285. /**
  57286. * Gets or sets the depth clamping value.
  57287. *
  57288. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57289. * to account for the shadow casters far away.
  57290. *
  57291. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57292. */
  57293. get depthClamp(): boolean;
  57294. set depthClamp(value: boolean);
  57295. private _cascadeBlendPercentage;
  57296. /**
  57297. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57298. * It defaults to 0.1 (10% blending).
  57299. */
  57300. get cascadeBlendPercentage(): number;
  57301. set cascadeBlendPercentage(value: number);
  57302. private _lambda;
  57303. /**
  57304. * Gets or set the lambda parameter.
  57305. * This parameter is used to split the camera frustum and create the cascades.
  57306. * 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.
  57307. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57308. */
  57309. get lambda(): number;
  57310. set lambda(value: number);
  57311. /**
  57312. * Gets the view matrix corresponding to a given cascade
  57313. * @param cascadeNum cascade to retrieve the view matrix from
  57314. * @returns the cascade view matrix
  57315. */
  57316. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57317. /**
  57318. * Gets the projection matrix corresponding to a given cascade
  57319. * @param cascadeNum cascade to retrieve the projection matrix from
  57320. * @returns the cascade projection matrix
  57321. */
  57322. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57323. /**
  57324. * Gets the transformation matrix corresponding to a given cascade
  57325. * @param cascadeNum cascade to retrieve the transformation matrix from
  57326. * @returns the cascade transformation matrix
  57327. */
  57328. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57329. private _depthRenderer;
  57330. /**
  57331. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57332. *
  57333. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57334. *
  57335. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57336. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57337. * @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
  57338. */
  57339. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57340. private _depthReducer;
  57341. private _autoCalcDepthBounds;
  57342. /**
  57343. * Gets or sets the autoCalcDepthBounds property.
  57344. *
  57345. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57346. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57347. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57348. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57349. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57350. */
  57351. get autoCalcDepthBounds(): boolean;
  57352. set autoCalcDepthBounds(value: boolean);
  57353. /**
  57354. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57355. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57356. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57357. * for setting the refresh rate on the renderer yourself!
  57358. */
  57359. get autoCalcDepthBoundsRefreshRate(): number;
  57360. set autoCalcDepthBoundsRefreshRate(value: number);
  57361. /**
  57362. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57363. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57364. * you change the camera near/far planes!
  57365. */
  57366. splitFrustum(): void;
  57367. private _splitFrustum;
  57368. private _computeMatrices;
  57369. private _computeFrustumInWorldSpace;
  57370. private _computeCascadeFrustum;
  57371. /**
  57372. * Support test.
  57373. */
  57374. static get IsSupported(): boolean;
  57375. /** @hidden */
  57376. static _SceneComponentInitialization: (scene: Scene) => void;
  57377. /**
  57378. * Creates a Cascaded Shadow Generator object.
  57379. * A ShadowGenerator is the required tool to use the shadows.
  57380. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57381. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57382. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57383. * @param light The directional light object generating the shadows.
  57384. * @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.
  57385. */
  57386. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57387. protected _initializeGenerator(): void;
  57388. protected _createTargetRenderTexture(): void;
  57389. protected _initializeShadowMap(): void;
  57390. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57391. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57392. /**
  57393. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57394. * @param defines Defines of the material we want to update
  57395. * @param lightIndex Index of the light in the enabled light list of the material
  57396. */
  57397. prepareDefines(defines: any, lightIndex: number): void;
  57398. /**
  57399. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57400. * defined in the generator but impacting the effect).
  57401. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57402. * @param effect The effect we are binfing the information for
  57403. */
  57404. bindShadowLight(lightIndex: string, effect: Effect): void;
  57405. /**
  57406. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57407. * (eq to view projection * shadow projection matrices)
  57408. * @returns The transform matrix used to create the shadow map
  57409. */
  57410. getTransformMatrix(): Matrix;
  57411. /**
  57412. * Disposes the ShadowGenerator.
  57413. * Returns nothing.
  57414. */
  57415. dispose(): void;
  57416. /**
  57417. * Serializes the shadow generator setup to a json object.
  57418. * @returns The serialized JSON object
  57419. */
  57420. serialize(): any;
  57421. /**
  57422. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57423. * @param parsedShadowGenerator The JSON object to parse
  57424. * @param scene The scene to create the shadow map for
  57425. * @returns The parsed shadow generator
  57426. */
  57427. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57428. }
  57429. }
  57430. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57431. import { Scene } from "babylonjs/scene";
  57432. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57433. import { AbstractScene } from "babylonjs/abstractScene";
  57434. /**
  57435. * Defines the shadow generator component responsible to manage any shadow generators
  57436. * in a given scene.
  57437. */
  57438. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57439. /**
  57440. * The component name helpfull to identify the component in the list of scene components.
  57441. */
  57442. readonly name: string;
  57443. /**
  57444. * The scene the component belongs to.
  57445. */
  57446. scene: Scene;
  57447. /**
  57448. * Creates a new instance of the component for the given scene
  57449. * @param scene Defines the scene to register the component in
  57450. */
  57451. constructor(scene: Scene);
  57452. /**
  57453. * Registers the component in a given scene
  57454. */
  57455. register(): void;
  57456. /**
  57457. * Rebuilds the elements related to this component in case of
  57458. * context lost for instance.
  57459. */
  57460. rebuild(): void;
  57461. /**
  57462. * Serializes the component data to the specified json object
  57463. * @param serializationObject The object to serialize to
  57464. */
  57465. serialize(serializationObject: any): void;
  57466. /**
  57467. * Adds all the elements from the container to the scene
  57468. * @param container the container holding the elements
  57469. */
  57470. addFromContainer(container: AbstractScene): void;
  57471. /**
  57472. * Removes all the elements in the container from the scene
  57473. * @param container contains the elements to remove
  57474. * @param dispose if the removed element should be disposed (default: false)
  57475. */
  57476. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57477. /**
  57478. * Rebuilds the elements related to this component in case of
  57479. * context lost for instance.
  57480. */
  57481. dispose(): void;
  57482. private _gatherRenderTargets;
  57483. }
  57484. }
  57485. declare module "babylonjs/Lights/Shadows/index" {
  57486. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57487. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57488. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57489. }
  57490. declare module "babylonjs/Lights/pointLight" {
  57491. import { Scene } from "babylonjs/scene";
  57492. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57494. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57495. import { Effect } from "babylonjs/Materials/effect";
  57496. /**
  57497. * A point light is a light defined by an unique point in world space.
  57498. * The light is emitted in every direction from this point.
  57499. * A good example of a point light is a standard light bulb.
  57500. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57501. */
  57502. export class PointLight extends ShadowLight {
  57503. private _shadowAngle;
  57504. /**
  57505. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57506. * This specifies what angle the shadow will use to be created.
  57507. *
  57508. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57509. */
  57510. get shadowAngle(): number;
  57511. /**
  57512. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57513. * This specifies what angle the shadow will use to be created.
  57514. *
  57515. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57516. */
  57517. set shadowAngle(value: number);
  57518. /**
  57519. * Gets the direction if it has been set.
  57520. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57521. */
  57522. get direction(): Vector3;
  57523. /**
  57524. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57525. */
  57526. set direction(value: Vector3);
  57527. /**
  57528. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57529. * A PointLight emits the light in every direction.
  57530. * It can cast shadows.
  57531. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57532. * ```javascript
  57533. * var pointLight = new PointLight("pl", camera.position, scene);
  57534. * ```
  57535. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57536. * @param name The light friendly name
  57537. * @param position The position of the point light in the scene
  57538. * @param scene The scene the lights belongs to
  57539. */
  57540. constructor(name: string, position: Vector3, scene: Scene);
  57541. /**
  57542. * Returns the string "PointLight"
  57543. * @returns the class name
  57544. */
  57545. getClassName(): string;
  57546. /**
  57547. * Returns the integer 0.
  57548. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57549. */
  57550. getTypeID(): number;
  57551. /**
  57552. * Specifies wether or not the shadowmap should be a cube texture.
  57553. * @returns true if the shadowmap needs to be a cube texture.
  57554. */
  57555. needCube(): boolean;
  57556. /**
  57557. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57558. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57559. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57560. */
  57561. getShadowDirection(faceIndex?: number): Vector3;
  57562. /**
  57563. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57564. * - fov = PI / 2
  57565. * - aspect ratio : 1.0
  57566. * - z-near and far equal to the active camera minZ and maxZ.
  57567. * Returns the PointLight.
  57568. */
  57569. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57570. protected _buildUniformLayout(): void;
  57571. /**
  57572. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57573. * @param effect The effect to update
  57574. * @param lightIndex The index of the light in the effect to update
  57575. * @returns The point light
  57576. */
  57577. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57578. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57579. /**
  57580. * Prepares the list of defines specific to the light type.
  57581. * @param defines the list of defines
  57582. * @param lightIndex defines the index of the light for the effect
  57583. */
  57584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57585. }
  57586. }
  57587. declare module "babylonjs/Lights/index" {
  57588. export * from "babylonjs/Lights/light";
  57589. export * from "babylonjs/Lights/shadowLight";
  57590. export * from "babylonjs/Lights/Shadows/index";
  57591. export * from "babylonjs/Lights/directionalLight";
  57592. export * from "babylonjs/Lights/hemisphericLight";
  57593. export * from "babylonjs/Lights/pointLight";
  57594. export * from "babylonjs/Lights/spotLight";
  57595. }
  57596. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57597. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57598. /**
  57599. * Header information of HDR texture files.
  57600. */
  57601. export interface HDRInfo {
  57602. /**
  57603. * The height of the texture in pixels.
  57604. */
  57605. height: number;
  57606. /**
  57607. * The width of the texture in pixels.
  57608. */
  57609. width: number;
  57610. /**
  57611. * The index of the beginning of the data in the binary file.
  57612. */
  57613. dataPosition: number;
  57614. }
  57615. /**
  57616. * This groups tools to convert HDR texture to native colors array.
  57617. */
  57618. export class HDRTools {
  57619. private static Ldexp;
  57620. private static Rgbe2float;
  57621. private static readStringLine;
  57622. /**
  57623. * Reads header information from an RGBE texture stored in a native array.
  57624. * More information on this format are available here:
  57625. * https://en.wikipedia.org/wiki/RGBE_image_format
  57626. *
  57627. * @param uint8array The binary file stored in native array.
  57628. * @return The header information.
  57629. */
  57630. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57631. /**
  57632. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57633. * This RGBE texture needs to store the information as a panorama.
  57634. *
  57635. * More information on this format are available here:
  57636. * https://en.wikipedia.org/wiki/RGBE_image_format
  57637. *
  57638. * @param buffer The binary file stored in an array buffer.
  57639. * @param size The expected size of the extracted cubemap.
  57640. * @return The Cube Map information.
  57641. */
  57642. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57643. /**
  57644. * Returns the pixels data extracted from an RGBE texture.
  57645. * This pixels will be stored left to right up to down in the R G B order in one array.
  57646. *
  57647. * More information on this format are available here:
  57648. * https://en.wikipedia.org/wiki/RGBE_image_format
  57649. *
  57650. * @param uint8array The binary file stored in an array buffer.
  57651. * @param hdrInfo The header information of the file.
  57652. * @return The pixels data in RGB right to left up to down order.
  57653. */
  57654. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57655. private static RGBE_ReadPixels_RLE;
  57656. }
  57657. }
  57658. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57659. import { Nullable } from "babylonjs/types";
  57660. import { Scene } from "babylonjs/scene";
  57661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57663. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57664. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57665. /**
  57666. * This represents a texture coming from an HDR input.
  57667. *
  57668. * The only supported format is currently panorama picture stored in RGBE format.
  57669. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57670. */
  57671. export class HDRCubeTexture extends BaseTexture {
  57672. private static _facesMapping;
  57673. private _generateHarmonics;
  57674. private _noMipmap;
  57675. private _textureMatrix;
  57676. private _size;
  57677. private _onLoad;
  57678. private _onError;
  57679. /**
  57680. * The texture URL.
  57681. */
  57682. url: string;
  57683. /**
  57684. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57685. */
  57686. coordinatesMode: number;
  57687. protected _isBlocking: boolean;
  57688. /**
  57689. * Sets wether or not the texture is blocking during loading.
  57690. */
  57691. set isBlocking(value: boolean);
  57692. /**
  57693. * Gets wether or not the texture is blocking during loading.
  57694. */
  57695. get isBlocking(): boolean;
  57696. protected _rotationY: number;
  57697. /**
  57698. * Sets texture matrix rotation angle around Y axis in radians.
  57699. */
  57700. set rotationY(value: number);
  57701. /**
  57702. * Gets texture matrix rotation angle around Y axis radians.
  57703. */
  57704. get rotationY(): number;
  57705. /**
  57706. * Gets or sets the center of the bounding box associated with the cube texture
  57707. * It must define where the camera used to render the texture was set
  57708. */
  57709. boundingBoxPosition: Vector3;
  57710. private _boundingBoxSize;
  57711. /**
  57712. * Gets or sets the size of the bounding box associated with the cube texture
  57713. * When defined, the cubemap will switch to local mode
  57714. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57715. * @example https://www.babylonjs-playground.com/#RNASML
  57716. */
  57717. set boundingBoxSize(value: Vector3);
  57718. get boundingBoxSize(): Vector3;
  57719. /**
  57720. * Instantiates an HDRTexture from the following parameters.
  57721. *
  57722. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57723. * @param scene The scene the texture will be used in
  57724. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57725. * @param noMipmap Forces to not generate the mipmap if true
  57726. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57727. * @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)
  57728. * @param reserved Reserved flag for internal use.
  57729. */
  57730. 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>);
  57731. /**
  57732. * Get the current class name of the texture useful for serialization or dynamic coding.
  57733. * @returns "HDRCubeTexture"
  57734. */
  57735. getClassName(): string;
  57736. /**
  57737. * Occurs when the file is raw .hdr file.
  57738. */
  57739. private loadTexture;
  57740. clone(): HDRCubeTexture;
  57741. delayLoad(): void;
  57742. /**
  57743. * Get the texture reflection matrix used to rotate/transform the reflection.
  57744. * @returns the reflection matrix
  57745. */
  57746. getReflectionTextureMatrix(): Matrix;
  57747. /**
  57748. * Set the texture reflection matrix used to rotate/transform the reflection.
  57749. * @param value Define the reflection matrix to set
  57750. */
  57751. setReflectionTextureMatrix(value: Matrix): void;
  57752. /**
  57753. * Parses a JSON representation of an HDR Texture in order to create the texture
  57754. * @param parsedTexture Define the JSON representation
  57755. * @param scene Define the scene the texture should be created in
  57756. * @param rootUrl Define the root url in case we need to load relative dependencies
  57757. * @returns the newly created texture after parsing
  57758. */
  57759. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57760. serialize(): any;
  57761. }
  57762. }
  57763. declare module "babylonjs/Physics/physicsEngine" {
  57764. import { Nullable } from "babylonjs/types";
  57765. import { Vector3 } from "babylonjs/Maths/math.vector";
  57766. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57767. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57768. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57769. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57770. /**
  57771. * Class used to control physics engine
  57772. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57773. */
  57774. export class PhysicsEngine implements IPhysicsEngine {
  57775. private _physicsPlugin;
  57776. /**
  57777. * Global value used to control the smallest number supported by the simulation
  57778. */
  57779. static Epsilon: number;
  57780. private _impostors;
  57781. private _joints;
  57782. private _subTimeStep;
  57783. /**
  57784. * Gets the gravity vector used by the simulation
  57785. */
  57786. gravity: Vector3;
  57787. /**
  57788. * Factory used to create the default physics plugin.
  57789. * @returns The default physics plugin
  57790. */
  57791. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57792. /**
  57793. * Creates a new Physics Engine
  57794. * @param gravity defines the gravity vector used by the simulation
  57795. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57796. */
  57797. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57798. /**
  57799. * Sets the gravity vector used by the simulation
  57800. * @param gravity defines the gravity vector to use
  57801. */
  57802. setGravity(gravity: Vector3): void;
  57803. /**
  57804. * Set the time step of the physics engine.
  57805. * Default is 1/60.
  57806. * To slow it down, enter 1/600 for example.
  57807. * To speed it up, 1/30
  57808. * @param newTimeStep defines the new timestep to apply to this world.
  57809. */
  57810. setTimeStep(newTimeStep?: number): void;
  57811. /**
  57812. * Get the time step of the physics engine.
  57813. * @returns the current time step
  57814. */
  57815. getTimeStep(): number;
  57816. /**
  57817. * Set the sub time step of the physics engine.
  57818. * Default is 0 meaning there is no sub steps
  57819. * To increase physics resolution precision, set a small value (like 1 ms)
  57820. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57821. */
  57822. setSubTimeStep(subTimeStep?: number): void;
  57823. /**
  57824. * Get the sub time step of the physics engine.
  57825. * @returns the current sub time step
  57826. */
  57827. getSubTimeStep(): number;
  57828. /**
  57829. * Release all resources
  57830. */
  57831. dispose(): void;
  57832. /**
  57833. * Gets the name of the current physics plugin
  57834. * @returns the name of the plugin
  57835. */
  57836. getPhysicsPluginName(): string;
  57837. /**
  57838. * Adding a new impostor for the impostor tracking.
  57839. * This will be done by the impostor itself.
  57840. * @param impostor the impostor to add
  57841. */
  57842. addImpostor(impostor: PhysicsImpostor): void;
  57843. /**
  57844. * Remove an impostor from the engine.
  57845. * This impostor and its mesh will not longer be updated by the physics engine.
  57846. * @param impostor the impostor to remove
  57847. */
  57848. removeImpostor(impostor: PhysicsImpostor): void;
  57849. /**
  57850. * Add a joint to the physics engine
  57851. * @param mainImpostor defines the main impostor to which the joint is added.
  57852. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57853. * @param joint defines the joint that will connect both impostors.
  57854. */
  57855. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57856. /**
  57857. * Removes a joint from the simulation
  57858. * @param mainImpostor defines the impostor used with the joint
  57859. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57860. * @param joint defines the joint to remove
  57861. */
  57862. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57863. /**
  57864. * Called by the scene. No need to call it.
  57865. * @param delta defines the timespam between frames
  57866. */
  57867. _step(delta: number): void;
  57868. /**
  57869. * Gets the current plugin used to run the simulation
  57870. * @returns current plugin
  57871. */
  57872. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57873. /**
  57874. * Gets the list of physic impostors
  57875. * @returns an array of PhysicsImpostor
  57876. */
  57877. getImpostors(): Array<PhysicsImpostor>;
  57878. /**
  57879. * Gets the impostor for a physics enabled object
  57880. * @param object defines the object impersonated by the impostor
  57881. * @returns the PhysicsImpostor or null if not found
  57882. */
  57883. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57884. /**
  57885. * Gets the impostor for a physics body object
  57886. * @param body defines physics body used by the impostor
  57887. * @returns the PhysicsImpostor or null if not found
  57888. */
  57889. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57890. /**
  57891. * Does a raycast in the physics world
  57892. * @param from when should the ray start?
  57893. * @param to when should the ray end?
  57894. * @returns PhysicsRaycastResult
  57895. */
  57896. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57897. }
  57898. }
  57899. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57900. import { Nullable } from "babylonjs/types";
  57901. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57903. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57904. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57905. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57906. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57907. /** @hidden */
  57908. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57909. private _useDeltaForWorldStep;
  57910. world: any;
  57911. name: string;
  57912. private _physicsMaterials;
  57913. private _fixedTimeStep;
  57914. private _cannonRaycastResult;
  57915. private _raycastResult;
  57916. private _physicsBodysToRemoveAfterStep;
  57917. BJSCANNON: any;
  57918. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57919. setGravity(gravity: Vector3): void;
  57920. setTimeStep(timeStep: number): void;
  57921. getTimeStep(): number;
  57922. executeStep(delta: number): void;
  57923. private _removeMarkedPhysicsBodiesFromWorld;
  57924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57927. private _processChildMeshes;
  57928. removePhysicsBody(impostor: PhysicsImpostor): void;
  57929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57931. private _addMaterial;
  57932. private _checkWithEpsilon;
  57933. private _createShape;
  57934. private _createHeightmap;
  57935. private _minus90X;
  57936. private _plus90X;
  57937. private _tmpPosition;
  57938. private _tmpDeltaPosition;
  57939. private _tmpUnityRotation;
  57940. private _updatePhysicsBodyTransformation;
  57941. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57942. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57943. isSupported(): boolean;
  57944. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57945. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57946. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57947. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57948. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57949. getBodyMass(impostor: PhysicsImpostor): number;
  57950. getBodyFriction(impostor: PhysicsImpostor): number;
  57951. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57952. getBodyRestitution(impostor: PhysicsImpostor): number;
  57953. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57954. sleepBody(impostor: PhysicsImpostor): void;
  57955. wakeUpBody(impostor: PhysicsImpostor): void;
  57956. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57957. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57958. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57959. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57960. getRadius(impostor: PhysicsImpostor): number;
  57961. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57962. dispose(): void;
  57963. private _extendNamespace;
  57964. /**
  57965. * Does a raycast in the physics world
  57966. * @param from when should the ray start?
  57967. * @param to when should the ray end?
  57968. * @returns PhysicsRaycastResult
  57969. */
  57970. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57971. }
  57972. }
  57973. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57974. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57975. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57976. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57978. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57979. import { Nullable } from "babylonjs/types";
  57980. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57981. /** @hidden */
  57982. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57983. world: any;
  57984. name: string;
  57985. BJSOIMO: any;
  57986. private _raycastResult;
  57987. constructor(iterations?: number, oimoInjection?: any);
  57988. setGravity(gravity: Vector3): void;
  57989. setTimeStep(timeStep: number): void;
  57990. getTimeStep(): number;
  57991. private _tmpImpostorsArray;
  57992. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57993. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57994. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57995. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57996. private _tmpPositionVector;
  57997. removePhysicsBody(impostor: PhysicsImpostor): void;
  57998. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57999. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58000. isSupported(): boolean;
  58001. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58002. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58003. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58004. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58005. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58006. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58007. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58008. getBodyMass(impostor: PhysicsImpostor): number;
  58009. getBodyFriction(impostor: PhysicsImpostor): number;
  58010. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58011. getBodyRestitution(impostor: PhysicsImpostor): number;
  58012. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58013. sleepBody(impostor: PhysicsImpostor): void;
  58014. wakeUpBody(impostor: PhysicsImpostor): void;
  58015. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58016. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58017. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58018. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58019. getRadius(impostor: PhysicsImpostor): number;
  58020. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58021. dispose(): void;
  58022. /**
  58023. * Does a raycast in the physics world
  58024. * @param from when should the ray start?
  58025. * @param to when should the ray end?
  58026. * @returns PhysicsRaycastResult
  58027. */
  58028. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58029. }
  58030. }
  58031. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58032. import { Nullable } from "babylonjs/types";
  58033. import { Scene } from "babylonjs/scene";
  58034. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58035. import { Color4 } from "babylonjs/Maths/math.color";
  58036. import { Mesh } from "babylonjs/Meshes/mesh";
  58037. /**
  58038. * Class containing static functions to help procedurally build meshes
  58039. */
  58040. export class RibbonBuilder {
  58041. /**
  58042. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58043. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58044. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58045. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58046. * * 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
  58047. * * 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
  58048. * * 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
  58049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58052. * * 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
  58053. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58054. * * 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
  58055. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58057. * @param name defines the name of the mesh
  58058. * @param options defines the options used to create the mesh
  58059. * @param scene defines the hosting scene
  58060. * @returns the ribbon mesh
  58061. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58063. */
  58064. static CreateRibbon(name: string, options: {
  58065. pathArray: Vector3[][];
  58066. closeArray?: boolean;
  58067. closePath?: boolean;
  58068. offset?: number;
  58069. updatable?: boolean;
  58070. sideOrientation?: number;
  58071. frontUVs?: Vector4;
  58072. backUVs?: Vector4;
  58073. instance?: Mesh;
  58074. invertUV?: boolean;
  58075. uvs?: Vector2[];
  58076. colors?: Color4[];
  58077. }, scene?: Nullable<Scene>): Mesh;
  58078. }
  58079. }
  58080. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58081. import { Nullable } from "babylonjs/types";
  58082. import { Scene } from "babylonjs/scene";
  58083. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58084. import { Mesh } from "babylonjs/Meshes/mesh";
  58085. /**
  58086. * Class containing static functions to help procedurally build meshes
  58087. */
  58088. export class ShapeBuilder {
  58089. /**
  58090. * 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.
  58091. * * 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.
  58092. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58093. * * 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.
  58094. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58095. * * 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
  58096. * * 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
  58097. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58102. * @param name defines the name of the mesh
  58103. * @param options defines the options used to create the mesh
  58104. * @param scene defines the hosting scene
  58105. * @returns the extruded shape mesh
  58106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58108. */
  58109. static ExtrudeShape(name: string, options: {
  58110. shape: Vector3[];
  58111. path: Vector3[];
  58112. scale?: number;
  58113. rotation?: number;
  58114. cap?: number;
  58115. updatable?: boolean;
  58116. sideOrientation?: number;
  58117. frontUVs?: Vector4;
  58118. backUVs?: Vector4;
  58119. instance?: Mesh;
  58120. invertUV?: boolean;
  58121. }, scene?: Nullable<Scene>): Mesh;
  58122. /**
  58123. * Creates an custom extruded shape mesh.
  58124. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58125. * * 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.
  58126. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58127. * * 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
  58128. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58129. * * 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
  58130. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58131. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58132. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58133. * * 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
  58134. * * 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
  58135. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58140. * @param name defines the name of the mesh
  58141. * @param options defines the options used to create the mesh
  58142. * @param scene defines the hosting scene
  58143. * @returns the custom extruded shape mesh
  58144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58145. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58147. */
  58148. static ExtrudeShapeCustom(name: string, options: {
  58149. shape: Vector3[];
  58150. path: Vector3[];
  58151. scaleFunction?: any;
  58152. rotationFunction?: any;
  58153. ribbonCloseArray?: boolean;
  58154. ribbonClosePath?: boolean;
  58155. cap?: number;
  58156. updatable?: boolean;
  58157. sideOrientation?: number;
  58158. frontUVs?: Vector4;
  58159. backUVs?: Vector4;
  58160. instance?: Mesh;
  58161. invertUV?: boolean;
  58162. }, scene?: Nullable<Scene>): Mesh;
  58163. private static _ExtrudeShapeGeneric;
  58164. }
  58165. }
  58166. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58167. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58168. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58169. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58170. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58171. import { Nullable } from "babylonjs/types";
  58172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58173. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58174. /**
  58175. * AmmoJS Physics plugin
  58176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58177. * @see https://github.com/kripken/ammo.js/
  58178. */
  58179. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58180. private _useDeltaForWorldStep;
  58181. /**
  58182. * Reference to the Ammo library
  58183. */
  58184. bjsAMMO: any;
  58185. /**
  58186. * Created ammoJS world which physics bodies are added to
  58187. */
  58188. world: any;
  58189. /**
  58190. * Name of the plugin
  58191. */
  58192. name: string;
  58193. private _timeStep;
  58194. private _fixedTimeStep;
  58195. private _maxSteps;
  58196. private _tmpQuaternion;
  58197. private _tmpAmmoTransform;
  58198. private _tmpAmmoQuaternion;
  58199. private _tmpAmmoConcreteContactResultCallback;
  58200. private _collisionConfiguration;
  58201. private _dispatcher;
  58202. private _overlappingPairCache;
  58203. private _solver;
  58204. private _softBodySolver;
  58205. private _tmpAmmoVectorA;
  58206. private _tmpAmmoVectorB;
  58207. private _tmpAmmoVectorC;
  58208. private _tmpAmmoVectorD;
  58209. private _tmpContactCallbackResult;
  58210. private _tmpAmmoVectorRCA;
  58211. private _tmpAmmoVectorRCB;
  58212. private _raycastResult;
  58213. private static readonly DISABLE_COLLISION_FLAG;
  58214. private static readonly KINEMATIC_FLAG;
  58215. private static readonly DISABLE_DEACTIVATION_FLAG;
  58216. /**
  58217. * Initializes the ammoJS plugin
  58218. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58219. * @param ammoInjection can be used to inject your own ammo reference
  58220. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58221. */
  58222. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58223. /**
  58224. * Sets the gravity of the physics world (m/(s^2))
  58225. * @param gravity Gravity to set
  58226. */
  58227. setGravity(gravity: Vector3): void;
  58228. /**
  58229. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58230. * @param timeStep timestep to use in seconds
  58231. */
  58232. setTimeStep(timeStep: number): void;
  58233. /**
  58234. * 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)
  58235. * @param fixedTimeStep fixedTimeStep to use in seconds
  58236. */
  58237. setFixedTimeStep(fixedTimeStep: number): void;
  58238. /**
  58239. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58240. * @param maxSteps the maximum number of steps by the physics engine per frame
  58241. */
  58242. setMaxSteps(maxSteps: number): void;
  58243. /**
  58244. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58245. * @returns the current timestep in seconds
  58246. */
  58247. getTimeStep(): number;
  58248. /**
  58249. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58250. */
  58251. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58252. private _isImpostorInContact;
  58253. private _isImpostorPairInContact;
  58254. private _stepSimulation;
  58255. /**
  58256. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58257. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58258. * After the step the babylon meshes are set to the position of the physics imposters
  58259. * @param delta amount of time to step forward
  58260. * @param impostors array of imposters to update before/after the step
  58261. */
  58262. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58263. /**
  58264. * Update babylon mesh to match physics world object
  58265. * @param impostor imposter to match
  58266. */
  58267. private _afterSoftStep;
  58268. /**
  58269. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58270. * @param impostor imposter to match
  58271. */
  58272. private _ropeStep;
  58273. /**
  58274. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58275. * @param impostor imposter to match
  58276. */
  58277. private _softbodyOrClothStep;
  58278. private _tmpMatrix;
  58279. /**
  58280. * Applies an impulse on the imposter
  58281. * @param impostor imposter to apply impulse to
  58282. * @param force amount of force to be applied to the imposter
  58283. * @param contactPoint the location to apply the impulse on the imposter
  58284. */
  58285. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58286. /**
  58287. * Applies a force on the imposter
  58288. * @param impostor imposter to apply force
  58289. * @param force amount of force to be applied to the imposter
  58290. * @param contactPoint the location to apply the force on the imposter
  58291. */
  58292. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58293. /**
  58294. * Creates a physics body using the plugin
  58295. * @param impostor the imposter to create the physics body on
  58296. */
  58297. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58298. /**
  58299. * Removes the physics body from the imposter and disposes of the body's memory
  58300. * @param impostor imposter to remove the physics body from
  58301. */
  58302. removePhysicsBody(impostor: PhysicsImpostor): void;
  58303. /**
  58304. * Generates a joint
  58305. * @param impostorJoint the imposter joint to create the joint with
  58306. */
  58307. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58308. /**
  58309. * Removes a joint
  58310. * @param impostorJoint the imposter joint to remove the joint from
  58311. */
  58312. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58313. private _addMeshVerts;
  58314. /**
  58315. * Initialise the soft body vertices to match its object's (mesh) vertices
  58316. * Softbody vertices (nodes) are in world space and to match this
  58317. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58318. * @param impostor to create the softbody for
  58319. */
  58320. private _softVertexData;
  58321. /**
  58322. * Create an impostor's soft body
  58323. * @param impostor to create the softbody for
  58324. */
  58325. private _createSoftbody;
  58326. /**
  58327. * Create cloth for an impostor
  58328. * @param impostor to create the softbody for
  58329. */
  58330. private _createCloth;
  58331. /**
  58332. * Create rope for an impostor
  58333. * @param impostor to create the softbody for
  58334. */
  58335. private _createRope;
  58336. /**
  58337. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58338. * @param impostor to create the custom physics shape for
  58339. */
  58340. private _createCustom;
  58341. private _addHullVerts;
  58342. private _createShape;
  58343. /**
  58344. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58345. * @param impostor imposter containing the physics body and babylon object
  58346. */
  58347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58348. /**
  58349. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58350. * @param impostor imposter containing the physics body and babylon object
  58351. * @param newPosition new position
  58352. * @param newRotation new rotation
  58353. */
  58354. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58355. /**
  58356. * If this plugin is supported
  58357. * @returns true if its supported
  58358. */
  58359. isSupported(): boolean;
  58360. /**
  58361. * Sets the linear velocity of the physics body
  58362. * @param impostor imposter to set the velocity on
  58363. * @param velocity velocity to set
  58364. */
  58365. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58366. /**
  58367. * Sets the angular velocity of the physics body
  58368. * @param impostor imposter to set the velocity on
  58369. * @param velocity velocity to set
  58370. */
  58371. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58372. /**
  58373. * gets the linear velocity
  58374. * @param impostor imposter to get linear velocity from
  58375. * @returns linear velocity
  58376. */
  58377. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58378. /**
  58379. * gets the angular velocity
  58380. * @param impostor imposter to get angular velocity from
  58381. * @returns angular velocity
  58382. */
  58383. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58384. /**
  58385. * Sets the mass of physics body
  58386. * @param impostor imposter to set the mass on
  58387. * @param mass mass to set
  58388. */
  58389. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58390. /**
  58391. * Gets the mass of the physics body
  58392. * @param impostor imposter to get the mass from
  58393. * @returns mass
  58394. */
  58395. getBodyMass(impostor: PhysicsImpostor): number;
  58396. /**
  58397. * Gets friction of the impostor
  58398. * @param impostor impostor to get friction from
  58399. * @returns friction value
  58400. */
  58401. getBodyFriction(impostor: PhysicsImpostor): number;
  58402. /**
  58403. * Sets friction of the impostor
  58404. * @param impostor impostor to set friction on
  58405. * @param friction friction value
  58406. */
  58407. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58408. /**
  58409. * Gets restitution of the impostor
  58410. * @param impostor impostor to get restitution from
  58411. * @returns restitution value
  58412. */
  58413. getBodyRestitution(impostor: PhysicsImpostor): number;
  58414. /**
  58415. * Sets resitution of the impostor
  58416. * @param impostor impostor to set resitution on
  58417. * @param restitution resitution value
  58418. */
  58419. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58420. /**
  58421. * Gets pressure inside the impostor
  58422. * @param impostor impostor to get pressure from
  58423. * @returns pressure value
  58424. */
  58425. getBodyPressure(impostor: PhysicsImpostor): number;
  58426. /**
  58427. * Sets pressure inside a soft body impostor
  58428. * Cloth and rope must remain 0 pressure
  58429. * @param impostor impostor to set pressure on
  58430. * @param pressure pressure value
  58431. */
  58432. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58433. /**
  58434. * Gets stiffness of the impostor
  58435. * @param impostor impostor to get stiffness from
  58436. * @returns pressure value
  58437. */
  58438. getBodyStiffness(impostor: PhysicsImpostor): number;
  58439. /**
  58440. * Sets stiffness of the impostor
  58441. * @param impostor impostor to set stiffness on
  58442. * @param stiffness stiffness value from 0 to 1
  58443. */
  58444. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58445. /**
  58446. * Gets velocityIterations of the impostor
  58447. * @param impostor impostor to get velocity iterations from
  58448. * @returns velocityIterations value
  58449. */
  58450. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58451. /**
  58452. * Sets velocityIterations of the impostor
  58453. * @param impostor impostor to set velocity iterations on
  58454. * @param velocityIterations velocityIterations value
  58455. */
  58456. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58457. /**
  58458. * Gets positionIterations of the impostor
  58459. * @param impostor impostor to get position iterations from
  58460. * @returns positionIterations value
  58461. */
  58462. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58463. /**
  58464. * Sets positionIterations of the impostor
  58465. * @param impostor impostor to set position on
  58466. * @param positionIterations positionIterations value
  58467. */
  58468. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58469. /**
  58470. * Append an anchor to a cloth object
  58471. * @param impostor is the cloth impostor to add anchor to
  58472. * @param otherImpostor is the rigid impostor to anchor to
  58473. * @param width ratio across width from 0 to 1
  58474. * @param height ratio up height from 0 to 1
  58475. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58476. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58477. */
  58478. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58479. /**
  58480. * Append an hook to a rope object
  58481. * @param impostor is the rope impostor to add hook to
  58482. * @param otherImpostor is the rigid impostor to hook to
  58483. * @param length ratio along the rope from 0 to 1
  58484. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58485. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58486. */
  58487. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58488. /**
  58489. * Sleeps the physics body and stops it from being active
  58490. * @param impostor impostor to sleep
  58491. */
  58492. sleepBody(impostor: PhysicsImpostor): void;
  58493. /**
  58494. * Activates the physics body
  58495. * @param impostor impostor to activate
  58496. */
  58497. wakeUpBody(impostor: PhysicsImpostor): void;
  58498. /**
  58499. * Updates the distance parameters of the joint
  58500. * @param joint joint to update
  58501. * @param maxDistance maximum distance of the joint
  58502. * @param minDistance minimum distance of the joint
  58503. */
  58504. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58505. /**
  58506. * Sets a motor on the joint
  58507. * @param joint joint to set motor on
  58508. * @param speed speed of the motor
  58509. * @param maxForce maximum force of the motor
  58510. * @param motorIndex index of the motor
  58511. */
  58512. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58513. /**
  58514. * Sets the motors limit
  58515. * @param joint joint to set limit on
  58516. * @param upperLimit upper limit
  58517. * @param lowerLimit lower limit
  58518. */
  58519. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58520. /**
  58521. * Syncs the position and rotation of a mesh with the impostor
  58522. * @param mesh mesh to sync
  58523. * @param impostor impostor to update the mesh with
  58524. */
  58525. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58526. /**
  58527. * Gets the radius of the impostor
  58528. * @param impostor impostor to get radius from
  58529. * @returns the radius
  58530. */
  58531. getRadius(impostor: PhysicsImpostor): number;
  58532. /**
  58533. * Gets the box size of the impostor
  58534. * @param impostor impostor to get box size from
  58535. * @param result the resulting box size
  58536. */
  58537. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58538. /**
  58539. * Disposes of the impostor
  58540. */
  58541. dispose(): void;
  58542. /**
  58543. * Does a raycast in the physics world
  58544. * @param from when should the ray start?
  58545. * @param to when should the ray end?
  58546. * @returns PhysicsRaycastResult
  58547. */
  58548. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58549. }
  58550. }
  58551. declare module "babylonjs/Probes/reflectionProbe" {
  58552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58553. import { Vector3 } from "babylonjs/Maths/math.vector";
  58554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58555. import { Nullable } from "babylonjs/types";
  58556. import { Scene } from "babylonjs/scene";
  58557. module "babylonjs/abstractScene" {
  58558. interface AbstractScene {
  58559. /**
  58560. * The list of reflection probes added to the scene
  58561. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58562. */
  58563. reflectionProbes: Array<ReflectionProbe>;
  58564. /**
  58565. * Removes the given reflection probe from this scene.
  58566. * @param toRemove The reflection probe to remove
  58567. * @returns The index of the removed reflection probe
  58568. */
  58569. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58570. /**
  58571. * Adds the given reflection probe to this scene.
  58572. * @param newReflectionProbe The reflection probe to add
  58573. */
  58574. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58575. }
  58576. }
  58577. /**
  58578. * Class used to generate realtime reflection / refraction cube textures
  58579. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58580. */
  58581. export class ReflectionProbe {
  58582. /** defines the name of the probe */
  58583. name: string;
  58584. private _scene;
  58585. private _renderTargetTexture;
  58586. private _projectionMatrix;
  58587. private _viewMatrix;
  58588. private _target;
  58589. private _add;
  58590. private _attachedMesh;
  58591. private _invertYAxis;
  58592. /** Gets or sets probe position (center of the cube map) */
  58593. position: Vector3;
  58594. /**
  58595. * Creates a new reflection probe
  58596. * @param name defines the name of the probe
  58597. * @param size defines the texture resolution (for each face)
  58598. * @param scene defines the hosting scene
  58599. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58600. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58601. */
  58602. constructor(
  58603. /** defines the name of the probe */
  58604. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58605. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58606. get samples(): number;
  58607. set samples(value: number);
  58608. /** Gets or sets the refresh rate to use (on every frame by default) */
  58609. get refreshRate(): number;
  58610. set refreshRate(value: number);
  58611. /**
  58612. * Gets the hosting scene
  58613. * @returns a Scene
  58614. */
  58615. getScene(): Scene;
  58616. /** Gets the internal CubeTexture used to render to */
  58617. get cubeTexture(): RenderTargetTexture;
  58618. /** Gets the list of meshes to render */
  58619. get renderList(): Nullable<AbstractMesh[]>;
  58620. /**
  58621. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58622. * @param mesh defines the mesh to attach to
  58623. */
  58624. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58625. /**
  58626. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58627. * @param renderingGroupId The rendering group id corresponding to its index
  58628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58629. */
  58630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58631. /**
  58632. * Clean all associated resources
  58633. */
  58634. dispose(): void;
  58635. /**
  58636. * Converts the reflection probe information to a readable string for debug purpose.
  58637. * @param fullDetails Supports for multiple levels of logging within scene loading
  58638. * @returns the human readable reflection probe info
  58639. */
  58640. toString(fullDetails?: boolean): string;
  58641. /**
  58642. * Get the class name of the relfection probe.
  58643. * @returns "ReflectionProbe"
  58644. */
  58645. getClassName(): string;
  58646. /**
  58647. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58648. * @returns The JSON representation of the texture
  58649. */
  58650. serialize(): any;
  58651. /**
  58652. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58653. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58654. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58655. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58656. * @returns The parsed reflection probe if successful
  58657. */
  58658. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58659. }
  58660. }
  58661. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58662. /** @hidden */
  58663. export var _BabylonLoaderRegistered: boolean;
  58664. /**
  58665. * Helps setting up some configuration for the babylon file loader.
  58666. */
  58667. export class BabylonFileLoaderConfiguration {
  58668. /**
  58669. * The loader does not allow injecting custom physix engine into the plugins.
  58670. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58671. * So you could set this variable to your engine import to make it work.
  58672. */
  58673. static LoaderInjectedPhysicsEngine: any;
  58674. }
  58675. }
  58676. declare module "babylonjs/Loading/Plugins/index" {
  58677. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58678. }
  58679. declare module "babylonjs/Loading/index" {
  58680. export * from "babylonjs/Loading/loadingScreen";
  58681. export * from "babylonjs/Loading/Plugins/index";
  58682. export * from "babylonjs/Loading/sceneLoader";
  58683. export * from "babylonjs/Loading/sceneLoaderFlags";
  58684. }
  58685. declare module "babylonjs/Materials/Background/index" {
  58686. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58687. }
  58688. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58689. import { Scene } from "babylonjs/scene";
  58690. import { Color3 } from "babylonjs/Maths/math.color";
  58691. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58693. /**
  58694. * The Physically based simple base material of BJS.
  58695. *
  58696. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58697. * It is used as the base class for both the specGloss and metalRough conventions.
  58698. */
  58699. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58700. /**
  58701. * Number of Simultaneous lights allowed on the material.
  58702. */
  58703. maxSimultaneousLights: number;
  58704. /**
  58705. * If sets to true, disables all the lights affecting the material.
  58706. */
  58707. disableLighting: boolean;
  58708. /**
  58709. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58710. */
  58711. environmentTexture: BaseTexture;
  58712. /**
  58713. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58714. */
  58715. invertNormalMapX: boolean;
  58716. /**
  58717. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58718. */
  58719. invertNormalMapY: boolean;
  58720. /**
  58721. * Normal map used in the model.
  58722. */
  58723. normalTexture: BaseTexture;
  58724. /**
  58725. * Emissivie color used to self-illuminate the model.
  58726. */
  58727. emissiveColor: Color3;
  58728. /**
  58729. * Emissivie texture used to self-illuminate the model.
  58730. */
  58731. emissiveTexture: BaseTexture;
  58732. /**
  58733. * Occlusion Channel Strenght.
  58734. */
  58735. occlusionStrength: number;
  58736. /**
  58737. * Occlusion Texture of the material (adding extra occlusion effects).
  58738. */
  58739. occlusionTexture: BaseTexture;
  58740. /**
  58741. * Defines the alpha limits in alpha test mode.
  58742. */
  58743. alphaCutOff: number;
  58744. /**
  58745. * Gets the current double sided mode.
  58746. */
  58747. get doubleSided(): boolean;
  58748. /**
  58749. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58750. */
  58751. set doubleSided(value: boolean);
  58752. /**
  58753. * Stores the pre-calculated light information of a mesh in a texture.
  58754. */
  58755. lightmapTexture: BaseTexture;
  58756. /**
  58757. * If true, the light map contains occlusion information instead of lighting info.
  58758. */
  58759. useLightmapAsShadowmap: boolean;
  58760. /**
  58761. * Instantiates a new PBRMaterial instance.
  58762. *
  58763. * @param name The material name
  58764. * @param scene The scene the material will be use in.
  58765. */
  58766. constructor(name: string, scene: Scene);
  58767. getClassName(): string;
  58768. }
  58769. }
  58770. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58771. import { Scene } from "babylonjs/scene";
  58772. import { Color3 } from "babylonjs/Maths/math.color";
  58773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58774. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58775. /**
  58776. * The PBR material of BJS following the metal roughness convention.
  58777. *
  58778. * This fits to the PBR convention in the GLTF definition:
  58779. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58780. */
  58781. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58782. /**
  58783. * The base color has two different interpretations depending on the value of metalness.
  58784. * When the material is a metal, the base color is the specific measured reflectance value
  58785. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58786. * of the material.
  58787. */
  58788. baseColor: Color3;
  58789. /**
  58790. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58791. * well as opacity information in the alpha channel.
  58792. */
  58793. baseTexture: BaseTexture;
  58794. /**
  58795. * Specifies the metallic scalar value of the material.
  58796. * Can also be used to scale the metalness values of the metallic texture.
  58797. */
  58798. metallic: number;
  58799. /**
  58800. * Specifies the roughness scalar value of the material.
  58801. * Can also be used to scale the roughness values of the metallic texture.
  58802. */
  58803. roughness: number;
  58804. /**
  58805. * Texture containing both the metallic value in the B channel and the
  58806. * roughness value in the G channel to keep better precision.
  58807. */
  58808. metallicRoughnessTexture: BaseTexture;
  58809. /**
  58810. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58811. *
  58812. * @param name The material name
  58813. * @param scene The scene the material will be use in.
  58814. */
  58815. constructor(name: string, scene: Scene);
  58816. /**
  58817. * Return the currrent class name of the material.
  58818. */
  58819. getClassName(): string;
  58820. /**
  58821. * Makes a duplicate of the current material.
  58822. * @param name - name to use for the new material.
  58823. */
  58824. clone(name: string): PBRMetallicRoughnessMaterial;
  58825. /**
  58826. * Serialize the material to a parsable JSON object.
  58827. */
  58828. serialize(): any;
  58829. /**
  58830. * Parses a JSON object correponding to the serialize function.
  58831. */
  58832. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58833. }
  58834. }
  58835. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58836. import { Scene } from "babylonjs/scene";
  58837. import { Color3 } from "babylonjs/Maths/math.color";
  58838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58839. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58840. /**
  58841. * The PBR material of BJS following the specular glossiness convention.
  58842. *
  58843. * This fits to the PBR convention in the GLTF definition:
  58844. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58845. */
  58846. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58847. /**
  58848. * Specifies the diffuse color of the material.
  58849. */
  58850. diffuseColor: Color3;
  58851. /**
  58852. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58853. * channel.
  58854. */
  58855. diffuseTexture: BaseTexture;
  58856. /**
  58857. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58858. */
  58859. specularColor: Color3;
  58860. /**
  58861. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58862. */
  58863. glossiness: number;
  58864. /**
  58865. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58866. */
  58867. specularGlossinessTexture: BaseTexture;
  58868. /**
  58869. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58870. *
  58871. * @param name The material name
  58872. * @param scene The scene the material will be use in.
  58873. */
  58874. constructor(name: string, scene: Scene);
  58875. /**
  58876. * Return the currrent class name of the material.
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Makes a duplicate of the current material.
  58881. * @param name - name to use for the new material.
  58882. */
  58883. clone(name: string): PBRSpecularGlossinessMaterial;
  58884. /**
  58885. * Serialize the material to a parsable JSON object.
  58886. */
  58887. serialize(): any;
  58888. /**
  58889. * Parses a JSON object correponding to the serialize function.
  58890. */
  58891. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58892. }
  58893. }
  58894. declare module "babylonjs/Materials/PBR/index" {
  58895. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58896. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58897. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58898. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58899. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58900. }
  58901. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58902. import { Nullable } from "babylonjs/types";
  58903. import { Scene } from "babylonjs/scene";
  58904. import { Matrix } from "babylonjs/Maths/math.vector";
  58905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58906. /**
  58907. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58908. * It can help converting any input color in a desired output one. This can then be used to create effects
  58909. * from sepia, black and white to sixties or futuristic rendering...
  58910. *
  58911. * The only supported format is currently 3dl.
  58912. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58913. */
  58914. export class ColorGradingTexture extends BaseTexture {
  58915. /**
  58916. * The current texture matrix. (will always be identity in color grading texture)
  58917. */
  58918. private _textureMatrix;
  58919. /**
  58920. * The texture URL.
  58921. */
  58922. url: string;
  58923. /**
  58924. * Empty line regex stored for GC.
  58925. */
  58926. private static _noneEmptyLineRegex;
  58927. private _engine;
  58928. /**
  58929. * Instantiates a ColorGradingTexture from the following parameters.
  58930. *
  58931. * @param url The location of the color gradind data (currently only supporting 3dl)
  58932. * @param scene The scene the texture will be used in
  58933. */
  58934. constructor(url: string, scene: Scene);
  58935. /**
  58936. * Returns the texture matrix used in most of the material.
  58937. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58938. */
  58939. getTextureMatrix(): Matrix;
  58940. /**
  58941. * Occurs when the file being loaded is a .3dl LUT file.
  58942. */
  58943. private load3dlTexture;
  58944. /**
  58945. * Starts the loading process of the texture.
  58946. */
  58947. private loadTexture;
  58948. /**
  58949. * Clones the color gradind texture.
  58950. */
  58951. clone(): ColorGradingTexture;
  58952. /**
  58953. * Called during delayed load for textures.
  58954. */
  58955. delayLoad(): void;
  58956. /**
  58957. * Parses a color grading texture serialized by Babylon.
  58958. * @param parsedTexture The texture information being parsedTexture
  58959. * @param scene The scene to load the texture in
  58960. * @param rootUrl The root url of the data assets to load
  58961. * @return A color gradind texture
  58962. */
  58963. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58964. /**
  58965. * Serializes the LUT texture to json format.
  58966. */
  58967. serialize(): any;
  58968. }
  58969. }
  58970. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58972. import { Scene } from "babylonjs/scene";
  58973. import { Nullable } from "babylonjs/types";
  58974. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58975. /**
  58976. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58977. */
  58978. export class EquiRectangularCubeTexture extends BaseTexture {
  58979. /** The six faces of the cube. */
  58980. private static _FacesMapping;
  58981. private _noMipmap;
  58982. private _onLoad;
  58983. private _onError;
  58984. /** The size of the cubemap. */
  58985. private _size;
  58986. /** The buffer of the image. */
  58987. private _buffer;
  58988. /** The width of the input image. */
  58989. private _width;
  58990. /** The height of the input image. */
  58991. private _height;
  58992. /** The URL to the image. */
  58993. url: string;
  58994. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58995. coordinatesMode: number;
  58996. /**
  58997. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58998. * @param url The location of the image
  58999. * @param scene The scene the texture will be used in
  59000. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59001. * @param noMipmap Forces to not generate the mipmap if true
  59002. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59003. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59004. * @param onLoad — defines a callback called when texture is loaded
  59005. * @param onError — defines a callback called if there is an error
  59006. */
  59007. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59008. /**
  59009. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59010. */
  59011. private loadImage;
  59012. /**
  59013. * Convert the image buffer into a cubemap and create a CubeTexture.
  59014. */
  59015. private loadTexture;
  59016. /**
  59017. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59018. * @param buffer The ArrayBuffer that should be converted.
  59019. * @returns The buffer as Float32Array.
  59020. */
  59021. private getFloat32ArrayFromArrayBuffer;
  59022. /**
  59023. * Get the current class name of the texture useful for serialization or dynamic coding.
  59024. * @returns "EquiRectangularCubeTexture"
  59025. */
  59026. getClassName(): string;
  59027. /**
  59028. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59029. * @returns A clone of the current EquiRectangularCubeTexture.
  59030. */
  59031. clone(): EquiRectangularCubeTexture;
  59032. }
  59033. }
  59034. declare module "babylonjs/Misc/tga" {
  59035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59036. /**
  59037. * Based on jsTGALoader - Javascript loader for TGA file
  59038. * By Vincent Thibault
  59039. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59040. */
  59041. export class TGATools {
  59042. private static _TYPE_INDEXED;
  59043. private static _TYPE_RGB;
  59044. private static _TYPE_GREY;
  59045. private static _TYPE_RLE_INDEXED;
  59046. private static _TYPE_RLE_RGB;
  59047. private static _TYPE_RLE_GREY;
  59048. private static _ORIGIN_MASK;
  59049. private static _ORIGIN_SHIFT;
  59050. private static _ORIGIN_BL;
  59051. private static _ORIGIN_BR;
  59052. private static _ORIGIN_UL;
  59053. private static _ORIGIN_UR;
  59054. /**
  59055. * Gets the header of a TGA file
  59056. * @param data defines the TGA data
  59057. * @returns the header
  59058. */
  59059. static GetTGAHeader(data: Uint8Array): any;
  59060. /**
  59061. * Uploads TGA content to a Babylon Texture
  59062. * @hidden
  59063. */
  59064. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59065. /** @hidden */
  59066. 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;
  59067. /** @hidden */
  59068. 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;
  59069. /** @hidden */
  59070. 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;
  59071. /** @hidden */
  59072. 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;
  59073. /** @hidden */
  59074. 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;
  59075. /** @hidden */
  59076. 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;
  59077. }
  59078. }
  59079. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59080. import { Nullable } from "babylonjs/types";
  59081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59082. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59083. /**
  59084. * Implementation of the TGA Texture Loader.
  59085. * @hidden
  59086. */
  59087. export class _TGATextureLoader implements IInternalTextureLoader {
  59088. /**
  59089. * Defines wether the loader supports cascade loading the different faces.
  59090. */
  59091. readonly supportCascades: boolean;
  59092. /**
  59093. * This returns if the loader support the current file information.
  59094. * @param extension defines the file extension of the file being loaded
  59095. * @returns true if the loader can load the specified file
  59096. */
  59097. canLoad(extension: string): boolean;
  59098. /**
  59099. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59100. * @param data contains the texture data
  59101. * @param texture defines the BabylonJS internal texture
  59102. * @param createPolynomials will be true if polynomials have been requested
  59103. * @param onLoad defines the callback to trigger once the texture is ready
  59104. * @param onError defines the callback to trigger in case of error
  59105. */
  59106. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59107. /**
  59108. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59109. * @param data contains the texture data
  59110. * @param texture defines the BabylonJS internal texture
  59111. * @param callback defines the method to call once ready to upload
  59112. */
  59113. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59114. }
  59115. }
  59116. declare module "babylonjs/Misc/basis" {
  59117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59118. /**
  59119. * Info about the .basis files
  59120. */
  59121. class BasisFileInfo {
  59122. /**
  59123. * If the file has alpha
  59124. */
  59125. hasAlpha: boolean;
  59126. /**
  59127. * Info about each image of the basis file
  59128. */
  59129. images: Array<{
  59130. levels: Array<{
  59131. width: number;
  59132. height: number;
  59133. transcodedPixels: ArrayBufferView;
  59134. }>;
  59135. }>;
  59136. }
  59137. /**
  59138. * Result of transcoding a basis file
  59139. */
  59140. class TranscodeResult {
  59141. /**
  59142. * Info about the .basis file
  59143. */
  59144. fileInfo: BasisFileInfo;
  59145. /**
  59146. * Format to use when loading the file
  59147. */
  59148. format: number;
  59149. }
  59150. /**
  59151. * Configuration options for the Basis transcoder
  59152. */
  59153. export class BasisTranscodeConfiguration {
  59154. /**
  59155. * Supported compression formats used to determine the supported output format of the transcoder
  59156. */
  59157. supportedCompressionFormats?: {
  59158. /**
  59159. * etc1 compression format
  59160. */
  59161. etc1?: boolean;
  59162. /**
  59163. * s3tc compression format
  59164. */
  59165. s3tc?: boolean;
  59166. /**
  59167. * pvrtc compression format
  59168. */
  59169. pvrtc?: boolean;
  59170. /**
  59171. * etc2 compression format
  59172. */
  59173. etc2?: boolean;
  59174. };
  59175. /**
  59176. * If mipmap levels should be loaded for transcoded images (Default: true)
  59177. */
  59178. loadMipmapLevels?: boolean;
  59179. /**
  59180. * Index of a single image to load (Default: all images)
  59181. */
  59182. loadSingleImage?: number;
  59183. }
  59184. /**
  59185. * Used to load .Basis files
  59186. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59187. */
  59188. export class BasisTools {
  59189. private static _IgnoreSupportedFormats;
  59190. /**
  59191. * URL to use when loading the basis transcoder
  59192. */
  59193. static JSModuleURL: string;
  59194. /**
  59195. * URL to use when loading the wasm module for the transcoder
  59196. */
  59197. static WasmModuleURL: string;
  59198. /**
  59199. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59200. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59201. * @returns internal format corresponding to the Basis format
  59202. */
  59203. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59204. private static _WorkerPromise;
  59205. private static _Worker;
  59206. private static _actionId;
  59207. private static _CreateWorkerAsync;
  59208. /**
  59209. * Transcodes a loaded image file to compressed pixel data
  59210. * @param data image data to transcode
  59211. * @param config configuration options for the transcoding
  59212. * @returns a promise resulting in the transcoded image
  59213. */
  59214. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59215. /**
  59216. * Loads a texture from the transcode result
  59217. * @param texture texture load to
  59218. * @param transcodeResult the result of transcoding the basis file to load from
  59219. */
  59220. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59221. }
  59222. }
  59223. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59224. import { Nullable } from "babylonjs/types";
  59225. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59226. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59227. /**
  59228. * Loader for .basis file format
  59229. */
  59230. export class _BasisTextureLoader implements IInternalTextureLoader {
  59231. /**
  59232. * Defines whether the loader supports cascade loading the different faces.
  59233. */
  59234. readonly supportCascades: boolean;
  59235. /**
  59236. * This returns if the loader support the current file information.
  59237. * @param extension defines the file extension of the file being loaded
  59238. * @returns true if the loader can load the specified file
  59239. */
  59240. canLoad(extension: string): boolean;
  59241. /**
  59242. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59243. * @param data contains the texture data
  59244. * @param texture defines the BabylonJS internal texture
  59245. * @param createPolynomials will be true if polynomials have been requested
  59246. * @param onLoad defines the callback to trigger once the texture is ready
  59247. * @param onError defines the callback to trigger in case of error
  59248. */
  59249. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59250. /**
  59251. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59252. * @param data contains the texture data
  59253. * @param texture defines the BabylonJS internal texture
  59254. * @param callback defines the method to call once ready to upload
  59255. */
  59256. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59257. }
  59258. }
  59259. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59260. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59261. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59262. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59263. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59264. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59265. }
  59266. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59267. import { Scene } from "babylonjs/scene";
  59268. import { Texture } from "babylonjs/Materials/Textures/texture";
  59269. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59270. /**
  59271. * 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.
  59272. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59273. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59274. */
  59275. export class CustomProceduralTexture extends ProceduralTexture {
  59276. private _animate;
  59277. private _time;
  59278. private _config;
  59279. private _texturePath;
  59280. /**
  59281. * Instantiates a new Custom Procedural Texture.
  59282. * 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.
  59283. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59284. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59285. * @param name Define the name of the texture
  59286. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59287. * @param size Define the size of the texture to create
  59288. * @param scene Define the scene the texture belongs to
  59289. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59290. * @param generateMipMaps Define if the texture should creates mip maps or not
  59291. */
  59292. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59293. private _loadJson;
  59294. /**
  59295. * Is the texture ready to be used ? (rendered at least once)
  59296. * @returns true if ready, otherwise, false.
  59297. */
  59298. isReady(): boolean;
  59299. /**
  59300. * Render the texture to its associated render target.
  59301. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59302. */
  59303. render(useCameraPostProcess?: boolean): void;
  59304. /**
  59305. * Update the list of dependant textures samplers in the shader.
  59306. */
  59307. updateTextures(): void;
  59308. /**
  59309. * Update the uniform values of the procedural texture in the shader.
  59310. */
  59311. updateShaderUniforms(): void;
  59312. /**
  59313. * Define if the texture animates or not.
  59314. */
  59315. get animate(): boolean;
  59316. set animate(value: boolean);
  59317. }
  59318. }
  59319. declare module "babylonjs/Shaders/noise.fragment" {
  59320. /** @hidden */
  59321. export var noisePixelShader: {
  59322. name: string;
  59323. shader: string;
  59324. };
  59325. }
  59326. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59327. import { Nullable } from "babylonjs/types";
  59328. import { Scene } from "babylonjs/scene";
  59329. import { Texture } from "babylonjs/Materials/Textures/texture";
  59330. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59331. import "babylonjs/Shaders/noise.fragment";
  59332. /**
  59333. * Class used to generate noise procedural textures
  59334. */
  59335. export class NoiseProceduralTexture extends ProceduralTexture {
  59336. private _time;
  59337. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59338. brightness: number;
  59339. /** Defines the number of octaves to process */
  59340. octaves: number;
  59341. /** Defines the level of persistence (0.8 by default) */
  59342. persistence: number;
  59343. /** Gets or sets animation speed factor (default is 1) */
  59344. animationSpeedFactor: number;
  59345. /**
  59346. * Creates a new NoiseProceduralTexture
  59347. * @param name defines the name fo the texture
  59348. * @param size defines the size of the texture (default is 256)
  59349. * @param scene defines the hosting scene
  59350. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59351. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59352. */
  59353. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59354. private _updateShaderUniforms;
  59355. protected _getDefines(): string;
  59356. /** Generate the current state of the procedural texture */
  59357. render(useCameraPostProcess?: boolean): void;
  59358. /**
  59359. * Serializes this noise procedural texture
  59360. * @returns a serialized noise procedural texture object
  59361. */
  59362. serialize(): any;
  59363. /**
  59364. * Clone the texture.
  59365. * @returns the cloned texture
  59366. */
  59367. clone(): NoiseProceduralTexture;
  59368. /**
  59369. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59370. * @param parsedTexture defines parsed texture data
  59371. * @param scene defines the current scene
  59372. * @param rootUrl defines the root URL containing noise procedural texture information
  59373. * @returns a parsed NoiseProceduralTexture
  59374. */
  59375. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59376. }
  59377. }
  59378. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59379. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59380. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59381. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59382. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59383. }
  59384. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59385. import { Nullable } from "babylonjs/types";
  59386. import { Scene } from "babylonjs/scene";
  59387. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59389. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59390. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59391. /**
  59392. * Raw cube texture where the raw buffers are passed in
  59393. */
  59394. export class RawCubeTexture extends CubeTexture {
  59395. /**
  59396. * Creates a cube texture where the raw buffers are passed in.
  59397. * @param scene defines the scene the texture is attached to
  59398. * @param data defines the array of data to use to create each face
  59399. * @param size defines the size of the textures
  59400. * @param format defines the format of the data
  59401. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59402. * @param generateMipMaps defines if the engine should generate the mip levels
  59403. * @param invertY defines if data must be stored with Y axis inverted
  59404. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59405. * @param compression defines the compression used (null by default)
  59406. */
  59407. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59408. /**
  59409. * Updates the raw cube texture.
  59410. * @param data defines the data to store
  59411. * @param format defines the data format
  59412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59413. * @param invertY defines if data must be stored with Y axis inverted
  59414. * @param compression defines the compression used (null by default)
  59415. * @param level defines which level of the texture to update
  59416. */
  59417. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59418. /**
  59419. * Updates a raw cube texture with RGBD encoded data.
  59420. * @param data defines the array of data [mipmap][face] to use to create each face
  59421. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59424. * @returns a promsie that resolves when the operation is complete
  59425. */
  59426. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59427. /**
  59428. * Clones the raw cube texture.
  59429. * @return a new cube texture
  59430. */
  59431. clone(): CubeTexture;
  59432. /** @hidden */
  59433. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59434. }
  59435. }
  59436. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59437. import { Scene } from "babylonjs/scene";
  59438. import { Texture } from "babylonjs/Materials/Textures/texture";
  59439. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59440. /**
  59441. * Class used to store 3D textures containing user data
  59442. */
  59443. export class RawTexture3D extends Texture {
  59444. /** Gets or sets the texture format to use */
  59445. format: number;
  59446. private _engine;
  59447. /**
  59448. * Create a new RawTexture3D
  59449. * @param data defines the data of the texture
  59450. * @param width defines the width of the texture
  59451. * @param height defines the height of the texture
  59452. * @param depth defines the depth of the texture
  59453. * @param format defines the texture format to use
  59454. * @param scene defines the hosting scene
  59455. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59456. * @param invertY defines if texture must be stored with Y axis inverted
  59457. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59458. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59459. */
  59460. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59461. /** Gets or sets the texture format to use */
  59462. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59463. /**
  59464. * Update the texture with new data
  59465. * @param data defines the data to store in the texture
  59466. */
  59467. update(data: ArrayBufferView): void;
  59468. }
  59469. }
  59470. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59471. import { Scene } from "babylonjs/scene";
  59472. import { Texture } from "babylonjs/Materials/Textures/texture";
  59473. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59474. /**
  59475. * Class used to store 2D array textures containing user data
  59476. */
  59477. export class RawTexture2DArray extends Texture {
  59478. /** Gets or sets the texture format to use */
  59479. format: number;
  59480. private _engine;
  59481. /**
  59482. * Create a new RawTexture2DArray
  59483. * @param data defines the data of the texture
  59484. * @param width defines the width of the texture
  59485. * @param height defines the height of the texture
  59486. * @param depth defines the number of layers of the texture
  59487. * @param format defines the texture format to use
  59488. * @param scene defines the hosting scene
  59489. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59490. * @param invertY defines if texture must be stored with Y axis inverted
  59491. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59492. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59493. */
  59494. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59495. /** Gets or sets the texture format to use */
  59496. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59497. /**
  59498. * Update the texture with new data
  59499. * @param data defines the data to store in the texture
  59500. */
  59501. update(data: ArrayBufferView): void;
  59502. }
  59503. }
  59504. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59505. import { Scene } from "babylonjs/scene";
  59506. import { Plane } from "babylonjs/Maths/math.plane";
  59507. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59508. /**
  59509. * Creates a refraction texture used by refraction channel of the standard material.
  59510. * It is like a mirror but to see through a material.
  59511. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59512. */
  59513. export class RefractionTexture extends RenderTargetTexture {
  59514. /**
  59515. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59516. * 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.
  59517. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59518. */
  59519. refractionPlane: Plane;
  59520. /**
  59521. * Define how deep under the surface we should see.
  59522. */
  59523. depth: number;
  59524. /**
  59525. * Creates a refraction texture used by refraction channel of the standard material.
  59526. * It is like a mirror but to see through a material.
  59527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59528. * @param name Define the texture name
  59529. * @param size Define the size of the underlying texture
  59530. * @param scene Define the scene the refraction belongs to
  59531. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59532. */
  59533. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59534. /**
  59535. * Clone the refraction texture.
  59536. * @returns the cloned texture
  59537. */
  59538. clone(): RefractionTexture;
  59539. /**
  59540. * Serialize the texture to a JSON representation you could use in Parse later on
  59541. * @returns the serialized JSON representation
  59542. */
  59543. serialize(): any;
  59544. }
  59545. }
  59546. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59547. import { Nullable } from "babylonjs/types";
  59548. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59549. import { Matrix } from "babylonjs/Maths/math.vector";
  59550. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59551. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59552. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59553. import { Scene } from "babylonjs/scene";
  59554. /**
  59555. * Defines the options related to the creation of an HtmlElementTexture
  59556. */
  59557. export interface IHtmlElementTextureOptions {
  59558. /**
  59559. * Defines wether mip maps should be created or not.
  59560. */
  59561. generateMipMaps?: boolean;
  59562. /**
  59563. * Defines the sampling mode of the texture.
  59564. */
  59565. samplingMode?: number;
  59566. /**
  59567. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59568. */
  59569. engine: Nullable<ThinEngine>;
  59570. /**
  59571. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59572. */
  59573. scene: Nullable<Scene>;
  59574. }
  59575. /**
  59576. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59577. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59578. * is automatically managed.
  59579. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59580. * in your application.
  59581. *
  59582. * As the update is not automatic, you need to call them manually.
  59583. */
  59584. export class HtmlElementTexture extends BaseTexture {
  59585. /**
  59586. * The texture URL.
  59587. */
  59588. element: HTMLVideoElement | HTMLCanvasElement;
  59589. private static readonly DefaultOptions;
  59590. private _textureMatrix;
  59591. private _engine;
  59592. private _isVideo;
  59593. private _generateMipMaps;
  59594. private _samplingMode;
  59595. /**
  59596. * Instantiates a HtmlElementTexture from the following parameters.
  59597. *
  59598. * @param name Defines the name of the texture
  59599. * @param element Defines the video or canvas the texture is filled with
  59600. * @param options Defines the other none mandatory texture creation options
  59601. */
  59602. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59603. private _createInternalTexture;
  59604. /**
  59605. * Returns the texture matrix used in most of the material.
  59606. */
  59607. getTextureMatrix(): Matrix;
  59608. /**
  59609. * Updates the content of the texture.
  59610. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59611. */
  59612. update(invertY?: Nullable<boolean>): void;
  59613. }
  59614. }
  59615. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59616. import { Vector2 } from "babylonjs/Maths/math.vector";
  59617. /**
  59618. * Defines the basic options interface of a TexturePacker Frame
  59619. */
  59620. export interface ITexturePackerFrame {
  59621. /**
  59622. * The frame ID
  59623. */
  59624. id: number;
  59625. /**
  59626. * The frames Scale
  59627. */
  59628. scale: Vector2;
  59629. /**
  59630. * The Frames offset
  59631. */
  59632. offset: Vector2;
  59633. }
  59634. /**
  59635. * This is a support class for frame Data on texture packer sets.
  59636. */
  59637. export class TexturePackerFrame implements ITexturePackerFrame {
  59638. /**
  59639. * The frame ID
  59640. */
  59641. id: number;
  59642. /**
  59643. * The frames Scale
  59644. */
  59645. scale: Vector2;
  59646. /**
  59647. * The Frames offset
  59648. */
  59649. offset: Vector2;
  59650. /**
  59651. * Initializes a texture package frame.
  59652. * @param id The numerical frame identifier
  59653. * @param scale Scalar Vector2 for UV frame
  59654. * @param offset Vector2 for the frame position in UV units.
  59655. * @returns TexturePackerFrame
  59656. */
  59657. constructor(id: number, scale: Vector2, offset: Vector2);
  59658. }
  59659. }
  59660. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59662. import { Scene } from "babylonjs/scene";
  59663. import { Nullable } from "babylonjs/types";
  59664. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59665. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59666. /**
  59667. * Defines the basic options interface of a TexturePacker
  59668. */
  59669. export interface ITexturePackerOptions {
  59670. /**
  59671. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59672. */
  59673. map?: string[];
  59674. /**
  59675. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59676. */
  59677. uvsIn?: string;
  59678. /**
  59679. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59680. */
  59681. uvsOut?: string;
  59682. /**
  59683. * number representing the layout style. Defaults to LAYOUT_STRIP
  59684. */
  59685. layout?: number;
  59686. /**
  59687. * number of columns if using custom column count layout(2). This defaults to 4.
  59688. */
  59689. colnum?: number;
  59690. /**
  59691. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59692. */
  59693. updateInputMeshes?: boolean;
  59694. /**
  59695. * boolean flag to dispose all the source textures. Defaults to true.
  59696. */
  59697. disposeSources?: boolean;
  59698. /**
  59699. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59700. */
  59701. fillBlanks?: boolean;
  59702. /**
  59703. * string value representing the context fill style color. Defaults to 'black'.
  59704. */
  59705. customFillColor?: string;
  59706. /**
  59707. * Width and Height Value of each Frame in the TexturePacker Sets
  59708. */
  59709. frameSize?: number;
  59710. /**
  59711. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59712. */
  59713. paddingRatio?: number;
  59714. /**
  59715. * Number that declares the fill method for the padding gutter.
  59716. */
  59717. paddingMode?: number;
  59718. /**
  59719. * If in SUBUV_COLOR padding mode what color to use.
  59720. */
  59721. paddingColor?: Color3 | Color4;
  59722. }
  59723. /**
  59724. * Defines the basic interface of a TexturePacker JSON File
  59725. */
  59726. export interface ITexturePackerJSON {
  59727. /**
  59728. * The frame ID
  59729. */
  59730. name: string;
  59731. /**
  59732. * The base64 channel data
  59733. */
  59734. sets: any;
  59735. /**
  59736. * The options of the Packer
  59737. */
  59738. options: ITexturePackerOptions;
  59739. /**
  59740. * The frame data of the Packer
  59741. */
  59742. frames: Array<number>;
  59743. }
  59744. /**
  59745. * This is a support class that generates a series of packed texture sets.
  59746. * @see https://doc.babylonjs.com/babylon101/materials
  59747. */
  59748. export class TexturePacker {
  59749. /** Packer Layout Constant 0 */
  59750. static readonly LAYOUT_STRIP: number;
  59751. /** Packer Layout Constant 1 */
  59752. static readonly LAYOUT_POWER2: number;
  59753. /** Packer Layout Constant 2 */
  59754. static readonly LAYOUT_COLNUM: number;
  59755. /** Packer Layout Constant 0 */
  59756. static readonly SUBUV_WRAP: number;
  59757. /** Packer Layout Constant 1 */
  59758. static readonly SUBUV_EXTEND: number;
  59759. /** Packer Layout Constant 2 */
  59760. static readonly SUBUV_COLOR: number;
  59761. /** The Name of the Texture Package */
  59762. name: string;
  59763. /** The scene scope of the TexturePacker */
  59764. scene: Scene;
  59765. /** The Meshes to target */
  59766. meshes: AbstractMesh[];
  59767. /** Arguments passed with the Constructor */
  59768. options: ITexturePackerOptions;
  59769. /** The promise that is started upon initialization */
  59770. promise: Nullable<Promise<TexturePacker | string>>;
  59771. /** The Container object for the channel sets that are generated */
  59772. sets: object;
  59773. /** The Container array for the frames that are generated */
  59774. frames: TexturePackerFrame[];
  59775. /** The expected number of textures the system is parsing. */
  59776. private _expecting;
  59777. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59778. private _paddingValue;
  59779. /**
  59780. * Initializes a texture package series from an array of meshes or a single mesh.
  59781. * @param name The name of the package
  59782. * @param meshes The target meshes to compose the package from
  59783. * @param options The arguments that texture packer should follow while building.
  59784. * @param scene The scene which the textures are scoped to.
  59785. * @returns TexturePacker
  59786. */
  59787. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59788. /**
  59789. * Starts the package process
  59790. * @param resolve The promises resolution function
  59791. * @returns TexturePacker
  59792. */
  59793. private _createFrames;
  59794. /**
  59795. * Calculates the Size of the Channel Sets
  59796. * @returns Vector2
  59797. */
  59798. private _calculateSize;
  59799. /**
  59800. * Calculates the UV data for the frames.
  59801. * @param baseSize the base frameSize
  59802. * @param padding the base frame padding
  59803. * @param dtSize size of the Dynamic Texture for that channel
  59804. * @param dtUnits is 1/dtSize
  59805. * @param update flag to update the input meshes
  59806. */
  59807. private _calculateMeshUVFrames;
  59808. /**
  59809. * Calculates the frames Offset.
  59810. * @param index of the frame
  59811. * @returns Vector2
  59812. */
  59813. private _getFrameOffset;
  59814. /**
  59815. * Updates a Mesh to the frame data
  59816. * @param mesh that is the target
  59817. * @param frameID or the frame index
  59818. */
  59819. private _updateMeshUV;
  59820. /**
  59821. * Updates a Meshes materials to use the texture packer channels
  59822. * @param m is the mesh to target
  59823. * @param force all channels on the packer to be set.
  59824. */
  59825. private _updateTextureReferences;
  59826. /**
  59827. * Public method to set a Mesh to a frame
  59828. * @param m that is the target
  59829. * @param frameID or the frame index
  59830. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59831. */
  59832. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59833. /**
  59834. * Starts the async promise to compile the texture packer.
  59835. * @returns Promise<void>
  59836. */
  59837. processAsync(): Promise<void>;
  59838. /**
  59839. * Disposes all textures associated with this packer
  59840. */
  59841. dispose(): void;
  59842. /**
  59843. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59844. * @param imageType is the image type to use.
  59845. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59846. */
  59847. download(imageType?: string, quality?: number): void;
  59848. /**
  59849. * Public method to load a texturePacker JSON file.
  59850. * @param data of the JSON file in string format.
  59851. */
  59852. updateFromJSON(data: string): void;
  59853. }
  59854. }
  59855. declare module "babylonjs/Materials/Textures/Packer/index" {
  59856. export * from "babylonjs/Materials/Textures/Packer/packer";
  59857. export * from "babylonjs/Materials/Textures/Packer/frame";
  59858. }
  59859. declare module "babylonjs/Materials/Textures/index" {
  59860. export * from "babylonjs/Materials/Textures/baseTexture";
  59861. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59862. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59863. export * from "babylonjs/Materials/Textures/cubeTexture";
  59864. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59865. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59866. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59867. export * from "babylonjs/Materials/Textures/internalTexture";
  59868. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59869. export * from "babylonjs/Materials/Textures/Loaders/index";
  59870. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59871. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59872. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59873. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59874. export * from "babylonjs/Materials/Textures/rawTexture";
  59875. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59876. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59877. export * from "babylonjs/Materials/Textures/refractionTexture";
  59878. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59879. export * from "babylonjs/Materials/Textures/texture";
  59880. export * from "babylonjs/Materials/Textures/videoTexture";
  59881. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59882. export * from "babylonjs/Materials/Textures/Packer/index";
  59883. }
  59884. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59885. /**
  59886. * Enum used to define the target of a block
  59887. */
  59888. export enum NodeMaterialBlockTargets {
  59889. /** Vertex shader */
  59890. Vertex = 1,
  59891. /** Fragment shader */
  59892. Fragment = 2,
  59893. /** Neutral */
  59894. Neutral = 4,
  59895. /** Vertex and Fragment */
  59896. VertexAndFragment = 3
  59897. }
  59898. }
  59899. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59900. /**
  59901. * Defines the kind of connection point for node based material
  59902. */
  59903. export enum NodeMaterialBlockConnectionPointTypes {
  59904. /** Float */
  59905. Float = 1,
  59906. /** Int */
  59907. Int = 2,
  59908. /** Vector2 */
  59909. Vector2 = 4,
  59910. /** Vector3 */
  59911. Vector3 = 8,
  59912. /** Vector4 */
  59913. Vector4 = 16,
  59914. /** Color3 */
  59915. Color3 = 32,
  59916. /** Color4 */
  59917. Color4 = 64,
  59918. /** Matrix */
  59919. Matrix = 128,
  59920. /** Detect type based on connection */
  59921. AutoDetect = 1024,
  59922. /** Output type that will be defined by input type */
  59923. BasedOnInput = 2048
  59924. }
  59925. }
  59926. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59927. /**
  59928. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59929. */
  59930. export enum NodeMaterialBlockConnectionPointMode {
  59931. /** Value is an uniform */
  59932. Uniform = 0,
  59933. /** Value is a mesh attribute */
  59934. Attribute = 1,
  59935. /** Value is a varying between vertex and fragment shaders */
  59936. Varying = 2,
  59937. /** Mode is undefined */
  59938. Undefined = 3
  59939. }
  59940. }
  59941. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59942. /**
  59943. * Enum used to define system values e.g. values automatically provided by the system
  59944. */
  59945. export enum NodeMaterialSystemValues {
  59946. /** World */
  59947. World = 1,
  59948. /** View */
  59949. View = 2,
  59950. /** Projection */
  59951. Projection = 3,
  59952. /** ViewProjection */
  59953. ViewProjection = 4,
  59954. /** WorldView */
  59955. WorldView = 5,
  59956. /** WorldViewProjection */
  59957. WorldViewProjection = 6,
  59958. /** CameraPosition */
  59959. CameraPosition = 7,
  59960. /** Fog Color */
  59961. FogColor = 8,
  59962. /** Delta time */
  59963. DeltaTime = 9
  59964. }
  59965. }
  59966. declare module "babylonjs/Materials/Node/Enums/index" {
  59967. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59968. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59969. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59970. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59971. }
  59972. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59974. /**
  59975. * Root class for all node material optimizers
  59976. */
  59977. export class NodeMaterialOptimizer {
  59978. /**
  59979. * Function used to optimize a NodeMaterial graph
  59980. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59981. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59982. */
  59983. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59984. }
  59985. }
  59986. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59990. import { Scene } from "babylonjs/scene";
  59991. /**
  59992. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59993. */
  59994. export class TransformBlock extends NodeMaterialBlock {
  59995. /**
  59996. * Defines the value to use to complement W value to transform it to a Vector4
  59997. */
  59998. complementW: number;
  59999. /**
  60000. * Defines the value to use to complement z value to transform it to a Vector4
  60001. */
  60002. complementZ: number;
  60003. /**
  60004. * Creates a new TransformBlock
  60005. * @param name defines the block name
  60006. */
  60007. constructor(name: string);
  60008. /**
  60009. * Gets the current class name
  60010. * @returns the class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Gets the vector input
  60015. */
  60016. get vector(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the output component
  60019. */
  60020. get output(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the xyz output component
  60023. */
  60024. get xyz(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the matrix transform input
  60027. */
  60028. get transform(): NodeMaterialConnectionPoint;
  60029. protected _buildBlock(state: NodeMaterialBuildState): this;
  60030. serialize(): any;
  60031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60032. protected _dumpPropertiesCode(): string;
  60033. }
  60034. }
  60035. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60039. /**
  60040. * Block used to output the vertex position
  60041. */
  60042. export class VertexOutputBlock extends NodeMaterialBlock {
  60043. /**
  60044. * Creates a new VertexOutputBlock
  60045. * @param name defines the block name
  60046. */
  60047. constructor(name: string);
  60048. /**
  60049. * Gets the current class name
  60050. * @returns the class name
  60051. */
  60052. getClassName(): string;
  60053. /**
  60054. * Gets the vector input component
  60055. */
  60056. get vector(): NodeMaterialConnectionPoint;
  60057. protected _buildBlock(state: NodeMaterialBuildState): this;
  60058. }
  60059. }
  60060. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60064. /**
  60065. * Block used to output the final color
  60066. */
  60067. export class FragmentOutputBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Create a new FragmentOutputBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the rgba input component
  60080. */
  60081. get rgba(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the rgb input component
  60084. */
  60085. get rgb(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the a input component
  60088. */
  60089. get a(): NodeMaterialConnectionPoint;
  60090. protected _buildBlock(state: NodeMaterialBuildState): this;
  60091. }
  60092. }
  60093. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60100. import { Effect } from "babylonjs/Materials/effect";
  60101. import { Mesh } from "babylonjs/Meshes/mesh";
  60102. import { Nullable } from "babylonjs/types";
  60103. import { Scene } from "babylonjs/scene";
  60104. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60105. /**
  60106. * Block used to read a reflection texture from a sampler
  60107. */
  60108. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60109. private _define3DName;
  60110. private _defineCubicName;
  60111. private _defineExplicitName;
  60112. private _defineProjectionName;
  60113. private _defineLocalCubicName;
  60114. private _defineSphericalName;
  60115. private _definePlanarName;
  60116. private _defineEquirectangularName;
  60117. private _defineMirroredEquirectangularFixedName;
  60118. private _defineEquirectangularFixedName;
  60119. private _defineSkyboxName;
  60120. private _cubeSamplerName;
  60121. private _2DSamplerName;
  60122. private _positionUVWName;
  60123. private _directionWName;
  60124. private _reflectionCoordsName;
  60125. private _reflection2DCoordsName;
  60126. private _reflectionColorName;
  60127. private _reflectionMatrixName;
  60128. /**
  60129. * Gets or sets the texture associated with the node
  60130. */
  60131. texture: Nullable<BaseTexture>;
  60132. /**
  60133. * Create a new TextureBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the world position input component
  60144. */
  60145. get position(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the world position input component
  60148. */
  60149. get worldPosition(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the world normal input component
  60152. */
  60153. get worldNormal(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the world input component
  60156. */
  60157. get world(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the camera (or eye) position component
  60160. */
  60161. get cameraPosition(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the view input component
  60164. */
  60165. get view(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the rgb output component
  60168. */
  60169. get rgb(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the r output component
  60172. */
  60173. get r(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the g output component
  60176. */
  60177. get g(): NodeMaterialConnectionPoint;
  60178. /**
  60179. * Gets the b output component
  60180. */
  60181. get b(): NodeMaterialConnectionPoint;
  60182. autoConfigure(material: NodeMaterial): void;
  60183. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60184. isReady(): boolean;
  60185. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60186. private _injectVertexCode;
  60187. private _writeOutput;
  60188. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60189. protected _dumpPropertiesCode(): string;
  60190. serialize(): any;
  60191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60192. }
  60193. }
  60194. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60196. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60197. import { Scene } from "babylonjs/scene";
  60198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60199. import { Matrix } from "babylonjs/Maths/math.vector";
  60200. import { Mesh } from "babylonjs/Meshes/mesh";
  60201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60202. import { Observable } from "babylonjs/Misc/observable";
  60203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60204. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60205. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60206. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60207. import { Nullable } from "babylonjs/types";
  60208. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60209. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60210. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60211. /**
  60212. * Interface used to configure the node material editor
  60213. */
  60214. export interface INodeMaterialEditorOptions {
  60215. /** Define the URl to load node editor script */
  60216. editorURL?: string;
  60217. }
  60218. /** @hidden */
  60219. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60220. NORMAL: boolean;
  60221. TANGENT: boolean;
  60222. UV1: boolean;
  60223. /** BONES */
  60224. NUM_BONE_INFLUENCERS: number;
  60225. BonesPerMesh: number;
  60226. BONETEXTURE: boolean;
  60227. /** MORPH TARGETS */
  60228. MORPHTARGETS: boolean;
  60229. MORPHTARGETS_NORMAL: boolean;
  60230. MORPHTARGETS_TANGENT: boolean;
  60231. MORPHTARGETS_UV: boolean;
  60232. NUM_MORPH_INFLUENCERS: number;
  60233. /** IMAGE PROCESSING */
  60234. IMAGEPROCESSING: boolean;
  60235. VIGNETTE: boolean;
  60236. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60237. VIGNETTEBLENDMODEOPAQUE: boolean;
  60238. TONEMAPPING: boolean;
  60239. TONEMAPPING_ACES: boolean;
  60240. CONTRAST: boolean;
  60241. EXPOSURE: boolean;
  60242. COLORCURVES: boolean;
  60243. COLORGRADING: boolean;
  60244. COLORGRADING3D: boolean;
  60245. SAMPLER3DGREENDEPTH: boolean;
  60246. SAMPLER3DBGRMAP: boolean;
  60247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60248. /** MISC. */
  60249. BUMPDIRECTUV: number;
  60250. constructor();
  60251. setValue(name: string, value: boolean): void;
  60252. }
  60253. /**
  60254. * Class used to configure NodeMaterial
  60255. */
  60256. export interface INodeMaterialOptions {
  60257. /**
  60258. * Defines if blocks should emit comments
  60259. */
  60260. emitComments: boolean;
  60261. }
  60262. /**
  60263. * Class used to create a node based material built by assembling shader blocks
  60264. */
  60265. export class NodeMaterial extends PushMaterial {
  60266. private static _BuildIdGenerator;
  60267. private _options;
  60268. private _vertexCompilationState;
  60269. private _fragmentCompilationState;
  60270. private _sharedData;
  60271. private _buildId;
  60272. private _buildWasSuccessful;
  60273. private _cachedWorldViewMatrix;
  60274. private _cachedWorldViewProjectionMatrix;
  60275. private _optimizers;
  60276. private _animationFrame;
  60277. /** Define the Url to load node editor script */
  60278. static EditorURL: string;
  60279. /** Define the Url to load snippets */
  60280. static SnippetUrl: string;
  60281. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60282. static IgnoreTexturesAtLoadTime: boolean;
  60283. private BJSNODEMATERIALEDITOR;
  60284. /** Get the inspector from bundle or global */
  60285. private _getGlobalNodeMaterialEditor;
  60286. /**
  60287. * Snippet ID if the material was created from the snippet server
  60288. */
  60289. snippetId: string;
  60290. /**
  60291. * Gets or sets data used by visual editor
  60292. * @see https://nme.babylonjs.com
  60293. */
  60294. editorData: any;
  60295. /**
  60296. * 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)
  60297. */
  60298. ignoreAlpha: boolean;
  60299. /**
  60300. * Defines the maximum number of lights that can be used in the material
  60301. */
  60302. maxSimultaneousLights: number;
  60303. /**
  60304. * Observable raised when the material is built
  60305. */
  60306. onBuildObservable: Observable<NodeMaterial>;
  60307. /**
  60308. * Gets or sets the root nodes of the material vertex shader
  60309. */
  60310. _vertexOutputNodes: NodeMaterialBlock[];
  60311. /**
  60312. * Gets or sets the root nodes of the material fragment (pixel) shader
  60313. */
  60314. _fragmentOutputNodes: NodeMaterialBlock[];
  60315. /** Gets or sets options to control the node material overall behavior */
  60316. get options(): INodeMaterialOptions;
  60317. set options(options: INodeMaterialOptions);
  60318. /**
  60319. * Default configuration related to image processing available in the standard Material.
  60320. */
  60321. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60322. /**
  60323. * Gets the image processing configuration used either in this material.
  60324. */
  60325. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60326. /**
  60327. * Sets the Default image processing configuration used either in the this material.
  60328. *
  60329. * If sets to null, the scene one is in use.
  60330. */
  60331. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60332. /**
  60333. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60334. */
  60335. attachedBlocks: NodeMaterialBlock[];
  60336. /**
  60337. * Create a new node based material
  60338. * @param name defines the material name
  60339. * @param scene defines the hosting scene
  60340. * @param options defines creation option
  60341. */
  60342. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60343. /**
  60344. * Gets the current class name of the material e.g. "NodeMaterial"
  60345. * @returns the class name
  60346. */
  60347. getClassName(): string;
  60348. /**
  60349. * Keep track of the image processing observer to allow dispose and replace.
  60350. */
  60351. private _imageProcessingObserver;
  60352. /**
  60353. * Attaches a new image processing configuration to the Standard Material.
  60354. * @param configuration
  60355. */
  60356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60357. /**
  60358. * Get a block by its name
  60359. * @param name defines the name of the block to retrieve
  60360. * @returns the required block or null if not found
  60361. */
  60362. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60363. /**
  60364. * Get a block by its name
  60365. * @param predicate defines the predicate used to find the good candidate
  60366. * @returns the required block or null if not found
  60367. */
  60368. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60369. /**
  60370. * Get an input block by its name
  60371. * @param predicate defines the predicate used to find the good candidate
  60372. * @returns the required input block or null if not found
  60373. */
  60374. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60375. /**
  60376. * Gets the list of input blocks attached to this material
  60377. * @returns an array of InputBlocks
  60378. */
  60379. getInputBlocks(): InputBlock[];
  60380. /**
  60381. * Adds a new optimizer to the list of optimizers
  60382. * @param optimizer defines the optimizers to add
  60383. * @returns the current material
  60384. */
  60385. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60386. /**
  60387. * Remove an optimizer from the list of optimizers
  60388. * @param optimizer defines the optimizers to remove
  60389. * @returns the current material
  60390. */
  60391. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60392. /**
  60393. * Add a new block to the list of output nodes
  60394. * @param node defines the node to add
  60395. * @returns the current material
  60396. */
  60397. addOutputNode(node: NodeMaterialBlock): this;
  60398. /**
  60399. * Remove a block from the list of root nodes
  60400. * @param node defines the node to remove
  60401. * @returns the current material
  60402. */
  60403. removeOutputNode(node: NodeMaterialBlock): this;
  60404. private _addVertexOutputNode;
  60405. private _removeVertexOutputNode;
  60406. private _addFragmentOutputNode;
  60407. private _removeFragmentOutputNode;
  60408. /**
  60409. * Specifies if the material will require alpha blending
  60410. * @returns a boolean specifying if alpha blending is needed
  60411. */
  60412. needAlphaBlending(): boolean;
  60413. /**
  60414. * Specifies if this material should be rendered in alpha test mode
  60415. * @returns a boolean specifying if an alpha test is needed.
  60416. */
  60417. needAlphaTesting(): boolean;
  60418. private _initializeBlock;
  60419. private _resetDualBlocks;
  60420. /**
  60421. * Remove a block from the current node material
  60422. * @param block defines the block to remove
  60423. */
  60424. removeBlock(block: NodeMaterialBlock): void;
  60425. /**
  60426. * Build the material and generates the inner effect
  60427. * @param verbose defines if the build should log activity
  60428. */
  60429. build(verbose?: boolean): void;
  60430. /**
  60431. * Runs an otpimization phase to try to improve the shader code
  60432. */
  60433. optimize(): void;
  60434. private _prepareDefinesForAttributes;
  60435. /**
  60436. * Get if the submesh is ready to be used and all its information available.
  60437. * Child classes can use it to update shaders
  60438. * @param mesh defines the mesh to check
  60439. * @param subMesh defines which submesh to check
  60440. * @param useInstances specifies that instances should be used
  60441. * @returns a boolean indicating that the submesh is ready or not
  60442. */
  60443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60444. /**
  60445. * Get a string representing the shaders built by the current node graph
  60446. */
  60447. get compiledShaders(): string;
  60448. /**
  60449. * Binds the world matrix to the material
  60450. * @param world defines the world transformation matrix
  60451. */
  60452. bindOnlyWorldMatrix(world: Matrix): void;
  60453. /**
  60454. * Binds the submesh to this material by preparing the effect and shader to draw
  60455. * @param world defines the world transformation matrix
  60456. * @param mesh defines the mesh containing the submesh
  60457. * @param subMesh defines the submesh to bind the material to
  60458. */
  60459. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60460. /**
  60461. * Gets the active textures from the material
  60462. * @returns an array of textures
  60463. */
  60464. getActiveTextures(): BaseTexture[];
  60465. /**
  60466. * Gets the list of texture blocks
  60467. * @returns an array of texture blocks
  60468. */
  60469. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60470. /**
  60471. * Specifies if the material uses a texture
  60472. * @param texture defines the texture to check against the material
  60473. * @returns a boolean specifying if the material uses the texture
  60474. */
  60475. hasTexture(texture: BaseTexture): boolean;
  60476. /**
  60477. * Disposes the material
  60478. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60479. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60480. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60481. */
  60482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60483. /** Creates the node editor window. */
  60484. private _createNodeEditor;
  60485. /**
  60486. * Launch the node material editor
  60487. * @param config Define the configuration of the editor
  60488. * @return a promise fulfilled when the node editor is visible
  60489. */
  60490. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60491. /**
  60492. * Clear the current material
  60493. */
  60494. clear(): void;
  60495. /**
  60496. * Clear the current material and set it to a default state
  60497. */
  60498. setToDefault(): void;
  60499. /**
  60500. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60501. * @param url defines the url to load from
  60502. * @returns a promise that will fullfil when the material is fully loaded
  60503. */
  60504. loadAsync(url: string): Promise<void>;
  60505. private _gatherBlocks;
  60506. /**
  60507. * Generate a string containing the code declaration required to create an equivalent of this material
  60508. * @returns a string
  60509. */
  60510. generateCode(): string;
  60511. /**
  60512. * Serializes this material in a JSON representation
  60513. * @returns the serialized material object
  60514. */
  60515. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60516. private _restoreConnections;
  60517. /**
  60518. * Clear the current graph and load a new one from a serialization object
  60519. * @param source defines the JSON representation of the material
  60520. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60521. */
  60522. loadFromSerialization(source: any, rootUrl?: string): void;
  60523. /**
  60524. * Makes a duplicate of the current material.
  60525. * @param name - name to use for the new material.
  60526. */
  60527. clone(name: string): NodeMaterial;
  60528. /**
  60529. * Creates a node material from parsed material data
  60530. * @param source defines the JSON representation of the material
  60531. * @param scene defines the hosting scene
  60532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60533. * @returns a new node material
  60534. */
  60535. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60536. /**
  60537. * Creates a node material from a snippet saved in a remote file
  60538. * @param name defines the name of the material to create
  60539. * @param url defines the url to load from
  60540. * @param scene defines the hosting scene
  60541. * @returns a promise that will resolve to the new node material
  60542. */
  60543. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60544. /**
  60545. * Creates a node material from a snippet saved by the node material editor
  60546. * @param snippetId defines the snippet to load
  60547. * @param scene defines the hosting scene
  60548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60549. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60550. * @returns a promise that will resolve to the new node material
  60551. */
  60552. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60553. /**
  60554. * Creates a new node material set to default basic configuration
  60555. * @param name defines the name of the material
  60556. * @param scene defines the hosting scene
  60557. * @returns a new NodeMaterial
  60558. */
  60559. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60560. }
  60561. }
  60562. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60565. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60569. import { Effect } from "babylonjs/Materials/effect";
  60570. import { Mesh } from "babylonjs/Meshes/mesh";
  60571. import { Nullable } from "babylonjs/types";
  60572. import { Texture } from "babylonjs/Materials/Textures/texture";
  60573. import { Scene } from "babylonjs/scene";
  60574. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60575. /**
  60576. * Block used to read a texture from a sampler
  60577. */
  60578. export class TextureBlock extends NodeMaterialBlock {
  60579. private _defineName;
  60580. private _linearDefineName;
  60581. private _tempTextureRead;
  60582. private _samplerName;
  60583. private _transformedUVName;
  60584. private _textureTransformName;
  60585. private _textureInfoName;
  60586. private _mainUVName;
  60587. private _mainUVDefineName;
  60588. /**
  60589. * Gets or sets the texture associated with the node
  60590. */
  60591. texture: Nullable<Texture>;
  60592. /**
  60593. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60594. */
  60595. convertToGammaSpace: boolean;
  60596. /**
  60597. * Create a new TextureBlock
  60598. * @param name defines the block name
  60599. */
  60600. constructor(name: string);
  60601. /**
  60602. * Gets the current class name
  60603. * @returns the class name
  60604. */
  60605. getClassName(): string;
  60606. /**
  60607. * Gets the uv input component
  60608. */
  60609. get uv(): NodeMaterialConnectionPoint;
  60610. /**
  60611. * Gets the rgba output component
  60612. */
  60613. get rgba(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the rgb output component
  60616. */
  60617. get rgb(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the r output component
  60620. */
  60621. get r(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Gets the g output component
  60624. */
  60625. get g(): NodeMaterialConnectionPoint;
  60626. /**
  60627. * Gets the b output component
  60628. */
  60629. get b(): NodeMaterialConnectionPoint;
  60630. /**
  60631. * Gets the a output component
  60632. */
  60633. get a(): NodeMaterialConnectionPoint;
  60634. get target(): NodeMaterialBlockTargets;
  60635. autoConfigure(material: NodeMaterial): void;
  60636. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60638. isReady(): boolean;
  60639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60640. private get _isMixed();
  60641. private _injectVertexCode;
  60642. private _writeTextureRead;
  60643. private _writeOutput;
  60644. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60645. protected _dumpPropertiesCode(): string;
  60646. serialize(): any;
  60647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60648. }
  60649. }
  60650. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60653. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60654. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60655. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60656. import { Scene } from "babylonjs/scene";
  60657. /**
  60658. * Class used to store shared data between 2 NodeMaterialBuildState
  60659. */
  60660. export class NodeMaterialBuildStateSharedData {
  60661. /**
  60662. * Gets the list of emitted varyings
  60663. */
  60664. temps: string[];
  60665. /**
  60666. * Gets the list of emitted varyings
  60667. */
  60668. varyings: string[];
  60669. /**
  60670. * Gets the varying declaration string
  60671. */
  60672. varyingDeclaration: string;
  60673. /**
  60674. * Input blocks
  60675. */
  60676. inputBlocks: InputBlock[];
  60677. /**
  60678. * Input blocks
  60679. */
  60680. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60681. /**
  60682. * Bindable blocks (Blocks that need to set data to the effect)
  60683. */
  60684. bindableBlocks: NodeMaterialBlock[];
  60685. /**
  60686. * List of blocks that can provide a compilation fallback
  60687. */
  60688. blocksWithFallbacks: NodeMaterialBlock[];
  60689. /**
  60690. * List of blocks that can provide a define update
  60691. */
  60692. blocksWithDefines: NodeMaterialBlock[];
  60693. /**
  60694. * List of blocks that can provide a repeatable content
  60695. */
  60696. repeatableContentBlocks: NodeMaterialBlock[];
  60697. /**
  60698. * List of blocks that can provide a dynamic list of uniforms
  60699. */
  60700. dynamicUniformBlocks: NodeMaterialBlock[];
  60701. /**
  60702. * List of blocks that can block the isReady function for the material
  60703. */
  60704. blockingBlocks: NodeMaterialBlock[];
  60705. /**
  60706. * Gets the list of animated inputs
  60707. */
  60708. animatedInputs: InputBlock[];
  60709. /**
  60710. * Build Id used to avoid multiple recompilations
  60711. */
  60712. buildId: number;
  60713. /** List of emitted variables */
  60714. variableNames: {
  60715. [key: string]: number;
  60716. };
  60717. /** List of emitted defines */
  60718. defineNames: {
  60719. [key: string]: number;
  60720. };
  60721. /** Should emit comments? */
  60722. emitComments: boolean;
  60723. /** Emit build activity */
  60724. verbose: boolean;
  60725. /** Gets or sets the hosting scene */
  60726. scene: Scene;
  60727. /**
  60728. * Gets the compilation hints emitted at compilation time
  60729. */
  60730. hints: {
  60731. needWorldViewMatrix: boolean;
  60732. needWorldViewProjectionMatrix: boolean;
  60733. needAlphaBlending: boolean;
  60734. needAlphaTesting: boolean;
  60735. };
  60736. /**
  60737. * List of compilation checks
  60738. */
  60739. checks: {
  60740. emitVertex: boolean;
  60741. emitFragment: boolean;
  60742. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60743. };
  60744. /** Creates a new shared data */
  60745. constructor();
  60746. /**
  60747. * Emits console errors and exceptions if there is a failing check
  60748. */
  60749. emitErrors(): void;
  60750. }
  60751. }
  60752. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60753. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60754. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60755. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60756. /**
  60757. * Class used to store node based material build state
  60758. */
  60759. export class NodeMaterialBuildState {
  60760. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60761. supportUniformBuffers: boolean;
  60762. /**
  60763. * Gets the list of emitted attributes
  60764. */
  60765. attributes: string[];
  60766. /**
  60767. * Gets the list of emitted uniforms
  60768. */
  60769. uniforms: string[];
  60770. /**
  60771. * Gets the list of emitted constants
  60772. */
  60773. constants: string[];
  60774. /**
  60775. * Gets the list of emitted samplers
  60776. */
  60777. samplers: string[];
  60778. /**
  60779. * Gets the list of emitted functions
  60780. */
  60781. functions: {
  60782. [key: string]: string;
  60783. };
  60784. /**
  60785. * Gets the list of emitted extensions
  60786. */
  60787. extensions: {
  60788. [key: string]: string;
  60789. };
  60790. /**
  60791. * Gets the target of the compilation state
  60792. */
  60793. target: NodeMaterialBlockTargets;
  60794. /**
  60795. * Gets the list of emitted counters
  60796. */
  60797. counters: {
  60798. [key: string]: number;
  60799. };
  60800. /**
  60801. * Shared data between multiple NodeMaterialBuildState instances
  60802. */
  60803. sharedData: NodeMaterialBuildStateSharedData;
  60804. /** @hidden */
  60805. _vertexState: NodeMaterialBuildState;
  60806. /** @hidden */
  60807. _attributeDeclaration: string;
  60808. /** @hidden */
  60809. _uniformDeclaration: string;
  60810. /** @hidden */
  60811. _constantDeclaration: string;
  60812. /** @hidden */
  60813. _samplerDeclaration: string;
  60814. /** @hidden */
  60815. _varyingTransfer: string;
  60816. private _repeatableContentAnchorIndex;
  60817. /** @hidden */
  60818. _builtCompilationString: string;
  60819. /**
  60820. * Gets the emitted compilation strings
  60821. */
  60822. compilationString: string;
  60823. /**
  60824. * Finalize the compilation strings
  60825. * @param state defines the current compilation state
  60826. */
  60827. finalize(state: NodeMaterialBuildState): void;
  60828. /** @hidden */
  60829. get _repeatableContentAnchor(): string;
  60830. /** @hidden */
  60831. _getFreeVariableName(prefix: string): string;
  60832. /** @hidden */
  60833. _getFreeDefineName(prefix: string): string;
  60834. /** @hidden */
  60835. _excludeVariableName(name: string): void;
  60836. /** @hidden */
  60837. _emit2DSampler(name: string): void;
  60838. /** @hidden */
  60839. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60840. /** @hidden */
  60841. _emitExtension(name: string, extension: string): void;
  60842. /** @hidden */
  60843. _emitFunction(name: string, code: string, comments: string): void;
  60844. /** @hidden */
  60845. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60846. replaceStrings?: {
  60847. search: RegExp;
  60848. replace: string;
  60849. }[];
  60850. repeatKey?: string;
  60851. }): string;
  60852. /** @hidden */
  60853. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60854. repeatKey?: string;
  60855. removeAttributes?: boolean;
  60856. removeUniforms?: boolean;
  60857. removeVaryings?: boolean;
  60858. removeIfDef?: boolean;
  60859. replaceStrings?: {
  60860. search: RegExp;
  60861. replace: string;
  60862. }[];
  60863. }, storeKey?: string): void;
  60864. /** @hidden */
  60865. _registerTempVariable(name: string): boolean;
  60866. /** @hidden */
  60867. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60868. /** @hidden */
  60869. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60870. /** @hidden */
  60871. _emitFloat(value: number): string;
  60872. }
  60873. }
  60874. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60875. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60877. import { Nullable } from "babylonjs/types";
  60878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60879. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60880. import { Effect } from "babylonjs/Materials/effect";
  60881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60882. import { Mesh } from "babylonjs/Meshes/mesh";
  60883. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60884. import { Scene } from "babylonjs/scene";
  60885. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60886. /**
  60887. * Defines a block that can be used inside a node based material
  60888. */
  60889. export class NodeMaterialBlock {
  60890. private _buildId;
  60891. private _buildTarget;
  60892. private _target;
  60893. private _isFinalMerger;
  60894. private _isInput;
  60895. protected _isUnique: boolean;
  60896. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60897. inputsAreExclusive: boolean;
  60898. /** @hidden */
  60899. _codeVariableName: string;
  60900. /** @hidden */
  60901. _inputs: NodeMaterialConnectionPoint[];
  60902. /** @hidden */
  60903. _outputs: NodeMaterialConnectionPoint[];
  60904. /** @hidden */
  60905. _preparationId: number;
  60906. /**
  60907. * Gets or sets the name of the block
  60908. */
  60909. name: string;
  60910. /**
  60911. * Gets or sets the unique id of the node
  60912. */
  60913. uniqueId: number;
  60914. /**
  60915. * Gets or sets the comments associated with this block
  60916. */
  60917. comments: string;
  60918. /**
  60919. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60920. */
  60921. get isUnique(): boolean;
  60922. /**
  60923. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60924. */
  60925. get isFinalMerger(): boolean;
  60926. /**
  60927. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60928. */
  60929. get isInput(): boolean;
  60930. /**
  60931. * Gets or sets the build Id
  60932. */
  60933. get buildId(): number;
  60934. set buildId(value: number);
  60935. /**
  60936. * Gets or sets the target of the block
  60937. */
  60938. get target(): NodeMaterialBlockTargets;
  60939. set target(value: NodeMaterialBlockTargets);
  60940. /**
  60941. * Gets the list of input points
  60942. */
  60943. get inputs(): NodeMaterialConnectionPoint[];
  60944. /** Gets the list of output points */
  60945. get outputs(): NodeMaterialConnectionPoint[];
  60946. /**
  60947. * Find an input by its name
  60948. * @param name defines the name of the input to look for
  60949. * @returns the input or null if not found
  60950. */
  60951. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60952. /**
  60953. * Find an output by its name
  60954. * @param name defines the name of the outputto look for
  60955. * @returns the output or null if not found
  60956. */
  60957. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60958. /**
  60959. * Creates a new NodeMaterialBlock
  60960. * @param name defines the block name
  60961. * @param target defines the target of that block (Vertex by default)
  60962. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60963. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60964. */
  60965. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60966. /**
  60967. * Initialize the block and prepare the context for build
  60968. * @param state defines the state that will be used for the build
  60969. */
  60970. initialize(state: NodeMaterialBuildState): void;
  60971. /**
  60972. * Bind data to effect. Will only be called for blocks with isBindable === true
  60973. * @param effect defines the effect to bind data to
  60974. * @param nodeMaterial defines the hosting NodeMaterial
  60975. * @param mesh defines the mesh that will be rendered
  60976. */
  60977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60978. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60979. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60980. protected _writeFloat(value: number): string;
  60981. /**
  60982. * Gets the current class name e.g. "NodeMaterialBlock"
  60983. * @returns the class name
  60984. */
  60985. getClassName(): string;
  60986. /**
  60987. * Register a new input. Must be called inside a block constructor
  60988. * @param name defines the connection point name
  60989. * @param type defines the connection point type
  60990. * @param isOptional defines a boolean indicating that this input can be omitted
  60991. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60992. * @returns the current block
  60993. */
  60994. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60995. /**
  60996. * Register a new output. Must be called inside a block constructor
  60997. * @param name defines the connection point name
  60998. * @param type defines the connection point type
  60999. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61000. * @returns the current block
  61001. */
  61002. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  61003. /**
  61004. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61005. * @param forOutput defines an optional connection point to check compatibility with
  61006. * @returns the first available input or null
  61007. */
  61008. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61009. /**
  61010. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61011. * @param forBlock defines an optional block to check compatibility with
  61012. * @returns the first available input or null
  61013. */
  61014. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61015. /**
  61016. * Gets the sibling of the given output
  61017. * @param current defines the current output
  61018. * @returns the next output in the list or null
  61019. */
  61020. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61021. /**
  61022. * Connect current block with another block
  61023. * @param other defines the block to connect with
  61024. * @param options define the various options to help pick the right connections
  61025. * @returns the current block
  61026. */
  61027. connectTo(other: NodeMaterialBlock, options?: {
  61028. input?: string;
  61029. output?: string;
  61030. outputSwizzle?: string;
  61031. }): this | undefined;
  61032. protected _buildBlock(state: NodeMaterialBuildState): void;
  61033. /**
  61034. * Add uniforms, samplers and uniform buffers at compilation time
  61035. * @param state defines the state to update
  61036. * @param nodeMaterial defines the node material requesting the update
  61037. * @param defines defines the material defines to update
  61038. * @param uniformBuffers defines the list of uniform buffer names
  61039. */
  61040. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61041. /**
  61042. * Add potential fallbacks if shader compilation fails
  61043. * @param mesh defines the mesh to be rendered
  61044. * @param fallbacks defines the current prioritized list of fallbacks
  61045. */
  61046. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61047. /**
  61048. * Initialize defines for shader compilation
  61049. * @param mesh defines the mesh to be rendered
  61050. * @param nodeMaterial defines the node material requesting the update
  61051. * @param defines defines the material defines to update
  61052. * @param useInstances specifies that instances should be used
  61053. */
  61054. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61055. /**
  61056. * Update defines for shader compilation
  61057. * @param mesh defines the mesh to be rendered
  61058. * @param nodeMaterial defines the node material requesting the update
  61059. * @param defines defines the material defines to update
  61060. * @param useInstances specifies that instances should be used
  61061. */
  61062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61063. /**
  61064. * Lets the block try to connect some inputs automatically
  61065. * @param material defines the hosting NodeMaterial
  61066. */
  61067. autoConfigure(material: NodeMaterial): void;
  61068. /**
  61069. * Function called when a block is declared as repeatable content generator
  61070. * @param vertexShaderState defines the current compilation state for the vertex shader
  61071. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61072. * @param mesh defines the mesh to be rendered
  61073. * @param defines defines the material defines to update
  61074. */
  61075. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61076. /**
  61077. * Checks if the block is ready
  61078. * @param mesh defines the mesh to be rendered
  61079. * @param nodeMaterial defines the node material requesting the update
  61080. * @param defines defines the material defines to update
  61081. * @param useInstances specifies that instances should be used
  61082. * @returns true if the block is ready
  61083. */
  61084. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61085. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61086. private _processBuild;
  61087. /**
  61088. * Compile the current node and generate the shader code
  61089. * @param state defines the current compilation state (uniforms, samplers, current string)
  61090. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61091. * @returns true if already built
  61092. */
  61093. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61094. protected _inputRename(name: string): string;
  61095. protected _outputRename(name: string): string;
  61096. protected _dumpPropertiesCode(): string;
  61097. /** @hidden */
  61098. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61099. /** @hidden */
  61100. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61101. /**
  61102. * Clone the current block to a new identical block
  61103. * @param scene defines the hosting scene
  61104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61105. * @returns a copy of the current block
  61106. */
  61107. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61108. /**
  61109. * Serializes this block in a JSON representation
  61110. * @returns the serialized block object
  61111. */
  61112. serialize(): any;
  61113. /** @hidden */
  61114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61115. /**
  61116. * Release resources
  61117. */
  61118. dispose(): void;
  61119. }
  61120. }
  61121. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61122. /**
  61123. * Enum defining the type of animations supported by InputBlock
  61124. */
  61125. export enum AnimatedInputBlockTypes {
  61126. /** No animation */
  61127. None = 0,
  61128. /** Time based animation. Will only work for floats */
  61129. Time = 1
  61130. }
  61131. }
  61132. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61134. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61135. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61136. import { Nullable } from "babylonjs/types";
  61137. import { Effect } from "babylonjs/Materials/effect";
  61138. import { Matrix } from "babylonjs/Maths/math.vector";
  61139. import { Scene } from "babylonjs/scene";
  61140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61142. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61143. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61144. import { Observable } from "babylonjs/Misc/observable";
  61145. /**
  61146. * Block used to expose an input value
  61147. */
  61148. export class InputBlock extends NodeMaterialBlock {
  61149. private _mode;
  61150. private _associatedVariableName;
  61151. private _storedValue;
  61152. private _valueCallback;
  61153. private _type;
  61154. private _animationType;
  61155. /** Gets or set a value used to limit the range of float values */
  61156. min: number;
  61157. /** Gets or set a value used to limit the range of float values */
  61158. max: number;
  61159. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61160. isBoolean: boolean;
  61161. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61162. matrixMode: number;
  61163. /** @hidden */
  61164. _systemValue: Nullable<NodeMaterialSystemValues>;
  61165. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61166. visibleInInspector: boolean;
  61167. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61168. isConstant: boolean;
  61169. /** Gets or sets the group to use to display this block in the Inspector */
  61170. groupInInspector: string;
  61171. /** Gets an observable raised when the value is changed */
  61172. onValueChangedObservable: Observable<InputBlock>;
  61173. /**
  61174. * Gets or sets the connection point type (default is float)
  61175. */
  61176. get type(): NodeMaterialBlockConnectionPointTypes;
  61177. /**
  61178. * Creates a new InputBlock
  61179. * @param name defines the block name
  61180. * @param target defines the target of that block (Vertex by default)
  61181. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61182. */
  61183. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61184. /**
  61185. * Gets the output component
  61186. */
  61187. get output(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Set the source of this connection point to a vertex attribute
  61190. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61191. * @returns the current connection point
  61192. */
  61193. setAsAttribute(attributeName?: string): InputBlock;
  61194. /**
  61195. * Set the source of this connection point to a system value
  61196. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61197. * @returns the current connection point
  61198. */
  61199. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61200. /**
  61201. * Gets or sets the value of that point.
  61202. * Please note that this value will be ignored if valueCallback is defined
  61203. */
  61204. get value(): any;
  61205. set value(value: any);
  61206. /**
  61207. * Gets or sets a callback used to get the value of that point.
  61208. * Please note that setting this value will force the connection point to ignore the value property
  61209. */
  61210. get valueCallback(): () => any;
  61211. set valueCallback(value: () => any);
  61212. /**
  61213. * Gets or sets the associated variable name in the shader
  61214. */
  61215. get associatedVariableName(): string;
  61216. set associatedVariableName(value: string);
  61217. /** Gets or sets the type of animation applied to the input */
  61218. get animationType(): AnimatedInputBlockTypes;
  61219. set animationType(value: AnimatedInputBlockTypes);
  61220. /**
  61221. * Gets a boolean indicating that this connection point not defined yet
  61222. */
  61223. get isUndefined(): boolean;
  61224. /**
  61225. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61226. * In this case the connection point name must be the name of the uniform to use.
  61227. * Can only be set on inputs
  61228. */
  61229. get isUniform(): boolean;
  61230. set isUniform(value: boolean);
  61231. /**
  61232. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61233. * In this case the connection point name must be the name of the attribute to use
  61234. * Can only be set on inputs
  61235. */
  61236. get isAttribute(): boolean;
  61237. set isAttribute(value: boolean);
  61238. /**
  61239. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61240. * Can only be set on exit points
  61241. */
  61242. get isVarying(): boolean;
  61243. set isVarying(value: boolean);
  61244. /**
  61245. * Gets a boolean indicating that the current connection point is a system value
  61246. */
  61247. get isSystemValue(): boolean;
  61248. /**
  61249. * Gets or sets the current well known value or null if not defined as a system value
  61250. */
  61251. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61252. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61253. /**
  61254. * Gets the current class name
  61255. * @returns the class name
  61256. */
  61257. getClassName(): string;
  61258. /**
  61259. * Animate the input if animationType !== None
  61260. * @param scene defines the rendering scene
  61261. */
  61262. animate(scene: Scene): void;
  61263. private _emitDefine;
  61264. initialize(state: NodeMaterialBuildState): void;
  61265. /**
  61266. * Set the input block to its default value (based on its type)
  61267. */
  61268. setDefaultValue(): void;
  61269. private _emitConstant;
  61270. private _emit;
  61271. /** @hidden */
  61272. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61273. /** @hidden */
  61274. _transmit(effect: Effect, scene: Scene): void;
  61275. protected _buildBlock(state: NodeMaterialBuildState): void;
  61276. protected _dumpPropertiesCode(): string;
  61277. dispose(): void;
  61278. serialize(): any;
  61279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61280. }
  61281. }
  61282. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61283. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61284. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61285. import { Nullable } from "babylonjs/types";
  61286. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61287. import { Observable } from "babylonjs/Misc/observable";
  61288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61289. /**
  61290. * Enum used to define the compatibility state between two connection points
  61291. */
  61292. export enum NodeMaterialConnectionPointCompatibilityStates {
  61293. /** Points are compatibles */
  61294. Compatible = 0,
  61295. /** Points are incompatible because of their types */
  61296. TypeIncompatible = 1,
  61297. /** Points are incompatible because of their targets (vertex vs fragment) */
  61298. TargetIncompatible = 2
  61299. }
  61300. /**
  61301. * Defines the direction of a connection point
  61302. */
  61303. export enum NodeMaterialConnectionPointDirection {
  61304. /** Input */
  61305. Input = 0,
  61306. /** Output */
  61307. Output = 1
  61308. }
  61309. /**
  61310. * Defines a connection point for a block
  61311. */
  61312. export class NodeMaterialConnectionPoint {
  61313. /** @hidden */
  61314. _ownerBlock: NodeMaterialBlock;
  61315. /** @hidden */
  61316. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61317. private _endpoints;
  61318. private _associatedVariableName;
  61319. private _direction;
  61320. /** @hidden */
  61321. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61322. /** @hidden */
  61323. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61324. private _type;
  61325. /** @hidden */
  61326. _enforceAssociatedVariableName: boolean;
  61327. /** Gets the direction of the point */
  61328. get direction(): NodeMaterialConnectionPointDirection;
  61329. /**
  61330. * Gets or sets the additional types supported by this connection point
  61331. */
  61332. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61333. /**
  61334. * Gets or sets the additional types excluded by this connection point
  61335. */
  61336. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61337. /**
  61338. * Observable triggered when this point is connected
  61339. */
  61340. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61341. /**
  61342. * Gets or sets the associated variable name in the shader
  61343. */
  61344. get associatedVariableName(): string;
  61345. set associatedVariableName(value: string);
  61346. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61347. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61348. /**
  61349. * Gets or sets the connection point type (default is float)
  61350. */
  61351. get type(): NodeMaterialBlockConnectionPointTypes;
  61352. set type(value: NodeMaterialBlockConnectionPointTypes);
  61353. /**
  61354. * Gets or sets the connection point name
  61355. */
  61356. name: string;
  61357. /**
  61358. * Gets or sets a boolean indicating that this connection point can be omitted
  61359. */
  61360. isOptional: boolean;
  61361. /**
  61362. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61363. */
  61364. define: string;
  61365. /** @hidden */
  61366. _prioritizeVertex: boolean;
  61367. private _target;
  61368. /** Gets or sets the target of that connection point */
  61369. get target(): NodeMaterialBlockTargets;
  61370. set target(value: NodeMaterialBlockTargets);
  61371. /**
  61372. * Gets a boolean indicating that the current point is connected
  61373. */
  61374. get isConnected(): boolean;
  61375. /**
  61376. * Gets a boolean indicating that the current point is connected to an input block
  61377. */
  61378. get isConnectedToInputBlock(): boolean;
  61379. /**
  61380. * Gets a the connected input block (if any)
  61381. */
  61382. get connectInputBlock(): Nullable<InputBlock>;
  61383. /** Get the other side of the connection (if any) */
  61384. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61385. /** Get the block that owns this connection point */
  61386. get ownerBlock(): NodeMaterialBlock;
  61387. /** Get the block connected on the other side of this connection (if any) */
  61388. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61389. /** Get the block connected on the endpoints of this connection (if any) */
  61390. get connectedBlocks(): Array<NodeMaterialBlock>;
  61391. /** Gets the list of connected endpoints */
  61392. get endpoints(): NodeMaterialConnectionPoint[];
  61393. /** Gets a boolean indicating if that output point is connected to at least one input */
  61394. get hasEndpoints(): boolean;
  61395. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61396. get isConnectedInVertexShader(): boolean;
  61397. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61398. get isConnectedInFragmentShader(): boolean;
  61399. /**
  61400. * Creates a new connection point
  61401. * @param name defines the connection point name
  61402. * @param ownerBlock defines the block hosting this connection point
  61403. * @param direction defines the direction of the connection point
  61404. */
  61405. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61406. /**
  61407. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61408. * @returns the class name
  61409. */
  61410. getClassName(): string;
  61411. /**
  61412. * Gets a boolean indicating if the current point can be connected to another point
  61413. * @param connectionPoint defines the other connection point
  61414. * @returns a boolean
  61415. */
  61416. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61417. /**
  61418. * Gets a number indicating if the current point can be connected to another point
  61419. * @param connectionPoint defines the other connection point
  61420. * @returns a number defining the compatibility state
  61421. */
  61422. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61423. /**
  61424. * Connect this point to another connection point
  61425. * @param connectionPoint defines the other connection point
  61426. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61427. * @returns the current connection point
  61428. */
  61429. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61430. /**
  61431. * Disconnect this point from one of his endpoint
  61432. * @param endpoint defines the other connection point
  61433. * @returns the current connection point
  61434. */
  61435. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Serializes this point in a JSON representation
  61438. * @returns the serialized point object
  61439. */
  61440. serialize(): any;
  61441. /**
  61442. * Release resources
  61443. */
  61444. dispose(): void;
  61445. }
  61446. }
  61447. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61451. import { Mesh } from "babylonjs/Meshes/mesh";
  61452. import { Effect } from "babylonjs/Materials/effect";
  61453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61454. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61456. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61457. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61458. /**
  61459. * Block used to add support for vertex skinning (bones)
  61460. */
  61461. export class BonesBlock extends NodeMaterialBlock {
  61462. /**
  61463. * Creates a new BonesBlock
  61464. * @param name defines the block name
  61465. */
  61466. constructor(name: string);
  61467. /**
  61468. * Initialize the block and prepare the context for build
  61469. * @param state defines the state that will be used for the build
  61470. */
  61471. initialize(state: NodeMaterialBuildState): void;
  61472. /**
  61473. * Gets the current class name
  61474. * @returns the class name
  61475. */
  61476. getClassName(): string;
  61477. /**
  61478. * Gets the matrix indices input component
  61479. */
  61480. get matricesIndices(): NodeMaterialConnectionPoint;
  61481. /**
  61482. * Gets the matrix weights input component
  61483. */
  61484. get matricesWeights(): NodeMaterialConnectionPoint;
  61485. /**
  61486. * Gets the extra matrix indices input component
  61487. */
  61488. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the extra matrix weights input component
  61491. */
  61492. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the world input component
  61495. */
  61496. get world(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the output component
  61499. */
  61500. get output(): NodeMaterialConnectionPoint;
  61501. autoConfigure(material: NodeMaterial): void;
  61502. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61505. protected _buildBlock(state: NodeMaterialBuildState): this;
  61506. }
  61507. }
  61508. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61513. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61514. /**
  61515. * Block used to add support for instances
  61516. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61517. */
  61518. export class InstancesBlock extends NodeMaterialBlock {
  61519. /**
  61520. * Creates a new InstancesBlock
  61521. * @param name defines the block name
  61522. */
  61523. constructor(name: string);
  61524. /**
  61525. * Gets the current class name
  61526. * @returns the class name
  61527. */
  61528. getClassName(): string;
  61529. /**
  61530. * Gets the first world row input component
  61531. */
  61532. get world0(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the second world row input component
  61535. */
  61536. get world1(): NodeMaterialConnectionPoint;
  61537. /**
  61538. * Gets the third world row input component
  61539. */
  61540. get world2(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the forth world row input component
  61543. */
  61544. get world3(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the world input component
  61547. */
  61548. get world(): NodeMaterialConnectionPoint;
  61549. /**
  61550. * Gets the output component
  61551. */
  61552. get output(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the isntanceID component
  61555. */
  61556. get instanceID(): NodeMaterialConnectionPoint;
  61557. autoConfigure(material: NodeMaterial): void;
  61558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61559. protected _buildBlock(state: NodeMaterialBuildState): this;
  61560. }
  61561. }
  61562. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61567. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61568. import { Effect } from "babylonjs/Materials/effect";
  61569. import { Mesh } from "babylonjs/Meshes/mesh";
  61570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61571. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61572. /**
  61573. * Block used to add morph targets support to vertex shader
  61574. */
  61575. export class MorphTargetsBlock extends NodeMaterialBlock {
  61576. private _repeatableContentAnchor;
  61577. /**
  61578. * Create a new MorphTargetsBlock
  61579. * @param name defines the block name
  61580. */
  61581. constructor(name: string);
  61582. /**
  61583. * Gets the current class name
  61584. * @returns the class name
  61585. */
  61586. getClassName(): string;
  61587. /**
  61588. * Gets the position input component
  61589. */
  61590. get position(): NodeMaterialConnectionPoint;
  61591. /**
  61592. * Gets the normal input component
  61593. */
  61594. get normal(): NodeMaterialConnectionPoint;
  61595. /**
  61596. * Gets the tangent input component
  61597. */
  61598. get tangent(): NodeMaterialConnectionPoint;
  61599. /**
  61600. * Gets the tangent input component
  61601. */
  61602. get uv(): NodeMaterialConnectionPoint;
  61603. /**
  61604. * Gets the position output component
  61605. */
  61606. get positionOutput(): NodeMaterialConnectionPoint;
  61607. /**
  61608. * Gets the normal output component
  61609. */
  61610. get normalOutput(): NodeMaterialConnectionPoint;
  61611. /**
  61612. * Gets the tangent output component
  61613. */
  61614. get tangentOutput(): NodeMaterialConnectionPoint;
  61615. /**
  61616. * Gets the tangent output component
  61617. */
  61618. get uvOutput(): NodeMaterialConnectionPoint;
  61619. initialize(state: NodeMaterialBuildState): void;
  61620. autoConfigure(material: NodeMaterial): void;
  61621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61623. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61624. protected _buildBlock(state: NodeMaterialBuildState): this;
  61625. }
  61626. }
  61627. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61631. import { Nullable } from "babylonjs/types";
  61632. import { Scene } from "babylonjs/scene";
  61633. import { Effect } from "babylonjs/Materials/effect";
  61634. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61635. import { Mesh } from "babylonjs/Meshes/mesh";
  61636. import { Light } from "babylonjs/Lights/light";
  61637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61638. /**
  61639. * Block used to get data information from a light
  61640. */
  61641. export class LightInformationBlock extends NodeMaterialBlock {
  61642. private _lightDataUniformName;
  61643. private _lightColorUniformName;
  61644. private _lightTypeDefineName;
  61645. /**
  61646. * Gets or sets the light associated with this block
  61647. */
  61648. light: Nullable<Light>;
  61649. /**
  61650. * Creates a new LightInformationBlock
  61651. * @param name defines the block name
  61652. */
  61653. constructor(name: string);
  61654. /**
  61655. * Gets the current class name
  61656. * @returns the class name
  61657. */
  61658. getClassName(): string;
  61659. /**
  61660. * Gets the world position input component
  61661. */
  61662. get worldPosition(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the direction output component
  61665. */
  61666. get direction(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the direction output component
  61669. */
  61670. get color(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the direction output component
  61673. */
  61674. get intensity(): NodeMaterialConnectionPoint;
  61675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61677. protected _buildBlock(state: NodeMaterialBuildState): this;
  61678. serialize(): any;
  61679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61680. }
  61681. }
  61682. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61683. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61684. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61685. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61686. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61687. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61688. }
  61689. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61695. import { Effect } from "babylonjs/Materials/effect";
  61696. import { Mesh } from "babylonjs/Meshes/mesh";
  61697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61698. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61699. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61700. /**
  61701. * Block used to add image processing support to fragment shader
  61702. */
  61703. export class ImageProcessingBlock extends NodeMaterialBlock {
  61704. /**
  61705. * Create a new ImageProcessingBlock
  61706. * @param name defines the block name
  61707. */
  61708. constructor(name: string);
  61709. /**
  61710. * Gets the current class name
  61711. * @returns the class name
  61712. */
  61713. getClassName(): string;
  61714. /**
  61715. * Gets the color input component
  61716. */
  61717. get color(): NodeMaterialConnectionPoint;
  61718. /**
  61719. * Gets the output component
  61720. */
  61721. get output(): NodeMaterialConnectionPoint;
  61722. /**
  61723. * Initialize the block and prepare the context for build
  61724. * @param state defines the state that will be used for the build
  61725. */
  61726. initialize(state: NodeMaterialBuildState): void;
  61727. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61730. protected _buildBlock(state: NodeMaterialBuildState): this;
  61731. }
  61732. }
  61733. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61739. import { Effect } from "babylonjs/Materials/effect";
  61740. import { Mesh } from "babylonjs/Meshes/mesh";
  61741. import { Scene } from "babylonjs/scene";
  61742. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61743. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61744. /**
  61745. * Block used to pertub normals based on a normal map
  61746. */
  61747. export class PerturbNormalBlock extends NodeMaterialBlock {
  61748. private _tangentSpaceParameterName;
  61749. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61750. invertX: boolean;
  61751. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61752. invertY: boolean;
  61753. /**
  61754. * Create a new PerturbNormalBlock
  61755. * @param name defines the block name
  61756. */
  61757. constructor(name: string);
  61758. /**
  61759. * Gets the current class name
  61760. * @returns the class name
  61761. */
  61762. getClassName(): string;
  61763. /**
  61764. * Gets the world position input component
  61765. */
  61766. get worldPosition(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the world normal input component
  61769. */
  61770. get worldNormal(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the world tangent input component
  61773. */
  61774. get worldTangent(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the uv input component
  61777. */
  61778. get uv(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the normal map color input component
  61781. */
  61782. get normalMapColor(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the strength input component
  61785. */
  61786. get strength(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the output component
  61789. */
  61790. get output(): NodeMaterialConnectionPoint;
  61791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61793. autoConfigure(material: NodeMaterial): void;
  61794. protected _buildBlock(state: NodeMaterialBuildState): this;
  61795. protected _dumpPropertiesCode(): string;
  61796. serialize(): any;
  61797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61798. }
  61799. }
  61800. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61804. /**
  61805. * Block used to discard a pixel if a value is smaller than a cutoff
  61806. */
  61807. export class DiscardBlock extends NodeMaterialBlock {
  61808. /**
  61809. * Create a new DiscardBlock
  61810. * @param name defines the block name
  61811. */
  61812. constructor(name: string);
  61813. /**
  61814. * Gets the current class name
  61815. * @returns the class name
  61816. */
  61817. getClassName(): string;
  61818. /**
  61819. * Gets the color input component
  61820. */
  61821. get value(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the cutoff input component
  61824. */
  61825. get cutoff(): NodeMaterialConnectionPoint;
  61826. protected _buildBlock(state: NodeMaterialBuildState): this;
  61827. }
  61828. }
  61829. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61833. /**
  61834. * Block used to test if the fragment shader is front facing
  61835. */
  61836. export class FrontFacingBlock extends NodeMaterialBlock {
  61837. /**
  61838. * Creates a new FrontFacingBlock
  61839. * @param name defines the block name
  61840. */
  61841. constructor(name: string);
  61842. /**
  61843. * Gets the current class name
  61844. * @returns the class name
  61845. */
  61846. getClassName(): string;
  61847. /**
  61848. * Gets the output component
  61849. */
  61850. get output(): NodeMaterialConnectionPoint;
  61851. protected _buildBlock(state: NodeMaterialBuildState): this;
  61852. }
  61853. }
  61854. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61858. /**
  61859. * Block used to get the derivative value on x and y of a given input
  61860. */
  61861. export class DerivativeBlock extends NodeMaterialBlock {
  61862. /**
  61863. * Create a new DerivativeBlock
  61864. * @param name defines the block name
  61865. */
  61866. constructor(name: string);
  61867. /**
  61868. * Gets the current class name
  61869. * @returns the class name
  61870. */
  61871. getClassName(): string;
  61872. /**
  61873. * Gets the input component
  61874. */
  61875. get input(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the derivative output on x
  61878. */
  61879. get dx(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the derivative output on y
  61882. */
  61883. get dy(): NodeMaterialConnectionPoint;
  61884. protected _buildBlock(state: NodeMaterialBuildState): this;
  61885. }
  61886. }
  61887. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61888. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61889. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61890. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61891. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61892. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61893. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61894. }
  61895. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61898. import { Mesh } from "babylonjs/Meshes/mesh";
  61899. import { Effect } from "babylonjs/Materials/effect";
  61900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61902. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61903. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61904. /**
  61905. * Block used to add support for scene fog
  61906. */
  61907. export class FogBlock extends NodeMaterialBlock {
  61908. private _fogDistanceName;
  61909. private _fogParameters;
  61910. /**
  61911. * Create a new FogBlock
  61912. * @param name defines the block name
  61913. */
  61914. constructor(name: string);
  61915. /**
  61916. * Gets the current class name
  61917. * @returns the class name
  61918. */
  61919. getClassName(): string;
  61920. /**
  61921. * Gets the world position input component
  61922. */
  61923. get worldPosition(): NodeMaterialConnectionPoint;
  61924. /**
  61925. * Gets the view input component
  61926. */
  61927. get view(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the color input component
  61930. */
  61931. get input(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the fog color input component
  61934. */
  61935. get fogColor(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the output component
  61938. */
  61939. get output(): NodeMaterialConnectionPoint;
  61940. autoConfigure(material: NodeMaterial): void;
  61941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61943. protected _buildBlock(state: NodeMaterialBuildState): this;
  61944. }
  61945. }
  61946. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61951. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61952. import { Effect } from "babylonjs/Materials/effect";
  61953. import { Mesh } from "babylonjs/Meshes/mesh";
  61954. import { Light } from "babylonjs/Lights/light";
  61955. import { Nullable } from "babylonjs/types";
  61956. import { Scene } from "babylonjs/scene";
  61957. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61958. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61959. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61961. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61962. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61963. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61964. /**
  61965. * Block used to add light in the fragment shader
  61966. */
  61967. export class LightBlock extends NodeMaterialBlock {
  61968. private _lightId;
  61969. /**
  61970. * Gets or sets the light associated with this block
  61971. */
  61972. light: Nullable<Light>;
  61973. /**
  61974. * Create a new LightBlock
  61975. * @param name defines the block name
  61976. */
  61977. constructor(name: string);
  61978. /**
  61979. * Gets the current class name
  61980. * @returns the class name
  61981. */
  61982. getClassName(): string;
  61983. /**
  61984. * Gets the world position input component
  61985. */
  61986. get worldPosition(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the world normal input component
  61989. */
  61990. get worldNormal(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the camera (or eye) position component
  61993. */
  61994. get cameraPosition(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the glossiness component
  61997. */
  61998. get glossiness(): NodeMaterialConnectionPoint;
  61999. /**
  62000. * Gets the glossinness power component
  62001. */
  62002. get glossPower(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the diffuse color component
  62005. */
  62006. get diffuseColor(): NodeMaterialConnectionPoint;
  62007. /**
  62008. * Gets the specular color component
  62009. */
  62010. get specularColor(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the diffuse output component
  62013. */
  62014. get diffuseOutput(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the specular output component
  62017. */
  62018. get specularOutput(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the shadow output component
  62021. */
  62022. get shadow(): NodeMaterialConnectionPoint;
  62023. autoConfigure(material: NodeMaterial): void;
  62024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62025. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62027. private _injectVertexCode;
  62028. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62029. serialize(): any;
  62030. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62031. }
  62032. }
  62033. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62034. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62035. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62036. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62037. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62038. }
  62039. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62040. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62041. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62042. }
  62043. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62047. /**
  62048. * Block used to multiply 2 values
  62049. */
  62050. export class MultiplyBlock extends NodeMaterialBlock {
  62051. /**
  62052. * Creates a new MultiplyBlock
  62053. * @param name defines the block name
  62054. */
  62055. constructor(name: string);
  62056. /**
  62057. * Gets the current class name
  62058. * @returns the class name
  62059. */
  62060. getClassName(): string;
  62061. /**
  62062. * Gets the left operand input component
  62063. */
  62064. get left(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the right operand input component
  62067. */
  62068. get right(): NodeMaterialConnectionPoint;
  62069. /**
  62070. * Gets the output component
  62071. */
  62072. get output(): NodeMaterialConnectionPoint;
  62073. protected _buildBlock(state: NodeMaterialBuildState): this;
  62074. }
  62075. }
  62076. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62080. /**
  62081. * Block used to add 2 vectors
  62082. */
  62083. export class AddBlock extends NodeMaterialBlock {
  62084. /**
  62085. * Creates a new AddBlock
  62086. * @param name defines the block name
  62087. */
  62088. constructor(name: string);
  62089. /**
  62090. * Gets the current class name
  62091. * @returns the class name
  62092. */
  62093. getClassName(): string;
  62094. /**
  62095. * Gets the left operand input component
  62096. */
  62097. get left(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the right operand input component
  62100. */
  62101. get right(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the output component
  62104. */
  62105. get output(): NodeMaterialConnectionPoint;
  62106. protected _buildBlock(state: NodeMaterialBuildState): this;
  62107. }
  62108. }
  62109. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62113. /**
  62114. * Block used to scale a vector by a float
  62115. */
  62116. export class ScaleBlock extends NodeMaterialBlock {
  62117. /**
  62118. * Creates a new ScaleBlock
  62119. * @param name defines the block name
  62120. */
  62121. constructor(name: string);
  62122. /**
  62123. * Gets the current class name
  62124. * @returns the class name
  62125. */
  62126. getClassName(): string;
  62127. /**
  62128. * Gets the input component
  62129. */
  62130. get input(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the factor input component
  62133. */
  62134. get factor(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Gets the output component
  62137. */
  62138. get output(): NodeMaterialConnectionPoint;
  62139. protected _buildBlock(state: NodeMaterialBuildState): this;
  62140. }
  62141. }
  62142. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62146. import { Scene } from "babylonjs/scene";
  62147. /**
  62148. * Block used to clamp a float
  62149. */
  62150. export class ClampBlock extends NodeMaterialBlock {
  62151. /** Gets or sets the minimum range */
  62152. minimum: number;
  62153. /** Gets or sets the maximum range */
  62154. maximum: number;
  62155. /**
  62156. * Creates a new ClampBlock
  62157. * @param name defines the block name
  62158. */
  62159. constructor(name: string);
  62160. /**
  62161. * Gets the current class name
  62162. * @returns the class name
  62163. */
  62164. getClassName(): string;
  62165. /**
  62166. * Gets the value input component
  62167. */
  62168. get value(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the output component
  62171. */
  62172. get output(): NodeMaterialConnectionPoint;
  62173. protected _buildBlock(state: NodeMaterialBuildState): this;
  62174. protected _dumpPropertiesCode(): string;
  62175. serialize(): any;
  62176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62177. }
  62178. }
  62179. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62183. /**
  62184. * Block used to apply a cross product between 2 vectors
  62185. */
  62186. export class CrossBlock extends NodeMaterialBlock {
  62187. /**
  62188. * Creates a new CrossBlock
  62189. * @param name defines the block name
  62190. */
  62191. constructor(name: string);
  62192. /**
  62193. * Gets the current class name
  62194. * @returns the class name
  62195. */
  62196. getClassName(): string;
  62197. /**
  62198. * Gets the left operand input component
  62199. */
  62200. get left(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the right operand input component
  62203. */
  62204. get right(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the output component
  62207. */
  62208. get output(): NodeMaterialConnectionPoint;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this;
  62210. }
  62211. }
  62212. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62216. /**
  62217. * Block used to apply a dot product between 2 vectors
  62218. */
  62219. export class DotBlock extends NodeMaterialBlock {
  62220. /**
  62221. * Creates a new DotBlock
  62222. * @param name defines the block name
  62223. */
  62224. constructor(name: string);
  62225. /**
  62226. * Gets the current class name
  62227. * @returns the class name
  62228. */
  62229. getClassName(): string;
  62230. /**
  62231. * Gets the left operand input component
  62232. */
  62233. get left(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the right operand input component
  62236. */
  62237. get right(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the output component
  62240. */
  62241. get output(): NodeMaterialConnectionPoint;
  62242. protected _buildBlock(state: NodeMaterialBuildState): this;
  62243. }
  62244. }
  62245. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62249. import { Vector2 } from "babylonjs/Maths/math.vector";
  62250. import { Scene } from "babylonjs/scene";
  62251. /**
  62252. * Block used to remap a float from a range to a new one
  62253. */
  62254. export class RemapBlock extends NodeMaterialBlock {
  62255. /**
  62256. * Gets or sets the source range
  62257. */
  62258. sourceRange: Vector2;
  62259. /**
  62260. * Gets or sets the target range
  62261. */
  62262. targetRange: Vector2;
  62263. /**
  62264. * Creates a new RemapBlock
  62265. * @param name defines the block name
  62266. */
  62267. constructor(name: string);
  62268. /**
  62269. * Gets the current class name
  62270. * @returns the class name
  62271. */
  62272. getClassName(): string;
  62273. /**
  62274. * Gets the input component
  62275. */
  62276. get input(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the source min input component
  62279. */
  62280. get sourceMin(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the source max input component
  62283. */
  62284. get sourceMax(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the target min input component
  62287. */
  62288. get targetMin(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the target max input component
  62291. */
  62292. get targetMax(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the output component
  62295. */
  62296. get output(): NodeMaterialConnectionPoint;
  62297. protected _buildBlock(state: NodeMaterialBuildState): this;
  62298. protected _dumpPropertiesCode(): string;
  62299. serialize(): any;
  62300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62301. }
  62302. }
  62303. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62307. /**
  62308. * Block used to normalize a vector
  62309. */
  62310. export class NormalizeBlock extends NodeMaterialBlock {
  62311. /**
  62312. * Creates a new NormalizeBlock
  62313. * @param name defines the block name
  62314. */
  62315. constructor(name: string);
  62316. /**
  62317. * Gets the current class name
  62318. * @returns the class name
  62319. */
  62320. getClassName(): string;
  62321. /**
  62322. * Gets the input component
  62323. */
  62324. get input(): NodeMaterialConnectionPoint;
  62325. /**
  62326. * Gets the output component
  62327. */
  62328. get output(): NodeMaterialConnectionPoint;
  62329. protected _buildBlock(state: NodeMaterialBuildState): this;
  62330. }
  62331. }
  62332. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62336. import { Scene } from "babylonjs/scene";
  62337. /**
  62338. * Operations supported by the Trigonometry block
  62339. */
  62340. export enum TrigonometryBlockOperations {
  62341. /** Cos */
  62342. Cos = 0,
  62343. /** Sin */
  62344. Sin = 1,
  62345. /** Abs */
  62346. Abs = 2,
  62347. /** Exp */
  62348. Exp = 3,
  62349. /** Exp2 */
  62350. Exp2 = 4,
  62351. /** Round */
  62352. Round = 5,
  62353. /** Floor */
  62354. Floor = 6,
  62355. /** Ceiling */
  62356. Ceiling = 7,
  62357. /** Square root */
  62358. Sqrt = 8,
  62359. /** Log */
  62360. Log = 9,
  62361. /** Tangent */
  62362. Tan = 10,
  62363. /** Arc tangent */
  62364. ArcTan = 11,
  62365. /** Arc cosinus */
  62366. ArcCos = 12,
  62367. /** Arc sinus */
  62368. ArcSin = 13,
  62369. /** Fraction */
  62370. Fract = 14,
  62371. /** Sign */
  62372. Sign = 15,
  62373. /** To radians (from degrees) */
  62374. Radians = 16,
  62375. /** To degrees (from radians) */
  62376. Degrees = 17
  62377. }
  62378. /**
  62379. * Block used to apply trigonometry operation to floats
  62380. */
  62381. export class TrigonometryBlock extends NodeMaterialBlock {
  62382. /**
  62383. * Gets or sets the operation applied by the block
  62384. */
  62385. operation: TrigonometryBlockOperations;
  62386. /**
  62387. * Creates a new TrigonometryBlock
  62388. * @param name defines the block name
  62389. */
  62390. constructor(name: string);
  62391. /**
  62392. * Gets the current class name
  62393. * @returns the class name
  62394. */
  62395. getClassName(): string;
  62396. /**
  62397. * Gets the input component
  62398. */
  62399. get input(): NodeMaterialConnectionPoint;
  62400. /**
  62401. * Gets the output component
  62402. */
  62403. get output(): NodeMaterialConnectionPoint;
  62404. protected _buildBlock(state: NodeMaterialBuildState): this;
  62405. serialize(): any;
  62406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62407. protected _dumpPropertiesCode(): string;
  62408. }
  62409. }
  62410. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62414. /**
  62415. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62416. */
  62417. export class ColorMergerBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Create a new ColorMergerBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the rgb component (input)
  62430. */
  62431. get rgbIn(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the r component (input)
  62434. */
  62435. get r(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the g component (input)
  62438. */
  62439. get g(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the b component (input)
  62442. */
  62443. get b(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the a component (input)
  62446. */
  62447. get a(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the rgba component (output)
  62450. */
  62451. get rgba(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the rgb component (output)
  62454. */
  62455. get rgbOut(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the rgb component (output)
  62458. * @deprecated Please use rgbOut instead.
  62459. */
  62460. get rgb(): NodeMaterialConnectionPoint;
  62461. protected _buildBlock(state: NodeMaterialBuildState): this;
  62462. }
  62463. }
  62464. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62468. /**
  62469. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62470. */
  62471. export class VectorMergerBlock extends NodeMaterialBlock {
  62472. /**
  62473. * Create a new VectorMergerBlock
  62474. * @param name defines the block name
  62475. */
  62476. constructor(name: string);
  62477. /**
  62478. * Gets the current class name
  62479. * @returns the class name
  62480. */
  62481. getClassName(): string;
  62482. /**
  62483. * Gets the xyz component (input)
  62484. */
  62485. get xyzIn(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the xy component (input)
  62488. */
  62489. get xyIn(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the x component (input)
  62492. */
  62493. get x(): NodeMaterialConnectionPoint;
  62494. /**
  62495. * Gets the y component (input)
  62496. */
  62497. get y(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the z component (input)
  62500. */
  62501. get z(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the w component (input)
  62504. */
  62505. get w(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the xyzw component (output)
  62508. */
  62509. get xyzw(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the xyz component (output)
  62512. */
  62513. get xyzOut(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the xy component (output)
  62516. */
  62517. get xyOut(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the xy component (output)
  62520. * @deprecated Please use xyOut instead.
  62521. */
  62522. get xy(): NodeMaterialConnectionPoint;
  62523. /**
  62524. * Gets the xyz component (output)
  62525. * @deprecated Please use xyzOut instead.
  62526. */
  62527. get xyz(): NodeMaterialConnectionPoint;
  62528. protected _buildBlock(state: NodeMaterialBuildState): this;
  62529. }
  62530. }
  62531. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62535. /**
  62536. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62537. */
  62538. export class ColorSplitterBlock extends NodeMaterialBlock {
  62539. /**
  62540. * Create a new ColorSplitterBlock
  62541. * @param name defines the block name
  62542. */
  62543. constructor(name: string);
  62544. /**
  62545. * Gets the current class name
  62546. * @returns the class name
  62547. */
  62548. getClassName(): string;
  62549. /**
  62550. * Gets the rgba component (input)
  62551. */
  62552. get rgba(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the rgb component (input)
  62555. */
  62556. get rgbIn(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the rgb component (output)
  62559. */
  62560. get rgbOut(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the r component (output)
  62563. */
  62564. get r(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the g component (output)
  62567. */
  62568. get g(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the b component (output)
  62571. */
  62572. get b(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the a component (output)
  62575. */
  62576. get a(): NodeMaterialConnectionPoint;
  62577. protected _inputRename(name: string): string;
  62578. protected _outputRename(name: string): string;
  62579. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62580. }
  62581. }
  62582. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62586. /**
  62587. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62588. */
  62589. export class VectorSplitterBlock extends NodeMaterialBlock {
  62590. /**
  62591. * Create a new VectorSplitterBlock
  62592. * @param name defines the block name
  62593. */
  62594. constructor(name: string);
  62595. /**
  62596. * Gets the current class name
  62597. * @returns the class name
  62598. */
  62599. getClassName(): string;
  62600. /**
  62601. * Gets the xyzw component (input)
  62602. */
  62603. get xyzw(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the xyz component (input)
  62606. */
  62607. get xyzIn(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the xy component (input)
  62610. */
  62611. get xyIn(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the xyz component (output)
  62614. */
  62615. get xyzOut(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the xy component (output)
  62618. */
  62619. get xyOut(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the x component (output)
  62622. */
  62623. get x(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the y component (output)
  62626. */
  62627. get y(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the z component (output)
  62630. */
  62631. get z(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the w component (output)
  62634. */
  62635. get w(): NodeMaterialConnectionPoint;
  62636. protected _inputRename(name: string): string;
  62637. protected _outputRename(name: string): string;
  62638. protected _buildBlock(state: NodeMaterialBuildState): this;
  62639. }
  62640. }
  62641. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62645. /**
  62646. * Block used to lerp between 2 values
  62647. */
  62648. export class LerpBlock extends NodeMaterialBlock {
  62649. /**
  62650. * Creates a new LerpBlock
  62651. * @param name defines the block name
  62652. */
  62653. constructor(name: string);
  62654. /**
  62655. * Gets the current class name
  62656. * @returns the class name
  62657. */
  62658. getClassName(): string;
  62659. /**
  62660. * Gets the left operand input component
  62661. */
  62662. get left(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the right operand input component
  62665. */
  62666. get right(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the gradient operand input component
  62669. */
  62670. get gradient(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the output component
  62673. */
  62674. get output(): NodeMaterialConnectionPoint;
  62675. protected _buildBlock(state: NodeMaterialBuildState): this;
  62676. }
  62677. }
  62678. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62682. /**
  62683. * Block used to divide 2 vectors
  62684. */
  62685. export class DivideBlock extends NodeMaterialBlock {
  62686. /**
  62687. * Creates a new DivideBlock
  62688. * @param name defines the block name
  62689. */
  62690. constructor(name: string);
  62691. /**
  62692. * Gets the current class name
  62693. * @returns the class name
  62694. */
  62695. getClassName(): string;
  62696. /**
  62697. * Gets the left operand input component
  62698. */
  62699. get left(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the right operand input component
  62702. */
  62703. get right(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. protected _buildBlock(state: NodeMaterialBuildState): this;
  62709. }
  62710. }
  62711. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62715. /**
  62716. * Block used to subtract 2 vectors
  62717. */
  62718. export class SubtractBlock extends NodeMaterialBlock {
  62719. /**
  62720. * Creates a new SubtractBlock
  62721. * @param name defines the block name
  62722. */
  62723. constructor(name: string);
  62724. /**
  62725. * Gets the current class name
  62726. * @returns the class name
  62727. */
  62728. getClassName(): string;
  62729. /**
  62730. * Gets the left operand input component
  62731. */
  62732. get left(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the right operand input component
  62735. */
  62736. get right(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the output component
  62739. */
  62740. get output(): NodeMaterialConnectionPoint;
  62741. protected _buildBlock(state: NodeMaterialBuildState): this;
  62742. }
  62743. }
  62744. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62748. /**
  62749. * Block used to step a value
  62750. */
  62751. export class StepBlock extends NodeMaterialBlock {
  62752. /**
  62753. * Creates a new StepBlock
  62754. * @param name defines the block name
  62755. */
  62756. constructor(name: string);
  62757. /**
  62758. * Gets the current class name
  62759. * @returns the class name
  62760. */
  62761. getClassName(): string;
  62762. /**
  62763. * Gets the value operand input component
  62764. */
  62765. get value(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the edge operand input component
  62768. */
  62769. get edge(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the output component
  62772. */
  62773. get output(): NodeMaterialConnectionPoint;
  62774. protected _buildBlock(state: NodeMaterialBuildState): this;
  62775. }
  62776. }
  62777. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62781. /**
  62782. * Block used to get the opposite (1 - x) of a value
  62783. */
  62784. export class OneMinusBlock extends NodeMaterialBlock {
  62785. /**
  62786. * Creates a new OneMinusBlock
  62787. * @param name defines the block name
  62788. */
  62789. constructor(name: string);
  62790. /**
  62791. * Gets the current class name
  62792. * @returns the class name
  62793. */
  62794. getClassName(): string;
  62795. /**
  62796. * Gets the input component
  62797. */
  62798. get input(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the output component
  62801. */
  62802. get output(): NodeMaterialConnectionPoint;
  62803. protected _buildBlock(state: NodeMaterialBuildState): this;
  62804. }
  62805. }
  62806. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62810. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62811. /**
  62812. * Block used to get the view direction
  62813. */
  62814. export class ViewDirectionBlock extends NodeMaterialBlock {
  62815. /**
  62816. * Creates a new ViewDirectionBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Gets the current class name
  62822. * @returns the class name
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Gets the world position component
  62827. */
  62828. get worldPosition(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the camera position component
  62831. */
  62832. get cameraPosition(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the output component
  62835. */
  62836. get output(): NodeMaterialConnectionPoint;
  62837. autoConfigure(material: NodeMaterial): void;
  62838. protected _buildBlock(state: NodeMaterialBuildState): this;
  62839. }
  62840. }
  62841. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62845. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62846. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62847. /**
  62848. * Block used to compute fresnel value
  62849. */
  62850. export class FresnelBlock extends NodeMaterialBlock {
  62851. /**
  62852. * Create a new FresnelBlock
  62853. * @param name defines the block name
  62854. */
  62855. constructor(name: string);
  62856. /**
  62857. * Gets the current class name
  62858. * @returns the class name
  62859. */
  62860. getClassName(): string;
  62861. /**
  62862. * Gets the world normal input component
  62863. */
  62864. get worldNormal(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the view direction input component
  62867. */
  62868. get viewDirection(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the bias input component
  62871. */
  62872. get bias(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the camera (or eye) position component
  62875. */
  62876. get power(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the fresnel output component
  62879. */
  62880. get fresnel(): NodeMaterialConnectionPoint;
  62881. autoConfigure(material: NodeMaterial): void;
  62882. protected _buildBlock(state: NodeMaterialBuildState): this;
  62883. }
  62884. }
  62885. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62889. /**
  62890. * Block used to get the max of 2 values
  62891. */
  62892. export class MaxBlock extends NodeMaterialBlock {
  62893. /**
  62894. * Creates a new MaxBlock
  62895. * @param name defines the block name
  62896. */
  62897. constructor(name: string);
  62898. /**
  62899. * Gets the current class name
  62900. * @returns the class name
  62901. */
  62902. getClassName(): string;
  62903. /**
  62904. * Gets the left operand input component
  62905. */
  62906. get left(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the right operand input component
  62909. */
  62910. get right(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the output component
  62913. */
  62914. get output(): NodeMaterialConnectionPoint;
  62915. protected _buildBlock(state: NodeMaterialBuildState): this;
  62916. }
  62917. }
  62918. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62922. /**
  62923. * Block used to get the min of 2 values
  62924. */
  62925. export class MinBlock extends NodeMaterialBlock {
  62926. /**
  62927. * Creates a new MinBlock
  62928. * @param name defines the block name
  62929. */
  62930. constructor(name: string);
  62931. /**
  62932. * Gets the current class name
  62933. * @returns the class name
  62934. */
  62935. getClassName(): string;
  62936. /**
  62937. * Gets the left operand input component
  62938. */
  62939. get left(): NodeMaterialConnectionPoint;
  62940. /**
  62941. * Gets the right operand input component
  62942. */
  62943. get right(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the output component
  62946. */
  62947. get output(): NodeMaterialConnectionPoint;
  62948. protected _buildBlock(state: NodeMaterialBuildState): this;
  62949. }
  62950. }
  62951. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62955. /**
  62956. * Block used to get the distance between 2 values
  62957. */
  62958. export class DistanceBlock extends NodeMaterialBlock {
  62959. /**
  62960. * Creates a new DistanceBlock
  62961. * @param name defines the block name
  62962. */
  62963. constructor(name: string);
  62964. /**
  62965. * Gets the current class name
  62966. * @returns the class name
  62967. */
  62968. getClassName(): string;
  62969. /**
  62970. * Gets the left operand input component
  62971. */
  62972. get left(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the right operand input component
  62975. */
  62976. get right(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the output component
  62979. */
  62980. get output(): NodeMaterialConnectionPoint;
  62981. protected _buildBlock(state: NodeMaterialBuildState): this;
  62982. }
  62983. }
  62984. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62988. /**
  62989. * Block used to get the length of a vector
  62990. */
  62991. export class LengthBlock extends NodeMaterialBlock {
  62992. /**
  62993. * Creates a new LengthBlock
  62994. * @param name defines the block name
  62995. */
  62996. constructor(name: string);
  62997. /**
  62998. * Gets the current class name
  62999. * @returns the class name
  63000. */
  63001. getClassName(): string;
  63002. /**
  63003. * Gets the value input component
  63004. */
  63005. get value(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the output component
  63008. */
  63009. get output(): NodeMaterialConnectionPoint;
  63010. protected _buildBlock(state: NodeMaterialBuildState): this;
  63011. }
  63012. }
  63013. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63017. /**
  63018. * Block used to get negative version of a value (i.e. x * -1)
  63019. */
  63020. export class NegateBlock extends NodeMaterialBlock {
  63021. /**
  63022. * Creates a new NegateBlock
  63023. * @param name defines the block name
  63024. */
  63025. constructor(name: string);
  63026. /**
  63027. * Gets the current class name
  63028. * @returns the class name
  63029. */
  63030. getClassName(): string;
  63031. /**
  63032. * Gets the value input component
  63033. */
  63034. get value(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the output component
  63037. */
  63038. get output(): NodeMaterialConnectionPoint;
  63039. protected _buildBlock(state: NodeMaterialBuildState): this;
  63040. }
  63041. }
  63042. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63046. /**
  63047. * Block used to get the value of the first parameter raised to the power of the second
  63048. */
  63049. export class PowBlock extends NodeMaterialBlock {
  63050. /**
  63051. * Creates a new PowBlock
  63052. * @param name defines the block name
  63053. */
  63054. constructor(name: string);
  63055. /**
  63056. * Gets the current class name
  63057. * @returns the class name
  63058. */
  63059. getClassName(): string;
  63060. /**
  63061. * Gets the value operand input component
  63062. */
  63063. get value(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the power operand input component
  63066. */
  63067. get power(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the output component
  63070. */
  63071. get output(): NodeMaterialConnectionPoint;
  63072. protected _buildBlock(state: NodeMaterialBuildState): this;
  63073. }
  63074. }
  63075. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63079. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63080. /**
  63081. * Block used to get a random number
  63082. */
  63083. export class RandomNumberBlock extends NodeMaterialBlock {
  63084. /**
  63085. * Creates a new RandomNumberBlock
  63086. * @param name defines the block name
  63087. */
  63088. constructor(name: string);
  63089. /**
  63090. * Gets the current class name
  63091. * @returns the class name
  63092. */
  63093. getClassName(): string;
  63094. /**
  63095. * Gets the seed input component
  63096. */
  63097. get seed(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the output component
  63100. */
  63101. get output(): NodeMaterialConnectionPoint;
  63102. protected _buildBlock(state: NodeMaterialBuildState): this;
  63103. }
  63104. }
  63105. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63109. /**
  63110. * Block used to compute arc tangent of 2 values
  63111. */
  63112. export class ArcTan2Block extends NodeMaterialBlock {
  63113. /**
  63114. * Creates a new ArcTan2Block
  63115. * @param name defines the block name
  63116. */
  63117. constructor(name: string);
  63118. /**
  63119. * Gets the current class name
  63120. * @returns the class name
  63121. */
  63122. getClassName(): string;
  63123. /**
  63124. * Gets the x operand input component
  63125. */
  63126. get x(): NodeMaterialConnectionPoint;
  63127. /**
  63128. * Gets the y operand input component
  63129. */
  63130. get y(): NodeMaterialConnectionPoint;
  63131. /**
  63132. * Gets the output component
  63133. */
  63134. get output(): NodeMaterialConnectionPoint;
  63135. protected _buildBlock(state: NodeMaterialBuildState): this;
  63136. }
  63137. }
  63138. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63142. /**
  63143. * Block used to smooth step a value
  63144. */
  63145. export class SmoothStepBlock extends NodeMaterialBlock {
  63146. /**
  63147. * Creates a new SmoothStepBlock
  63148. * @param name defines the block name
  63149. */
  63150. constructor(name: string);
  63151. /**
  63152. * Gets the current class name
  63153. * @returns the class name
  63154. */
  63155. getClassName(): string;
  63156. /**
  63157. * Gets the value operand input component
  63158. */
  63159. get value(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the first edge operand input component
  63162. */
  63163. get edge0(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the second edge operand input component
  63166. */
  63167. get edge1(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the output component
  63170. */
  63171. get output(): NodeMaterialConnectionPoint;
  63172. protected _buildBlock(state: NodeMaterialBuildState): this;
  63173. }
  63174. }
  63175. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63179. /**
  63180. * Block used to get the reciprocal (1 / x) of a value
  63181. */
  63182. export class ReciprocalBlock extends NodeMaterialBlock {
  63183. /**
  63184. * Creates a new ReciprocalBlock
  63185. * @param name defines the block name
  63186. */
  63187. constructor(name: string);
  63188. /**
  63189. * Gets the current class name
  63190. * @returns the class name
  63191. */
  63192. getClassName(): string;
  63193. /**
  63194. * Gets the input component
  63195. */
  63196. get input(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the output component
  63199. */
  63200. get output(): NodeMaterialConnectionPoint;
  63201. protected _buildBlock(state: NodeMaterialBuildState): this;
  63202. }
  63203. }
  63204. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63208. /**
  63209. * Block used to replace a color by another one
  63210. */
  63211. export class ReplaceColorBlock extends NodeMaterialBlock {
  63212. /**
  63213. * Creates a new ReplaceColorBlock
  63214. * @param name defines the block name
  63215. */
  63216. constructor(name: string);
  63217. /**
  63218. * Gets the current class name
  63219. * @returns the class name
  63220. */
  63221. getClassName(): string;
  63222. /**
  63223. * Gets the value input component
  63224. */
  63225. get value(): NodeMaterialConnectionPoint;
  63226. /**
  63227. * Gets the reference input component
  63228. */
  63229. get reference(): NodeMaterialConnectionPoint;
  63230. /**
  63231. * Gets the distance input component
  63232. */
  63233. get distance(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the replacement input component
  63236. */
  63237. get replacement(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the output component
  63240. */
  63241. get output(): NodeMaterialConnectionPoint;
  63242. protected _buildBlock(state: NodeMaterialBuildState): this;
  63243. }
  63244. }
  63245. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63249. /**
  63250. * Block used to posterize a value
  63251. * @see https://en.wikipedia.org/wiki/Posterization
  63252. */
  63253. export class PosterizeBlock extends NodeMaterialBlock {
  63254. /**
  63255. * Creates a new PosterizeBlock
  63256. * @param name defines the block name
  63257. */
  63258. constructor(name: string);
  63259. /**
  63260. * Gets the current class name
  63261. * @returns the class name
  63262. */
  63263. getClassName(): string;
  63264. /**
  63265. * Gets the value input component
  63266. */
  63267. get value(): NodeMaterialConnectionPoint;
  63268. /**
  63269. * Gets the steps input component
  63270. */
  63271. get steps(): NodeMaterialConnectionPoint;
  63272. /**
  63273. * Gets the output component
  63274. */
  63275. get output(): NodeMaterialConnectionPoint;
  63276. protected _buildBlock(state: NodeMaterialBuildState): this;
  63277. }
  63278. }
  63279. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63283. import { Scene } from "babylonjs/scene";
  63284. /**
  63285. * Operations supported by the Wave block
  63286. */
  63287. export enum WaveBlockKind {
  63288. /** SawTooth */
  63289. SawTooth = 0,
  63290. /** Square */
  63291. Square = 1,
  63292. /** Triangle */
  63293. Triangle = 2
  63294. }
  63295. /**
  63296. * Block used to apply wave operation to floats
  63297. */
  63298. export class WaveBlock extends NodeMaterialBlock {
  63299. /**
  63300. * Gets or sets the kibnd of wave to be applied by the block
  63301. */
  63302. kind: WaveBlockKind;
  63303. /**
  63304. * Creates a new WaveBlock
  63305. * @param name defines the block name
  63306. */
  63307. constructor(name: string);
  63308. /**
  63309. * Gets the current class name
  63310. * @returns the class name
  63311. */
  63312. getClassName(): string;
  63313. /**
  63314. * Gets the input component
  63315. */
  63316. get input(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the output component
  63319. */
  63320. get output(): NodeMaterialConnectionPoint;
  63321. protected _buildBlock(state: NodeMaterialBuildState): this;
  63322. serialize(): any;
  63323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63324. }
  63325. }
  63326. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63330. import { Color3 } from "babylonjs/Maths/math.color";
  63331. import { Scene } from "babylonjs/scene";
  63332. /**
  63333. * Class used to store a color step for the GradientBlock
  63334. */
  63335. export class GradientBlockColorStep {
  63336. /**
  63337. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63338. */
  63339. step: number;
  63340. /**
  63341. * Gets or sets the color associated with this step
  63342. */
  63343. color: Color3;
  63344. /**
  63345. * Creates a new GradientBlockColorStep
  63346. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63347. * @param color defines the color associated with this step
  63348. */
  63349. constructor(
  63350. /**
  63351. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63352. */
  63353. step: number,
  63354. /**
  63355. * Gets or sets the color associated with this step
  63356. */
  63357. color: Color3);
  63358. }
  63359. /**
  63360. * Block used to return a color from a gradient based on an input value between 0 and 1
  63361. */
  63362. export class GradientBlock extends NodeMaterialBlock {
  63363. /**
  63364. * Gets or sets the list of color steps
  63365. */
  63366. colorSteps: GradientBlockColorStep[];
  63367. /**
  63368. * Creates a new GradientBlock
  63369. * @param name defines the block name
  63370. */
  63371. constructor(name: string);
  63372. /**
  63373. * Gets the current class name
  63374. * @returns the class name
  63375. */
  63376. getClassName(): string;
  63377. /**
  63378. * Gets the gradient input component
  63379. */
  63380. get gradient(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the output component
  63383. */
  63384. get output(): NodeMaterialConnectionPoint;
  63385. private _writeColorConstant;
  63386. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63387. serialize(): any;
  63388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63389. protected _dumpPropertiesCode(): string;
  63390. }
  63391. }
  63392. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63396. /**
  63397. * Block used to normalize lerp between 2 values
  63398. */
  63399. export class NLerpBlock extends NodeMaterialBlock {
  63400. /**
  63401. * Creates a new NLerpBlock
  63402. * @param name defines the block name
  63403. */
  63404. constructor(name: string);
  63405. /**
  63406. * Gets the current class name
  63407. * @returns the class name
  63408. */
  63409. getClassName(): string;
  63410. /**
  63411. * Gets the left operand input component
  63412. */
  63413. get left(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the right operand input component
  63416. */
  63417. get right(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the gradient operand input component
  63420. */
  63421. get gradient(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the output component
  63424. */
  63425. get output(): NodeMaterialConnectionPoint;
  63426. protected _buildBlock(state: NodeMaterialBuildState): this;
  63427. }
  63428. }
  63429. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63433. import { Scene } from "babylonjs/scene";
  63434. /**
  63435. * block used to Generate a Worley Noise 3D Noise Pattern
  63436. */
  63437. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63438. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63439. manhattanDistance: boolean;
  63440. /**
  63441. * Creates a new WorleyNoise3DBlock
  63442. * @param name defines the block name
  63443. */
  63444. constructor(name: string);
  63445. /**
  63446. * Gets the current class name
  63447. * @returns the class name
  63448. */
  63449. getClassName(): string;
  63450. /**
  63451. * Gets the seed input component
  63452. */
  63453. get seed(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the jitter input component
  63456. */
  63457. get jitter(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the output component
  63460. */
  63461. get output(): NodeMaterialConnectionPoint;
  63462. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63463. /**
  63464. * Exposes the properties to the UI?
  63465. */
  63466. protected _dumpPropertiesCode(): string;
  63467. /**
  63468. * Exposes the properties to the Seralize?
  63469. */
  63470. serialize(): any;
  63471. /**
  63472. * Exposes the properties to the deseralize?
  63473. */
  63474. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63475. }
  63476. }
  63477. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63481. /**
  63482. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63483. */
  63484. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63485. /**
  63486. * Creates a new SimplexPerlin3DBlock
  63487. * @param name defines the block name
  63488. */
  63489. constructor(name: string);
  63490. /**
  63491. * Gets the current class name
  63492. * @returns the class name
  63493. */
  63494. getClassName(): string;
  63495. /**
  63496. * Gets the seed operand input component
  63497. */
  63498. get seed(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the output component
  63501. */
  63502. get output(): NodeMaterialConnectionPoint;
  63503. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63504. }
  63505. }
  63506. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63510. /**
  63511. * Block used to blend normals
  63512. */
  63513. export class NormalBlendBlock extends NodeMaterialBlock {
  63514. /**
  63515. * Creates a new NormalBlendBlock
  63516. * @param name defines the block name
  63517. */
  63518. constructor(name: string);
  63519. /**
  63520. * Gets the current class name
  63521. * @returns the class name
  63522. */
  63523. getClassName(): string;
  63524. /**
  63525. * Gets the first input component
  63526. */
  63527. get normalMap0(): NodeMaterialConnectionPoint;
  63528. /**
  63529. * Gets the second input component
  63530. */
  63531. get normalMap1(): NodeMaterialConnectionPoint;
  63532. /**
  63533. * Gets the output component
  63534. */
  63535. get output(): NodeMaterialConnectionPoint;
  63536. protected _buildBlock(state: NodeMaterialBuildState): this;
  63537. }
  63538. }
  63539. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63543. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63544. /**
  63545. * Block used to rotate a 2d vector by a given angle
  63546. */
  63547. export class Rotate2dBlock extends NodeMaterialBlock {
  63548. /**
  63549. * Creates a new Rotate2dBlock
  63550. * @param name defines the block name
  63551. */
  63552. constructor(name: string);
  63553. /**
  63554. * Gets the current class name
  63555. * @returns the class name
  63556. */
  63557. getClassName(): string;
  63558. /**
  63559. * Gets the input vector
  63560. */
  63561. get input(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the input angle
  63564. */
  63565. get angle(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the output component
  63568. */
  63569. get output(): NodeMaterialConnectionPoint;
  63570. autoConfigure(material: NodeMaterial): void;
  63571. protected _buildBlock(state: NodeMaterialBuildState): this;
  63572. }
  63573. }
  63574. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63578. /**
  63579. * Block used to get the reflected vector from a direction and a normal
  63580. */
  63581. export class ReflectBlock extends NodeMaterialBlock {
  63582. /**
  63583. * Creates a new ReflectBlock
  63584. * @param name defines the block name
  63585. */
  63586. constructor(name: string);
  63587. /**
  63588. * Gets the current class name
  63589. * @returns the class name
  63590. */
  63591. getClassName(): string;
  63592. /**
  63593. * Gets the incident component
  63594. */
  63595. get incident(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the normal component
  63598. */
  63599. get normal(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the output component
  63602. */
  63603. get output(): NodeMaterialConnectionPoint;
  63604. protected _buildBlock(state: NodeMaterialBuildState): this;
  63605. }
  63606. }
  63607. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63611. /**
  63612. * Block used to get the refracted vector from a direction and a normal
  63613. */
  63614. export class RefractBlock extends NodeMaterialBlock {
  63615. /**
  63616. * Creates a new RefractBlock
  63617. * @param name defines the block name
  63618. */
  63619. constructor(name: string);
  63620. /**
  63621. * Gets the current class name
  63622. * @returns the class name
  63623. */
  63624. getClassName(): string;
  63625. /**
  63626. * Gets the incident component
  63627. */
  63628. get incident(): NodeMaterialConnectionPoint;
  63629. /**
  63630. * Gets the normal component
  63631. */
  63632. get normal(): NodeMaterialConnectionPoint;
  63633. /**
  63634. * Gets the index of refraction component
  63635. */
  63636. get ior(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the output component
  63639. */
  63640. get output(): NodeMaterialConnectionPoint;
  63641. protected _buildBlock(state: NodeMaterialBuildState): this;
  63642. }
  63643. }
  63644. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63648. /**
  63649. * Block used to desaturate a color
  63650. */
  63651. export class DesaturateBlock extends NodeMaterialBlock {
  63652. /**
  63653. * Creates a new DesaturateBlock
  63654. * @param name defines the block name
  63655. */
  63656. constructor(name: string);
  63657. /**
  63658. * Gets the current class name
  63659. * @returns the class name
  63660. */
  63661. getClassName(): string;
  63662. /**
  63663. * Gets the color operand input component
  63664. */
  63665. get color(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the level operand input component
  63668. */
  63669. get level(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the output component
  63672. */
  63673. get output(): NodeMaterialConnectionPoint;
  63674. protected _buildBlock(state: NodeMaterialBuildState): this;
  63675. }
  63676. }
  63677. declare module "babylonjs/Materials/Node/Blocks/index" {
  63678. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63679. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63680. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63681. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63682. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63683. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63684. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63685. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63686. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63687. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63688. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63689. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63690. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63700. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63702. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63703. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63704. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63705. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63706. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63707. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63708. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63709. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63710. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63711. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63712. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63713. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63714. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63715. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63716. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63717. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63718. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63719. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63720. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63721. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63722. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63723. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63724. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63725. }
  63726. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63727. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63728. }
  63729. declare module "babylonjs/Materials/Node/index" {
  63730. export * from "babylonjs/Materials/Node/Enums/index";
  63731. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63732. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63733. export * from "babylonjs/Materials/Node/nodeMaterial";
  63734. export * from "babylonjs/Materials/Node/Blocks/index";
  63735. export * from "babylonjs/Materials/Node/Optimizers/index";
  63736. }
  63737. declare module "babylonjs/Materials/effectRenderer" {
  63738. import { Nullable } from "babylonjs/types";
  63739. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63741. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63742. import { Viewport } from "babylonjs/Maths/math.viewport";
  63743. import { Observable } from "babylonjs/Misc/observable";
  63744. import { Effect } from "babylonjs/Materials/effect";
  63745. import "babylonjs/Shaders/postprocess.vertex";
  63746. /**
  63747. * Effect Render Options
  63748. */
  63749. export interface IEffectRendererOptions {
  63750. /**
  63751. * Defines the vertices positions.
  63752. */
  63753. positions?: number[];
  63754. /**
  63755. * Defines the indices.
  63756. */
  63757. indices?: number[];
  63758. }
  63759. /**
  63760. * Helper class to render one or more effects.
  63761. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63762. */
  63763. export class EffectRenderer {
  63764. private engine;
  63765. private static _DefaultOptions;
  63766. private _vertexBuffers;
  63767. private _indexBuffer;
  63768. private _fullscreenViewport;
  63769. /**
  63770. * Creates an effect renderer
  63771. * @param engine the engine to use for rendering
  63772. * @param options defines the options of the effect renderer
  63773. */
  63774. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63775. /**
  63776. * Sets the current viewport in normalized coordinates 0-1
  63777. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63778. */
  63779. setViewport(viewport?: Viewport): void;
  63780. /**
  63781. * Binds the embedded attributes buffer to the effect.
  63782. * @param effect Defines the effect to bind the attributes for
  63783. */
  63784. bindBuffers(effect: Effect): void;
  63785. /**
  63786. * Sets the current effect wrapper to use during draw.
  63787. * The effect needs to be ready before calling this api.
  63788. * This also sets the default full screen position attribute.
  63789. * @param effectWrapper Defines the effect to draw with
  63790. */
  63791. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63792. /**
  63793. * Draws a full screen quad.
  63794. */
  63795. draw(): void;
  63796. private isRenderTargetTexture;
  63797. /**
  63798. * renders one or more effects to a specified texture
  63799. * @param effectWrapper the effect to renderer
  63800. * @param outputTexture texture to draw to, if null it will render to the screen.
  63801. */
  63802. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63803. /**
  63804. * Disposes of the effect renderer
  63805. */
  63806. dispose(): void;
  63807. }
  63808. /**
  63809. * Options to create an EffectWrapper
  63810. */
  63811. interface EffectWrapperCreationOptions {
  63812. /**
  63813. * Engine to use to create the effect
  63814. */
  63815. engine: ThinEngine;
  63816. /**
  63817. * Fragment shader for the effect
  63818. */
  63819. fragmentShader: string;
  63820. /**
  63821. * Vertex shader for the effect
  63822. */
  63823. vertexShader?: string;
  63824. /**
  63825. * Attributes to use in the shader
  63826. */
  63827. attributeNames?: Array<string>;
  63828. /**
  63829. * Uniforms to use in the shader
  63830. */
  63831. uniformNames?: Array<string>;
  63832. /**
  63833. * Texture sampler names to use in the shader
  63834. */
  63835. samplerNames?: Array<string>;
  63836. /**
  63837. * The friendly name of the effect displayed in Spector.
  63838. */
  63839. name?: string;
  63840. }
  63841. /**
  63842. * Wraps an effect to be used for rendering
  63843. */
  63844. export class EffectWrapper {
  63845. /**
  63846. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63847. */
  63848. onApplyObservable: Observable<{}>;
  63849. /**
  63850. * The underlying effect
  63851. */
  63852. effect: Effect;
  63853. /**
  63854. * Creates an effect to be renderer
  63855. * @param creationOptions options to create the effect
  63856. */
  63857. constructor(creationOptions: EffectWrapperCreationOptions);
  63858. /**
  63859. * Disposes of the effect wrapper
  63860. */
  63861. dispose(): void;
  63862. }
  63863. }
  63864. declare module "babylonjs/Materials/index" {
  63865. export * from "babylonjs/Materials/Background/index";
  63866. export * from "babylonjs/Materials/colorCurves";
  63867. export * from "babylonjs/Materials/iEffectFallbacks";
  63868. export * from "babylonjs/Materials/effectFallbacks";
  63869. export * from "babylonjs/Materials/effect";
  63870. export * from "babylonjs/Materials/fresnelParameters";
  63871. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63872. export * from "babylonjs/Materials/material";
  63873. export * from "babylonjs/Materials/materialDefines";
  63874. export * from "babylonjs/Materials/materialHelper";
  63875. export * from "babylonjs/Materials/multiMaterial";
  63876. export * from "babylonjs/Materials/PBR/index";
  63877. export * from "babylonjs/Materials/pushMaterial";
  63878. export * from "babylonjs/Materials/shaderMaterial";
  63879. export * from "babylonjs/Materials/standardMaterial";
  63880. export * from "babylonjs/Materials/Textures/index";
  63881. export * from "babylonjs/Materials/uniformBuffer";
  63882. export * from "babylonjs/Materials/materialFlags";
  63883. export * from "babylonjs/Materials/Node/index";
  63884. export * from "babylonjs/Materials/effectRenderer";
  63885. }
  63886. declare module "babylonjs/Maths/index" {
  63887. export * from "babylonjs/Maths/math.scalar";
  63888. export * from "babylonjs/Maths/math";
  63889. export * from "babylonjs/Maths/sphericalPolynomial";
  63890. }
  63891. declare module "babylonjs/Misc/workerPool" {
  63892. import { IDisposable } from "babylonjs/scene";
  63893. /**
  63894. * Helper class to push actions to a pool of workers.
  63895. */
  63896. export class WorkerPool implements IDisposable {
  63897. private _workerInfos;
  63898. private _pendingActions;
  63899. /**
  63900. * Constructor
  63901. * @param workers Array of workers to use for actions
  63902. */
  63903. constructor(workers: Array<Worker>);
  63904. /**
  63905. * Terminates all workers and clears any pending actions.
  63906. */
  63907. dispose(): void;
  63908. /**
  63909. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63910. * pended until a worker has completed its action.
  63911. * @param action The action to perform. Call onComplete when the action is complete.
  63912. */
  63913. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63914. private _execute;
  63915. }
  63916. }
  63917. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63918. import { IDisposable } from "babylonjs/scene";
  63919. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63920. /**
  63921. * Configuration for Draco compression
  63922. */
  63923. export interface IDracoCompressionConfiguration {
  63924. /**
  63925. * Configuration for the decoder.
  63926. */
  63927. decoder: {
  63928. /**
  63929. * The url to the WebAssembly module.
  63930. */
  63931. wasmUrl?: string;
  63932. /**
  63933. * The url to the WebAssembly binary.
  63934. */
  63935. wasmBinaryUrl?: string;
  63936. /**
  63937. * The url to the fallback JavaScript module.
  63938. */
  63939. fallbackUrl?: string;
  63940. };
  63941. }
  63942. /**
  63943. * Draco compression (https://google.github.io/draco/)
  63944. *
  63945. * This class wraps the Draco module.
  63946. *
  63947. * **Encoder**
  63948. *
  63949. * The encoder is not currently implemented.
  63950. *
  63951. * **Decoder**
  63952. *
  63953. * 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.
  63954. *
  63955. * To update the configuration, use the following code:
  63956. * ```javascript
  63957. * DracoCompression.Configuration = {
  63958. * decoder: {
  63959. * wasmUrl: "<url to the WebAssembly library>",
  63960. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63961. * fallbackUrl: "<url to the fallback JavaScript library>",
  63962. * }
  63963. * };
  63964. * ```
  63965. *
  63966. * 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.
  63967. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63968. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63969. *
  63970. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63971. * ```javascript
  63972. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63973. * ```
  63974. *
  63975. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63976. */
  63977. export class DracoCompression implements IDisposable {
  63978. private _workerPoolPromise?;
  63979. private _decoderModulePromise?;
  63980. /**
  63981. * The configuration. Defaults to the following urls:
  63982. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63983. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63984. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63985. */
  63986. static Configuration: IDracoCompressionConfiguration;
  63987. /**
  63988. * Returns true if the decoder configuration is available.
  63989. */
  63990. static get DecoderAvailable(): boolean;
  63991. /**
  63992. * Default number of workers to create when creating the draco compression object.
  63993. */
  63994. static DefaultNumWorkers: number;
  63995. private static GetDefaultNumWorkers;
  63996. private static _Default;
  63997. /**
  63998. * Default instance for the draco compression object.
  63999. */
  64000. static get Default(): DracoCompression;
  64001. /**
  64002. * Constructor
  64003. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64004. */
  64005. constructor(numWorkers?: number);
  64006. /**
  64007. * Stop all async operations and release resources.
  64008. */
  64009. dispose(): void;
  64010. /**
  64011. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64012. * @returns a promise that resolves when ready
  64013. */
  64014. whenReadyAsync(): Promise<void>;
  64015. /**
  64016. * Decode Draco compressed mesh data to vertex data.
  64017. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64018. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64019. * @returns A promise that resolves with the decoded vertex data
  64020. */
  64021. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64022. [kind: string]: number;
  64023. }): Promise<VertexData>;
  64024. }
  64025. }
  64026. declare module "babylonjs/Meshes/Compression/index" {
  64027. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64028. }
  64029. declare module "babylonjs/Meshes/csg" {
  64030. import { Nullable } from "babylonjs/types";
  64031. import { Scene } from "babylonjs/scene";
  64032. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64033. import { Mesh } from "babylonjs/Meshes/mesh";
  64034. import { Material } from "babylonjs/Materials/material";
  64035. /**
  64036. * Class for building Constructive Solid Geometry
  64037. */
  64038. export class CSG {
  64039. private polygons;
  64040. /**
  64041. * The world matrix
  64042. */
  64043. matrix: Matrix;
  64044. /**
  64045. * Stores the position
  64046. */
  64047. position: Vector3;
  64048. /**
  64049. * Stores the rotation
  64050. */
  64051. rotation: Vector3;
  64052. /**
  64053. * Stores the rotation quaternion
  64054. */
  64055. rotationQuaternion: Nullable<Quaternion>;
  64056. /**
  64057. * Stores the scaling vector
  64058. */
  64059. scaling: Vector3;
  64060. /**
  64061. * Convert the Mesh to CSG
  64062. * @param mesh The Mesh to convert to CSG
  64063. * @returns A new CSG from the Mesh
  64064. */
  64065. static FromMesh(mesh: Mesh): CSG;
  64066. /**
  64067. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64068. * @param polygons Polygons used to construct a CSG solid
  64069. */
  64070. private static FromPolygons;
  64071. /**
  64072. * Clones, or makes a deep copy, of the CSG
  64073. * @returns A new CSG
  64074. */
  64075. clone(): CSG;
  64076. /**
  64077. * Unions this CSG with another CSG
  64078. * @param csg The CSG to union against this CSG
  64079. * @returns The unioned CSG
  64080. */
  64081. union(csg: CSG): CSG;
  64082. /**
  64083. * Unions this CSG with another CSG in place
  64084. * @param csg The CSG to union against this CSG
  64085. */
  64086. unionInPlace(csg: CSG): void;
  64087. /**
  64088. * Subtracts this CSG with another CSG
  64089. * @param csg The CSG to subtract against this CSG
  64090. * @returns A new CSG
  64091. */
  64092. subtract(csg: CSG): CSG;
  64093. /**
  64094. * Subtracts this CSG with another CSG in place
  64095. * @param csg The CSG to subtact against this CSG
  64096. */
  64097. subtractInPlace(csg: CSG): void;
  64098. /**
  64099. * Intersect this CSG with another CSG
  64100. * @param csg The CSG to intersect against this CSG
  64101. * @returns A new CSG
  64102. */
  64103. intersect(csg: CSG): CSG;
  64104. /**
  64105. * Intersects this CSG with another CSG in place
  64106. * @param csg The CSG to intersect against this CSG
  64107. */
  64108. intersectInPlace(csg: CSG): void;
  64109. /**
  64110. * Return a new CSG solid with solid and empty space switched. This solid is
  64111. * not modified.
  64112. * @returns A new CSG solid with solid and empty space switched
  64113. */
  64114. inverse(): CSG;
  64115. /**
  64116. * Inverses the CSG in place
  64117. */
  64118. inverseInPlace(): void;
  64119. /**
  64120. * This is used to keep meshes transformations so they can be restored
  64121. * when we build back a Babylon Mesh
  64122. * NB : All CSG operations are performed in world coordinates
  64123. * @param csg The CSG to copy the transform attributes from
  64124. * @returns This CSG
  64125. */
  64126. copyTransformAttributes(csg: CSG): CSG;
  64127. /**
  64128. * Build Raw mesh from CSG
  64129. * Coordinates here are in world space
  64130. * @param name The name of the mesh geometry
  64131. * @param scene The Scene
  64132. * @param keepSubMeshes Specifies if the submeshes should be kept
  64133. * @returns A new Mesh
  64134. */
  64135. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64136. /**
  64137. * Build Mesh from CSG taking material and transforms into account
  64138. * @param name The name of the Mesh
  64139. * @param material The material of the Mesh
  64140. * @param scene The Scene
  64141. * @param keepSubMeshes Specifies if submeshes should be kept
  64142. * @returns The new Mesh
  64143. */
  64144. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64145. }
  64146. }
  64147. declare module "babylonjs/Meshes/trailMesh" {
  64148. import { Mesh } from "babylonjs/Meshes/mesh";
  64149. import { Scene } from "babylonjs/scene";
  64150. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64151. /**
  64152. * Class used to create a trail following a mesh
  64153. */
  64154. export class TrailMesh extends Mesh {
  64155. private _generator;
  64156. private _autoStart;
  64157. private _running;
  64158. private _diameter;
  64159. private _length;
  64160. private _sectionPolygonPointsCount;
  64161. private _sectionVectors;
  64162. private _sectionNormalVectors;
  64163. private _beforeRenderObserver;
  64164. /**
  64165. * @constructor
  64166. * @param name The value used by scene.getMeshByName() to do a lookup.
  64167. * @param generator The mesh or transform node to generate a trail.
  64168. * @param scene The scene to add this mesh to.
  64169. * @param diameter Diameter of trailing mesh. Default is 1.
  64170. * @param length Length of trailing mesh. Default is 60.
  64171. * @param autoStart Automatically start trailing mesh. Default true.
  64172. */
  64173. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64174. /**
  64175. * "TrailMesh"
  64176. * @returns "TrailMesh"
  64177. */
  64178. getClassName(): string;
  64179. private _createMesh;
  64180. /**
  64181. * Start trailing mesh.
  64182. */
  64183. start(): void;
  64184. /**
  64185. * Stop trailing mesh.
  64186. */
  64187. stop(): void;
  64188. /**
  64189. * Update trailing mesh geometry.
  64190. */
  64191. update(): void;
  64192. /**
  64193. * Returns a new TrailMesh object.
  64194. * @param name is a string, the name given to the new mesh
  64195. * @param newGenerator use new generator object for cloned trail mesh
  64196. * @returns a new mesh
  64197. */
  64198. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64199. /**
  64200. * Serializes this trail mesh
  64201. * @param serializationObject object to write serialization to
  64202. */
  64203. serialize(serializationObject: any): void;
  64204. /**
  64205. * Parses a serialized trail mesh
  64206. * @param parsedMesh the serialized mesh
  64207. * @param scene the scene to create the trail mesh in
  64208. * @returns the created trail mesh
  64209. */
  64210. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64211. }
  64212. }
  64213. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64214. import { Nullable } from "babylonjs/types";
  64215. import { Scene } from "babylonjs/scene";
  64216. import { Vector4 } from "babylonjs/Maths/math.vector";
  64217. import { Color4 } from "babylonjs/Maths/math.color";
  64218. import { Mesh } from "babylonjs/Meshes/mesh";
  64219. /**
  64220. * Class containing static functions to help procedurally build meshes
  64221. */
  64222. export class TiledBoxBuilder {
  64223. /**
  64224. * Creates a box mesh
  64225. * 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)
  64226. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64230. * @param name defines the name of the mesh
  64231. * @param options defines the options used to create the mesh
  64232. * @param scene defines the hosting scene
  64233. * @returns the box mesh
  64234. */
  64235. static CreateTiledBox(name: string, options: {
  64236. pattern?: number;
  64237. width?: number;
  64238. height?: number;
  64239. depth?: number;
  64240. tileSize?: number;
  64241. tileWidth?: number;
  64242. tileHeight?: number;
  64243. alignHorizontal?: number;
  64244. alignVertical?: number;
  64245. faceUV?: Vector4[];
  64246. faceColors?: Color4[];
  64247. sideOrientation?: number;
  64248. updatable?: boolean;
  64249. }, scene?: Nullable<Scene>): Mesh;
  64250. }
  64251. }
  64252. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64253. import { Vector4 } from "babylonjs/Maths/math.vector";
  64254. import { Mesh } from "babylonjs/Meshes/mesh";
  64255. /**
  64256. * Class containing static functions to help procedurally build meshes
  64257. */
  64258. export class TorusKnotBuilder {
  64259. /**
  64260. * Creates a torus knot mesh
  64261. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64262. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64263. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64264. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64268. * @param name defines the name of the mesh
  64269. * @param options defines the options used to create the mesh
  64270. * @param scene defines the hosting scene
  64271. * @returns the torus knot mesh
  64272. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64273. */
  64274. static CreateTorusKnot(name: string, options: {
  64275. radius?: number;
  64276. tube?: number;
  64277. radialSegments?: number;
  64278. tubularSegments?: number;
  64279. p?: number;
  64280. q?: number;
  64281. updatable?: boolean;
  64282. sideOrientation?: number;
  64283. frontUVs?: Vector4;
  64284. backUVs?: Vector4;
  64285. }, scene: any): Mesh;
  64286. }
  64287. }
  64288. declare module "babylonjs/Meshes/polygonMesh" {
  64289. import { Scene } from "babylonjs/scene";
  64290. import { Vector2 } from "babylonjs/Maths/math.vector";
  64291. import { Mesh } from "babylonjs/Meshes/mesh";
  64292. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64293. import { Path2 } from "babylonjs/Maths/math.path";
  64294. /**
  64295. * Polygon
  64296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64297. */
  64298. export class Polygon {
  64299. /**
  64300. * Creates a rectangle
  64301. * @param xmin bottom X coord
  64302. * @param ymin bottom Y coord
  64303. * @param xmax top X coord
  64304. * @param ymax top Y coord
  64305. * @returns points that make the resulting rectation
  64306. */
  64307. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64308. /**
  64309. * Creates a circle
  64310. * @param radius radius of circle
  64311. * @param cx scale in x
  64312. * @param cy scale in y
  64313. * @param numberOfSides number of sides that make up the circle
  64314. * @returns points that make the resulting circle
  64315. */
  64316. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64317. /**
  64318. * Creates a polygon from input string
  64319. * @param input Input polygon data
  64320. * @returns the parsed points
  64321. */
  64322. static Parse(input: string): Vector2[];
  64323. /**
  64324. * Starts building a polygon from x and y coordinates
  64325. * @param x x coordinate
  64326. * @param y y coordinate
  64327. * @returns the started path2
  64328. */
  64329. static StartingAt(x: number, y: number): Path2;
  64330. }
  64331. /**
  64332. * Builds a polygon
  64333. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64334. */
  64335. export class PolygonMeshBuilder {
  64336. private _points;
  64337. private _outlinepoints;
  64338. private _holes;
  64339. private _name;
  64340. private _scene;
  64341. private _epoints;
  64342. private _eholes;
  64343. private _addToepoint;
  64344. /**
  64345. * Babylon reference to the earcut plugin.
  64346. */
  64347. bjsEarcut: any;
  64348. /**
  64349. * Creates a PolygonMeshBuilder
  64350. * @param name name of the builder
  64351. * @param contours Path of the polygon
  64352. * @param scene scene to add to when creating the mesh
  64353. * @param earcutInjection can be used to inject your own earcut reference
  64354. */
  64355. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64356. /**
  64357. * Adds a whole within the polygon
  64358. * @param hole Array of points defining the hole
  64359. * @returns this
  64360. */
  64361. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64362. /**
  64363. * Creates the polygon
  64364. * @param updatable If the mesh should be updatable
  64365. * @param depth The depth of the mesh created
  64366. * @returns the created mesh
  64367. */
  64368. build(updatable?: boolean, depth?: number): Mesh;
  64369. /**
  64370. * Creates the polygon
  64371. * @param depth The depth of the mesh created
  64372. * @returns the created VertexData
  64373. */
  64374. buildVertexData(depth?: number): VertexData;
  64375. /**
  64376. * Adds a side to the polygon
  64377. * @param positions points that make the polygon
  64378. * @param normals normals of the polygon
  64379. * @param uvs uvs of the polygon
  64380. * @param indices indices of the polygon
  64381. * @param bounds bounds of the polygon
  64382. * @param points points of the polygon
  64383. * @param depth depth of the polygon
  64384. * @param flip flip of the polygon
  64385. */
  64386. private addSide;
  64387. }
  64388. }
  64389. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64390. import { Scene } from "babylonjs/scene";
  64391. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64392. import { Color4 } from "babylonjs/Maths/math.color";
  64393. import { Mesh } from "babylonjs/Meshes/mesh";
  64394. import { Nullable } from "babylonjs/types";
  64395. /**
  64396. * Class containing static functions to help procedurally build meshes
  64397. */
  64398. export class PolygonBuilder {
  64399. /**
  64400. * Creates a polygon mesh
  64401. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64402. * * 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
  64403. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64406. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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. * Creates an extruded polygon mesh, with depth in the Y direction.
  64426. * * 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)
  64427. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64428. * @param name defines the name of the mesh
  64429. * @param options defines the options used to create the mesh
  64430. * @param scene defines the hosting scene
  64431. * @param earcutInjection can be used to inject your own earcut reference
  64432. * @returns the polygon mesh
  64433. */
  64434. static ExtrudePolygon(name: string, options: {
  64435. shape: Vector3[];
  64436. holes?: Vector3[][];
  64437. depth?: number;
  64438. faceUV?: Vector4[];
  64439. faceColors?: Color4[];
  64440. updatable?: boolean;
  64441. sideOrientation?: number;
  64442. frontUVs?: Vector4;
  64443. backUVs?: Vector4;
  64444. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64445. }
  64446. }
  64447. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64448. import { Scene } from "babylonjs/scene";
  64449. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64450. import { Mesh } from "babylonjs/Meshes/mesh";
  64451. import { Nullable } from "babylonjs/types";
  64452. /**
  64453. * Class containing static functions to help procedurally build meshes
  64454. */
  64455. export class LatheBuilder {
  64456. /**
  64457. * Creates lathe mesh.
  64458. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64459. * * 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
  64460. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64461. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64462. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64463. * * 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
  64464. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64465. * * 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
  64466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64470. * @param name defines the name of the mesh
  64471. * @param options defines the options used to create the mesh
  64472. * @param scene defines the hosting scene
  64473. * @returns the lathe mesh
  64474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64475. */
  64476. static CreateLathe(name: string, options: {
  64477. shape: Vector3[];
  64478. radius?: number;
  64479. tessellation?: number;
  64480. clip?: number;
  64481. arc?: number;
  64482. closed?: boolean;
  64483. updatable?: boolean;
  64484. sideOrientation?: number;
  64485. frontUVs?: Vector4;
  64486. backUVs?: Vector4;
  64487. cap?: number;
  64488. invertUV?: boolean;
  64489. }, scene?: Nullable<Scene>): Mesh;
  64490. }
  64491. }
  64492. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64493. import { Nullable } from "babylonjs/types";
  64494. import { Scene } from "babylonjs/scene";
  64495. import { Vector4 } from "babylonjs/Maths/math.vector";
  64496. import { Mesh } from "babylonjs/Meshes/mesh";
  64497. /**
  64498. * Class containing static functions to help procedurally build meshes
  64499. */
  64500. export class TiledPlaneBuilder {
  64501. /**
  64502. * Creates a tiled plane mesh
  64503. * * The parameter `pattern` will, depending on value, do nothing or
  64504. * * * flip (reflect about central vertical) alternate tiles across and up
  64505. * * * flip every tile on alternate rows
  64506. * * * rotate (180 degs) alternate tiles across and up
  64507. * * * rotate every tile on alternate rows
  64508. * * * flip and rotate alternate tiles across and up
  64509. * * * flip and rotate every tile on alternate rows
  64510. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64511. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64514. * * 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)
  64515. * * 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)
  64516. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64517. * @param name defines the name of the mesh
  64518. * @param options defines the options used to create the mesh
  64519. * @param scene defines the hosting scene
  64520. * @returns the box mesh
  64521. */
  64522. static CreateTiledPlane(name: string, options: {
  64523. pattern?: number;
  64524. tileSize?: number;
  64525. tileWidth?: number;
  64526. tileHeight?: number;
  64527. size?: number;
  64528. width?: number;
  64529. height?: number;
  64530. alignHorizontal?: number;
  64531. alignVertical?: number;
  64532. sideOrientation?: number;
  64533. frontUVs?: Vector4;
  64534. backUVs?: Vector4;
  64535. updatable?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. }
  64538. }
  64539. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64540. import { Nullable } from "babylonjs/types";
  64541. import { Scene } from "babylonjs/scene";
  64542. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64543. import { Mesh } from "babylonjs/Meshes/mesh";
  64544. /**
  64545. * Class containing static functions to help procedurally build meshes
  64546. */
  64547. export class TubeBuilder {
  64548. /**
  64549. * Creates a tube mesh.
  64550. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64551. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64552. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64553. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64554. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64555. * * 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)
  64556. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64557. * * 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
  64558. * * 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
  64559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64563. * @param name defines the name of the mesh
  64564. * @param options defines the options used to create the mesh
  64565. * @param scene defines the hosting scene
  64566. * @returns the tube mesh
  64567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64568. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64569. */
  64570. static CreateTube(name: string, options: {
  64571. path: Vector3[];
  64572. radius?: number;
  64573. tessellation?: number;
  64574. radiusFunction?: {
  64575. (i: number, distance: number): number;
  64576. };
  64577. cap?: number;
  64578. arc?: number;
  64579. updatable?: boolean;
  64580. sideOrientation?: number;
  64581. frontUVs?: Vector4;
  64582. backUVs?: Vector4;
  64583. instance?: Mesh;
  64584. invertUV?: boolean;
  64585. }, scene?: Nullable<Scene>): Mesh;
  64586. }
  64587. }
  64588. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64589. import { Scene } from "babylonjs/scene";
  64590. import { Vector4 } from "babylonjs/Maths/math.vector";
  64591. import { Mesh } from "babylonjs/Meshes/mesh";
  64592. import { Nullable } from "babylonjs/types";
  64593. /**
  64594. * Class containing static functions to help procedurally build meshes
  64595. */
  64596. export class IcoSphereBuilder {
  64597. /**
  64598. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64599. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64600. * * 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`)
  64601. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64602. * * 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
  64603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64606. * @param name defines the name of the mesh
  64607. * @param options defines the options used to create the mesh
  64608. * @param scene defines the hosting scene
  64609. * @returns the icosahedron mesh
  64610. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64611. */
  64612. static CreateIcoSphere(name: string, options: {
  64613. radius?: number;
  64614. radiusX?: number;
  64615. radiusY?: number;
  64616. radiusZ?: number;
  64617. flat?: boolean;
  64618. subdivisions?: number;
  64619. sideOrientation?: number;
  64620. frontUVs?: Vector4;
  64621. backUVs?: Vector4;
  64622. updatable?: boolean;
  64623. }, scene?: Nullable<Scene>): Mesh;
  64624. }
  64625. }
  64626. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64627. import { Vector3 } from "babylonjs/Maths/math.vector";
  64628. import { Mesh } from "babylonjs/Meshes/mesh";
  64629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64630. /**
  64631. * Class containing static functions to help procedurally build meshes
  64632. */
  64633. export class DecalBuilder {
  64634. /**
  64635. * Creates a decal mesh.
  64636. * 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
  64637. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64638. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64639. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64640. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64641. * @param name defines the name of the mesh
  64642. * @param sourceMesh defines the mesh where the decal must be applied
  64643. * @param options defines the options used to create the mesh
  64644. * @param scene defines the hosting scene
  64645. * @returns the decal mesh
  64646. * @see https://doc.babylonjs.com/how_to/decals
  64647. */
  64648. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64649. position?: Vector3;
  64650. normal?: Vector3;
  64651. size?: Vector3;
  64652. angle?: number;
  64653. }): Mesh;
  64654. }
  64655. }
  64656. declare module "babylonjs/Meshes/meshBuilder" {
  64657. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64658. import { Nullable } from "babylonjs/types";
  64659. import { Scene } from "babylonjs/scene";
  64660. import { Mesh } from "babylonjs/Meshes/mesh";
  64661. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64662. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64664. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64665. import { Plane } from "babylonjs/Maths/math.plane";
  64666. /**
  64667. * Class containing static functions to help procedurally build meshes
  64668. */
  64669. export class MeshBuilder {
  64670. /**
  64671. * Creates a box mesh
  64672. * * The parameter `size` sets the size (float) of each box side (default 1)
  64673. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64674. * * 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)
  64675. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64679. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64680. * @param name defines the name of the mesh
  64681. * @param options defines the options used to create the mesh
  64682. * @param scene defines the hosting scene
  64683. * @returns the box mesh
  64684. */
  64685. static CreateBox(name: string, options: {
  64686. size?: number;
  64687. width?: number;
  64688. height?: number;
  64689. depth?: number;
  64690. faceUV?: Vector4[];
  64691. faceColors?: Color4[];
  64692. sideOrientation?: number;
  64693. frontUVs?: Vector4;
  64694. backUVs?: Vector4;
  64695. wrap?: boolean;
  64696. topBaseAt?: number;
  64697. bottomBaseAt?: number;
  64698. updatable?: boolean;
  64699. }, scene?: Nullable<Scene>): Mesh;
  64700. /**
  64701. * Creates a tiled box mesh
  64702. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64704. * @param name defines the name of the mesh
  64705. * @param options defines the options used to create the mesh
  64706. * @param scene defines the hosting scene
  64707. * @returns the tiled box mesh
  64708. */
  64709. static CreateTiledBox(name: string, options: {
  64710. pattern?: number;
  64711. size?: number;
  64712. width?: number;
  64713. height?: number;
  64714. depth: number;
  64715. tileSize?: number;
  64716. tileWidth?: number;
  64717. tileHeight?: number;
  64718. faceUV?: Vector4[];
  64719. faceColors?: Color4[];
  64720. alignHorizontal?: number;
  64721. alignVertical?: number;
  64722. sideOrientation?: number;
  64723. updatable?: boolean;
  64724. }, scene?: Nullable<Scene>): Mesh;
  64725. /**
  64726. * Creates a sphere mesh
  64727. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64728. * * 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`)
  64729. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64730. * * 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
  64731. * * 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)
  64732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64735. * @param name defines the name of the mesh
  64736. * @param options defines the options used to create the mesh
  64737. * @param scene defines the hosting scene
  64738. * @returns the sphere mesh
  64739. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64740. */
  64741. static CreateSphere(name: string, options: {
  64742. segments?: number;
  64743. diameter?: number;
  64744. diameterX?: number;
  64745. diameterY?: number;
  64746. diameterZ?: number;
  64747. arc?: number;
  64748. slice?: number;
  64749. sideOrientation?: number;
  64750. frontUVs?: Vector4;
  64751. backUVs?: Vector4;
  64752. updatable?: boolean;
  64753. }, scene?: Nullable<Scene>): Mesh;
  64754. /**
  64755. * Creates a plane polygonal mesh. By default, this is a disc
  64756. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64757. * * 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
  64758. * * 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
  64759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the plane polygonal mesh
  64766. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64767. */
  64768. static CreateDisc(name: string, options: {
  64769. radius?: number;
  64770. tessellation?: number;
  64771. arc?: number;
  64772. updatable?: boolean;
  64773. sideOrientation?: number;
  64774. frontUVs?: Vector4;
  64775. backUVs?: Vector4;
  64776. }, scene?: Nullable<Scene>): Mesh;
  64777. /**
  64778. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64779. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64780. * * 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`)
  64781. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64782. * * 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
  64783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64786. * @param name defines the name of the mesh
  64787. * @param options defines the options used to create the mesh
  64788. * @param scene defines the hosting scene
  64789. * @returns the icosahedron mesh
  64790. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64791. */
  64792. static CreateIcoSphere(name: string, options: {
  64793. radius?: number;
  64794. radiusX?: number;
  64795. radiusY?: number;
  64796. radiusZ?: number;
  64797. flat?: boolean;
  64798. subdivisions?: number;
  64799. sideOrientation?: number;
  64800. frontUVs?: Vector4;
  64801. backUVs?: Vector4;
  64802. updatable?: boolean;
  64803. }, scene?: Nullable<Scene>): Mesh;
  64804. /**
  64805. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64806. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64807. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64808. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64809. * * 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
  64810. * * 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
  64811. * * 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
  64812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64815. * * 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
  64816. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64817. * * 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
  64818. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64820. * @param name defines the name of the mesh
  64821. * @param options defines the options used to create the mesh
  64822. * @param scene defines the hosting scene
  64823. * @returns the ribbon mesh
  64824. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64826. */
  64827. static CreateRibbon(name: string, options: {
  64828. pathArray: Vector3[][];
  64829. closeArray?: boolean;
  64830. closePath?: boolean;
  64831. offset?: number;
  64832. updatable?: boolean;
  64833. sideOrientation?: number;
  64834. frontUVs?: Vector4;
  64835. backUVs?: Vector4;
  64836. instance?: Mesh;
  64837. invertUV?: boolean;
  64838. uvs?: Vector2[];
  64839. colors?: Color4[];
  64840. }, scene?: Nullable<Scene>): Mesh;
  64841. /**
  64842. * Creates a cylinder or a cone mesh
  64843. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64844. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64845. * * 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.
  64846. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64847. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64848. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64849. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64850. * * 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).
  64851. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64852. * * 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).
  64853. * * 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
  64854. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64855. * * 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
  64856. * * 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.
  64857. * * If `enclose` is false, a ring surface is one element.
  64858. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64859. * * 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
  64860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64863. * @param name defines the name of the mesh
  64864. * @param options defines the options used to create the mesh
  64865. * @param scene defines the hosting scene
  64866. * @returns the cylinder mesh
  64867. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64868. */
  64869. static CreateCylinder(name: string, options: {
  64870. height?: number;
  64871. diameterTop?: number;
  64872. diameterBottom?: number;
  64873. diameter?: number;
  64874. tessellation?: number;
  64875. subdivisions?: number;
  64876. arc?: number;
  64877. faceColors?: Color4[];
  64878. faceUV?: Vector4[];
  64879. updatable?: boolean;
  64880. hasRings?: boolean;
  64881. enclose?: boolean;
  64882. cap?: number;
  64883. sideOrientation?: number;
  64884. frontUVs?: Vector4;
  64885. backUVs?: Vector4;
  64886. }, scene?: Nullable<Scene>): Mesh;
  64887. /**
  64888. * Creates a torus mesh
  64889. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64890. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64891. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64895. * @param name defines the name of the mesh
  64896. * @param options defines the options used to create the mesh
  64897. * @param scene defines the hosting scene
  64898. * @returns the torus mesh
  64899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64900. */
  64901. static CreateTorus(name: string, options: {
  64902. diameter?: number;
  64903. thickness?: number;
  64904. tessellation?: number;
  64905. updatable?: boolean;
  64906. sideOrientation?: number;
  64907. frontUVs?: Vector4;
  64908. backUVs?: Vector4;
  64909. }, scene?: Nullable<Scene>): Mesh;
  64910. /**
  64911. * Creates a torus knot mesh
  64912. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64913. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64914. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64915. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64919. * @param name defines the name of the mesh
  64920. * @param options defines the options used to create the mesh
  64921. * @param scene defines the hosting scene
  64922. * @returns the torus knot mesh
  64923. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64924. */
  64925. static CreateTorusKnot(name: string, options: {
  64926. radius?: number;
  64927. tube?: number;
  64928. radialSegments?: number;
  64929. tubularSegments?: number;
  64930. p?: number;
  64931. q?: number;
  64932. updatable?: boolean;
  64933. sideOrientation?: number;
  64934. frontUVs?: Vector4;
  64935. backUVs?: Vector4;
  64936. }, scene?: Nullable<Scene>): Mesh;
  64937. /**
  64938. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64939. * * 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
  64940. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64941. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64942. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64943. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64944. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64945. * * 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
  64946. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64949. * @param name defines the name of the new line system
  64950. * @param options defines the options used to create the line system
  64951. * @param scene defines the hosting scene
  64952. * @returns a new line system mesh
  64953. */
  64954. static CreateLineSystem(name: string, options: {
  64955. lines: Vector3[][];
  64956. updatable?: boolean;
  64957. instance?: Nullable<LinesMesh>;
  64958. colors?: Nullable<Color4[][]>;
  64959. useVertexAlpha?: boolean;
  64960. }, scene: Nullable<Scene>): LinesMesh;
  64961. /**
  64962. * Creates a line mesh
  64963. * 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
  64964. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64965. * * The parameter `points` is an array successive Vector3
  64966. * * 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
  64967. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64968. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64969. * * When updating an instance, remember that only point positions can change, not the number of points
  64970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64972. * @param name defines the name of the new line system
  64973. * @param options defines the options used to create the line system
  64974. * @param scene defines the hosting scene
  64975. * @returns a new line mesh
  64976. */
  64977. static CreateLines(name: string, options: {
  64978. points: Vector3[];
  64979. updatable?: boolean;
  64980. instance?: Nullable<LinesMesh>;
  64981. colors?: Color4[];
  64982. useVertexAlpha?: boolean;
  64983. }, scene?: Nullable<Scene>): LinesMesh;
  64984. /**
  64985. * Creates a dashed line mesh
  64986. * * 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
  64987. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64988. * * The parameter `points` is an array successive Vector3
  64989. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64990. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64991. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64992. * * 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
  64993. * * When updating an instance, remember that only point positions can change, not the number of points
  64994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64995. * @param name defines the name of the mesh
  64996. * @param options defines the options used to create the mesh
  64997. * @param scene defines the hosting scene
  64998. * @returns the dashed line mesh
  64999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65000. */
  65001. static CreateDashedLines(name: string, options: {
  65002. points: Vector3[];
  65003. dashSize?: number;
  65004. gapSize?: number;
  65005. dashNb?: number;
  65006. updatable?: boolean;
  65007. instance?: LinesMesh;
  65008. }, scene?: Nullable<Scene>): LinesMesh;
  65009. /**
  65010. * 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.
  65011. * * 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.
  65012. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65013. * * 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.
  65014. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65015. * * 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
  65016. * * 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
  65017. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65022. * @param name defines the name of the mesh
  65023. * @param options defines the options used to create the mesh
  65024. * @param scene defines the hosting scene
  65025. * @returns the extruded shape mesh
  65026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65028. */
  65029. static ExtrudeShape(name: string, options: {
  65030. shape: Vector3[];
  65031. path: Vector3[];
  65032. scale?: number;
  65033. rotation?: number;
  65034. cap?: number;
  65035. updatable?: boolean;
  65036. sideOrientation?: number;
  65037. frontUVs?: Vector4;
  65038. backUVs?: Vector4;
  65039. instance?: Mesh;
  65040. invertUV?: boolean;
  65041. }, scene?: Nullable<Scene>): Mesh;
  65042. /**
  65043. * Creates an custom extruded shape mesh.
  65044. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65045. * * 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.
  65046. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65047. * * 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
  65048. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65049. * * 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
  65050. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65051. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65052. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65053. * * 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
  65054. * * 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
  65055. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65060. * @param name defines the name of the mesh
  65061. * @param options defines the options used to create the mesh
  65062. * @param scene defines the hosting scene
  65063. * @returns the custom extruded shape mesh
  65064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65067. */
  65068. static ExtrudeShapeCustom(name: string, options: {
  65069. shape: Vector3[];
  65070. path: Vector3[];
  65071. scaleFunction?: any;
  65072. rotationFunction?: any;
  65073. ribbonCloseArray?: boolean;
  65074. ribbonClosePath?: boolean;
  65075. cap?: number;
  65076. updatable?: boolean;
  65077. sideOrientation?: number;
  65078. frontUVs?: Vector4;
  65079. backUVs?: Vector4;
  65080. instance?: Mesh;
  65081. invertUV?: boolean;
  65082. }, scene?: Nullable<Scene>): Mesh;
  65083. /**
  65084. * Creates lathe mesh.
  65085. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65086. * * 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
  65087. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65088. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65089. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65090. * * 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
  65091. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65092. * * 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
  65093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65097. * @param name defines the name of the mesh
  65098. * @param options defines the options used to create the mesh
  65099. * @param scene defines the hosting scene
  65100. * @returns the lathe mesh
  65101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65102. */
  65103. static CreateLathe(name: string, options: {
  65104. shape: Vector3[];
  65105. radius?: number;
  65106. tessellation?: number;
  65107. clip?: number;
  65108. arc?: number;
  65109. closed?: boolean;
  65110. updatable?: boolean;
  65111. sideOrientation?: number;
  65112. frontUVs?: Vector4;
  65113. backUVs?: Vector4;
  65114. cap?: number;
  65115. invertUV?: boolean;
  65116. }, scene?: Nullable<Scene>): Mesh;
  65117. /**
  65118. * Creates a tiled plane mesh
  65119. * * You can set a limited pattern arrangement with the tiles
  65120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65123. * @param name defines the name of the mesh
  65124. * @param options defines the options used to create the mesh
  65125. * @param scene defines the hosting scene
  65126. * @returns the plane mesh
  65127. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65128. */
  65129. static CreateTiledPlane(name: string, options: {
  65130. pattern?: number;
  65131. tileSize?: number;
  65132. tileWidth?: number;
  65133. tileHeight?: number;
  65134. size?: number;
  65135. width?: number;
  65136. height?: number;
  65137. alignHorizontal?: number;
  65138. alignVertical?: number;
  65139. sideOrientation?: number;
  65140. frontUVs?: Vector4;
  65141. backUVs?: Vector4;
  65142. updatable?: boolean;
  65143. }, scene?: Nullable<Scene>): Mesh;
  65144. /**
  65145. * Creates a plane mesh
  65146. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65147. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65148. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  65156. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65157. */
  65158. static CreatePlane(name: string, options: {
  65159. size?: number;
  65160. width?: number;
  65161. height?: number;
  65162. sideOrientation?: number;
  65163. frontUVs?: Vector4;
  65164. backUVs?: Vector4;
  65165. updatable?: boolean;
  65166. sourcePlane?: Plane;
  65167. }, scene?: Nullable<Scene>): Mesh;
  65168. /**
  65169. * Creates a ground mesh
  65170. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65171. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  65177. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65178. */
  65179. static CreateGround(name: string, options: {
  65180. width?: number;
  65181. height?: number;
  65182. subdivisions?: number;
  65183. subdivisionsX?: number;
  65184. subdivisionsY?: number;
  65185. updatable?: boolean;
  65186. }, scene?: Nullable<Scene>): Mesh;
  65187. /**
  65188. * Creates a tiled ground mesh
  65189. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65190. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65191. * * 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
  65192. * * 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
  65193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65194. * @param name defines the name of the mesh
  65195. * @param options defines the options used to create the mesh
  65196. * @param scene defines the hosting scene
  65197. * @returns the tiled ground mesh
  65198. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65199. */
  65200. static CreateTiledGround(name: string, options: {
  65201. xmin: number;
  65202. zmin: number;
  65203. xmax: number;
  65204. zmax: number;
  65205. subdivisions?: {
  65206. w: number;
  65207. h: number;
  65208. };
  65209. precision?: {
  65210. w: number;
  65211. h: number;
  65212. };
  65213. updatable?: boolean;
  65214. }, scene?: Nullable<Scene>): Mesh;
  65215. /**
  65216. * Creates a ground mesh from a height map
  65217. * * The parameter `url` sets the URL of the height map image resource.
  65218. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65219. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65220. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65221. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65222. * * 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.
  65223. * * 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).
  65224. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65226. * @param name defines the name of the mesh
  65227. * @param url defines the url to the height map
  65228. * @param options defines the options used to create the mesh
  65229. * @param scene defines the hosting scene
  65230. * @returns the ground mesh
  65231. * @see https://doc.babylonjs.com/babylon101/height_map
  65232. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65233. */
  65234. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65235. width?: number;
  65236. height?: number;
  65237. subdivisions?: number;
  65238. minHeight?: number;
  65239. maxHeight?: number;
  65240. colorFilter?: Color3;
  65241. alphaFilter?: number;
  65242. updatable?: boolean;
  65243. onReady?: (mesh: GroundMesh) => void;
  65244. }, scene?: Nullable<Scene>): GroundMesh;
  65245. /**
  65246. * Creates a polygon mesh
  65247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65248. * * 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
  65249. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65252. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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 an extruded polygon mesh, with depth in the Y direction.
  65272. * * 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)
  65273. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65274. * @param name defines the name of the mesh
  65275. * @param options defines the options used to create the mesh
  65276. * @param scene defines the hosting scene
  65277. * @param earcutInjection can be used to inject your own earcut reference
  65278. * @returns the polygon mesh
  65279. */
  65280. static ExtrudePolygon(name: string, options: {
  65281. shape: Vector3[];
  65282. holes?: Vector3[][];
  65283. depth?: number;
  65284. faceUV?: Vector4[];
  65285. faceColors?: Color4[];
  65286. updatable?: boolean;
  65287. sideOrientation?: number;
  65288. frontUVs?: Vector4;
  65289. backUVs?: Vector4;
  65290. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65291. /**
  65292. * Creates a tube mesh.
  65293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65298. * * 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)
  65299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65300. * * 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
  65301. * * 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
  65302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65306. * @param name defines the name of the mesh
  65307. * @param options defines the options used to create the mesh
  65308. * @param scene defines the hosting scene
  65309. * @returns the tube mesh
  65310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65311. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65312. */
  65313. static CreateTube(name: string, options: {
  65314. path: Vector3[];
  65315. radius?: number;
  65316. tessellation?: number;
  65317. radiusFunction?: {
  65318. (i: number, distance: number): number;
  65319. };
  65320. cap?: number;
  65321. arc?: number;
  65322. updatable?: boolean;
  65323. sideOrientation?: number;
  65324. frontUVs?: Vector4;
  65325. backUVs?: Vector4;
  65326. instance?: Mesh;
  65327. invertUV?: boolean;
  65328. }, scene?: Nullable<Scene>): Mesh;
  65329. /**
  65330. * Creates a polyhedron mesh
  65331. * * 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
  65332. * * The parameter `size` (positive float, default 1) sets the polygon size
  65333. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65334. * * 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`
  65335. * * 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
  65336. * * 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)`)
  65337. * * 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
  65338. * * 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
  65339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65342. * @param name defines the name of the mesh
  65343. * @param options defines the options used to create the mesh
  65344. * @param scene defines the hosting scene
  65345. * @returns the polyhedron mesh
  65346. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65347. */
  65348. static CreatePolyhedron(name: string, options: {
  65349. type?: number;
  65350. size?: number;
  65351. sizeX?: number;
  65352. sizeY?: number;
  65353. sizeZ?: number;
  65354. custom?: any;
  65355. faceUV?: Vector4[];
  65356. faceColors?: Color4[];
  65357. flat?: boolean;
  65358. updatable?: boolean;
  65359. sideOrientation?: number;
  65360. frontUVs?: Vector4;
  65361. backUVs?: Vector4;
  65362. }, scene?: Nullable<Scene>): Mesh;
  65363. /**
  65364. * Creates a decal mesh.
  65365. * 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
  65366. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65367. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65368. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65369. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65370. * @param name defines the name of the mesh
  65371. * @param sourceMesh defines the mesh where the decal must be applied
  65372. * @param options defines the options used to create the mesh
  65373. * @param scene defines the hosting scene
  65374. * @returns the decal mesh
  65375. * @see https://doc.babylonjs.com/how_to/decals
  65376. */
  65377. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65378. position?: Vector3;
  65379. normal?: Vector3;
  65380. size?: Vector3;
  65381. angle?: number;
  65382. }): Mesh;
  65383. }
  65384. }
  65385. declare module "babylonjs/Meshes/meshSimplification" {
  65386. import { Mesh } from "babylonjs/Meshes/mesh";
  65387. /**
  65388. * A simplifier interface for future simplification implementations
  65389. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65390. */
  65391. export interface ISimplifier {
  65392. /**
  65393. * Simplification of a given mesh according to the given settings.
  65394. * Since this requires computation, it is assumed that the function runs async.
  65395. * @param settings The settings of the simplification, including quality and distance
  65396. * @param successCallback A callback that will be called after the mesh was simplified.
  65397. * @param errorCallback in case of an error, this callback will be called. optional.
  65398. */
  65399. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65400. }
  65401. /**
  65402. * Expected simplification settings.
  65403. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65404. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65405. */
  65406. export interface ISimplificationSettings {
  65407. /**
  65408. * Gets or sets the expected quality
  65409. */
  65410. quality: number;
  65411. /**
  65412. * Gets or sets the distance when this optimized version should be used
  65413. */
  65414. distance: number;
  65415. /**
  65416. * Gets an already optimized mesh
  65417. */
  65418. optimizeMesh?: boolean;
  65419. }
  65420. /**
  65421. * Class used to specify simplification options
  65422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65423. */
  65424. export class SimplificationSettings implements ISimplificationSettings {
  65425. /** expected quality */
  65426. quality: number;
  65427. /** distance when this optimized version should be used */
  65428. distance: number;
  65429. /** already optimized mesh */
  65430. optimizeMesh?: boolean | undefined;
  65431. /**
  65432. * Creates a SimplificationSettings
  65433. * @param quality expected quality
  65434. * @param distance distance when this optimized version should be used
  65435. * @param optimizeMesh already optimized mesh
  65436. */
  65437. constructor(
  65438. /** expected quality */
  65439. quality: number,
  65440. /** distance when this optimized version should be used */
  65441. distance: number,
  65442. /** already optimized mesh */
  65443. optimizeMesh?: boolean | undefined);
  65444. }
  65445. /**
  65446. * Interface used to define a simplification task
  65447. */
  65448. export interface ISimplificationTask {
  65449. /**
  65450. * Array of settings
  65451. */
  65452. settings: Array<ISimplificationSettings>;
  65453. /**
  65454. * Simplification type
  65455. */
  65456. simplificationType: SimplificationType;
  65457. /**
  65458. * Mesh to simplify
  65459. */
  65460. mesh: Mesh;
  65461. /**
  65462. * Callback called on success
  65463. */
  65464. successCallback?: () => void;
  65465. /**
  65466. * Defines if parallel processing can be used
  65467. */
  65468. parallelProcessing: boolean;
  65469. }
  65470. /**
  65471. * Queue used to order the simplification tasks
  65472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65473. */
  65474. export class SimplificationQueue {
  65475. private _simplificationArray;
  65476. /**
  65477. * Gets a boolean indicating that the process is still running
  65478. */
  65479. running: boolean;
  65480. /**
  65481. * Creates a new queue
  65482. */
  65483. constructor();
  65484. /**
  65485. * Adds a new simplification task
  65486. * @param task defines a task to add
  65487. */
  65488. addTask(task: ISimplificationTask): void;
  65489. /**
  65490. * Execute next task
  65491. */
  65492. executeNext(): void;
  65493. /**
  65494. * Execute a simplification task
  65495. * @param task defines the task to run
  65496. */
  65497. runSimplification(task: ISimplificationTask): void;
  65498. private getSimplifier;
  65499. }
  65500. /**
  65501. * The implemented types of simplification
  65502. * At the moment only Quadratic Error Decimation is implemented
  65503. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65504. */
  65505. export enum SimplificationType {
  65506. /** Quadratic error decimation */
  65507. QUADRATIC = 0
  65508. }
  65509. /**
  65510. * An implementation of the Quadratic Error simplification algorithm.
  65511. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65512. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65513. * @author RaananW
  65514. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65515. */
  65516. export class QuadraticErrorSimplification implements ISimplifier {
  65517. private _mesh;
  65518. private triangles;
  65519. private vertices;
  65520. private references;
  65521. private _reconstructedMesh;
  65522. /** Gets or sets the number pf sync interations */
  65523. syncIterations: number;
  65524. /** Gets or sets the aggressiveness of the simplifier */
  65525. aggressiveness: number;
  65526. /** Gets or sets the number of allowed iterations for decimation */
  65527. decimationIterations: number;
  65528. /** Gets or sets the espilon to use for bounding box computation */
  65529. boundingBoxEpsilon: number;
  65530. /**
  65531. * Creates a new QuadraticErrorSimplification
  65532. * @param _mesh defines the target mesh
  65533. */
  65534. constructor(_mesh: Mesh);
  65535. /**
  65536. * Simplification of a given mesh according to the given settings.
  65537. * Since this requires computation, it is assumed that the function runs async.
  65538. * @param settings The settings of the simplification, including quality and distance
  65539. * @param successCallback A callback that will be called after the mesh was simplified.
  65540. */
  65541. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65542. private runDecimation;
  65543. private initWithMesh;
  65544. private init;
  65545. private reconstructMesh;
  65546. private initDecimatedMesh;
  65547. private isFlipped;
  65548. private updateTriangles;
  65549. private identifyBorder;
  65550. private updateMesh;
  65551. private vertexError;
  65552. private calculateError;
  65553. }
  65554. }
  65555. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65556. import { Scene } from "babylonjs/scene";
  65557. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65558. import { ISceneComponent } from "babylonjs/sceneComponent";
  65559. module "babylonjs/scene" {
  65560. interface Scene {
  65561. /** @hidden (Backing field) */
  65562. _simplificationQueue: SimplificationQueue;
  65563. /**
  65564. * Gets or sets the simplification queue attached to the scene
  65565. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65566. */
  65567. simplificationQueue: SimplificationQueue;
  65568. }
  65569. }
  65570. module "babylonjs/Meshes/mesh" {
  65571. interface Mesh {
  65572. /**
  65573. * Simplify the mesh according to the given array of settings.
  65574. * Function will return immediately and will simplify async
  65575. * @param settings a collection of simplification settings
  65576. * @param parallelProcessing should all levels calculate parallel or one after the other
  65577. * @param simplificationType the type of simplification to run
  65578. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65579. * @returns the current mesh
  65580. */
  65581. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65582. }
  65583. }
  65584. /**
  65585. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65586. * created in a scene
  65587. */
  65588. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65589. /**
  65590. * The component name helpfull to identify the component in the list of scene components.
  65591. */
  65592. readonly name: string;
  65593. /**
  65594. * The scene the component belongs to.
  65595. */
  65596. scene: Scene;
  65597. /**
  65598. * Creates a new instance of the component for the given scene
  65599. * @param scene Defines the scene to register the component in
  65600. */
  65601. constructor(scene: Scene);
  65602. /**
  65603. * Registers the component in a given scene
  65604. */
  65605. register(): void;
  65606. /**
  65607. * Rebuilds the elements related to this component in case of
  65608. * context lost for instance.
  65609. */
  65610. rebuild(): void;
  65611. /**
  65612. * Disposes the component and the associated ressources
  65613. */
  65614. dispose(): void;
  65615. private _beforeCameraUpdate;
  65616. }
  65617. }
  65618. declare module "babylonjs/Meshes/Builders/index" {
  65619. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65620. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65621. export * from "babylonjs/Meshes/Builders/discBuilder";
  65622. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65623. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65624. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65625. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65626. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65627. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65628. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65629. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65630. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65631. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65632. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65633. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65634. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65635. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65636. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65637. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65638. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65639. }
  65640. declare module "babylonjs/Meshes/index" {
  65641. export * from "babylonjs/Meshes/abstractMesh";
  65642. export * from "babylonjs/Meshes/buffer";
  65643. export * from "babylonjs/Meshes/Compression/index";
  65644. export * from "babylonjs/Meshes/csg";
  65645. export * from "babylonjs/Meshes/geometry";
  65646. export * from "babylonjs/Meshes/groundMesh";
  65647. export * from "babylonjs/Meshes/trailMesh";
  65648. export * from "babylonjs/Meshes/instancedMesh";
  65649. export * from "babylonjs/Meshes/linesMesh";
  65650. export * from "babylonjs/Meshes/mesh";
  65651. export * from "babylonjs/Meshes/mesh.vertexData";
  65652. export * from "babylonjs/Meshes/meshBuilder";
  65653. export * from "babylonjs/Meshes/meshSimplification";
  65654. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65655. export * from "babylonjs/Meshes/polygonMesh";
  65656. export * from "babylonjs/Meshes/subMesh";
  65657. export * from "babylonjs/Meshes/meshLODLevel";
  65658. export * from "babylonjs/Meshes/transformNode";
  65659. export * from "babylonjs/Meshes/Builders/index";
  65660. export * from "babylonjs/Meshes/dataBuffer";
  65661. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65662. }
  65663. declare module "babylonjs/Morph/index" {
  65664. export * from "babylonjs/Morph/morphTarget";
  65665. export * from "babylonjs/Morph/morphTargetManager";
  65666. }
  65667. declare module "babylonjs/Navigation/INavigationEngine" {
  65668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65669. import { Vector3 } from "babylonjs/Maths/math";
  65670. import { Mesh } from "babylonjs/Meshes/mesh";
  65671. import { Scene } from "babylonjs/scene";
  65672. /**
  65673. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65674. */
  65675. export interface INavigationEnginePlugin {
  65676. /**
  65677. * plugin name
  65678. */
  65679. name: string;
  65680. /**
  65681. * Creates a navigation mesh
  65682. * @param meshes array of all the geometry used to compute the navigatio mesh
  65683. * @param parameters bunch of parameters used to filter geometry
  65684. */
  65685. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65686. /**
  65687. * Create a navigation mesh debug mesh
  65688. * @param scene is where the mesh will be added
  65689. * @returns debug display mesh
  65690. */
  65691. createDebugNavMesh(scene: Scene): Mesh;
  65692. /**
  65693. * Get a navigation mesh constrained position, closest to the parameter position
  65694. * @param position world position
  65695. * @returns the closest point to position constrained by the navigation mesh
  65696. */
  65697. getClosestPoint(position: Vector3): Vector3;
  65698. /**
  65699. * Get a navigation mesh constrained position, closest to the parameter position
  65700. * @param position world position
  65701. * @param result output the closest point to position constrained by the navigation mesh
  65702. */
  65703. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65704. /**
  65705. * Get a navigation mesh constrained position, within a particular radius
  65706. * @param position world position
  65707. * @param maxRadius the maximum distance to the constrained world position
  65708. * @returns the closest point to position constrained by the navigation mesh
  65709. */
  65710. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65711. /**
  65712. * Get a navigation mesh constrained position, within a particular radius
  65713. * @param position world position
  65714. * @param maxRadius the maximum distance to the constrained world position
  65715. * @param result output the closest point to position constrained by the navigation mesh
  65716. */
  65717. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65718. /**
  65719. * Compute the final position from a segment made of destination-position
  65720. * @param position world position
  65721. * @param destination world position
  65722. * @returns the resulting point along the navmesh
  65723. */
  65724. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65725. /**
  65726. * Compute the final position from a segment made of destination-position
  65727. * @param position world position
  65728. * @param destination world position
  65729. * @param result output the resulting point along the navmesh
  65730. */
  65731. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65732. /**
  65733. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65734. * @param start world position
  65735. * @param end world position
  65736. * @returns array containing world position composing the path
  65737. */
  65738. computePath(start: Vector3, end: Vector3): Vector3[];
  65739. /**
  65740. * If this plugin is supported
  65741. * @returns true if plugin is supported
  65742. */
  65743. isSupported(): boolean;
  65744. /**
  65745. * Create a new Crowd so you can add agents
  65746. * @param maxAgents the maximum agent count in the crowd
  65747. * @param maxAgentRadius the maximum radius an agent can have
  65748. * @param scene to attach the crowd to
  65749. * @returns the crowd you can add agents to
  65750. */
  65751. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65752. /**
  65753. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65754. * The queries will try to find a solution within those bounds
  65755. * default is (1,1,1)
  65756. * @param extent x,y,z value that define the extent around the queries point of reference
  65757. */
  65758. setDefaultQueryExtent(extent: Vector3): void;
  65759. /**
  65760. * Get the Bounding box extent specified by setDefaultQueryExtent
  65761. * @returns the box extent values
  65762. */
  65763. getDefaultQueryExtent(): Vector3;
  65764. /**
  65765. * build the navmesh from a previously saved state using getNavmeshData
  65766. * @param data the Uint8Array returned by getNavmeshData
  65767. */
  65768. buildFromNavmeshData(data: Uint8Array): void;
  65769. /**
  65770. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65771. * @returns data the Uint8Array that can be saved and reused
  65772. */
  65773. getNavmeshData(): Uint8Array;
  65774. /**
  65775. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65776. * @param result output the box extent values
  65777. */
  65778. getDefaultQueryExtentToRef(result: Vector3): void;
  65779. /**
  65780. * Release all resources
  65781. */
  65782. dispose(): void;
  65783. }
  65784. /**
  65785. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65786. */
  65787. export interface ICrowd {
  65788. /**
  65789. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65790. * You can attach anything to that node. The node position is updated in the scene update tick.
  65791. * @param pos world position that will be constrained by the navigation mesh
  65792. * @param parameters agent parameters
  65793. * @param transform hooked to the agent that will be update by the scene
  65794. * @returns agent index
  65795. */
  65796. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65797. /**
  65798. * Returns the agent position in world space
  65799. * @param index agent index returned by addAgent
  65800. * @returns world space position
  65801. */
  65802. getAgentPosition(index: number): Vector3;
  65803. /**
  65804. * Gets the agent position result in world space
  65805. * @param index agent index returned by addAgent
  65806. * @param result output world space position
  65807. */
  65808. getAgentPositionToRef(index: number, result: Vector3): void;
  65809. /**
  65810. * Gets the agent velocity in world space
  65811. * @param index agent index returned by addAgent
  65812. * @returns world space velocity
  65813. */
  65814. getAgentVelocity(index: number): Vector3;
  65815. /**
  65816. * Gets the agent velocity result in world space
  65817. * @param index agent index returned by addAgent
  65818. * @param result output world space velocity
  65819. */
  65820. getAgentVelocityToRef(index: number, result: Vector3): void;
  65821. /**
  65822. * remove a particular agent previously created
  65823. * @param index agent index returned by addAgent
  65824. */
  65825. removeAgent(index: number): void;
  65826. /**
  65827. * get the list of all agents attached to this crowd
  65828. * @returns list of agent indices
  65829. */
  65830. getAgents(): number[];
  65831. /**
  65832. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65833. * @param deltaTime in seconds
  65834. */
  65835. update(deltaTime: number): void;
  65836. /**
  65837. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65838. * @param index agent index returned by addAgent
  65839. * @param destination targeted world position
  65840. */
  65841. agentGoto(index: number, destination: Vector3): void;
  65842. /**
  65843. * Teleport the agent to a new position
  65844. * @param index agent index returned by addAgent
  65845. * @param destination targeted world position
  65846. */
  65847. agentTeleport(index: number, destination: Vector3): void;
  65848. /**
  65849. * Update agent parameters
  65850. * @param index agent index returned by addAgent
  65851. * @param parameters agent parameters
  65852. */
  65853. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65854. /**
  65855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65856. * The queries will try to find a solution within those bounds
  65857. * default is (1,1,1)
  65858. * @param extent x,y,z value that define the extent around the queries point of reference
  65859. */
  65860. setDefaultQueryExtent(extent: Vector3): void;
  65861. /**
  65862. * Get the Bounding box extent specified by setDefaultQueryExtent
  65863. * @returns the box extent values
  65864. */
  65865. getDefaultQueryExtent(): Vector3;
  65866. /**
  65867. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65868. * @param result output the box extent values
  65869. */
  65870. getDefaultQueryExtentToRef(result: Vector3): void;
  65871. /**
  65872. * Release all resources
  65873. */
  65874. dispose(): void;
  65875. }
  65876. /**
  65877. * Configures an agent
  65878. */
  65879. export interface IAgentParameters {
  65880. /**
  65881. * Agent radius. [Limit: >= 0]
  65882. */
  65883. radius: number;
  65884. /**
  65885. * Agent height. [Limit: > 0]
  65886. */
  65887. height: number;
  65888. /**
  65889. * Maximum allowed acceleration. [Limit: >= 0]
  65890. */
  65891. maxAcceleration: number;
  65892. /**
  65893. * Maximum allowed speed. [Limit: >= 0]
  65894. */
  65895. maxSpeed: number;
  65896. /**
  65897. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65898. */
  65899. collisionQueryRange: number;
  65900. /**
  65901. * The path visibility optimization range. [Limit: > 0]
  65902. */
  65903. pathOptimizationRange: number;
  65904. /**
  65905. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65906. */
  65907. separationWeight: number;
  65908. }
  65909. /**
  65910. * Configures the navigation mesh creation
  65911. */
  65912. export interface INavMeshParameters {
  65913. /**
  65914. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65915. */
  65916. cs: number;
  65917. /**
  65918. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65919. */
  65920. ch: number;
  65921. /**
  65922. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65923. */
  65924. walkableSlopeAngle: number;
  65925. /**
  65926. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65927. * be considered walkable. [Limit: >= 3] [Units: vx]
  65928. */
  65929. walkableHeight: number;
  65930. /**
  65931. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65932. */
  65933. walkableClimb: number;
  65934. /**
  65935. * The distance to erode/shrink the walkable area of the heightfield away from
  65936. * obstructions. [Limit: >=0] [Units: vx]
  65937. */
  65938. walkableRadius: number;
  65939. /**
  65940. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65941. */
  65942. maxEdgeLen: number;
  65943. /**
  65944. * The maximum distance a simplfied contour's border edges should deviate
  65945. * the original raw contour. [Limit: >=0] [Units: vx]
  65946. */
  65947. maxSimplificationError: number;
  65948. /**
  65949. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65950. */
  65951. minRegionArea: number;
  65952. /**
  65953. * Any regions with a span count smaller than this value will, if possible,
  65954. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65955. */
  65956. mergeRegionArea: number;
  65957. /**
  65958. * The maximum number of vertices allowed for polygons generated during the
  65959. * contour to polygon conversion process. [Limit: >= 3]
  65960. */
  65961. maxVertsPerPoly: number;
  65962. /**
  65963. * Sets the sampling distance to use when generating the detail mesh.
  65964. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65965. */
  65966. detailSampleDist: number;
  65967. /**
  65968. * The maximum distance the detail mesh surface should deviate from heightfield
  65969. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65970. */
  65971. detailSampleMaxError: number;
  65972. }
  65973. }
  65974. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65975. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65976. import { Mesh } from "babylonjs/Meshes/mesh";
  65977. import { Scene } from "babylonjs/scene";
  65978. import { Vector3 } from "babylonjs/Maths/math";
  65979. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65980. /**
  65981. * RecastJS navigation plugin
  65982. */
  65983. export class RecastJSPlugin implements INavigationEnginePlugin {
  65984. /**
  65985. * Reference to the Recast library
  65986. */
  65987. bjsRECAST: any;
  65988. /**
  65989. * plugin name
  65990. */
  65991. name: string;
  65992. /**
  65993. * the first navmesh created. We might extend this to support multiple navmeshes
  65994. */
  65995. navMesh: any;
  65996. /**
  65997. * Initializes the recastJS plugin
  65998. * @param recastInjection can be used to inject your own recast reference
  65999. */
  66000. constructor(recastInjection?: any);
  66001. /**
  66002. * Creates a navigation mesh
  66003. * @param meshes array of all the geometry used to compute the navigatio mesh
  66004. * @param parameters bunch of parameters used to filter geometry
  66005. */
  66006. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66007. /**
  66008. * Create a navigation mesh debug mesh
  66009. * @param scene is where the mesh will be added
  66010. * @returns debug display mesh
  66011. */
  66012. createDebugNavMesh(scene: Scene): Mesh;
  66013. /**
  66014. * Get a navigation mesh constrained position, closest to the parameter position
  66015. * @param position world position
  66016. * @returns the closest point to position constrained by the navigation mesh
  66017. */
  66018. getClosestPoint(position: Vector3): Vector3;
  66019. /**
  66020. * Get a navigation mesh constrained position, closest to the parameter position
  66021. * @param position world position
  66022. * @param result output the closest point to position constrained by the navigation mesh
  66023. */
  66024. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66025. /**
  66026. * Get a navigation mesh constrained position, within a particular radius
  66027. * @param position world position
  66028. * @param maxRadius the maximum distance to the constrained world position
  66029. * @returns the closest point to position constrained by the navigation mesh
  66030. */
  66031. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66032. /**
  66033. * Get a navigation mesh constrained position, within a particular radius
  66034. * @param position world position
  66035. * @param maxRadius the maximum distance to the constrained world position
  66036. * @param result output the closest point to position constrained by the navigation mesh
  66037. */
  66038. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66039. /**
  66040. * Compute the final position from a segment made of destination-position
  66041. * @param position world position
  66042. * @param destination world position
  66043. * @returns the resulting point along the navmesh
  66044. */
  66045. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66046. /**
  66047. * Compute the final position from a segment made of destination-position
  66048. * @param position world position
  66049. * @param destination world position
  66050. * @param result output the resulting point along the navmesh
  66051. */
  66052. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66053. /**
  66054. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66055. * @param start world position
  66056. * @param end world position
  66057. * @returns array containing world position composing the path
  66058. */
  66059. computePath(start: Vector3, end: Vector3): Vector3[];
  66060. /**
  66061. * Create a new Crowd so you can add agents
  66062. * @param maxAgents the maximum agent count in the crowd
  66063. * @param maxAgentRadius the maximum radius an agent can have
  66064. * @param scene to attach the crowd to
  66065. * @returns the crowd you can add agents to
  66066. */
  66067. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66068. /**
  66069. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66070. * The queries will try to find a solution within those bounds
  66071. * default is (1,1,1)
  66072. * @param extent x,y,z value that define the extent around the queries point of reference
  66073. */
  66074. setDefaultQueryExtent(extent: Vector3): void;
  66075. /**
  66076. * Get the Bounding box extent specified by setDefaultQueryExtent
  66077. * @returns the box extent values
  66078. */
  66079. getDefaultQueryExtent(): Vector3;
  66080. /**
  66081. * build the navmesh from a previously saved state using getNavmeshData
  66082. * @param data the Uint8Array returned by getNavmeshData
  66083. */
  66084. buildFromNavmeshData(data: Uint8Array): void;
  66085. /**
  66086. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66087. * @returns data the Uint8Array that can be saved and reused
  66088. */
  66089. getNavmeshData(): Uint8Array;
  66090. /**
  66091. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66092. * @param result output the box extent values
  66093. */
  66094. getDefaultQueryExtentToRef(result: Vector3): void;
  66095. /**
  66096. * Disposes
  66097. */
  66098. dispose(): void;
  66099. /**
  66100. * If this plugin is supported
  66101. * @returns true if plugin is supported
  66102. */
  66103. isSupported(): boolean;
  66104. }
  66105. /**
  66106. * Recast detour crowd implementation
  66107. */
  66108. export class RecastJSCrowd implements ICrowd {
  66109. /**
  66110. * Recast/detour plugin
  66111. */
  66112. bjsRECASTPlugin: RecastJSPlugin;
  66113. /**
  66114. * Link to the detour crowd
  66115. */
  66116. recastCrowd: any;
  66117. /**
  66118. * One transform per agent
  66119. */
  66120. transforms: TransformNode[];
  66121. /**
  66122. * All agents created
  66123. */
  66124. agents: number[];
  66125. /**
  66126. * Link to the scene is kept to unregister the crowd from the scene
  66127. */
  66128. private _scene;
  66129. /**
  66130. * Observer for crowd updates
  66131. */
  66132. private _onBeforeAnimationsObserver;
  66133. /**
  66134. * Constructor
  66135. * @param plugin recastJS plugin
  66136. * @param maxAgents the maximum agent count in the crowd
  66137. * @param maxAgentRadius the maximum radius an agent can have
  66138. * @param scene to attach the crowd to
  66139. * @returns the crowd you can add agents to
  66140. */
  66141. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66142. /**
  66143. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66144. * You can attach anything to that node. The node position is updated in the scene update tick.
  66145. * @param pos world position that will be constrained by the navigation mesh
  66146. * @param parameters agent parameters
  66147. * @param transform hooked to the agent that will be update by the scene
  66148. * @returns agent index
  66149. */
  66150. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66151. /**
  66152. * Returns the agent position in world space
  66153. * @param index agent index returned by addAgent
  66154. * @returns world space position
  66155. */
  66156. getAgentPosition(index: number): Vector3;
  66157. /**
  66158. * Returns the agent position result in world space
  66159. * @param index agent index returned by addAgent
  66160. * @param result output world space position
  66161. */
  66162. getAgentPositionToRef(index: number, result: Vector3): void;
  66163. /**
  66164. * Returns the agent velocity in world space
  66165. * @param index agent index returned by addAgent
  66166. * @returns world space velocity
  66167. */
  66168. getAgentVelocity(index: number): Vector3;
  66169. /**
  66170. * Returns the agent velocity result in world space
  66171. * @param index agent index returned by addAgent
  66172. * @param result output world space velocity
  66173. */
  66174. getAgentVelocityToRef(index: number, result: Vector3): void;
  66175. /**
  66176. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66177. * @param index agent index returned by addAgent
  66178. * @param destination targeted world position
  66179. */
  66180. agentGoto(index: number, destination: Vector3): void;
  66181. /**
  66182. * Teleport the agent to a new position
  66183. * @param index agent index returned by addAgent
  66184. * @param destination targeted world position
  66185. */
  66186. agentTeleport(index: number, destination: Vector3): void;
  66187. /**
  66188. * Update agent parameters
  66189. * @param index agent index returned by addAgent
  66190. * @param parameters agent parameters
  66191. */
  66192. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66193. /**
  66194. * remove a particular agent previously created
  66195. * @param index agent index returned by addAgent
  66196. */
  66197. removeAgent(index: number): void;
  66198. /**
  66199. * get the list of all agents attached to this crowd
  66200. * @returns list of agent indices
  66201. */
  66202. getAgents(): number[];
  66203. /**
  66204. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66205. * @param deltaTime in seconds
  66206. */
  66207. update(deltaTime: number): void;
  66208. /**
  66209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66210. * The queries will try to find a solution within those bounds
  66211. * default is (1,1,1)
  66212. * @param extent x,y,z value that define the extent around the queries point of reference
  66213. */
  66214. setDefaultQueryExtent(extent: Vector3): void;
  66215. /**
  66216. * Get the Bounding box extent specified by setDefaultQueryExtent
  66217. * @returns the box extent values
  66218. */
  66219. getDefaultQueryExtent(): Vector3;
  66220. /**
  66221. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66222. * @param result output the box extent values
  66223. */
  66224. getDefaultQueryExtentToRef(result: Vector3): void;
  66225. /**
  66226. * Release all resources
  66227. */
  66228. dispose(): void;
  66229. }
  66230. }
  66231. declare module "babylonjs/Navigation/Plugins/index" {
  66232. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66233. }
  66234. declare module "babylonjs/Navigation/index" {
  66235. export * from "babylonjs/Navigation/INavigationEngine";
  66236. export * from "babylonjs/Navigation/Plugins/index";
  66237. }
  66238. declare module "babylonjs/Offline/database" {
  66239. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66240. /**
  66241. * Class used to enable access to IndexedDB
  66242. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66243. */
  66244. export class Database implements IOfflineProvider {
  66245. private _callbackManifestChecked;
  66246. private _currentSceneUrl;
  66247. private _db;
  66248. private _enableSceneOffline;
  66249. private _enableTexturesOffline;
  66250. private _manifestVersionFound;
  66251. private _mustUpdateRessources;
  66252. private _hasReachedQuota;
  66253. private _isSupported;
  66254. private _idbFactory;
  66255. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66256. private static IsUASupportingBlobStorage;
  66257. /**
  66258. * Gets a boolean indicating if Database storate is enabled (off by default)
  66259. */
  66260. static IDBStorageEnabled: boolean;
  66261. /**
  66262. * Gets a boolean indicating if scene must be saved in the database
  66263. */
  66264. get enableSceneOffline(): boolean;
  66265. /**
  66266. * Gets a boolean indicating if textures must be saved in the database
  66267. */
  66268. get enableTexturesOffline(): boolean;
  66269. /**
  66270. * Creates a new Database
  66271. * @param urlToScene defines the url to load the scene
  66272. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66273. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66274. */
  66275. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66276. private static _ParseURL;
  66277. private static _ReturnFullUrlLocation;
  66278. private _checkManifestFile;
  66279. /**
  66280. * Open the database and make it available
  66281. * @param successCallback defines the callback to call on success
  66282. * @param errorCallback defines the callback to call on error
  66283. */
  66284. open(successCallback: () => void, errorCallback: () => void): void;
  66285. /**
  66286. * Loads an image from the database
  66287. * @param url defines the url to load from
  66288. * @param image defines the target DOM image
  66289. */
  66290. loadImage(url: string, image: HTMLImageElement): void;
  66291. private _loadImageFromDBAsync;
  66292. private _saveImageIntoDBAsync;
  66293. private _checkVersionFromDB;
  66294. private _loadVersionFromDBAsync;
  66295. private _saveVersionIntoDBAsync;
  66296. /**
  66297. * Loads a file from database
  66298. * @param url defines the URL to load from
  66299. * @param sceneLoaded defines a callback to call on success
  66300. * @param progressCallBack defines a callback to call when progress changed
  66301. * @param errorCallback defines a callback to call on error
  66302. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66303. */
  66304. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66305. private _loadFileAsync;
  66306. private _saveFileAsync;
  66307. /**
  66308. * Validates if xhr data is correct
  66309. * @param xhr defines the request to validate
  66310. * @param dataType defines the expected data type
  66311. * @returns true if data is correct
  66312. */
  66313. private static _ValidateXHRData;
  66314. }
  66315. }
  66316. declare module "babylonjs/Offline/index" {
  66317. export * from "babylonjs/Offline/database";
  66318. export * from "babylonjs/Offline/IOfflineProvider";
  66319. }
  66320. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66321. /** @hidden */
  66322. export var gpuUpdateParticlesPixelShader: {
  66323. name: string;
  66324. shader: string;
  66325. };
  66326. }
  66327. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66328. /** @hidden */
  66329. export var gpuUpdateParticlesVertexShader: {
  66330. name: string;
  66331. shader: string;
  66332. };
  66333. }
  66334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66335. /** @hidden */
  66336. export var clipPlaneFragmentDeclaration2: {
  66337. name: string;
  66338. shader: string;
  66339. };
  66340. }
  66341. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66342. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66343. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66344. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66345. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66346. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66347. /** @hidden */
  66348. export var gpuRenderParticlesPixelShader: {
  66349. name: string;
  66350. shader: string;
  66351. };
  66352. }
  66353. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66354. /** @hidden */
  66355. export var clipPlaneVertexDeclaration2: {
  66356. name: string;
  66357. shader: string;
  66358. };
  66359. }
  66360. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66361. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66362. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66363. /** @hidden */
  66364. export var gpuRenderParticlesVertexShader: {
  66365. name: string;
  66366. shader: string;
  66367. };
  66368. }
  66369. declare module "babylonjs/Particles/gpuParticleSystem" {
  66370. import { Nullable } from "babylonjs/types";
  66371. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66372. import { Observable } from "babylonjs/Misc/observable";
  66373. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66375. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66376. import { Scene, IDisposable } from "babylonjs/scene";
  66377. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66378. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66379. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66380. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66381. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66382. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66383. /**
  66384. * This represents a GPU particle system in Babylon
  66385. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66386. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66387. */
  66388. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66389. /**
  66390. * The layer mask we are rendering the particles through.
  66391. */
  66392. layerMask: number;
  66393. private _capacity;
  66394. private _activeCount;
  66395. private _currentActiveCount;
  66396. private _accumulatedCount;
  66397. private _renderEffect;
  66398. private _updateEffect;
  66399. private _buffer0;
  66400. private _buffer1;
  66401. private _spriteBuffer;
  66402. private _updateVAO;
  66403. private _renderVAO;
  66404. private _targetIndex;
  66405. private _sourceBuffer;
  66406. private _targetBuffer;
  66407. private _engine;
  66408. private _currentRenderId;
  66409. private _started;
  66410. private _stopped;
  66411. private _timeDelta;
  66412. private _randomTexture;
  66413. private _randomTexture2;
  66414. private _attributesStrideSize;
  66415. private _updateEffectOptions;
  66416. private _randomTextureSize;
  66417. private _actualFrame;
  66418. private readonly _rawTextureWidth;
  66419. /**
  66420. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66421. */
  66422. static get IsSupported(): boolean;
  66423. /**
  66424. * An event triggered when the system is disposed.
  66425. */
  66426. onDisposeObservable: Observable<GPUParticleSystem>;
  66427. /**
  66428. * Gets the maximum number of particles active at the same time.
  66429. * @returns The max number of active particles.
  66430. */
  66431. getCapacity(): number;
  66432. /**
  66433. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66434. * to override the particles.
  66435. */
  66436. forceDepthWrite: boolean;
  66437. /**
  66438. * Gets or set the number of active particles
  66439. */
  66440. get activeParticleCount(): number;
  66441. set activeParticleCount(value: number);
  66442. private _preWarmDone;
  66443. /**
  66444. * Specifies if the particles are updated in emitter local space or world space.
  66445. * This is always false for GPU particles
  66446. */
  66447. get isLocal(): boolean;
  66448. set isLocal(value: boolean);
  66449. /**
  66450. * Is this system ready to be used/rendered
  66451. * @return true if the system is ready
  66452. */
  66453. isReady(): boolean;
  66454. /**
  66455. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66456. * @returns True if it has been started, otherwise false.
  66457. */
  66458. isStarted(): boolean;
  66459. /**
  66460. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66461. * @returns True if it has been stopped, otherwise false.
  66462. */
  66463. isStopped(): boolean;
  66464. /**
  66465. * Gets a boolean indicating that the system is stopping
  66466. * @returns true if the system is currently stopping
  66467. */
  66468. isStopping(): boolean;
  66469. /**
  66470. * Gets the number of particles active at the same time.
  66471. * @returns The number of active particles.
  66472. */
  66473. getActiveCount(): number;
  66474. /**
  66475. * Starts the particle system and begins to emit
  66476. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66477. */
  66478. start(delay?: number): void;
  66479. /**
  66480. * Stops the particle system.
  66481. */
  66482. stop(): void;
  66483. /**
  66484. * Remove all active particles
  66485. */
  66486. reset(): void;
  66487. /**
  66488. * Returns the string "GPUParticleSystem"
  66489. * @returns a string containing the class name
  66490. */
  66491. getClassName(): string;
  66492. private _colorGradientsTexture;
  66493. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66494. /**
  66495. * Adds a new color gradient
  66496. * @param gradient defines the gradient to use (between 0 and 1)
  66497. * @param color1 defines the color to affect to the specified gradient
  66498. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66499. * @returns the current particle system
  66500. */
  66501. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66502. private _refreshColorGradient;
  66503. /** Force the system to rebuild all gradients that need to be resync */
  66504. forceRefreshGradients(): void;
  66505. /**
  66506. * Remove a specific color gradient
  66507. * @param gradient defines the gradient to remove
  66508. * @returns the current particle system
  66509. */
  66510. removeColorGradient(gradient: number): GPUParticleSystem;
  66511. private _angularSpeedGradientsTexture;
  66512. private _sizeGradientsTexture;
  66513. private _velocityGradientsTexture;
  66514. private _limitVelocityGradientsTexture;
  66515. private _dragGradientsTexture;
  66516. private _addFactorGradient;
  66517. /**
  66518. * Adds a new size gradient
  66519. * @param gradient defines the gradient to use (between 0 and 1)
  66520. * @param factor defines the size factor to affect to the specified gradient
  66521. * @returns the current particle system
  66522. */
  66523. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66524. /**
  66525. * Remove a specific size gradient
  66526. * @param gradient defines the gradient to remove
  66527. * @returns the current particle system
  66528. */
  66529. removeSizeGradient(gradient: number): GPUParticleSystem;
  66530. private _refreshFactorGradient;
  66531. /**
  66532. * Adds a new angular speed gradient
  66533. * @param gradient defines the gradient to use (between 0 and 1)
  66534. * @param factor defines the angular speed to affect to the specified gradient
  66535. * @returns the current particle system
  66536. */
  66537. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66538. /**
  66539. * Remove a specific angular speed gradient
  66540. * @param gradient defines the gradient to remove
  66541. * @returns the current particle system
  66542. */
  66543. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66544. /**
  66545. * Adds a new velocity gradient
  66546. * @param gradient defines the gradient to use (between 0 and 1)
  66547. * @param factor defines the velocity to affect to the specified gradient
  66548. * @returns the current particle system
  66549. */
  66550. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66551. /**
  66552. * Remove a specific velocity gradient
  66553. * @param gradient defines the gradient to remove
  66554. * @returns the current particle system
  66555. */
  66556. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66557. /**
  66558. * Adds a new limit velocity gradient
  66559. * @param gradient defines the gradient to use (between 0 and 1)
  66560. * @param factor defines the limit velocity value to affect to the specified gradient
  66561. * @returns the current particle system
  66562. */
  66563. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66564. /**
  66565. * Remove a specific limit velocity gradient
  66566. * @param gradient defines the gradient to remove
  66567. * @returns the current particle system
  66568. */
  66569. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66570. /**
  66571. * Adds a new drag gradient
  66572. * @param gradient defines the gradient to use (between 0 and 1)
  66573. * @param factor defines the drag value to affect to the specified gradient
  66574. * @returns the current particle system
  66575. */
  66576. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66577. /**
  66578. * Remove a specific drag gradient
  66579. * @param gradient defines the gradient to remove
  66580. * @returns the current particle system
  66581. */
  66582. removeDragGradient(gradient: number): GPUParticleSystem;
  66583. /**
  66584. * Not supported by GPUParticleSystem
  66585. * @param gradient defines the gradient to use (between 0 and 1)
  66586. * @param factor defines the emit rate value to affect to the specified gradient
  66587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66588. * @returns the current particle system
  66589. */
  66590. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66591. /**
  66592. * Not supported by GPUParticleSystem
  66593. * @param gradient defines the gradient to remove
  66594. * @returns the current particle system
  66595. */
  66596. removeEmitRateGradient(gradient: number): IParticleSystem;
  66597. /**
  66598. * Not supported by GPUParticleSystem
  66599. * @param gradient defines the gradient to use (between 0 and 1)
  66600. * @param factor defines the start size value to affect to the specified gradient
  66601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66602. * @returns the current particle system
  66603. */
  66604. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66605. /**
  66606. * Not supported by GPUParticleSystem
  66607. * @param gradient defines the gradient to remove
  66608. * @returns the current particle system
  66609. */
  66610. removeStartSizeGradient(gradient: number): IParticleSystem;
  66611. /**
  66612. * Not supported by GPUParticleSystem
  66613. * @param gradient defines the gradient to use (between 0 and 1)
  66614. * @param min defines the color remap minimal range
  66615. * @param max defines the color remap maximal range
  66616. * @returns the current particle system
  66617. */
  66618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66619. /**
  66620. * Not supported by GPUParticleSystem
  66621. * @param gradient defines the gradient to remove
  66622. * @returns the current particle system
  66623. */
  66624. removeColorRemapGradient(): IParticleSystem;
  66625. /**
  66626. * Not supported by GPUParticleSystem
  66627. * @param gradient defines the gradient to use (between 0 and 1)
  66628. * @param min defines the alpha remap minimal range
  66629. * @param max defines the alpha remap maximal range
  66630. * @returns the current particle system
  66631. */
  66632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66633. /**
  66634. * Not supported by GPUParticleSystem
  66635. * @param gradient defines the gradient to remove
  66636. * @returns the current particle system
  66637. */
  66638. removeAlphaRemapGradient(): IParticleSystem;
  66639. /**
  66640. * Not supported by GPUParticleSystem
  66641. * @param gradient defines the gradient to use (between 0 and 1)
  66642. * @param color defines the color to affect to the specified gradient
  66643. * @returns the current particle system
  66644. */
  66645. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66646. /**
  66647. * Not supported by GPUParticleSystem
  66648. * @param gradient defines the gradient to remove
  66649. * @returns the current particle system
  66650. */
  66651. removeRampGradient(): IParticleSystem;
  66652. /**
  66653. * Not supported by GPUParticleSystem
  66654. * @returns the list of ramp gradients
  66655. */
  66656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66657. /**
  66658. * Not supported by GPUParticleSystem
  66659. * Gets or sets a boolean indicating that ramp gradients must be used
  66660. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66661. */
  66662. get useRampGradients(): boolean;
  66663. set useRampGradients(value: boolean);
  66664. /**
  66665. * Not supported by GPUParticleSystem
  66666. * @param gradient defines the gradient to use (between 0 and 1)
  66667. * @param factor defines the life time factor to affect to the specified gradient
  66668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66669. * @returns the current particle system
  66670. */
  66671. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66672. /**
  66673. * Not supported by GPUParticleSystem
  66674. * @param gradient defines the gradient to remove
  66675. * @returns the current particle system
  66676. */
  66677. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66678. /**
  66679. * Instantiates a GPU particle system.
  66680. * 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.
  66681. * @param name The name of the particle system
  66682. * @param options The options used to create the system
  66683. * @param scene The scene the particle system belongs to
  66684. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66685. */
  66686. constructor(name: string, options: Partial<{
  66687. capacity: number;
  66688. randomTextureSize: number;
  66689. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66690. protected _reset(): void;
  66691. private _createUpdateVAO;
  66692. private _createRenderVAO;
  66693. private _initialize;
  66694. /** @hidden */
  66695. _recreateUpdateEffect(): void;
  66696. /** @hidden */
  66697. _recreateRenderEffect(): void;
  66698. /**
  66699. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66700. * @param preWarm defines if we are in the pre-warmimg phase
  66701. */
  66702. animate(preWarm?: boolean): void;
  66703. private _createFactorGradientTexture;
  66704. private _createSizeGradientTexture;
  66705. private _createAngularSpeedGradientTexture;
  66706. private _createVelocityGradientTexture;
  66707. private _createLimitVelocityGradientTexture;
  66708. private _createDragGradientTexture;
  66709. private _createColorGradientTexture;
  66710. /**
  66711. * Renders the particle system in its current state
  66712. * @param preWarm defines if the system should only update the particles but not render them
  66713. * @returns the current number of particles
  66714. */
  66715. render(preWarm?: boolean): number;
  66716. /**
  66717. * Rebuilds the particle system
  66718. */
  66719. rebuild(): void;
  66720. private _releaseBuffers;
  66721. private _releaseVAOs;
  66722. /**
  66723. * Disposes the particle system and free the associated resources
  66724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66725. */
  66726. dispose(disposeTexture?: boolean): void;
  66727. /**
  66728. * Clones the particle system.
  66729. * @param name The name of the cloned object
  66730. * @param newEmitter The new emitter to use
  66731. * @returns the cloned particle system
  66732. */
  66733. clone(name: string, newEmitter: any): GPUParticleSystem;
  66734. /**
  66735. * Serializes the particle system to a JSON object
  66736. * @param serializeTexture defines if the texture must be serialized as well
  66737. * @returns the JSON object
  66738. */
  66739. serialize(serializeTexture?: boolean): any;
  66740. /**
  66741. * Parses a JSON object to create a GPU particle system.
  66742. * @param parsedParticleSystem The JSON object to parse
  66743. * @param scene The scene to create the particle system in
  66744. * @param rootUrl The root url to use to load external dependencies like texture
  66745. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66746. * @returns the parsed GPU particle system
  66747. */
  66748. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66749. }
  66750. }
  66751. declare module "babylonjs/Particles/particleSystemSet" {
  66752. import { Nullable } from "babylonjs/types";
  66753. import { Color3 } from "babylonjs/Maths/math.color";
  66754. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66756. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66757. import { Scene, IDisposable } from "babylonjs/scene";
  66758. /**
  66759. * Represents a set of particle systems working together to create a specific effect
  66760. */
  66761. export class ParticleSystemSet implements IDisposable {
  66762. /**
  66763. * Gets or sets base Assets URL
  66764. */
  66765. static BaseAssetsUrl: string;
  66766. private _emitterCreationOptions;
  66767. private _emitterNode;
  66768. /**
  66769. * Gets the particle system list
  66770. */
  66771. systems: IParticleSystem[];
  66772. /**
  66773. * Gets the emitter node used with this set
  66774. */
  66775. get emitterNode(): Nullable<TransformNode>;
  66776. /**
  66777. * Creates a new emitter mesh as a sphere
  66778. * @param options defines the options used to create the sphere
  66779. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66780. * @param scene defines the hosting scene
  66781. */
  66782. setEmitterAsSphere(options: {
  66783. diameter: number;
  66784. segments: number;
  66785. color: Color3;
  66786. }, renderingGroupId: number, scene: Scene): void;
  66787. /**
  66788. * Starts all particle systems of the set
  66789. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66790. */
  66791. start(emitter?: AbstractMesh): void;
  66792. /**
  66793. * Release all associated resources
  66794. */
  66795. dispose(): void;
  66796. /**
  66797. * Serialize the set into a JSON compatible object
  66798. * @param serializeTexture defines if the texture must be serialized as well
  66799. * @returns a JSON compatible representation of the set
  66800. */
  66801. serialize(serializeTexture?: boolean): any;
  66802. /**
  66803. * Parse a new ParticleSystemSet from a serialized source
  66804. * @param data defines a JSON compatible representation of the set
  66805. * @param scene defines the hosting scene
  66806. * @param gpu defines if we want GPU particles or CPU particles
  66807. * @returns a new ParticleSystemSet
  66808. */
  66809. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66810. }
  66811. }
  66812. declare module "babylonjs/Particles/particleHelper" {
  66813. import { Nullable } from "babylonjs/types";
  66814. import { Scene } from "babylonjs/scene";
  66815. import { Vector3 } from "babylonjs/Maths/math.vector";
  66816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66817. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66818. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66819. /**
  66820. * This class is made for on one-liner static method to help creating particle system set.
  66821. */
  66822. export class ParticleHelper {
  66823. /**
  66824. * Gets or sets base Assets URL
  66825. */
  66826. static BaseAssetsUrl: string;
  66827. /** Define the Url to load snippets */
  66828. static SnippetUrl: string;
  66829. /**
  66830. * Create a default particle system that you can tweak
  66831. * @param emitter defines the emitter to use
  66832. * @param capacity defines the system capacity (default is 500 particles)
  66833. * @param scene defines the hosting scene
  66834. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66835. * @returns the new Particle system
  66836. */
  66837. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66838. /**
  66839. * This is the main static method (one-liner) of this helper to create different particle systems
  66840. * @param type This string represents the type to the particle system to create
  66841. * @param scene The scene where the particle system should live
  66842. * @param gpu If the system will use gpu
  66843. * @returns the ParticleSystemSet created
  66844. */
  66845. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66846. /**
  66847. * Static function used to export a particle system to a ParticleSystemSet variable.
  66848. * Please note that the emitter shape is not exported
  66849. * @param systems defines the particle systems to export
  66850. * @returns the created particle system set
  66851. */
  66852. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66853. /**
  66854. * Creates a particle system from a snippet saved in a remote file
  66855. * @param name defines the name of the particle system to create
  66856. * @param url defines the url to load from
  66857. * @param scene defines the hosting scene
  66858. * @param gpu If the system will use gpu
  66859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66860. * @returns a promise that will resolve to the new particle system
  66861. */
  66862. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66863. /**
  66864. * Creates a particle system from a snippet saved by the particle system editor
  66865. * @param snippetId defines the snippet to load
  66866. * @param scene defines the hosting scene
  66867. * @param gpu If the system will use gpu
  66868. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66869. * @returns a promise that will resolve to the new particle system
  66870. */
  66871. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66872. }
  66873. }
  66874. declare module "babylonjs/Particles/particleSystemComponent" {
  66875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66876. import { Effect } from "babylonjs/Materials/effect";
  66877. import "babylonjs/Shaders/particles.vertex";
  66878. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66879. module "babylonjs/Engines/engine" {
  66880. interface Engine {
  66881. /**
  66882. * Create an effect to use with particle systems.
  66883. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66884. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66885. * @param uniformsNames defines a list of attribute names
  66886. * @param samplers defines an array of string used to represent textures
  66887. * @param defines defines the string containing the defines to use to compile the shaders
  66888. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66889. * @param onCompiled defines a function to call when the effect creation is successful
  66890. * @param onError defines a function to call when the effect creation has failed
  66891. * @returns the new Effect
  66892. */
  66893. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66894. }
  66895. }
  66896. module "babylonjs/Meshes/mesh" {
  66897. interface Mesh {
  66898. /**
  66899. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66900. * @returns an array of IParticleSystem
  66901. */
  66902. getEmittedParticleSystems(): IParticleSystem[];
  66903. /**
  66904. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66905. * @returns an array of IParticleSystem
  66906. */
  66907. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66908. }
  66909. }
  66910. /**
  66911. * @hidden
  66912. */
  66913. export var _IDoNeedToBeInTheBuild: number;
  66914. }
  66915. declare module "babylonjs/Particles/pointsCloudSystem" {
  66916. import { Color4 } from "babylonjs/Maths/math";
  66917. import { Mesh } from "babylonjs/Meshes/mesh";
  66918. import { Scene, IDisposable } from "babylonjs/scene";
  66919. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66920. /** Defines the 4 color options */
  66921. export enum PointColor {
  66922. /** color value */
  66923. Color = 2,
  66924. /** uv value */
  66925. UV = 1,
  66926. /** random value */
  66927. Random = 0,
  66928. /** stated value */
  66929. Stated = 3
  66930. }
  66931. /**
  66932. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66933. * 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.
  66934. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66935. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66936. *
  66937. * Full documentation here : TO BE ENTERED
  66938. */
  66939. export class PointsCloudSystem implements IDisposable {
  66940. /**
  66941. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66942. * Example : var p = SPS.particles[i];
  66943. */
  66944. particles: CloudPoint[];
  66945. /**
  66946. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66947. */
  66948. nbParticles: number;
  66949. /**
  66950. * This a counter for your own usage. It's not set by any SPS functions.
  66951. */
  66952. counter: number;
  66953. /**
  66954. * The PCS name. This name is also given to the underlying mesh.
  66955. */
  66956. name: string;
  66957. /**
  66958. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66959. */
  66960. mesh: Mesh;
  66961. /**
  66962. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66963. * Please read :
  66964. */
  66965. vars: any;
  66966. /**
  66967. * @hidden
  66968. */
  66969. _size: number;
  66970. private _scene;
  66971. private _promises;
  66972. private _positions;
  66973. private _indices;
  66974. private _normals;
  66975. private _colors;
  66976. private _uvs;
  66977. private _indices32;
  66978. private _positions32;
  66979. private _colors32;
  66980. private _uvs32;
  66981. private _updatable;
  66982. private _isVisibilityBoxLocked;
  66983. private _alwaysVisible;
  66984. private _groups;
  66985. private _groupCounter;
  66986. private _computeParticleColor;
  66987. private _computeParticleTexture;
  66988. private _computeParticleRotation;
  66989. private _computeBoundingBox;
  66990. private _isReady;
  66991. /**
  66992. * Creates a PCS (Points Cloud System) object
  66993. * @param name (String) is the PCS name, this will be the underlying mesh name
  66994. * @param pointSize (number) is the size for each point
  66995. * @param scene (Scene) is the scene in which the PCS is added
  66996. * @param options defines the options of the PCS e.g.
  66997. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66998. */
  66999. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67000. updatable?: boolean;
  67001. });
  67002. /**
  67003. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67004. * If no points were added to the PCS, the returned mesh is just a single point.
  67005. * @returns a promise for the created mesh
  67006. */
  67007. buildMeshAsync(): Promise<Mesh>;
  67008. /**
  67009. * @hidden
  67010. */
  67011. private _buildMesh;
  67012. private _addParticle;
  67013. private _randomUnitVector;
  67014. private _getColorIndicesForCoord;
  67015. private _setPointsColorOrUV;
  67016. private _colorFromTexture;
  67017. private _calculateDensity;
  67018. /**
  67019. * Adds points to the PCS in random positions within a unit sphere
  67020. * @param nb (positive integer) the number of particles to be created from this model
  67021. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67022. * @returns the number of groups in the system
  67023. */
  67024. addPoints(nb: number, pointFunction?: any): number;
  67025. /**
  67026. * Adds points to the PCS from the surface of the model shape
  67027. * @param mesh is any Mesh object that will be used as a surface model for the points
  67028. * @param nb (positive integer) the number of particles to be created from this model
  67029. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67030. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67031. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67032. * @returns the number of groups in the system
  67033. */
  67034. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67035. /**
  67036. * Adds points to the PCS inside the model shape
  67037. * @param mesh is any Mesh object that will be used as a surface model for the points
  67038. * @param nb (positive integer) the number of particles to be created from this model
  67039. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67040. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67041. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67042. * @returns the number of groups in the system
  67043. */
  67044. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67045. /**
  67046. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67047. * This method calls `updateParticle()` for each particle of the SPS.
  67048. * For an animated SPS, it is usually called within the render loop.
  67049. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67050. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67051. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67052. * @returns the PCS.
  67053. */
  67054. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67055. /**
  67056. * Disposes the PCS.
  67057. */
  67058. dispose(): void;
  67059. /**
  67060. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67061. * doc :
  67062. * @returns the PCS.
  67063. */
  67064. refreshVisibleSize(): PointsCloudSystem;
  67065. /**
  67066. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67067. * @param size the size (float) of the visibility box
  67068. * note : this doesn't lock the PCS mesh bounding box.
  67069. * doc :
  67070. */
  67071. setVisibilityBox(size: number): void;
  67072. /**
  67073. * Gets whether the PCS is always visible or not
  67074. * doc :
  67075. */
  67076. get isAlwaysVisible(): boolean;
  67077. /**
  67078. * Sets the PCS as always visible or not
  67079. * doc :
  67080. */
  67081. set isAlwaysVisible(val: boolean);
  67082. /**
  67083. * Tells to `setParticles()` to compute the particle rotations or not
  67084. * Default value : false. The PCS is faster when it's set to false
  67085. * Note : particle rotations are only applied to parent particles
  67086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67087. */
  67088. set computeParticleRotation(val: boolean);
  67089. /**
  67090. * Tells to `setParticles()` to compute the particle colors or not.
  67091. * Default value : true. The PCS is faster when it's set to false.
  67092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67093. */
  67094. set computeParticleColor(val: boolean);
  67095. set computeParticleTexture(val: boolean);
  67096. /**
  67097. * Gets if `setParticles()` computes the particle colors or not.
  67098. * Default value : false. The PCS is faster when it's set to false.
  67099. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67100. */
  67101. get computeParticleColor(): boolean;
  67102. /**
  67103. * Gets if `setParticles()` computes the particle textures or not.
  67104. * Default value : false. The PCS is faster when it's set to false.
  67105. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67106. */
  67107. get computeParticleTexture(): boolean;
  67108. /**
  67109. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67110. */
  67111. set computeBoundingBox(val: boolean);
  67112. /**
  67113. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67114. */
  67115. get computeBoundingBox(): boolean;
  67116. /**
  67117. * This function does nothing. It may be overwritten to set all the particle first values.
  67118. * The PCS doesn't call this function, you may have to call it by your own.
  67119. * doc :
  67120. */
  67121. initParticles(): void;
  67122. /**
  67123. * This function does nothing. It may be overwritten to recycle a particle
  67124. * The PCS doesn't call this function, you can to call it
  67125. * doc :
  67126. * @param particle The particle to recycle
  67127. * @returns the recycled particle
  67128. */
  67129. recycleParticle(particle: CloudPoint): CloudPoint;
  67130. /**
  67131. * Updates a particle : this function should be overwritten by the user.
  67132. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67133. * doc :
  67134. * @example : just set a particle position or velocity and recycle conditions
  67135. * @param particle The particle to update
  67136. * @returns the updated particle
  67137. */
  67138. updateParticle(particle: CloudPoint): CloudPoint;
  67139. /**
  67140. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67141. * This does nothing and may be overwritten by the user.
  67142. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67143. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67144. * @param update the boolean update value actually passed to setParticles()
  67145. */
  67146. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67147. /**
  67148. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67149. * This will be passed three parameters.
  67150. * This does nothing and may be overwritten by the user.
  67151. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67152. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67153. * @param update the boolean update value actually passed to setParticles()
  67154. */
  67155. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67156. }
  67157. }
  67158. declare module "babylonjs/Particles/cloudPoint" {
  67159. import { Nullable } from "babylonjs/types";
  67160. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67161. import { Mesh } from "babylonjs/Meshes/mesh";
  67162. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67163. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67164. /**
  67165. * Represents one particle of a points cloud system.
  67166. */
  67167. export class CloudPoint {
  67168. /**
  67169. * particle global index
  67170. */
  67171. idx: number;
  67172. /**
  67173. * The color of the particle
  67174. */
  67175. color: Nullable<Color4>;
  67176. /**
  67177. * The world space position of the particle.
  67178. */
  67179. position: Vector3;
  67180. /**
  67181. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67182. */
  67183. rotation: Vector3;
  67184. /**
  67185. * The world space rotation quaternion of the particle.
  67186. */
  67187. rotationQuaternion: Nullable<Quaternion>;
  67188. /**
  67189. * The uv of the particle.
  67190. */
  67191. uv: Nullable<Vector2>;
  67192. /**
  67193. * The current speed of the particle.
  67194. */
  67195. velocity: Vector3;
  67196. /**
  67197. * The pivot point in the particle local space.
  67198. */
  67199. pivot: Vector3;
  67200. /**
  67201. * Must the particle be translated from its pivot point in its local space ?
  67202. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67203. * Default : false
  67204. */
  67205. translateFromPivot: boolean;
  67206. /**
  67207. * Index of this particle in the global "positions" array (Internal use)
  67208. * @hidden
  67209. */
  67210. _pos: number;
  67211. /**
  67212. * @hidden Index of this particle in the global "indices" array (Internal use)
  67213. */
  67214. _ind: number;
  67215. /**
  67216. * Group this particle belongs to
  67217. */
  67218. _group: PointsGroup;
  67219. /**
  67220. * Group id of this particle
  67221. */
  67222. groupId: number;
  67223. /**
  67224. * Index of the particle in its group id (Internal use)
  67225. */
  67226. idxInGroup: number;
  67227. /**
  67228. * @hidden Particle BoundingInfo object (Internal use)
  67229. */
  67230. _boundingInfo: BoundingInfo;
  67231. /**
  67232. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67233. */
  67234. _pcs: PointsCloudSystem;
  67235. /**
  67236. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67237. */
  67238. _stillInvisible: boolean;
  67239. /**
  67240. * @hidden Last computed particle rotation matrix
  67241. */
  67242. _rotationMatrix: number[];
  67243. /**
  67244. * Parent particle Id, if any.
  67245. * Default null.
  67246. */
  67247. parentId: Nullable<number>;
  67248. /**
  67249. * @hidden Internal global position in the PCS.
  67250. */
  67251. _globalPosition: Vector3;
  67252. /**
  67253. * Creates a Point Cloud object.
  67254. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67255. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67256. * @param group (PointsGroup) is the group the particle belongs to
  67257. * @param groupId (integer) is the group identifier in the PCS.
  67258. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67259. * @param pcs defines the PCS it is associated to
  67260. */
  67261. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67262. /**
  67263. * get point size
  67264. */
  67265. get size(): Vector3;
  67266. /**
  67267. * Set point size
  67268. */
  67269. set size(scale: Vector3);
  67270. /**
  67271. * Legacy support, changed quaternion to rotationQuaternion
  67272. */
  67273. get quaternion(): Nullable<Quaternion>;
  67274. /**
  67275. * Legacy support, changed quaternion to rotationQuaternion
  67276. */
  67277. set quaternion(q: Nullable<Quaternion>);
  67278. /**
  67279. * Returns a boolean. True if the particle intersects a mesh, else false
  67280. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67281. * @param target is the object (point or mesh) what the intersection is computed against
  67282. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67283. * @returns true if it intersects
  67284. */
  67285. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67286. /**
  67287. * get the rotation matrix of the particle
  67288. * @hidden
  67289. */
  67290. getRotationMatrix(m: Matrix): void;
  67291. }
  67292. /**
  67293. * Represents a group of points in a points cloud system
  67294. * * PCS internal tool, don't use it manually.
  67295. */
  67296. export class PointsGroup {
  67297. /**
  67298. * The group id
  67299. * @hidden
  67300. */
  67301. groupID: number;
  67302. /**
  67303. * image data for group (internal use)
  67304. * @hidden
  67305. */
  67306. _groupImageData: Nullable<ArrayBufferView>;
  67307. /**
  67308. * Image Width (internal use)
  67309. * @hidden
  67310. */
  67311. _groupImgWidth: number;
  67312. /**
  67313. * Image Height (internal use)
  67314. * @hidden
  67315. */
  67316. _groupImgHeight: number;
  67317. /**
  67318. * Custom position function (internal use)
  67319. * @hidden
  67320. */
  67321. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67322. /**
  67323. * density per facet for surface points
  67324. * @hidden
  67325. */
  67326. _groupDensity: number[];
  67327. /**
  67328. * Only when points are colored by texture carries pointer to texture list array
  67329. * @hidden
  67330. */
  67331. _textureNb: number;
  67332. /**
  67333. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67334. * PCS internal tool, don't use it manually.
  67335. * @hidden
  67336. */
  67337. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67338. }
  67339. }
  67340. declare module "babylonjs/Particles/index" {
  67341. export * from "babylonjs/Particles/baseParticleSystem";
  67342. export * from "babylonjs/Particles/EmitterTypes/index";
  67343. export * from "babylonjs/Particles/gpuParticleSystem";
  67344. export * from "babylonjs/Particles/IParticleSystem";
  67345. export * from "babylonjs/Particles/particle";
  67346. export * from "babylonjs/Particles/particleHelper";
  67347. export * from "babylonjs/Particles/particleSystem";
  67348. export * from "babylonjs/Particles/particleSystemComponent";
  67349. export * from "babylonjs/Particles/particleSystemSet";
  67350. export * from "babylonjs/Particles/solidParticle";
  67351. export * from "babylonjs/Particles/solidParticleSystem";
  67352. export * from "babylonjs/Particles/cloudPoint";
  67353. export * from "babylonjs/Particles/pointsCloudSystem";
  67354. export * from "babylonjs/Particles/subEmitter";
  67355. }
  67356. declare module "babylonjs/Physics/physicsEngineComponent" {
  67357. import { Nullable } from "babylonjs/types";
  67358. import { Observable, Observer } from "babylonjs/Misc/observable";
  67359. import { Vector3 } from "babylonjs/Maths/math.vector";
  67360. import { Mesh } from "babylonjs/Meshes/mesh";
  67361. import { ISceneComponent } from "babylonjs/sceneComponent";
  67362. import { Scene } from "babylonjs/scene";
  67363. import { Node } from "babylonjs/node";
  67364. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67365. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67366. module "babylonjs/scene" {
  67367. interface Scene {
  67368. /** @hidden (Backing field) */
  67369. _physicsEngine: Nullable<IPhysicsEngine>;
  67370. /** @hidden */
  67371. _physicsTimeAccumulator: number;
  67372. /**
  67373. * Gets the current physics engine
  67374. * @returns a IPhysicsEngine or null if none attached
  67375. */
  67376. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67377. /**
  67378. * Enables physics to the current scene
  67379. * @param gravity defines the scene's gravity for the physics engine
  67380. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67381. * @return a boolean indicating if the physics engine was initialized
  67382. */
  67383. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67384. /**
  67385. * Disables and disposes the physics engine associated with the scene
  67386. */
  67387. disablePhysicsEngine(): void;
  67388. /**
  67389. * Gets a boolean indicating if there is an active physics engine
  67390. * @returns a boolean indicating if there is an active physics engine
  67391. */
  67392. isPhysicsEnabled(): boolean;
  67393. /**
  67394. * Deletes a physics compound impostor
  67395. * @param compound defines the compound to delete
  67396. */
  67397. deleteCompoundImpostor(compound: any): void;
  67398. /**
  67399. * An event triggered when physic simulation is about to be run
  67400. */
  67401. onBeforePhysicsObservable: Observable<Scene>;
  67402. /**
  67403. * An event triggered when physic simulation has been done
  67404. */
  67405. onAfterPhysicsObservable: Observable<Scene>;
  67406. }
  67407. }
  67408. module "babylonjs/Meshes/abstractMesh" {
  67409. interface AbstractMesh {
  67410. /** @hidden */
  67411. _physicsImpostor: Nullable<PhysicsImpostor>;
  67412. /**
  67413. * Gets or sets impostor used for physic simulation
  67414. * @see http://doc.babylonjs.com/features/physics_engine
  67415. */
  67416. physicsImpostor: Nullable<PhysicsImpostor>;
  67417. /**
  67418. * Gets the current physics impostor
  67419. * @see http://doc.babylonjs.com/features/physics_engine
  67420. * @returns a physics impostor or null
  67421. */
  67422. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67423. /** Apply a physic impulse to the mesh
  67424. * @param force defines the force to apply
  67425. * @param contactPoint defines where to apply the force
  67426. * @returns the current mesh
  67427. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67428. */
  67429. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67430. /**
  67431. * Creates a physic joint between two meshes
  67432. * @param otherMesh defines the other mesh to use
  67433. * @param pivot1 defines the pivot to use on this mesh
  67434. * @param pivot2 defines the pivot to use on the other mesh
  67435. * @param options defines additional options (can be plugin dependent)
  67436. * @returns the current mesh
  67437. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67438. */
  67439. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67440. /** @hidden */
  67441. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67442. }
  67443. }
  67444. /**
  67445. * Defines the physics engine scene component responsible to manage a physics engine
  67446. */
  67447. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67448. /**
  67449. * The component name helpful to identify the component in the list of scene components.
  67450. */
  67451. readonly name: string;
  67452. /**
  67453. * The scene the component belongs to.
  67454. */
  67455. scene: Scene;
  67456. /**
  67457. * Creates a new instance of the component for the given scene
  67458. * @param scene Defines the scene to register the component in
  67459. */
  67460. constructor(scene: Scene);
  67461. /**
  67462. * Registers the component in a given scene
  67463. */
  67464. register(): void;
  67465. /**
  67466. * Rebuilds the elements related to this component in case of
  67467. * context lost for instance.
  67468. */
  67469. rebuild(): void;
  67470. /**
  67471. * Disposes the component and the associated ressources
  67472. */
  67473. dispose(): void;
  67474. }
  67475. }
  67476. declare module "babylonjs/Physics/physicsHelper" {
  67477. import { Nullable } from "babylonjs/types";
  67478. import { Vector3 } from "babylonjs/Maths/math.vector";
  67479. import { Mesh } from "babylonjs/Meshes/mesh";
  67480. import { Scene } from "babylonjs/scene";
  67481. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67482. /**
  67483. * A helper for physics simulations
  67484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67485. */
  67486. export class PhysicsHelper {
  67487. private _scene;
  67488. private _physicsEngine;
  67489. /**
  67490. * Initializes the Physics helper
  67491. * @param scene Babylon.js scene
  67492. */
  67493. constructor(scene: Scene);
  67494. /**
  67495. * Applies a radial explosion impulse
  67496. * @param origin the origin of the explosion
  67497. * @param radiusOrEventOptions the radius or the options of radial explosion
  67498. * @param strength the explosion strength
  67499. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67500. * @returns A physics radial explosion event, or null
  67501. */
  67502. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67503. /**
  67504. * Applies a radial explosion force
  67505. * @param origin the origin of the explosion
  67506. * @param radiusOrEventOptions the radius or the options of radial explosion
  67507. * @param strength the explosion strength
  67508. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67509. * @returns A physics radial explosion event, or null
  67510. */
  67511. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67512. /**
  67513. * Creates a gravitational field
  67514. * @param origin the origin of the explosion
  67515. * @param radiusOrEventOptions the radius or the options of radial explosion
  67516. * @param strength the explosion strength
  67517. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67518. * @returns A physics gravitational field event, or null
  67519. */
  67520. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67521. /**
  67522. * Creates a physics updraft event
  67523. * @param origin the origin of the updraft
  67524. * @param radiusOrEventOptions the radius or the options of the updraft
  67525. * @param strength the strength of the updraft
  67526. * @param height the height of the updraft
  67527. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67528. * @returns A physics updraft event, or null
  67529. */
  67530. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67531. /**
  67532. * Creates a physics vortex event
  67533. * @param origin the of the vortex
  67534. * @param radiusOrEventOptions the radius or the options of the vortex
  67535. * @param strength the strength of the vortex
  67536. * @param height the height of the vortex
  67537. * @returns a Physics vortex event, or null
  67538. * A physics vortex event or null
  67539. */
  67540. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67541. }
  67542. /**
  67543. * Represents a physics radial explosion event
  67544. */
  67545. class PhysicsRadialExplosionEvent {
  67546. private _scene;
  67547. private _options;
  67548. private _sphere;
  67549. private _dataFetched;
  67550. /**
  67551. * Initializes a radial explosioin event
  67552. * @param _scene BabylonJS scene
  67553. * @param _options The options for the vortex event
  67554. */
  67555. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67556. /**
  67557. * Returns the data related to the radial explosion event (sphere).
  67558. * @returns The radial explosion event data
  67559. */
  67560. getData(): PhysicsRadialExplosionEventData;
  67561. /**
  67562. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67563. * @param impostor A physics imposter
  67564. * @param origin the origin of the explosion
  67565. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67566. */
  67567. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67568. /**
  67569. * Triggers affecterd impostors callbacks
  67570. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67571. */
  67572. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67573. /**
  67574. * Disposes the sphere.
  67575. * @param force Specifies if the sphere should be disposed by force
  67576. */
  67577. dispose(force?: boolean): void;
  67578. /*** Helpers ***/
  67579. private _prepareSphere;
  67580. private _intersectsWithSphere;
  67581. }
  67582. /**
  67583. * Represents a gravitational field event
  67584. */
  67585. class PhysicsGravitationalFieldEvent {
  67586. private _physicsHelper;
  67587. private _scene;
  67588. private _origin;
  67589. private _options;
  67590. private _tickCallback;
  67591. private _sphere;
  67592. private _dataFetched;
  67593. /**
  67594. * Initializes the physics gravitational field event
  67595. * @param _physicsHelper A physics helper
  67596. * @param _scene BabylonJS scene
  67597. * @param _origin The origin position of the gravitational field event
  67598. * @param _options The options for the vortex event
  67599. */
  67600. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67601. /**
  67602. * Returns the data related to the gravitational field event (sphere).
  67603. * @returns A gravitational field event
  67604. */
  67605. getData(): PhysicsGravitationalFieldEventData;
  67606. /**
  67607. * Enables the gravitational field.
  67608. */
  67609. enable(): void;
  67610. /**
  67611. * Disables the gravitational field.
  67612. */
  67613. disable(): void;
  67614. /**
  67615. * Disposes the sphere.
  67616. * @param force The force to dispose from the gravitational field event
  67617. */
  67618. dispose(force?: boolean): void;
  67619. private _tick;
  67620. }
  67621. /**
  67622. * Represents a physics updraft event
  67623. */
  67624. class PhysicsUpdraftEvent {
  67625. private _scene;
  67626. private _origin;
  67627. private _options;
  67628. private _physicsEngine;
  67629. private _originTop;
  67630. private _originDirection;
  67631. private _tickCallback;
  67632. private _cylinder;
  67633. private _cylinderPosition;
  67634. private _dataFetched;
  67635. /**
  67636. * Initializes the physics updraft event
  67637. * @param _scene BabylonJS scene
  67638. * @param _origin The origin position of the updraft
  67639. * @param _options The options for the updraft event
  67640. */
  67641. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67642. /**
  67643. * Returns the data related to the updraft event (cylinder).
  67644. * @returns A physics updraft event
  67645. */
  67646. getData(): PhysicsUpdraftEventData;
  67647. /**
  67648. * Enables the updraft.
  67649. */
  67650. enable(): void;
  67651. /**
  67652. * Disables the updraft.
  67653. */
  67654. disable(): void;
  67655. /**
  67656. * Disposes the cylinder.
  67657. * @param force Specifies if the updraft should be disposed by force
  67658. */
  67659. dispose(force?: boolean): void;
  67660. private getImpostorHitData;
  67661. private _tick;
  67662. /*** Helpers ***/
  67663. private _prepareCylinder;
  67664. private _intersectsWithCylinder;
  67665. }
  67666. /**
  67667. * Represents a physics vortex event
  67668. */
  67669. class PhysicsVortexEvent {
  67670. private _scene;
  67671. private _origin;
  67672. private _options;
  67673. private _physicsEngine;
  67674. private _originTop;
  67675. private _tickCallback;
  67676. private _cylinder;
  67677. private _cylinderPosition;
  67678. private _dataFetched;
  67679. /**
  67680. * Initializes the physics vortex event
  67681. * @param _scene The BabylonJS scene
  67682. * @param _origin The origin position of the vortex
  67683. * @param _options The options for the vortex event
  67684. */
  67685. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67686. /**
  67687. * Returns the data related to the vortex event (cylinder).
  67688. * @returns The physics vortex event data
  67689. */
  67690. getData(): PhysicsVortexEventData;
  67691. /**
  67692. * Enables the vortex.
  67693. */
  67694. enable(): void;
  67695. /**
  67696. * Disables the cortex.
  67697. */
  67698. disable(): void;
  67699. /**
  67700. * Disposes the sphere.
  67701. * @param force
  67702. */
  67703. dispose(force?: boolean): void;
  67704. private getImpostorHitData;
  67705. private _tick;
  67706. /*** Helpers ***/
  67707. private _prepareCylinder;
  67708. private _intersectsWithCylinder;
  67709. }
  67710. /**
  67711. * Options fot the radial explosion event
  67712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67713. */
  67714. export class PhysicsRadialExplosionEventOptions {
  67715. /**
  67716. * The radius of the sphere for the radial explosion.
  67717. */
  67718. radius: number;
  67719. /**
  67720. * The strenth of the explosion.
  67721. */
  67722. strength: number;
  67723. /**
  67724. * The strenght of the force in correspondence to the distance of the affected object
  67725. */
  67726. falloff: PhysicsRadialImpulseFalloff;
  67727. /**
  67728. * Sphere options for the radial explosion.
  67729. */
  67730. sphere: {
  67731. segments: number;
  67732. diameter: number;
  67733. };
  67734. /**
  67735. * Sphere options for the radial explosion.
  67736. */
  67737. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67738. }
  67739. /**
  67740. * Options fot the updraft event
  67741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67742. */
  67743. export class PhysicsUpdraftEventOptions {
  67744. /**
  67745. * The radius of the cylinder for the vortex
  67746. */
  67747. radius: number;
  67748. /**
  67749. * The strenth of the updraft.
  67750. */
  67751. strength: number;
  67752. /**
  67753. * The height of the cylinder for the updraft.
  67754. */
  67755. height: number;
  67756. /**
  67757. * The mode for the the updraft.
  67758. */
  67759. updraftMode: PhysicsUpdraftMode;
  67760. }
  67761. /**
  67762. * Options fot the vortex event
  67763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67764. */
  67765. export class PhysicsVortexEventOptions {
  67766. /**
  67767. * The radius of the cylinder for the vortex
  67768. */
  67769. radius: number;
  67770. /**
  67771. * The strenth of the vortex.
  67772. */
  67773. strength: number;
  67774. /**
  67775. * The height of the cylinder for the vortex.
  67776. */
  67777. height: number;
  67778. /**
  67779. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67780. */
  67781. centripetalForceThreshold: number;
  67782. /**
  67783. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67784. */
  67785. centripetalForceMultiplier: number;
  67786. /**
  67787. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67788. */
  67789. centrifugalForceMultiplier: number;
  67790. /**
  67791. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67792. */
  67793. updraftForceMultiplier: number;
  67794. }
  67795. /**
  67796. * The strenght of the force in correspondence to the distance of the affected object
  67797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67798. */
  67799. export enum PhysicsRadialImpulseFalloff {
  67800. /** Defines that impulse is constant in strength across it's whole radius */
  67801. Constant = 0,
  67802. /** Defines that impulse gets weaker if it's further from the origin */
  67803. Linear = 1
  67804. }
  67805. /**
  67806. * The strength of the force in correspondence to the distance of the affected object
  67807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67808. */
  67809. export enum PhysicsUpdraftMode {
  67810. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67811. Center = 0,
  67812. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67813. Perpendicular = 1
  67814. }
  67815. /**
  67816. * Interface for a physics hit data
  67817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67818. */
  67819. export interface PhysicsHitData {
  67820. /**
  67821. * The force applied at the contact point
  67822. */
  67823. force: Vector3;
  67824. /**
  67825. * The contact point
  67826. */
  67827. contactPoint: Vector3;
  67828. /**
  67829. * The distance from the origin to the contact point
  67830. */
  67831. distanceFromOrigin: number;
  67832. }
  67833. /**
  67834. * Interface for radial explosion event data
  67835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67836. */
  67837. export interface PhysicsRadialExplosionEventData {
  67838. /**
  67839. * A sphere used for the radial explosion event
  67840. */
  67841. sphere: Mesh;
  67842. }
  67843. /**
  67844. * Interface for gravitational field event data
  67845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67846. */
  67847. export interface PhysicsGravitationalFieldEventData {
  67848. /**
  67849. * A sphere mesh used for the gravitational field event
  67850. */
  67851. sphere: Mesh;
  67852. }
  67853. /**
  67854. * Interface for updraft event data
  67855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67856. */
  67857. export interface PhysicsUpdraftEventData {
  67858. /**
  67859. * A cylinder used for the updraft event
  67860. */
  67861. cylinder: Mesh;
  67862. }
  67863. /**
  67864. * Interface for vortex event data
  67865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67866. */
  67867. export interface PhysicsVortexEventData {
  67868. /**
  67869. * A cylinder used for the vortex event
  67870. */
  67871. cylinder: Mesh;
  67872. }
  67873. /**
  67874. * Interface for an affected physics impostor
  67875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67876. */
  67877. export interface PhysicsAffectedImpostorWithData {
  67878. /**
  67879. * The impostor affected by the effect
  67880. */
  67881. impostor: PhysicsImpostor;
  67882. /**
  67883. * The data about the hit/horce from the explosion
  67884. */
  67885. hitData: PhysicsHitData;
  67886. }
  67887. }
  67888. declare module "babylonjs/Physics/Plugins/index" {
  67889. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67890. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67891. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67892. }
  67893. declare module "babylonjs/Physics/index" {
  67894. export * from "babylonjs/Physics/IPhysicsEngine";
  67895. export * from "babylonjs/Physics/physicsEngine";
  67896. export * from "babylonjs/Physics/physicsEngineComponent";
  67897. export * from "babylonjs/Physics/physicsHelper";
  67898. export * from "babylonjs/Physics/physicsImpostor";
  67899. export * from "babylonjs/Physics/physicsJoint";
  67900. export * from "babylonjs/Physics/Plugins/index";
  67901. }
  67902. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67903. /** @hidden */
  67904. export var blackAndWhitePixelShader: {
  67905. name: string;
  67906. shader: string;
  67907. };
  67908. }
  67909. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67911. import { Camera } from "babylonjs/Cameras/camera";
  67912. import { Engine } from "babylonjs/Engines/engine";
  67913. import "babylonjs/Shaders/blackAndWhite.fragment";
  67914. /**
  67915. * Post process used to render in black and white
  67916. */
  67917. export class BlackAndWhitePostProcess extends PostProcess {
  67918. /**
  67919. * Linear about to convert he result to black and white (default: 1)
  67920. */
  67921. degree: number;
  67922. /**
  67923. * Creates a black and white post process
  67924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67925. * @param name The name of the effect.
  67926. * @param options The required width/height ratio to downsize to before computing the render pass.
  67927. * @param camera The camera to apply the render pass to.
  67928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67929. * @param engine The engine which the post process will be applied. (default: current engine)
  67930. * @param reusable If the post process can be reused on the same frame. (default: false)
  67931. */
  67932. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67933. }
  67934. }
  67935. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67936. import { Nullable } from "babylonjs/types";
  67937. import { Camera } from "babylonjs/Cameras/camera";
  67938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67939. import { Engine } from "babylonjs/Engines/engine";
  67940. /**
  67941. * This represents a set of one or more post processes in Babylon.
  67942. * A post process can be used to apply a shader to a texture after it is rendered.
  67943. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67944. */
  67945. export class PostProcessRenderEffect {
  67946. private _postProcesses;
  67947. private _getPostProcesses;
  67948. private _singleInstance;
  67949. private _cameras;
  67950. private _indicesForCamera;
  67951. /**
  67952. * Name of the effect
  67953. * @hidden
  67954. */
  67955. _name: string;
  67956. /**
  67957. * Instantiates a post process render effect.
  67958. * A post process can be used to apply a shader to a texture after it is rendered.
  67959. * @param engine The engine the effect is tied to
  67960. * @param name The name of the effect
  67961. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67962. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67963. */
  67964. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67965. /**
  67966. * Checks if all the post processes in the effect are supported.
  67967. */
  67968. get isSupported(): boolean;
  67969. /**
  67970. * Updates the current state of the effect
  67971. * @hidden
  67972. */
  67973. _update(): void;
  67974. /**
  67975. * Attaches the effect on cameras
  67976. * @param cameras The camera to attach to.
  67977. * @hidden
  67978. */
  67979. _attachCameras(cameras: Camera): void;
  67980. /**
  67981. * Attaches the effect on cameras
  67982. * @param cameras The camera to attach to.
  67983. * @hidden
  67984. */
  67985. _attachCameras(cameras: Camera[]): void;
  67986. /**
  67987. * Detaches the effect on cameras
  67988. * @param cameras The camera to detatch from.
  67989. * @hidden
  67990. */
  67991. _detachCameras(cameras: Camera): void;
  67992. /**
  67993. * Detatches the effect on cameras
  67994. * @param cameras The camera to detatch from.
  67995. * @hidden
  67996. */
  67997. _detachCameras(cameras: Camera[]): void;
  67998. /**
  67999. * Enables the effect on given cameras
  68000. * @param cameras The camera to enable.
  68001. * @hidden
  68002. */
  68003. _enable(cameras: Camera): void;
  68004. /**
  68005. * Enables the effect on given cameras
  68006. * @param cameras The camera to enable.
  68007. * @hidden
  68008. */
  68009. _enable(cameras: Nullable<Camera[]>): void;
  68010. /**
  68011. * Disables the effect on the given cameras
  68012. * @param cameras The camera to disable.
  68013. * @hidden
  68014. */
  68015. _disable(cameras: Camera): void;
  68016. /**
  68017. * Disables the effect on the given cameras
  68018. * @param cameras The camera to disable.
  68019. * @hidden
  68020. */
  68021. _disable(cameras: Nullable<Camera[]>): void;
  68022. /**
  68023. * Gets a list of the post processes contained in the effect.
  68024. * @param camera The camera to get the post processes on.
  68025. * @returns The list of the post processes in the effect.
  68026. */
  68027. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68028. }
  68029. }
  68030. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68031. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68032. /** @hidden */
  68033. export var extractHighlightsPixelShader: {
  68034. name: string;
  68035. shader: string;
  68036. };
  68037. }
  68038. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68039. import { Nullable } from "babylonjs/types";
  68040. import { Camera } from "babylonjs/Cameras/camera";
  68041. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68042. import { Engine } from "babylonjs/Engines/engine";
  68043. import "babylonjs/Shaders/extractHighlights.fragment";
  68044. /**
  68045. * 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.
  68046. */
  68047. export class ExtractHighlightsPostProcess extends PostProcess {
  68048. /**
  68049. * The luminance threshold, pixels below this value will be set to black.
  68050. */
  68051. threshold: number;
  68052. /** @hidden */
  68053. _exposure: number;
  68054. /**
  68055. * Post process which has the input texture to be used when performing highlight extraction
  68056. * @hidden
  68057. */
  68058. _inputPostProcess: Nullable<PostProcess>;
  68059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68060. }
  68061. }
  68062. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68063. /** @hidden */
  68064. export var bloomMergePixelShader: {
  68065. name: string;
  68066. shader: string;
  68067. };
  68068. }
  68069. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68070. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68071. import { Nullable } from "babylonjs/types";
  68072. import { Engine } from "babylonjs/Engines/engine";
  68073. import { Camera } from "babylonjs/Cameras/camera";
  68074. import "babylonjs/Shaders/bloomMerge.fragment";
  68075. /**
  68076. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68077. */
  68078. export class BloomMergePostProcess extends PostProcess {
  68079. /** Weight of the bloom to be added to the original input. */
  68080. weight: number;
  68081. /**
  68082. * Creates a new instance of @see BloomMergePostProcess
  68083. * @param name The name of the effect.
  68084. * @param originalFromInput Post process which's input will be used for the merge.
  68085. * @param blurred Blurred highlights post process which's output will be used.
  68086. * @param weight Weight of the bloom to be added to the original input.
  68087. * @param options The required width/height ratio to downsize to before computing the render pass.
  68088. * @param camera The camera to apply the render pass to.
  68089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68090. * @param engine The engine which the post process will be applied. (default: current engine)
  68091. * @param reusable If the post process can be reused on the same frame. (default: false)
  68092. * @param textureType Type of textures used when performing the post process. (default: 0)
  68093. * @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)
  68094. */
  68095. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68096. /** Weight of the bloom to be added to the original input. */
  68097. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68098. }
  68099. }
  68100. declare module "babylonjs/PostProcesses/bloomEffect" {
  68101. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68102. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68103. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68104. import { Camera } from "babylonjs/Cameras/camera";
  68105. import { Scene } from "babylonjs/scene";
  68106. /**
  68107. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68108. */
  68109. export class BloomEffect extends PostProcessRenderEffect {
  68110. private bloomScale;
  68111. /**
  68112. * @hidden Internal
  68113. */
  68114. _effects: Array<PostProcess>;
  68115. /**
  68116. * @hidden Internal
  68117. */
  68118. _downscale: ExtractHighlightsPostProcess;
  68119. private _blurX;
  68120. private _blurY;
  68121. private _merge;
  68122. /**
  68123. * The luminance threshold to find bright areas of the image to bloom.
  68124. */
  68125. get threshold(): number;
  68126. set threshold(value: number);
  68127. /**
  68128. * The strength of the bloom.
  68129. */
  68130. get weight(): number;
  68131. set weight(value: number);
  68132. /**
  68133. * Specifies the size of the bloom blur kernel, relative to the final output size
  68134. */
  68135. get kernel(): number;
  68136. set kernel(value: number);
  68137. /**
  68138. * Creates a new instance of @see BloomEffect
  68139. * @param scene The scene the effect belongs to.
  68140. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68141. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68142. * @param bloomWeight The the strength of bloom.
  68143. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68144. * @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)
  68145. */
  68146. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68147. /**
  68148. * Disposes each of the internal effects for a given camera.
  68149. * @param camera The camera to dispose the effect on.
  68150. */
  68151. disposeEffects(camera: Camera): void;
  68152. /**
  68153. * @hidden Internal
  68154. */
  68155. _updateEffects(): void;
  68156. /**
  68157. * Internal
  68158. * @returns if all the contained post processes are ready.
  68159. * @hidden
  68160. */
  68161. _isReady(): boolean;
  68162. }
  68163. }
  68164. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68165. /** @hidden */
  68166. export var chromaticAberrationPixelShader: {
  68167. name: string;
  68168. shader: string;
  68169. };
  68170. }
  68171. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68172. import { Vector2 } from "babylonjs/Maths/math.vector";
  68173. import { Nullable } from "babylonjs/types";
  68174. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68175. import { Camera } from "babylonjs/Cameras/camera";
  68176. import { Engine } from "babylonjs/Engines/engine";
  68177. import "babylonjs/Shaders/chromaticAberration.fragment";
  68178. /**
  68179. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68180. */
  68181. export class ChromaticAberrationPostProcess extends PostProcess {
  68182. /**
  68183. * The amount of seperation of rgb channels (default: 30)
  68184. */
  68185. aberrationAmount: number;
  68186. /**
  68187. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68188. */
  68189. radialIntensity: number;
  68190. /**
  68191. * 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))
  68192. */
  68193. direction: Vector2;
  68194. /**
  68195. * 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))
  68196. */
  68197. centerPosition: Vector2;
  68198. /**
  68199. * Creates a new instance ChromaticAberrationPostProcess
  68200. * @param name The name of the effect.
  68201. * @param screenWidth The width of the screen to apply the effect on.
  68202. * @param screenHeight The height of the screen to apply the effect on.
  68203. * @param options The required width/height ratio to downsize to before computing the render pass.
  68204. * @param camera The camera to apply the render pass to.
  68205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68206. * @param engine The engine which the post process will be applied. (default: current engine)
  68207. * @param reusable If the post process can be reused on the same frame. (default: false)
  68208. * @param textureType Type of textures used when performing the post process. (default: 0)
  68209. * @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)
  68210. */
  68211. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68212. }
  68213. }
  68214. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68215. /** @hidden */
  68216. export var circleOfConfusionPixelShader: {
  68217. name: string;
  68218. shader: string;
  68219. };
  68220. }
  68221. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68222. import { Nullable } from "babylonjs/types";
  68223. import { Engine } from "babylonjs/Engines/engine";
  68224. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68226. import { Camera } from "babylonjs/Cameras/camera";
  68227. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68228. /**
  68229. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68230. */
  68231. export class CircleOfConfusionPostProcess extends PostProcess {
  68232. /**
  68233. * 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.
  68234. */
  68235. lensSize: number;
  68236. /**
  68237. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68238. */
  68239. fStop: number;
  68240. /**
  68241. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68242. */
  68243. focusDistance: number;
  68244. /**
  68245. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68246. */
  68247. focalLength: number;
  68248. private _depthTexture;
  68249. /**
  68250. * Creates a new instance CircleOfConfusionPostProcess
  68251. * @param name The name of the effect.
  68252. * @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.
  68253. * @param options The required width/height ratio to downsize to before computing the render pass.
  68254. * @param camera The camera to apply the render pass to.
  68255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68256. * @param engine The engine which the post process will be applied. (default: current engine)
  68257. * @param reusable If the post process can be reused on the same frame. (default: false)
  68258. * @param textureType Type of textures used when performing the post process. (default: 0)
  68259. * @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)
  68260. */
  68261. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68262. /**
  68263. * 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.
  68264. */
  68265. set depthTexture(value: RenderTargetTexture);
  68266. }
  68267. }
  68268. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68269. /** @hidden */
  68270. export var colorCorrectionPixelShader: {
  68271. name: string;
  68272. shader: string;
  68273. };
  68274. }
  68275. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68277. import { Engine } from "babylonjs/Engines/engine";
  68278. import { Camera } from "babylonjs/Cameras/camera";
  68279. import "babylonjs/Shaders/colorCorrection.fragment";
  68280. /**
  68281. *
  68282. * This post-process allows the modification of rendered colors by using
  68283. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68284. *
  68285. * The object needs to be provided an url to a texture containing the color
  68286. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68287. * Use an image editing software to tweak the LUT to match your needs.
  68288. *
  68289. * For an example of a color LUT, see here:
  68290. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68291. * For explanations on color grading, see here:
  68292. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68293. *
  68294. */
  68295. export class ColorCorrectionPostProcess extends PostProcess {
  68296. private _colorTableTexture;
  68297. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68298. }
  68299. }
  68300. declare module "babylonjs/Shaders/convolution.fragment" {
  68301. /** @hidden */
  68302. export var convolutionPixelShader: {
  68303. name: string;
  68304. shader: string;
  68305. };
  68306. }
  68307. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68308. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68309. import { Nullable } from "babylonjs/types";
  68310. import { Camera } from "babylonjs/Cameras/camera";
  68311. import { Engine } from "babylonjs/Engines/engine";
  68312. import "babylonjs/Shaders/convolution.fragment";
  68313. /**
  68314. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68315. * input texture to perform effects such as edge detection or sharpening
  68316. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68317. */
  68318. export class ConvolutionPostProcess extends PostProcess {
  68319. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68320. kernel: number[];
  68321. /**
  68322. * Creates a new instance ConvolutionPostProcess
  68323. * @param name The name of the effect.
  68324. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68325. * @param options The required width/height ratio to downsize to before computing the render pass.
  68326. * @param camera The camera to apply the render pass to.
  68327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68328. * @param engine The engine which the post process will be applied. (default: current engine)
  68329. * @param reusable If the post process can be reused on the same frame. (default: false)
  68330. * @param textureType Type of textures used when performing the post process. (default: 0)
  68331. */
  68332. constructor(name: string,
  68333. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68334. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68335. /**
  68336. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68337. */
  68338. static EdgeDetect0Kernel: number[];
  68339. /**
  68340. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68341. */
  68342. static EdgeDetect1Kernel: number[];
  68343. /**
  68344. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68345. */
  68346. static EdgeDetect2Kernel: number[];
  68347. /**
  68348. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68349. */
  68350. static SharpenKernel: number[];
  68351. /**
  68352. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68353. */
  68354. static EmbossKernel: number[];
  68355. /**
  68356. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68357. */
  68358. static GaussianKernel: number[];
  68359. }
  68360. }
  68361. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68362. import { Nullable } from "babylonjs/types";
  68363. import { Vector2 } from "babylonjs/Maths/math.vector";
  68364. import { Camera } from "babylonjs/Cameras/camera";
  68365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68366. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68367. import { Engine } from "babylonjs/Engines/engine";
  68368. import { Scene } from "babylonjs/scene";
  68369. /**
  68370. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68371. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68372. * based on samples that have a large difference in distance than the center pixel.
  68373. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68374. */
  68375. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68376. direction: Vector2;
  68377. /**
  68378. * Creates a new instance CircleOfConfusionPostProcess
  68379. * @param name The name of the effect.
  68380. * @param scene The scene the effect belongs to.
  68381. * @param direction The direction the blur should be applied.
  68382. * @param kernel The size of the kernel used to blur.
  68383. * @param options The required width/height ratio to downsize to before computing the render pass.
  68384. * @param camera The camera to apply the render pass to.
  68385. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68386. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68388. * @param engine The engine which the post process will be applied. (default: current engine)
  68389. * @param reusable If the post process can be reused on the same frame. (default: false)
  68390. * @param textureType Type of textures used when performing the post process. (default: 0)
  68391. * @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)
  68392. */
  68393. 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);
  68394. }
  68395. }
  68396. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68397. /** @hidden */
  68398. export var depthOfFieldMergePixelShader: {
  68399. name: string;
  68400. shader: string;
  68401. };
  68402. }
  68403. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68404. import { Nullable } from "babylonjs/types";
  68405. import { Camera } from "babylonjs/Cameras/camera";
  68406. import { Effect } from "babylonjs/Materials/effect";
  68407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68408. import { Engine } from "babylonjs/Engines/engine";
  68409. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68410. /**
  68411. * Options to be set when merging outputs from the default pipeline.
  68412. */
  68413. export class DepthOfFieldMergePostProcessOptions {
  68414. /**
  68415. * The original image to merge on top of
  68416. */
  68417. originalFromInput: PostProcess;
  68418. /**
  68419. * Parameters to perform the merge of the depth of field effect
  68420. */
  68421. depthOfField?: {
  68422. circleOfConfusion: PostProcess;
  68423. blurSteps: Array<PostProcess>;
  68424. };
  68425. /**
  68426. * Parameters to perform the merge of bloom effect
  68427. */
  68428. bloom?: {
  68429. blurred: PostProcess;
  68430. weight: number;
  68431. };
  68432. }
  68433. /**
  68434. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68435. */
  68436. export class DepthOfFieldMergePostProcess extends PostProcess {
  68437. private blurSteps;
  68438. /**
  68439. * Creates a new instance of DepthOfFieldMergePostProcess
  68440. * @param name The name of the effect.
  68441. * @param originalFromInput Post process which's input will be used for the merge.
  68442. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68443. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68444. * @param options The required width/height ratio to downsize to before computing the render pass.
  68445. * @param camera The camera to apply the render pass to.
  68446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68447. * @param engine The engine which the post process will be applied. (default: current engine)
  68448. * @param reusable If the post process can be reused on the same frame. (default: false)
  68449. * @param textureType Type of textures used when performing the post process. (default: 0)
  68450. * @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)
  68451. */
  68452. 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);
  68453. /**
  68454. * Updates the effect with the current post process compile time values and recompiles the shader.
  68455. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68456. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68457. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68458. * @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
  68459. * @param onCompiled Called when the shader has been compiled.
  68460. * @param onError Called if there is an error when compiling a shader.
  68461. */
  68462. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68463. }
  68464. }
  68465. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68466. import { Nullable } from "babylonjs/types";
  68467. import { Camera } from "babylonjs/Cameras/camera";
  68468. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68470. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68471. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68472. import { Scene } from "babylonjs/scene";
  68473. /**
  68474. * Specifies the level of max blur that should be applied when using the depth of field effect
  68475. */
  68476. export enum DepthOfFieldEffectBlurLevel {
  68477. /**
  68478. * Subtle blur
  68479. */
  68480. Low = 0,
  68481. /**
  68482. * Medium blur
  68483. */
  68484. Medium = 1,
  68485. /**
  68486. * Large blur
  68487. */
  68488. High = 2
  68489. }
  68490. /**
  68491. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68492. */
  68493. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68494. private _circleOfConfusion;
  68495. /**
  68496. * @hidden Internal, blurs from high to low
  68497. */
  68498. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68499. private _depthOfFieldBlurY;
  68500. private _dofMerge;
  68501. /**
  68502. * @hidden Internal post processes in depth of field effect
  68503. */
  68504. _effects: Array<PostProcess>;
  68505. /**
  68506. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68507. */
  68508. set focalLength(value: number);
  68509. get focalLength(): number;
  68510. /**
  68511. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68512. */
  68513. set fStop(value: number);
  68514. get fStop(): number;
  68515. /**
  68516. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68517. */
  68518. set focusDistance(value: number);
  68519. get focusDistance(): number;
  68520. /**
  68521. * 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.
  68522. */
  68523. set lensSize(value: number);
  68524. get lensSize(): number;
  68525. /**
  68526. * Creates a new instance DepthOfFieldEffect
  68527. * @param scene The scene the effect belongs to.
  68528. * @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.
  68529. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68530. * @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)
  68531. */
  68532. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68533. /**
  68534. * Get the current class name of the current effet
  68535. * @returns "DepthOfFieldEffect"
  68536. */
  68537. getClassName(): string;
  68538. /**
  68539. * 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.
  68540. */
  68541. set depthTexture(value: RenderTargetTexture);
  68542. /**
  68543. * Disposes each of the internal effects for a given camera.
  68544. * @param camera The camera to dispose the effect on.
  68545. */
  68546. disposeEffects(camera: Camera): void;
  68547. /**
  68548. * @hidden Internal
  68549. */
  68550. _updateEffects(): void;
  68551. /**
  68552. * Internal
  68553. * @returns if all the contained post processes are ready.
  68554. * @hidden
  68555. */
  68556. _isReady(): boolean;
  68557. }
  68558. }
  68559. declare module "babylonjs/Shaders/displayPass.fragment" {
  68560. /** @hidden */
  68561. export var displayPassPixelShader: {
  68562. name: string;
  68563. shader: string;
  68564. };
  68565. }
  68566. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68567. import { Nullable } from "babylonjs/types";
  68568. import { Camera } from "babylonjs/Cameras/camera";
  68569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68570. import { Engine } from "babylonjs/Engines/engine";
  68571. import "babylonjs/Shaders/displayPass.fragment";
  68572. /**
  68573. * DisplayPassPostProcess which produces an output the same as it's input
  68574. */
  68575. export class DisplayPassPostProcess extends PostProcess {
  68576. /**
  68577. * Creates the DisplayPassPostProcess
  68578. * @param name The name of the effect.
  68579. * @param options The required width/height ratio to downsize to before computing the render pass.
  68580. * @param camera The camera to apply the render pass to.
  68581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68582. * @param engine The engine which the post process will be applied. (default: current engine)
  68583. * @param reusable If the post process can be reused on the same frame. (default: false)
  68584. */
  68585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68586. }
  68587. }
  68588. declare module "babylonjs/Shaders/filter.fragment" {
  68589. /** @hidden */
  68590. export var filterPixelShader: {
  68591. name: string;
  68592. shader: string;
  68593. };
  68594. }
  68595. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68596. import { Nullable } from "babylonjs/types";
  68597. import { Matrix } from "babylonjs/Maths/math.vector";
  68598. import { Camera } from "babylonjs/Cameras/camera";
  68599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68600. import { Engine } from "babylonjs/Engines/engine";
  68601. import "babylonjs/Shaders/filter.fragment";
  68602. /**
  68603. * Applies a kernel filter to the image
  68604. */
  68605. export class FilterPostProcess extends PostProcess {
  68606. /** The matrix to be applied to the image */
  68607. kernelMatrix: Matrix;
  68608. /**
  68609. *
  68610. * @param name The name of the effect.
  68611. * @param kernelMatrix The matrix to be applied to the image
  68612. * @param options The required width/height ratio to downsize to before computing the render pass.
  68613. * @param camera The camera to apply the render pass to.
  68614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68615. * @param engine The engine which the post process will be applied. (default: current engine)
  68616. * @param reusable If the post process can be reused on the same frame. (default: false)
  68617. */
  68618. constructor(name: string,
  68619. /** The matrix to be applied to the image */
  68620. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68621. }
  68622. }
  68623. declare module "babylonjs/Shaders/fxaa.fragment" {
  68624. /** @hidden */
  68625. export var fxaaPixelShader: {
  68626. name: string;
  68627. shader: string;
  68628. };
  68629. }
  68630. declare module "babylonjs/Shaders/fxaa.vertex" {
  68631. /** @hidden */
  68632. export var fxaaVertexShader: {
  68633. name: string;
  68634. shader: string;
  68635. };
  68636. }
  68637. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68638. import { Nullable } from "babylonjs/types";
  68639. import { Camera } from "babylonjs/Cameras/camera";
  68640. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68641. import { Engine } from "babylonjs/Engines/engine";
  68642. import "babylonjs/Shaders/fxaa.fragment";
  68643. import "babylonjs/Shaders/fxaa.vertex";
  68644. /**
  68645. * Fxaa post process
  68646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68647. */
  68648. export class FxaaPostProcess extends PostProcess {
  68649. /** @hidden */
  68650. texelWidth: number;
  68651. /** @hidden */
  68652. texelHeight: number;
  68653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68654. private _getDefines;
  68655. }
  68656. }
  68657. declare module "babylonjs/Shaders/grain.fragment" {
  68658. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68659. /** @hidden */
  68660. export var grainPixelShader: {
  68661. name: string;
  68662. shader: string;
  68663. };
  68664. }
  68665. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68666. import { Nullable } from "babylonjs/types";
  68667. import { Camera } from "babylonjs/Cameras/camera";
  68668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68669. import { Engine } from "babylonjs/Engines/engine";
  68670. import "babylonjs/Shaders/grain.fragment";
  68671. /**
  68672. * The GrainPostProcess adds noise to the image at mid luminance levels
  68673. */
  68674. export class GrainPostProcess extends PostProcess {
  68675. /**
  68676. * The intensity of the grain added (default: 30)
  68677. */
  68678. intensity: number;
  68679. /**
  68680. * If the grain should be randomized on every frame
  68681. */
  68682. animated: boolean;
  68683. /**
  68684. * Creates a new instance of @see GrainPostProcess
  68685. * @param name The name of the effect.
  68686. * @param options The required width/height ratio to downsize to before computing the render pass.
  68687. * @param camera The camera to apply the render pass to.
  68688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68689. * @param engine The engine which the post process will be applied. (default: current engine)
  68690. * @param reusable If the post process can be reused on the same frame. (default: false)
  68691. * @param textureType Type of textures used when performing the post process. (default: 0)
  68692. * @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)
  68693. */
  68694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68695. }
  68696. }
  68697. declare module "babylonjs/Shaders/highlights.fragment" {
  68698. /** @hidden */
  68699. export var highlightsPixelShader: {
  68700. name: string;
  68701. shader: string;
  68702. };
  68703. }
  68704. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68705. import { Nullable } from "babylonjs/types";
  68706. import { Camera } from "babylonjs/Cameras/camera";
  68707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68708. import { Engine } from "babylonjs/Engines/engine";
  68709. import "babylonjs/Shaders/highlights.fragment";
  68710. /**
  68711. * Extracts highlights from the image
  68712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68713. */
  68714. export class HighlightsPostProcess extends PostProcess {
  68715. /**
  68716. * Extracts highlights from the image
  68717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68718. * @param name The name of the effect.
  68719. * @param options The required width/height ratio to downsize to before computing the render pass.
  68720. * @param camera The camera to apply the render pass to.
  68721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68722. * @param engine The engine which the post process will be applied. (default: current engine)
  68723. * @param reusable If the post process can be reused on the same frame. (default: false)
  68724. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68725. */
  68726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68727. }
  68728. }
  68729. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68730. /** @hidden */
  68731. export var mrtFragmentDeclaration: {
  68732. name: string;
  68733. shader: string;
  68734. };
  68735. }
  68736. declare module "babylonjs/Shaders/geometry.fragment" {
  68737. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68738. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68739. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68740. /** @hidden */
  68741. export var geometryPixelShader: {
  68742. name: string;
  68743. shader: string;
  68744. };
  68745. }
  68746. declare module "babylonjs/Shaders/geometry.vertex" {
  68747. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68750. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68751. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68752. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68753. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68754. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68755. /** @hidden */
  68756. export var geometryVertexShader: {
  68757. name: string;
  68758. shader: string;
  68759. };
  68760. }
  68761. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68762. import { Matrix } from "babylonjs/Maths/math.vector";
  68763. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68764. import { Mesh } from "babylonjs/Meshes/mesh";
  68765. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68766. import { Effect } from "babylonjs/Materials/effect";
  68767. import { Scene } from "babylonjs/scene";
  68768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68769. import "babylonjs/Shaders/geometry.fragment";
  68770. import "babylonjs/Shaders/geometry.vertex";
  68771. /** @hidden */
  68772. interface ISavedTransformationMatrix {
  68773. world: Matrix;
  68774. viewProjection: Matrix;
  68775. }
  68776. /**
  68777. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68778. */
  68779. export class GeometryBufferRenderer {
  68780. /**
  68781. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68782. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68783. */
  68784. static readonly POSITION_TEXTURE_TYPE: number;
  68785. /**
  68786. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68787. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68788. */
  68789. static readonly VELOCITY_TEXTURE_TYPE: number;
  68790. /**
  68791. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68792. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68793. */
  68794. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68795. /**
  68796. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68797. * in order to compute objects velocities when enableVelocity is set to "true"
  68798. * @hidden
  68799. */
  68800. _previousTransformationMatrices: {
  68801. [index: number]: ISavedTransformationMatrix;
  68802. };
  68803. /**
  68804. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68805. * in order to compute objects velocities when enableVelocity is set to "true"
  68806. * @hidden
  68807. */
  68808. _previousBonesTransformationMatrices: {
  68809. [index: number]: Float32Array;
  68810. };
  68811. /**
  68812. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68813. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68814. */
  68815. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68816. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68817. renderTransparentMeshes: boolean;
  68818. private _scene;
  68819. private _multiRenderTarget;
  68820. private _ratio;
  68821. private _enablePosition;
  68822. private _enableVelocity;
  68823. private _enableReflectivity;
  68824. private _positionIndex;
  68825. private _velocityIndex;
  68826. private _reflectivityIndex;
  68827. protected _effect: Effect;
  68828. protected _cachedDefines: string;
  68829. /**
  68830. * Set the render list (meshes to be rendered) used in the G buffer.
  68831. */
  68832. set renderList(meshes: Mesh[]);
  68833. /**
  68834. * Gets wether or not G buffer are supported by the running hardware.
  68835. * This requires draw buffer supports
  68836. */
  68837. get isSupported(): boolean;
  68838. /**
  68839. * Returns the index of the given texture type in the G-Buffer textures array
  68840. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68841. * @returns the index of the given texture type in the G-Buffer textures array
  68842. */
  68843. getTextureIndex(textureType: number): number;
  68844. /**
  68845. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68846. */
  68847. get enablePosition(): boolean;
  68848. /**
  68849. * Sets whether or not objects positions are enabled for the G buffer.
  68850. */
  68851. set enablePosition(enable: boolean);
  68852. /**
  68853. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68854. */
  68855. get enableVelocity(): boolean;
  68856. /**
  68857. * Sets wether or not objects velocities are enabled for the G buffer.
  68858. */
  68859. set enableVelocity(enable: boolean);
  68860. /**
  68861. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68862. */
  68863. get enableReflectivity(): boolean;
  68864. /**
  68865. * Sets wether or not objects roughness are enabled for the G buffer.
  68866. */
  68867. set enableReflectivity(enable: boolean);
  68868. /**
  68869. * Gets the scene associated with the buffer.
  68870. */
  68871. get scene(): Scene;
  68872. /**
  68873. * Gets the ratio used by the buffer during its creation.
  68874. * How big is the buffer related to the main canvas.
  68875. */
  68876. get ratio(): number;
  68877. /** @hidden */
  68878. static _SceneComponentInitialization: (scene: Scene) => void;
  68879. /**
  68880. * Creates a new G Buffer for the scene
  68881. * @param scene The scene the buffer belongs to
  68882. * @param ratio How big is the buffer related to the main canvas.
  68883. */
  68884. constructor(scene: Scene, ratio?: number);
  68885. /**
  68886. * Checks wether everything is ready to render a submesh to the G buffer.
  68887. * @param subMesh the submesh to check readiness for
  68888. * @param useInstances is the mesh drawn using instance or not
  68889. * @returns true if ready otherwise false
  68890. */
  68891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68892. /**
  68893. * Gets the current underlying G Buffer.
  68894. * @returns the buffer
  68895. */
  68896. getGBuffer(): MultiRenderTarget;
  68897. /**
  68898. * Gets the number of samples used to render the buffer (anti aliasing).
  68899. */
  68900. get samples(): number;
  68901. /**
  68902. * Sets the number of samples used to render the buffer (anti aliasing).
  68903. */
  68904. set samples(value: number);
  68905. /**
  68906. * Disposes the renderer and frees up associated resources.
  68907. */
  68908. dispose(): void;
  68909. protected _createRenderTargets(): void;
  68910. private _copyBonesTransformationMatrices;
  68911. }
  68912. }
  68913. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68914. import { Nullable } from "babylonjs/types";
  68915. import { Scene } from "babylonjs/scene";
  68916. import { ISceneComponent } from "babylonjs/sceneComponent";
  68917. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68918. module "babylonjs/scene" {
  68919. interface Scene {
  68920. /** @hidden (Backing field) */
  68921. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68922. /**
  68923. * Gets or Sets the current geometry buffer associated to the scene.
  68924. */
  68925. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68926. /**
  68927. * Enables a GeometryBufferRender and associates it with the scene
  68928. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68929. * @returns the GeometryBufferRenderer
  68930. */
  68931. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68932. /**
  68933. * Disables the GeometryBufferRender associated with the scene
  68934. */
  68935. disableGeometryBufferRenderer(): void;
  68936. }
  68937. }
  68938. /**
  68939. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68940. * in several rendering techniques.
  68941. */
  68942. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68943. /**
  68944. * The component name helpful to identify the component in the list of scene components.
  68945. */
  68946. readonly name: string;
  68947. /**
  68948. * The scene the component belongs to.
  68949. */
  68950. scene: Scene;
  68951. /**
  68952. * Creates a new instance of the component for the given scene
  68953. * @param scene Defines the scene to register the component in
  68954. */
  68955. constructor(scene: Scene);
  68956. /**
  68957. * Registers the component in a given scene
  68958. */
  68959. register(): void;
  68960. /**
  68961. * Rebuilds the elements related to this component in case of
  68962. * context lost for instance.
  68963. */
  68964. rebuild(): void;
  68965. /**
  68966. * Disposes the component and the associated ressources
  68967. */
  68968. dispose(): void;
  68969. private _gatherRenderTargets;
  68970. }
  68971. }
  68972. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68973. /** @hidden */
  68974. export var motionBlurPixelShader: {
  68975. name: string;
  68976. shader: string;
  68977. };
  68978. }
  68979. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68980. import { Nullable } from "babylonjs/types";
  68981. import { Camera } from "babylonjs/Cameras/camera";
  68982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68983. import { Scene } from "babylonjs/scene";
  68984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68985. import "babylonjs/Animations/animatable";
  68986. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68987. import "babylonjs/Shaders/motionBlur.fragment";
  68988. import { Engine } from "babylonjs/Engines/engine";
  68989. /**
  68990. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68991. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68992. * As an example, all you have to do is to create the post-process:
  68993. * var mb = new BABYLON.MotionBlurPostProcess(
  68994. * 'mb', // The name of the effect.
  68995. * scene, // The scene containing the objects to blur according to their velocity.
  68996. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68997. * camera // The camera to apply the render pass to.
  68998. * );
  68999. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69000. */
  69001. export class MotionBlurPostProcess extends PostProcess {
  69002. /**
  69003. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69004. */
  69005. motionStrength: number;
  69006. /**
  69007. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69008. */
  69009. get motionBlurSamples(): number;
  69010. /**
  69011. * Sets the number of iterations to be used for motion blur quality
  69012. */
  69013. set motionBlurSamples(samples: number);
  69014. private _motionBlurSamples;
  69015. private _geometryBufferRenderer;
  69016. /**
  69017. * Creates a new instance MotionBlurPostProcess
  69018. * @param name The name of the effect.
  69019. * @param scene The scene containing the objects to blur according to their velocity.
  69020. * @param options The required width/height ratio to downsize to before computing the render pass.
  69021. * @param camera The camera to apply the render pass to.
  69022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69023. * @param engine The engine which the post process will be applied. (default: current engine)
  69024. * @param reusable If the post process can be reused on the same frame. (default: false)
  69025. * @param textureType Type of textures used when performing the post process. (default: 0)
  69026. * @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)
  69027. */
  69028. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69029. /**
  69030. * Excludes the given skinned mesh from computing bones velocities.
  69031. * 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.
  69032. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69033. */
  69034. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69035. /**
  69036. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69037. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69038. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69039. */
  69040. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69041. /**
  69042. * Disposes the post process.
  69043. * @param camera The camera to dispose the post process on.
  69044. */
  69045. dispose(camera?: Camera): void;
  69046. }
  69047. }
  69048. declare module "babylonjs/Shaders/refraction.fragment" {
  69049. /** @hidden */
  69050. export var refractionPixelShader: {
  69051. name: string;
  69052. shader: string;
  69053. };
  69054. }
  69055. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69056. import { Color3 } from "babylonjs/Maths/math.color";
  69057. import { Camera } from "babylonjs/Cameras/camera";
  69058. import { Texture } from "babylonjs/Materials/Textures/texture";
  69059. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69060. import { Engine } from "babylonjs/Engines/engine";
  69061. import "babylonjs/Shaders/refraction.fragment";
  69062. /**
  69063. * Post process which applies a refractin texture
  69064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69065. */
  69066. export class RefractionPostProcess extends PostProcess {
  69067. /** the base color of the refraction (used to taint the rendering) */
  69068. color: Color3;
  69069. /** simulated refraction depth */
  69070. depth: number;
  69071. /** the coefficient of the base color (0 to remove base color tainting) */
  69072. colorLevel: number;
  69073. private _refTexture;
  69074. private _ownRefractionTexture;
  69075. /**
  69076. * Gets or sets the refraction texture
  69077. * Please note that you are responsible for disposing the texture if you set it manually
  69078. */
  69079. get refractionTexture(): Texture;
  69080. set refractionTexture(value: Texture);
  69081. /**
  69082. * Initializes the RefractionPostProcess
  69083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69084. * @param name The name of the effect.
  69085. * @param refractionTextureUrl Url of the refraction texture to use
  69086. * @param color the base color of the refraction (used to taint the rendering)
  69087. * @param depth simulated refraction depth
  69088. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69089. * @param camera The camera to apply the render pass to.
  69090. * @param options The required width/height ratio to downsize to before computing the render pass.
  69091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69092. * @param engine The engine which the post process will be applied. (default: current engine)
  69093. * @param reusable If the post process can be reused on the same frame. (default: false)
  69094. */
  69095. constructor(name: string, refractionTextureUrl: string,
  69096. /** the base color of the refraction (used to taint the rendering) */
  69097. color: Color3,
  69098. /** simulated refraction depth */
  69099. depth: number,
  69100. /** the coefficient of the base color (0 to remove base color tainting) */
  69101. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69102. /**
  69103. * Disposes of the post process
  69104. * @param camera Camera to dispose post process on
  69105. */
  69106. dispose(camera: Camera): void;
  69107. }
  69108. }
  69109. declare module "babylonjs/Shaders/sharpen.fragment" {
  69110. /** @hidden */
  69111. export var sharpenPixelShader: {
  69112. name: string;
  69113. shader: string;
  69114. };
  69115. }
  69116. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69117. import { Nullable } from "babylonjs/types";
  69118. import { Camera } from "babylonjs/Cameras/camera";
  69119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69120. import "babylonjs/Shaders/sharpen.fragment";
  69121. import { Engine } from "babylonjs/Engines/engine";
  69122. /**
  69123. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69125. */
  69126. export class SharpenPostProcess extends PostProcess {
  69127. /**
  69128. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69129. */
  69130. colorAmount: number;
  69131. /**
  69132. * How much sharpness should be applied (default: 0.3)
  69133. */
  69134. edgeAmount: number;
  69135. /**
  69136. * Creates a new instance ConvolutionPostProcess
  69137. * @param name The name of the effect.
  69138. * @param options The required width/height ratio to downsize to before computing the render pass.
  69139. * @param camera The camera to apply the render pass to.
  69140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69141. * @param engine The engine which the post process will be applied. (default: current engine)
  69142. * @param reusable If the post process can be reused on the same frame. (default: false)
  69143. * @param textureType Type of textures used when performing the post process. (default: 0)
  69144. * @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)
  69145. */
  69146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69147. }
  69148. }
  69149. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69150. import { Nullable } from "babylonjs/types";
  69151. import { Camera } from "babylonjs/Cameras/camera";
  69152. import { Engine } from "babylonjs/Engines/engine";
  69153. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69154. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69155. /**
  69156. * PostProcessRenderPipeline
  69157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69158. */
  69159. export class PostProcessRenderPipeline {
  69160. private engine;
  69161. private _renderEffects;
  69162. private _renderEffectsForIsolatedPass;
  69163. /**
  69164. * List of inspectable custom properties (used by the Inspector)
  69165. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69166. */
  69167. inspectableCustomProperties: IInspectable[];
  69168. /**
  69169. * @hidden
  69170. */
  69171. protected _cameras: Camera[];
  69172. /** @hidden */
  69173. _name: string;
  69174. /**
  69175. * Gets pipeline name
  69176. */
  69177. get name(): string;
  69178. /** Gets the list of attached cameras */
  69179. get cameras(): Camera[];
  69180. /**
  69181. * Initializes a PostProcessRenderPipeline
  69182. * @param engine engine to add the pipeline to
  69183. * @param name name of the pipeline
  69184. */
  69185. constructor(engine: Engine, name: string);
  69186. /**
  69187. * Gets the class name
  69188. * @returns "PostProcessRenderPipeline"
  69189. */
  69190. getClassName(): string;
  69191. /**
  69192. * If all the render effects in the pipeline are supported
  69193. */
  69194. get isSupported(): boolean;
  69195. /**
  69196. * Adds an effect to the pipeline
  69197. * @param renderEffect the effect to add
  69198. */
  69199. addEffect(renderEffect: PostProcessRenderEffect): void;
  69200. /** @hidden */
  69201. _rebuild(): void;
  69202. /** @hidden */
  69203. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69204. /** @hidden */
  69205. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69206. /** @hidden */
  69207. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69208. /** @hidden */
  69209. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69210. /** @hidden */
  69211. _attachCameras(cameras: Camera, unique: boolean): void;
  69212. /** @hidden */
  69213. _attachCameras(cameras: Camera[], unique: boolean): void;
  69214. /** @hidden */
  69215. _detachCameras(cameras: Camera): void;
  69216. /** @hidden */
  69217. _detachCameras(cameras: Nullable<Camera[]>): void;
  69218. /** @hidden */
  69219. _update(): void;
  69220. /** @hidden */
  69221. _reset(): void;
  69222. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69223. /**
  69224. * Disposes of the pipeline
  69225. */
  69226. dispose(): void;
  69227. }
  69228. }
  69229. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69230. import { Camera } from "babylonjs/Cameras/camera";
  69231. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69232. /**
  69233. * PostProcessRenderPipelineManager class
  69234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69235. */
  69236. export class PostProcessRenderPipelineManager {
  69237. private _renderPipelines;
  69238. /**
  69239. * Initializes a PostProcessRenderPipelineManager
  69240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69241. */
  69242. constructor();
  69243. /**
  69244. * Gets the list of supported render pipelines
  69245. */
  69246. get supportedPipelines(): PostProcessRenderPipeline[];
  69247. /**
  69248. * Adds a pipeline to the manager
  69249. * @param renderPipeline The pipeline to add
  69250. */
  69251. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69252. /**
  69253. * Attaches a camera to the pipeline
  69254. * @param renderPipelineName The name of the pipeline to attach to
  69255. * @param cameras the camera to attach
  69256. * @param unique if the camera can be attached multiple times to the pipeline
  69257. */
  69258. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69259. /**
  69260. * Detaches a camera from the pipeline
  69261. * @param renderPipelineName The name of the pipeline to detach from
  69262. * @param cameras the camera to detach
  69263. */
  69264. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69265. /**
  69266. * Enables an effect by name on a pipeline
  69267. * @param renderPipelineName the name of the pipeline to enable the effect in
  69268. * @param renderEffectName the name of the effect to enable
  69269. * @param cameras the cameras that the effect should be enabled on
  69270. */
  69271. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69272. /**
  69273. * Disables an effect by name on a pipeline
  69274. * @param renderPipelineName the name of the pipeline to disable the effect in
  69275. * @param renderEffectName the name of the effect to disable
  69276. * @param cameras the cameras that the effect should be disabled on
  69277. */
  69278. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69279. /**
  69280. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69281. */
  69282. update(): void;
  69283. /** @hidden */
  69284. _rebuild(): void;
  69285. /**
  69286. * Disposes of the manager and pipelines
  69287. */
  69288. dispose(): void;
  69289. }
  69290. }
  69291. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69292. import { ISceneComponent } from "babylonjs/sceneComponent";
  69293. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69294. import { Scene } from "babylonjs/scene";
  69295. module "babylonjs/scene" {
  69296. interface Scene {
  69297. /** @hidden (Backing field) */
  69298. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69299. /**
  69300. * Gets the postprocess render pipeline manager
  69301. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69302. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69303. */
  69304. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69305. }
  69306. }
  69307. /**
  69308. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69309. */
  69310. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69311. /**
  69312. * The component name helpfull to identify the component in the list of scene components.
  69313. */
  69314. readonly name: string;
  69315. /**
  69316. * The scene the component belongs to.
  69317. */
  69318. scene: Scene;
  69319. /**
  69320. * Creates a new instance of the component for the given scene
  69321. * @param scene Defines the scene to register the component in
  69322. */
  69323. constructor(scene: Scene);
  69324. /**
  69325. * Registers the component in a given scene
  69326. */
  69327. register(): void;
  69328. /**
  69329. * Rebuilds the elements related to this component in case of
  69330. * context lost for instance.
  69331. */
  69332. rebuild(): void;
  69333. /**
  69334. * Disposes the component and the associated ressources
  69335. */
  69336. dispose(): void;
  69337. private _gatherRenderTargets;
  69338. }
  69339. }
  69340. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69341. import { Nullable } from "babylonjs/types";
  69342. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69343. import { Camera } from "babylonjs/Cameras/camera";
  69344. import { IDisposable } from "babylonjs/scene";
  69345. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69346. import { Scene } from "babylonjs/scene";
  69347. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69348. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69349. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69350. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69351. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69352. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69353. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69354. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69355. import { Animation } from "babylonjs/Animations/animation";
  69356. /**
  69357. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69358. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69359. */
  69360. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69361. private _scene;
  69362. private _camerasToBeAttached;
  69363. /**
  69364. * ID of the sharpen post process,
  69365. */
  69366. private readonly SharpenPostProcessId;
  69367. /**
  69368. * @ignore
  69369. * ID of the image processing post process;
  69370. */
  69371. readonly ImageProcessingPostProcessId: string;
  69372. /**
  69373. * @ignore
  69374. * ID of the Fast Approximate Anti-Aliasing post process;
  69375. */
  69376. readonly FxaaPostProcessId: string;
  69377. /**
  69378. * ID of the chromatic aberration post process,
  69379. */
  69380. private readonly ChromaticAberrationPostProcessId;
  69381. /**
  69382. * ID of the grain post process
  69383. */
  69384. private readonly GrainPostProcessId;
  69385. /**
  69386. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69387. */
  69388. sharpen: SharpenPostProcess;
  69389. private _sharpenEffect;
  69390. private bloom;
  69391. /**
  69392. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69393. */
  69394. depthOfField: DepthOfFieldEffect;
  69395. /**
  69396. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69397. */
  69398. fxaa: FxaaPostProcess;
  69399. /**
  69400. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69401. */
  69402. imageProcessing: ImageProcessingPostProcess;
  69403. /**
  69404. * Chromatic aberration post process which will shift rgb colors in the image
  69405. */
  69406. chromaticAberration: ChromaticAberrationPostProcess;
  69407. private _chromaticAberrationEffect;
  69408. /**
  69409. * Grain post process which add noise to the image
  69410. */
  69411. grain: GrainPostProcess;
  69412. private _grainEffect;
  69413. /**
  69414. * Glow post process which adds a glow to emissive areas of the image
  69415. */
  69416. private _glowLayer;
  69417. /**
  69418. * Animations which can be used to tweak settings over a period of time
  69419. */
  69420. animations: Animation[];
  69421. private _imageProcessingConfigurationObserver;
  69422. private _sharpenEnabled;
  69423. private _bloomEnabled;
  69424. private _depthOfFieldEnabled;
  69425. private _depthOfFieldBlurLevel;
  69426. private _fxaaEnabled;
  69427. private _imageProcessingEnabled;
  69428. private _defaultPipelineTextureType;
  69429. private _bloomScale;
  69430. private _chromaticAberrationEnabled;
  69431. private _grainEnabled;
  69432. private _buildAllowed;
  69433. /**
  69434. * Gets active scene
  69435. */
  69436. get scene(): Scene;
  69437. /**
  69438. * Enable or disable the sharpen process from the pipeline
  69439. */
  69440. set sharpenEnabled(enabled: boolean);
  69441. get sharpenEnabled(): boolean;
  69442. private _resizeObserver;
  69443. private _hardwareScaleLevel;
  69444. private _bloomKernel;
  69445. /**
  69446. * Specifies the size of the bloom blur kernel, relative to the final output size
  69447. */
  69448. get bloomKernel(): number;
  69449. set bloomKernel(value: number);
  69450. /**
  69451. * Specifies the weight of the bloom in the final rendering
  69452. */
  69453. private _bloomWeight;
  69454. /**
  69455. * Specifies the luma threshold for the area that will be blurred by the bloom
  69456. */
  69457. private _bloomThreshold;
  69458. private _hdr;
  69459. /**
  69460. * The strength of the bloom.
  69461. */
  69462. set bloomWeight(value: number);
  69463. get bloomWeight(): number;
  69464. /**
  69465. * The strength of the bloom.
  69466. */
  69467. set bloomThreshold(value: number);
  69468. get bloomThreshold(): number;
  69469. /**
  69470. * The scale of the bloom, lower value will provide better performance.
  69471. */
  69472. set bloomScale(value: number);
  69473. get bloomScale(): number;
  69474. /**
  69475. * Enable or disable the bloom from the pipeline
  69476. */
  69477. set bloomEnabled(enabled: boolean);
  69478. get bloomEnabled(): boolean;
  69479. private _rebuildBloom;
  69480. /**
  69481. * If the depth of field is enabled.
  69482. */
  69483. get depthOfFieldEnabled(): boolean;
  69484. set depthOfFieldEnabled(enabled: boolean);
  69485. /**
  69486. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69487. */
  69488. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69489. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69490. /**
  69491. * If the anti aliasing is enabled.
  69492. */
  69493. set fxaaEnabled(enabled: boolean);
  69494. get fxaaEnabled(): boolean;
  69495. private _samples;
  69496. /**
  69497. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69498. */
  69499. set samples(sampleCount: number);
  69500. get samples(): number;
  69501. /**
  69502. * If image processing is enabled.
  69503. */
  69504. set imageProcessingEnabled(enabled: boolean);
  69505. get imageProcessingEnabled(): boolean;
  69506. /**
  69507. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69508. */
  69509. set glowLayerEnabled(enabled: boolean);
  69510. get glowLayerEnabled(): boolean;
  69511. /**
  69512. * Gets the glow layer (or null if not defined)
  69513. */
  69514. get glowLayer(): Nullable<GlowLayer>;
  69515. /**
  69516. * Enable or disable the chromaticAberration process from the pipeline
  69517. */
  69518. set chromaticAberrationEnabled(enabled: boolean);
  69519. get chromaticAberrationEnabled(): boolean;
  69520. /**
  69521. * Enable or disable the grain process from the pipeline
  69522. */
  69523. set grainEnabled(enabled: boolean);
  69524. get grainEnabled(): boolean;
  69525. /**
  69526. * @constructor
  69527. * @param name - The rendering pipeline name (default: "")
  69528. * @param hdr - If high dynamic range textures should be used (default: true)
  69529. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69530. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69531. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69532. */
  69533. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69534. /**
  69535. * Get the class name
  69536. * @returns "DefaultRenderingPipeline"
  69537. */
  69538. getClassName(): string;
  69539. /**
  69540. * Force the compilation of the entire pipeline.
  69541. */
  69542. prepare(): void;
  69543. private _hasCleared;
  69544. private _prevPostProcess;
  69545. private _prevPrevPostProcess;
  69546. private _setAutoClearAndTextureSharing;
  69547. private _depthOfFieldSceneObserver;
  69548. private _buildPipeline;
  69549. private _disposePostProcesses;
  69550. /**
  69551. * Adds a camera to the pipeline
  69552. * @param camera the camera to be added
  69553. */
  69554. addCamera(camera: Camera): void;
  69555. /**
  69556. * Removes a camera from the pipeline
  69557. * @param camera the camera to remove
  69558. */
  69559. removeCamera(camera: Camera): void;
  69560. /**
  69561. * Dispose of the pipeline and stop all post processes
  69562. */
  69563. dispose(): void;
  69564. /**
  69565. * Serialize the rendering pipeline (Used when exporting)
  69566. * @returns the serialized object
  69567. */
  69568. serialize(): any;
  69569. /**
  69570. * Parse the serialized pipeline
  69571. * @param source Source pipeline.
  69572. * @param scene The scene to load the pipeline to.
  69573. * @param rootUrl The URL of the serialized pipeline.
  69574. * @returns An instantiated pipeline from the serialized object.
  69575. */
  69576. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69577. }
  69578. }
  69579. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69580. /** @hidden */
  69581. export var lensHighlightsPixelShader: {
  69582. name: string;
  69583. shader: string;
  69584. };
  69585. }
  69586. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69587. /** @hidden */
  69588. export var depthOfFieldPixelShader: {
  69589. name: string;
  69590. shader: string;
  69591. };
  69592. }
  69593. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69594. import { Camera } from "babylonjs/Cameras/camera";
  69595. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69596. import { Scene } from "babylonjs/scene";
  69597. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69598. import "babylonjs/Shaders/chromaticAberration.fragment";
  69599. import "babylonjs/Shaders/lensHighlights.fragment";
  69600. import "babylonjs/Shaders/depthOfField.fragment";
  69601. /**
  69602. * BABYLON.JS Chromatic Aberration GLSL Shader
  69603. * Author: Olivier Guyot
  69604. * Separates very slightly R, G and B colors on the edges of the screen
  69605. * Inspired by Francois Tarlier & Martins Upitis
  69606. */
  69607. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69608. /**
  69609. * @ignore
  69610. * The chromatic aberration PostProcess id in the pipeline
  69611. */
  69612. LensChromaticAberrationEffect: string;
  69613. /**
  69614. * @ignore
  69615. * The highlights enhancing PostProcess id in the pipeline
  69616. */
  69617. HighlightsEnhancingEffect: string;
  69618. /**
  69619. * @ignore
  69620. * The depth-of-field PostProcess id in the pipeline
  69621. */
  69622. LensDepthOfFieldEffect: string;
  69623. private _scene;
  69624. private _depthTexture;
  69625. private _grainTexture;
  69626. private _chromaticAberrationPostProcess;
  69627. private _highlightsPostProcess;
  69628. private _depthOfFieldPostProcess;
  69629. private _edgeBlur;
  69630. private _grainAmount;
  69631. private _chromaticAberration;
  69632. private _distortion;
  69633. private _highlightsGain;
  69634. private _highlightsThreshold;
  69635. private _dofDistance;
  69636. private _dofAperture;
  69637. private _dofDarken;
  69638. private _dofPentagon;
  69639. private _blurNoise;
  69640. /**
  69641. * @constructor
  69642. *
  69643. * Effect parameters are as follow:
  69644. * {
  69645. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69646. * edge_blur: number; // from 0 to x (1 for realism)
  69647. * distortion: number; // from 0 to x (1 for realism)
  69648. * grain_amount: number; // from 0 to 1
  69649. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69650. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69651. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69652. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69653. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69654. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69655. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69656. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69657. * }
  69658. * Note: if an effect parameter is unset, effect is disabled
  69659. *
  69660. * @param name The rendering pipeline name
  69661. * @param parameters - An object containing all parameters (see above)
  69662. * @param scene The scene linked to this pipeline
  69663. * @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)
  69664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69665. */
  69666. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69667. /**
  69668. * Get the class name
  69669. * @returns "LensRenderingPipeline"
  69670. */
  69671. getClassName(): string;
  69672. /**
  69673. * Gets associated scene
  69674. */
  69675. get scene(): Scene;
  69676. /**
  69677. * Gets or sets the edge blur
  69678. */
  69679. get edgeBlur(): number;
  69680. set edgeBlur(value: number);
  69681. /**
  69682. * Gets or sets the grain amount
  69683. */
  69684. get grainAmount(): number;
  69685. set grainAmount(value: number);
  69686. /**
  69687. * Gets or sets the chromatic aberration amount
  69688. */
  69689. get chromaticAberration(): number;
  69690. set chromaticAberration(value: number);
  69691. /**
  69692. * Gets or sets the depth of field aperture
  69693. */
  69694. get dofAperture(): number;
  69695. set dofAperture(value: number);
  69696. /**
  69697. * Gets or sets the edge distortion
  69698. */
  69699. get edgeDistortion(): number;
  69700. set edgeDistortion(value: number);
  69701. /**
  69702. * Gets or sets the depth of field distortion
  69703. */
  69704. get dofDistortion(): number;
  69705. set dofDistortion(value: number);
  69706. /**
  69707. * Gets or sets the darken out of focus amount
  69708. */
  69709. get darkenOutOfFocus(): number;
  69710. set darkenOutOfFocus(value: number);
  69711. /**
  69712. * Gets or sets a boolean indicating if blur noise is enabled
  69713. */
  69714. get blurNoise(): boolean;
  69715. set blurNoise(value: boolean);
  69716. /**
  69717. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69718. */
  69719. get pentagonBokeh(): boolean;
  69720. set pentagonBokeh(value: boolean);
  69721. /**
  69722. * Gets or sets the highlight grain amount
  69723. */
  69724. get highlightsGain(): number;
  69725. set highlightsGain(value: number);
  69726. /**
  69727. * Gets or sets the highlight threshold
  69728. */
  69729. get highlightsThreshold(): number;
  69730. set highlightsThreshold(value: number);
  69731. /**
  69732. * Sets the amount of blur at the edges
  69733. * @param amount blur amount
  69734. */
  69735. setEdgeBlur(amount: number): void;
  69736. /**
  69737. * Sets edge blur to 0
  69738. */
  69739. disableEdgeBlur(): void;
  69740. /**
  69741. * Sets the amout of grain
  69742. * @param amount Amount of grain
  69743. */
  69744. setGrainAmount(amount: number): void;
  69745. /**
  69746. * Set grain amount to 0
  69747. */
  69748. disableGrain(): void;
  69749. /**
  69750. * Sets the chromatic aberration amount
  69751. * @param amount amount of chromatic aberration
  69752. */
  69753. setChromaticAberration(amount: number): void;
  69754. /**
  69755. * Sets chromatic aberration amount to 0
  69756. */
  69757. disableChromaticAberration(): void;
  69758. /**
  69759. * Sets the EdgeDistortion amount
  69760. * @param amount amount of EdgeDistortion
  69761. */
  69762. setEdgeDistortion(amount: number): void;
  69763. /**
  69764. * Sets edge distortion to 0
  69765. */
  69766. disableEdgeDistortion(): void;
  69767. /**
  69768. * Sets the FocusDistance amount
  69769. * @param amount amount of FocusDistance
  69770. */
  69771. setFocusDistance(amount: number): void;
  69772. /**
  69773. * Disables depth of field
  69774. */
  69775. disableDepthOfField(): void;
  69776. /**
  69777. * Sets the Aperture amount
  69778. * @param amount amount of Aperture
  69779. */
  69780. setAperture(amount: number): void;
  69781. /**
  69782. * Sets the DarkenOutOfFocus amount
  69783. * @param amount amount of DarkenOutOfFocus
  69784. */
  69785. setDarkenOutOfFocus(amount: number): void;
  69786. private _pentagonBokehIsEnabled;
  69787. /**
  69788. * Creates a pentagon bokeh effect
  69789. */
  69790. enablePentagonBokeh(): void;
  69791. /**
  69792. * Disables the pentagon bokeh effect
  69793. */
  69794. disablePentagonBokeh(): void;
  69795. /**
  69796. * Enables noise blur
  69797. */
  69798. enableNoiseBlur(): void;
  69799. /**
  69800. * Disables noise blur
  69801. */
  69802. disableNoiseBlur(): void;
  69803. /**
  69804. * Sets the HighlightsGain amount
  69805. * @param amount amount of HighlightsGain
  69806. */
  69807. setHighlightsGain(amount: number): void;
  69808. /**
  69809. * Sets the HighlightsThreshold amount
  69810. * @param amount amount of HighlightsThreshold
  69811. */
  69812. setHighlightsThreshold(amount: number): void;
  69813. /**
  69814. * Disables highlights
  69815. */
  69816. disableHighlights(): void;
  69817. /**
  69818. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69819. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69820. */
  69821. dispose(disableDepthRender?: boolean): void;
  69822. private _createChromaticAberrationPostProcess;
  69823. private _createHighlightsPostProcess;
  69824. private _createDepthOfFieldPostProcess;
  69825. private _createGrainTexture;
  69826. }
  69827. }
  69828. declare module "babylonjs/Shaders/ssao2.fragment" {
  69829. /** @hidden */
  69830. export var ssao2PixelShader: {
  69831. name: string;
  69832. shader: string;
  69833. };
  69834. }
  69835. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69836. /** @hidden */
  69837. export var ssaoCombinePixelShader: {
  69838. name: string;
  69839. shader: string;
  69840. };
  69841. }
  69842. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69843. import { Camera } from "babylonjs/Cameras/camera";
  69844. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69845. import { Scene } from "babylonjs/scene";
  69846. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69847. import "babylonjs/Shaders/ssao2.fragment";
  69848. import "babylonjs/Shaders/ssaoCombine.fragment";
  69849. /**
  69850. * Render pipeline to produce ssao effect
  69851. */
  69852. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69853. /**
  69854. * @ignore
  69855. * The PassPostProcess id in the pipeline that contains the original scene color
  69856. */
  69857. SSAOOriginalSceneColorEffect: string;
  69858. /**
  69859. * @ignore
  69860. * The SSAO PostProcess id in the pipeline
  69861. */
  69862. SSAORenderEffect: string;
  69863. /**
  69864. * @ignore
  69865. * The horizontal blur PostProcess id in the pipeline
  69866. */
  69867. SSAOBlurHRenderEffect: string;
  69868. /**
  69869. * @ignore
  69870. * The vertical blur PostProcess id in the pipeline
  69871. */
  69872. SSAOBlurVRenderEffect: string;
  69873. /**
  69874. * @ignore
  69875. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69876. */
  69877. SSAOCombineRenderEffect: string;
  69878. /**
  69879. * The output strength of the SSAO post-process. Default value is 1.0.
  69880. */
  69881. totalStrength: number;
  69882. /**
  69883. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69884. */
  69885. maxZ: number;
  69886. /**
  69887. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69888. */
  69889. minZAspect: number;
  69890. private _samples;
  69891. /**
  69892. * Number of samples used for the SSAO calculations. Default value is 8
  69893. */
  69894. set samples(n: number);
  69895. get samples(): number;
  69896. private _textureSamples;
  69897. /**
  69898. * Number of samples to use for antialiasing
  69899. */
  69900. set textureSamples(n: number);
  69901. get textureSamples(): number;
  69902. /**
  69903. * Ratio object used for SSAO ratio and blur ratio
  69904. */
  69905. private _ratio;
  69906. /**
  69907. * Dynamically generated sphere sampler.
  69908. */
  69909. private _sampleSphere;
  69910. /**
  69911. * Blur filter offsets
  69912. */
  69913. private _samplerOffsets;
  69914. private _expensiveBlur;
  69915. /**
  69916. * If bilateral blur should be used
  69917. */
  69918. set expensiveBlur(b: boolean);
  69919. get expensiveBlur(): boolean;
  69920. /**
  69921. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69922. */
  69923. radius: number;
  69924. /**
  69925. * The base color of the SSAO post-process
  69926. * The final result is "base + ssao" between [0, 1]
  69927. */
  69928. base: number;
  69929. /**
  69930. * Support test.
  69931. */
  69932. static get IsSupported(): boolean;
  69933. private _scene;
  69934. private _depthTexture;
  69935. private _normalTexture;
  69936. private _randomTexture;
  69937. private _originalColorPostProcess;
  69938. private _ssaoPostProcess;
  69939. private _blurHPostProcess;
  69940. private _blurVPostProcess;
  69941. private _ssaoCombinePostProcess;
  69942. /**
  69943. * Gets active scene
  69944. */
  69945. get scene(): Scene;
  69946. /**
  69947. * @constructor
  69948. * @param name The rendering pipeline name
  69949. * @param scene The scene linked to this pipeline
  69950. * @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 }
  69951. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69952. */
  69953. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69954. /**
  69955. * Get the class name
  69956. * @returns "SSAO2RenderingPipeline"
  69957. */
  69958. getClassName(): string;
  69959. /**
  69960. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69961. */
  69962. dispose(disableGeometryBufferRenderer?: boolean): void;
  69963. private _createBlurPostProcess;
  69964. /** @hidden */
  69965. _rebuild(): void;
  69966. private _bits;
  69967. private _radicalInverse_VdC;
  69968. private _hammersley;
  69969. private _hemisphereSample_uniform;
  69970. private _generateHemisphere;
  69971. private _createSSAOPostProcess;
  69972. private _createSSAOCombinePostProcess;
  69973. private _createRandomTexture;
  69974. /**
  69975. * Serialize the rendering pipeline (Used when exporting)
  69976. * @returns the serialized object
  69977. */
  69978. serialize(): any;
  69979. /**
  69980. * Parse the serialized pipeline
  69981. * @param source Source pipeline.
  69982. * @param scene The scene to load the pipeline to.
  69983. * @param rootUrl The URL of the serialized pipeline.
  69984. * @returns An instantiated pipeline from the serialized object.
  69985. */
  69986. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69987. }
  69988. }
  69989. declare module "babylonjs/Shaders/ssao.fragment" {
  69990. /** @hidden */
  69991. export var ssaoPixelShader: {
  69992. name: string;
  69993. shader: string;
  69994. };
  69995. }
  69996. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69997. import { Camera } from "babylonjs/Cameras/camera";
  69998. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69999. import { Scene } from "babylonjs/scene";
  70000. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70001. import "babylonjs/Shaders/ssao.fragment";
  70002. import "babylonjs/Shaders/ssaoCombine.fragment";
  70003. /**
  70004. * Render pipeline to produce ssao effect
  70005. */
  70006. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70007. /**
  70008. * @ignore
  70009. * The PassPostProcess id in the pipeline that contains the original scene color
  70010. */
  70011. SSAOOriginalSceneColorEffect: string;
  70012. /**
  70013. * @ignore
  70014. * The SSAO PostProcess id in the pipeline
  70015. */
  70016. SSAORenderEffect: string;
  70017. /**
  70018. * @ignore
  70019. * The horizontal blur PostProcess id in the pipeline
  70020. */
  70021. SSAOBlurHRenderEffect: string;
  70022. /**
  70023. * @ignore
  70024. * The vertical blur PostProcess id in the pipeline
  70025. */
  70026. SSAOBlurVRenderEffect: string;
  70027. /**
  70028. * @ignore
  70029. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70030. */
  70031. SSAOCombineRenderEffect: string;
  70032. /**
  70033. * The output strength of the SSAO post-process. Default value is 1.0.
  70034. */
  70035. totalStrength: number;
  70036. /**
  70037. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70038. */
  70039. radius: number;
  70040. /**
  70041. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70042. * Must not be equal to fallOff and superior to fallOff.
  70043. * Default value is 0.0075
  70044. */
  70045. area: number;
  70046. /**
  70047. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70048. * Must not be equal to area and inferior to area.
  70049. * Default value is 0.000001
  70050. */
  70051. fallOff: number;
  70052. /**
  70053. * The base color of the SSAO post-process
  70054. * The final result is "base + ssao" between [0, 1]
  70055. */
  70056. base: number;
  70057. private _scene;
  70058. private _depthTexture;
  70059. private _randomTexture;
  70060. private _originalColorPostProcess;
  70061. private _ssaoPostProcess;
  70062. private _blurHPostProcess;
  70063. private _blurVPostProcess;
  70064. private _ssaoCombinePostProcess;
  70065. private _firstUpdate;
  70066. /**
  70067. * Gets active scene
  70068. */
  70069. get scene(): Scene;
  70070. /**
  70071. * @constructor
  70072. * @param name - The rendering pipeline name
  70073. * @param scene - The scene linked to this pipeline
  70074. * @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 }
  70075. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70076. */
  70077. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70078. /**
  70079. * Get the class name
  70080. * @returns "SSAORenderingPipeline"
  70081. */
  70082. getClassName(): string;
  70083. /**
  70084. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70085. */
  70086. dispose(disableDepthRender?: boolean): void;
  70087. private _createBlurPostProcess;
  70088. /** @hidden */
  70089. _rebuild(): void;
  70090. private _createSSAOPostProcess;
  70091. private _createSSAOCombinePostProcess;
  70092. private _createRandomTexture;
  70093. }
  70094. }
  70095. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70096. /** @hidden */
  70097. export var screenSpaceReflectionPixelShader: {
  70098. name: string;
  70099. shader: string;
  70100. };
  70101. }
  70102. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70103. import { Nullable } from "babylonjs/types";
  70104. import { Camera } from "babylonjs/Cameras/camera";
  70105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70106. import { Scene } from "babylonjs/scene";
  70107. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70108. import { Engine } from "babylonjs/Engines/engine";
  70109. /**
  70110. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70111. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70112. */
  70113. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70114. /**
  70115. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70116. */
  70117. threshold: number;
  70118. /**
  70119. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70120. */
  70121. strength: number;
  70122. /**
  70123. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70124. */
  70125. reflectionSpecularFalloffExponent: number;
  70126. /**
  70127. * 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]
  70128. */
  70129. step: number;
  70130. /**
  70131. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70132. */
  70133. roughnessFactor: number;
  70134. private _geometryBufferRenderer;
  70135. private _enableSmoothReflections;
  70136. private _reflectionSamples;
  70137. private _smoothSteps;
  70138. /**
  70139. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70140. * @param name The name of the effect.
  70141. * @param scene The scene containing the objects to calculate reflections.
  70142. * @param options The required width/height ratio to downsize to before computing the render pass.
  70143. * @param camera The camera to apply the render pass to.
  70144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70145. * @param engine The engine which the post process will be applied. (default: current engine)
  70146. * @param reusable If the post process can be reused on the same frame. (default: false)
  70147. * @param textureType Type of textures used when performing the post process. (default: 0)
  70148. * @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)
  70149. */
  70150. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70151. /**
  70152. * Gets wether or not smoothing reflections is enabled.
  70153. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70154. */
  70155. get enableSmoothReflections(): boolean;
  70156. /**
  70157. * Sets wether or not smoothing reflections is enabled.
  70158. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70159. */
  70160. set enableSmoothReflections(enabled: boolean);
  70161. /**
  70162. * Gets the number of samples taken while computing reflections. More samples count is high,
  70163. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70164. */
  70165. get reflectionSamples(): number;
  70166. /**
  70167. * Sets the number of samples taken while computing reflections. More samples count is high,
  70168. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70169. */
  70170. set reflectionSamples(samples: number);
  70171. /**
  70172. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70173. * more the post-process will require GPU power and can generate a drop in FPS.
  70174. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70175. */
  70176. get smoothSteps(): number;
  70177. set smoothSteps(steps: number);
  70178. private _updateEffectDefines;
  70179. }
  70180. }
  70181. declare module "babylonjs/Shaders/standard.fragment" {
  70182. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70183. /** @hidden */
  70184. export var standardPixelShader: {
  70185. name: string;
  70186. shader: string;
  70187. };
  70188. }
  70189. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70190. import { Nullable } from "babylonjs/types";
  70191. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70192. import { Camera } from "babylonjs/Cameras/camera";
  70193. import { Texture } from "babylonjs/Materials/Textures/texture";
  70194. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70195. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70196. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70197. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70198. import { IDisposable } from "babylonjs/scene";
  70199. import { SpotLight } from "babylonjs/Lights/spotLight";
  70200. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70201. import { Scene } from "babylonjs/scene";
  70202. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70203. import { Animation } from "babylonjs/Animations/animation";
  70204. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70205. import "babylonjs/Shaders/standard.fragment";
  70206. /**
  70207. * Standard rendering pipeline
  70208. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70209. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70210. */
  70211. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70212. /**
  70213. * Public members
  70214. */
  70215. /**
  70216. * Post-process which contains the original scene color before the pipeline applies all the effects
  70217. */
  70218. originalPostProcess: Nullable<PostProcess>;
  70219. /**
  70220. * Post-process used to down scale an image x4
  70221. */
  70222. downSampleX4PostProcess: Nullable<PostProcess>;
  70223. /**
  70224. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70225. */
  70226. brightPassPostProcess: Nullable<PostProcess>;
  70227. /**
  70228. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70229. */
  70230. blurHPostProcesses: PostProcess[];
  70231. /**
  70232. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70233. */
  70234. blurVPostProcesses: PostProcess[];
  70235. /**
  70236. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70237. */
  70238. textureAdderPostProcess: Nullable<PostProcess>;
  70239. /**
  70240. * Post-process used to create volumetric lighting effect
  70241. */
  70242. volumetricLightPostProcess: Nullable<PostProcess>;
  70243. /**
  70244. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70245. */
  70246. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70247. /**
  70248. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70249. */
  70250. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70251. /**
  70252. * Post-process used to merge the volumetric light effect and the real scene color
  70253. */
  70254. volumetricLightMergePostProces: Nullable<PostProcess>;
  70255. /**
  70256. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70257. */
  70258. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70259. /**
  70260. * Base post-process used to calculate the average luminance of the final image for HDR
  70261. */
  70262. luminancePostProcess: Nullable<PostProcess>;
  70263. /**
  70264. * Post-processes used to create down sample post-processes in order to get
  70265. * the average luminance of the final image for HDR
  70266. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70267. */
  70268. luminanceDownSamplePostProcesses: PostProcess[];
  70269. /**
  70270. * Post-process used to create a HDR effect (light adaptation)
  70271. */
  70272. hdrPostProcess: Nullable<PostProcess>;
  70273. /**
  70274. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70275. */
  70276. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70277. /**
  70278. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70279. */
  70280. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70281. /**
  70282. * Post-process used to merge the final HDR post-process and the real scene color
  70283. */
  70284. hdrFinalPostProcess: Nullable<PostProcess>;
  70285. /**
  70286. * Post-process used to create a lens flare effect
  70287. */
  70288. lensFlarePostProcess: Nullable<PostProcess>;
  70289. /**
  70290. * Post-process that merges the result of the lens flare post-process and the real scene color
  70291. */
  70292. lensFlareComposePostProcess: Nullable<PostProcess>;
  70293. /**
  70294. * Post-process used to create a motion blur effect
  70295. */
  70296. motionBlurPostProcess: Nullable<PostProcess>;
  70297. /**
  70298. * Post-process used to create a depth of field effect
  70299. */
  70300. depthOfFieldPostProcess: Nullable<PostProcess>;
  70301. /**
  70302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70303. */
  70304. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70305. /**
  70306. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70307. */
  70308. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70309. /**
  70310. * Represents the brightness threshold in order to configure the illuminated surfaces
  70311. */
  70312. brightThreshold: number;
  70313. /**
  70314. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70315. */
  70316. blurWidth: number;
  70317. /**
  70318. * Sets if the blur for highlighted surfaces must be only horizontal
  70319. */
  70320. horizontalBlur: boolean;
  70321. /**
  70322. * Gets the overall exposure used by the pipeline
  70323. */
  70324. get exposure(): number;
  70325. /**
  70326. * Sets the overall exposure used by the pipeline
  70327. */
  70328. set exposure(value: number);
  70329. /**
  70330. * Texture used typically to simulate "dirty" on camera lens
  70331. */
  70332. lensTexture: Nullable<Texture>;
  70333. /**
  70334. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70335. */
  70336. volumetricLightCoefficient: number;
  70337. /**
  70338. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70339. */
  70340. volumetricLightPower: number;
  70341. /**
  70342. * Used the set the blur intensity to smooth the volumetric lights
  70343. */
  70344. volumetricLightBlurScale: number;
  70345. /**
  70346. * Light (spot or directional) used to generate the volumetric lights rays
  70347. * The source light must have a shadow generate so the pipeline can get its
  70348. * depth map
  70349. */
  70350. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70351. /**
  70352. * For eye adaptation, represents the minimum luminance the eye can see
  70353. */
  70354. hdrMinimumLuminance: number;
  70355. /**
  70356. * For eye adaptation, represents the decrease luminance speed
  70357. */
  70358. hdrDecreaseRate: number;
  70359. /**
  70360. * For eye adaptation, represents the increase luminance speed
  70361. */
  70362. hdrIncreaseRate: number;
  70363. /**
  70364. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70365. */
  70366. get hdrAutoExposure(): boolean;
  70367. /**
  70368. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70369. */
  70370. set hdrAutoExposure(value: boolean);
  70371. /**
  70372. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70373. */
  70374. lensColorTexture: Nullable<Texture>;
  70375. /**
  70376. * The overall strengh for the lens flare effect
  70377. */
  70378. lensFlareStrength: number;
  70379. /**
  70380. * Dispersion coefficient for lens flare ghosts
  70381. */
  70382. lensFlareGhostDispersal: number;
  70383. /**
  70384. * Main lens flare halo width
  70385. */
  70386. lensFlareHaloWidth: number;
  70387. /**
  70388. * Based on the lens distortion effect, defines how much the lens flare result
  70389. * is distorted
  70390. */
  70391. lensFlareDistortionStrength: number;
  70392. /**
  70393. * Configures the blur intensity used for for lens flare (halo)
  70394. */
  70395. lensFlareBlurWidth: number;
  70396. /**
  70397. * Lens star texture must be used to simulate rays on the flares and is available
  70398. * in the documentation
  70399. */
  70400. lensStarTexture: Nullable<Texture>;
  70401. /**
  70402. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70403. * flare effect by taking account of the dirt texture
  70404. */
  70405. lensFlareDirtTexture: Nullable<Texture>;
  70406. /**
  70407. * Represents the focal length for the depth of field effect
  70408. */
  70409. depthOfFieldDistance: number;
  70410. /**
  70411. * Represents the blur intensity for the blurred part of the depth of field effect
  70412. */
  70413. depthOfFieldBlurWidth: number;
  70414. /**
  70415. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70416. */
  70417. get motionStrength(): number;
  70418. /**
  70419. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70420. */
  70421. set motionStrength(strength: number);
  70422. /**
  70423. * Gets wether or not the motion blur post-process is object based or screen based.
  70424. */
  70425. get objectBasedMotionBlur(): boolean;
  70426. /**
  70427. * Sets wether or not the motion blur post-process should be object based or screen based
  70428. */
  70429. set objectBasedMotionBlur(value: boolean);
  70430. /**
  70431. * List of animations for the pipeline (IAnimatable implementation)
  70432. */
  70433. animations: Animation[];
  70434. /**
  70435. * Private members
  70436. */
  70437. private _scene;
  70438. private _currentDepthOfFieldSource;
  70439. private _basePostProcess;
  70440. private _fixedExposure;
  70441. private _currentExposure;
  70442. private _hdrAutoExposure;
  70443. private _hdrCurrentLuminance;
  70444. private _motionStrength;
  70445. private _isObjectBasedMotionBlur;
  70446. private _floatTextureType;
  70447. private _camerasToBeAttached;
  70448. private _ratio;
  70449. private _bloomEnabled;
  70450. private _depthOfFieldEnabled;
  70451. private _vlsEnabled;
  70452. private _lensFlareEnabled;
  70453. private _hdrEnabled;
  70454. private _motionBlurEnabled;
  70455. private _fxaaEnabled;
  70456. private _screenSpaceReflectionsEnabled;
  70457. private _motionBlurSamples;
  70458. private _volumetricLightStepsCount;
  70459. private _samples;
  70460. /**
  70461. * @ignore
  70462. * Specifies if the bloom pipeline is enabled
  70463. */
  70464. get BloomEnabled(): boolean;
  70465. set BloomEnabled(enabled: boolean);
  70466. /**
  70467. * @ignore
  70468. * Specifies if the depth of field pipeline is enabed
  70469. */
  70470. get DepthOfFieldEnabled(): boolean;
  70471. set DepthOfFieldEnabled(enabled: boolean);
  70472. /**
  70473. * @ignore
  70474. * Specifies if the lens flare pipeline is enabed
  70475. */
  70476. get LensFlareEnabled(): boolean;
  70477. set LensFlareEnabled(enabled: boolean);
  70478. /**
  70479. * @ignore
  70480. * Specifies if the HDR pipeline is enabled
  70481. */
  70482. get HDREnabled(): boolean;
  70483. set HDREnabled(enabled: boolean);
  70484. /**
  70485. * @ignore
  70486. * Specifies if the volumetric lights scattering effect is enabled
  70487. */
  70488. get VLSEnabled(): boolean;
  70489. set VLSEnabled(enabled: boolean);
  70490. /**
  70491. * @ignore
  70492. * Specifies if the motion blur effect is enabled
  70493. */
  70494. get MotionBlurEnabled(): boolean;
  70495. set MotionBlurEnabled(enabled: boolean);
  70496. /**
  70497. * Specifies if anti-aliasing is enabled
  70498. */
  70499. get fxaaEnabled(): boolean;
  70500. set fxaaEnabled(enabled: boolean);
  70501. /**
  70502. * Specifies if screen space reflections are enabled.
  70503. */
  70504. get screenSpaceReflectionsEnabled(): boolean;
  70505. set screenSpaceReflectionsEnabled(enabled: boolean);
  70506. /**
  70507. * Specifies the number of steps used to calculate the volumetric lights
  70508. * Typically in interval [50, 200]
  70509. */
  70510. get volumetricLightStepsCount(): number;
  70511. set volumetricLightStepsCount(count: number);
  70512. /**
  70513. * Specifies the number of samples used for the motion blur effect
  70514. * Typically in interval [16, 64]
  70515. */
  70516. get motionBlurSamples(): number;
  70517. set motionBlurSamples(samples: number);
  70518. /**
  70519. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70520. */
  70521. get samples(): number;
  70522. set samples(sampleCount: number);
  70523. /**
  70524. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70525. * @constructor
  70526. * @param name The rendering pipeline name
  70527. * @param scene The scene linked to this pipeline
  70528. * @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)
  70529. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70531. */
  70532. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70533. private _buildPipeline;
  70534. private _createDownSampleX4PostProcess;
  70535. private _createBrightPassPostProcess;
  70536. private _createBlurPostProcesses;
  70537. private _createTextureAdderPostProcess;
  70538. private _createVolumetricLightPostProcess;
  70539. private _createLuminancePostProcesses;
  70540. private _createHdrPostProcess;
  70541. private _createLensFlarePostProcess;
  70542. private _createDepthOfFieldPostProcess;
  70543. private _createMotionBlurPostProcess;
  70544. private _getDepthTexture;
  70545. private _disposePostProcesses;
  70546. /**
  70547. * Dispose of the pipeline and stop all post processes
  70548. */
  70549. dispose(): void;
  70550. /**
  70551. * Serialize the rendering pipeline (Used when exporting)
  70552. * @returns the serialized object
  70553. */
  70554. serialize(): any;
  70555. /**
  70556. * Parse the serialized pipeline
  70557. * @param source Source pipeline.
  70558. * @param scene The scene to load the pipeline to.
  70559. * @param rootUrl The URL of the serialized pipeline.
  70560. * @returns An instantiated pipeline from the serialized object.
  70561. */
  70562. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70563. /**
  70564. * Luminance steps
  70565. */
  70566. static LuminanceSteps: number;
  70567. }
  70568. }
  70569. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70570. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70573. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70574. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70575. }
  70576. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70577. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70578. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70579. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70580. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70581. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70582. }
  70583. declare module "babylonjs/Shaders/tonemap.fragment" {
  70584. /** @hidden */
  70585. export var tonemapPixelShader: {
  70586. name: string;
  70587. shader: string;
  70588. };
  70589. }
  70590. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70591. import { Camera } from "babylonjs/Cameras/camera";
  70592. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70593. import "babylonjs/Shaders/tonemap.fragment";
  70594. import { Engine } from "babylonjs/Engines/engine";
  70595. /** Defines operator used for tonemapping */
  70596. export enum TonemappingOperator {
  70597. /** Hable */
  70598. Hable = 0,
  70599. /** Reinhard */
  70600. Reinhard = 1,
  70601. /** HejiDawson */
  70602. HejiDawson = 2,
  70603. /** Photographic */
  70604. Photographic = 3
  70605. }
  70606. /**
  70607. * Defines a post process to apply tone mapping
  70608. */
  70609. export class TonemapPostProcess extends PostProcess {
  70610. private _operator;
  70611. /** Defines the required exposure adjustement */
  70612. exposureAdjustment: number;
  70613. /**
  70614. * Creates a new TonemapPostProcess
  70615. * @param name defines the name of the postprocess
  70616. * @param _operator defines the operator to use
  70617. * @param exposureAdjustment defines the required exposure adjustement
  70618. * @param camera defines the camera to use (can be null)
  70619. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70620. * @param engine defines the hosting engine (can be ignore if camera is set)
  70621. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70622. */
  70623. constructor(name: string, _operator: TonemappingOperator,
  70624. /** Defines the required exposure adjustement */
  70625. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70626. }
  70627. }
  70628. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70629. /** @hidden */
  70630. export var volumetricLightScatteringPixelShader: {
  70631. name: string;
  70632. shader: string;
  70633. };
  70634. }
  70635. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70637. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70640. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70641. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70642. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70643. /** @hidden */
  70644. export var volumetricLightScatteringPassVertexShader: {
  70645. name: string;
  70646. shader: string;
  70647. };
  70648. }
  70649. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70650. /** @hidden */
  70651. export var volumetricLightScatteringPassPixelShader: {
  70652. name: string;
  70653. shader: string;
  70654. };
  70655. }
  70656. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70657. import { Vector3 } from "babylonjs/Maths/math.vector";
  70658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70659. import { Mesh } from "babylonjs/Meshes/mesh";
  70660. import { Camera } from "babylonjs/Cameras/camera";
  70661. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70663. import { Scene } from "babylonjs/scene";
  70664. import "babylonjs/Meshes/Builders/planeBuilder";
  70665. import "babylonjs/Shaders/depth.vertex";
  70666. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70667. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70668. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70669. import { Engine } from "babylonjs/Engines/engine";
  70670. /**
  70671. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70672. */
  70673. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70674. private _volumetricLightScatteringPass;
  70675. private _volumetricLightScatteringRTT;
  70676. private _viewPort;
  70677. private _screenCoordinates;
  70678. private _cachedDefines;
  70679. /**
  70680. * If not undefined, the mesh position is computed from the attached node position
  70681. */
  70682. attachedNode: {
  70683. position: Vector3;
  70684. };
  70685. /**
  70686. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70687. */
  70688. customMeshPosition: Vector3;
  70689. /**
  70690. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70691. */
  70692. useCustomMeshPosition: boolean;
  70693. /**
  70694. * If the post-process should inverse the light scattering direction
  70695. */
  70696. invert: boolean;
  70697. /**
  70698. * The internal mesh used by the post-process
  70699. */
  70700. mesh: Mesh;
  70701. /**
  70702. * @hidden
  70703. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70704. */
  70705. get useDiffuseColor(): boolean;
  70706. set useDiffuseColor(useDiffuseColor: boolean);
  70707. /**
  70708. * Array containing the excluded meshes not rendered in the internal pass
  70709. */
  70710. excludedMeshes: AbstractMesh[];
  70711. /**
  70712. * Controls the overall intensity of the post-process
  70713. */
  70714. exposure: number;
  70715. /**
  70716. * Dissipates each sample's contribution in range [0, 1]
  70717. */
  70718. decay: number;
  70719. /**
  70720. * Controls the overall intensity of each sample
  70721. */
  70722. weight: number;
  70723. /**
  70724. * Controls the density of each sample
  70725. */
  70726. density: number;
  70727. /**
  70728. * @constructor
  70729. * @param name The post-process name
  70730. * @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)
  70731. * @param camera The camera that the post-process will be attached to
  70732. * @param mesh The mesh used to create the light scattering
  70733. * @param samples The post-process quality, default 100
  70734. * @param samplingModeThe post-process filtering mode
  70735. * @param engine The babylon engine
  70736. * @param reusable If the post-process is reusable
  70737. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70738. */
  70739. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70740. /**
  70741. * Returns the string "VolumetricLightScatteringPostProcess"
  70742. * @returns "VolumetricLightScatteringPostProcess"
  70743. */
  70744. getClassName(): string;
  70745. private _isReady;
  70746. /**
  70747. * Sets the new light position for light scattering effect
  70748. * @param position The new custom light position
  70749. */
  70750. setCustomMeshPosition(position: Vector3): void;
  70751. /**
  70752. * Returns the light position for light scattering effect
  70753. * @return Vector3 The custom light position
  70754. */
  70755. getCustomMeshPosition(): Vector3;
  70756. /**
  70757. * Disposes the internal assets and detaches the post-process from the camera
  70758. */
  70759. dispose(camera: Camera): void;
  70760. /**
  70761. * Returns the render target texture used by the post-process
  70762. * @return the render target texture used by the post-process
  70763. */
  70764. getPass(): RenderTargetTexture;
  70765. private _meshExcluded;
  70766. private _createPass;
  70767. private _updateMeshScreenCoordinates;
  70768. /**
  70769. * Creates a default mesh for the Volumeric Light Scattering post-process
  70770. * @param name The mesh name
  70771. * @param scene The scene where to create the mesh
  70772. * @return the default mesh
  70773. */
  70774. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70775. }
  70776. }
  70777. declare module "babylonjs/PostProcesses/index" {
  70778. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70779. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70780. export * from "babylonjs/PostProcesses/bloomEffect";
  70781. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70782. export * from "babylonjs/PostProcesses/blurPostProcess";
  70783. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70784. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70785. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70786. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70787. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70788. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70789. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70790. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70791. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70792. export * from "babylonjs/PostProcesses/filterPostProcess";
  70793. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70794. export * from "babylonjs/PostProcesses/grainPostProcess";
  70795. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70796. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70797. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70798. export * from "babylonjs/PostProcesses/passPostProcess";
  70799. export * from "babylonjs/PostProcesses/postProcess";
  70800. export * from "babylonjs/PostProcesses/postProcessManager";
  70801. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70802. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70803. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70804. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70805. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70806. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70807. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70808. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70809. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70810. }
  70811. declare module "babylonjs/Probes/index" {
  70812. export * from "babylonjs/Probes/reflectionProbe";
  70813. }
  70814. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70815. import { Scene } from "babylonjs/scene";
  70816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70817. import { SmartArray } from "babylonjs/Misc/smartArray";
  70818. import { ISceneComponent } from "babylonjs/sceneComponent";
  70819. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70820. import "babylonjs/Meshes/Builders/boxBuilder";
  70821. import "babylonjs/Shaders/color.fragment";
  70822. import "babylonjs/Shaders/color.vertex";
  70823. import { Color3 } from "babylonjs/Maths/math.color";
  70824. module "babylonjs/scene" {
  70825. interface Scene {
  70826. /** @hidden (Backing field) */
  70827. _boundingBoxRenderer: BoundingBoxRenderer;
  70828. /** @hidden (Backing field) */
  70829. _forceShowBoundingBoxes: boolean;
  70830. /**
  70831. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70832. */
  70833. forceShowBoundingBoxes: boolean;
  70834. /**
  70835. * Gets the bounding box renderer associated with the scene
  70836. * @returns a BoundingBoxRenderer
  70837. */
  70838. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70839. }
  70840. }
  70841. module "babylonjs/Meshes/abstractMesh" {
  70842. interface AbstractMesh {
  70843. /** @hidden (Backing field) */
  70844. _showBoundingBox: boolean;
  70845. /**
  70846. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70847. */
  70848. showBoundingBox: boolean;
  70849. }
  70850. }
  70851. /**
  70852. * Component responsible of rendering the bounding box of the meshes in a scene.
  70853. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70854. */
  70855. export class BoundingBoxRenderer implements ISceneComponent {
  70856. /**
  70857. * The component name helpfull to identify the component in the list of scene components.
  70858. */
  70859. readonly name: string;
  70860. /**
  70861. * The scene the component belongs to.
  70862. */
  70863. scene: Scene;
  70864. /**
  70865. * Color of the bounding box lines placed in front of an object
  70866. */
  70867. frontColor: Color3;
  70868. /**
  70869. * Color of the bounding box lines placed behind an object
  70870. */
  70871. backColor: Color3;
  70872. /**
  70873. * Defines if the renderer should show the back lines or not
  70874. */
  70875. showBackLines: boolean;
  70876. /**
  70877. * @hidden
  70878. */
  70879. renderList: SmartArray<BoundingBox>;
  70880. private _colorShader;
  70881. private _vertexBuffers;
  70882. private _indexBuffer;
  70883. private _fillIndexBuffer;
  70884. private _fillIndexData;
  70885. /**
  70886. * Instantiates a new bounding box renderer in a scene.
  70887. * @param scene the scene the renderer renders in
  70888. */
  70889. constructor(scene: Scene);
  70890. /**
  70891. * Registers the component in a given scene
  70892. */
  70893. register(): void;
  70894. private _evaluateSubMesh;
  70895. private _activeMesh;
  70896. private _prepareRessources;
  70897. private _createIndexBuffer;
  70898. /**
  70899. * Rebuilds the elements related to this component in case of
  70900. * context lost for instance.
  70901. */
  70902. rebuild(): void;
  70903. /**
  70904. * @hidden
  70905. */
  70906. reset(): void;
  70907. /**
  70908. * Render the bounding boxes of a specific rendering group
  70909. * @param renderingGroupId defines the rendering group to render
  70910. */
  70911. render(renderingGroupId: number): void;
  70912. /**
  70913. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70914. * @param mesh Define the mesh to render the occlusion bounding box for
  70915. */
  70916. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70917. /**
  70918. * Dispose and release the resources attached to this renderer.
  70919. */
  70920. dispose(): void;
  70921. }
  70922. }
  70923. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70924. import { Nullable } from "babylonjs/types";
  70925. import { Scene } from "babylonjs/scene";
  70926. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70927. import { Camera } from "babylonjs/Cameras/camera";
  70928. import { ISceneComponent } from "babylonjs/sceneComponent";
  70929. module "babylonjs/scene" {
  70930. interface Scene {
  70931. /** @hidden (Backing field) */
  70932. _depthRenderer: {
  70933. [id: string]: DepthRenderer;
  70934. };
  70935. /**
  70936. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70937. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70938. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70939. * @returns the created depth renderer
  70940. */
  70941. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70942. /**
  70943. * Disables a depth renderer for a given camera
  70944. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70945. */
  70946. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70947. }
  70948. }
  70949. /**
  70950. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70951. * in several rendering techniques.
  70952. */
  70953. export class DepthRendererSceneComponent implements ISceneComponent {
  70954. /**
  70955. * The component name helpfull to identify the component in the list of scene components.
  70956. */
  70957. readonly name: string;
  70958. /**
  70959. * The scene the component belongs to.
  70960. */
  70961. scene: Scene;
  70962. /**
  70963. * Creates a new instance of the component for the given scene
  70964. * @param scene Defines the scene to register the component in
  70965. */
  70966. constructor(scene: Scene);
  70967. /**
  70968. * Registers the component in a given scene
  70969. */
  70970. register(): void;
  70971. /**
  70972. * Rebuilds the elements related to this component in case of
  70973. * context lost for instance.
  70974. */
  70975. rebuild(): void;
  70976. /**
  70977. * Disposes the component and the associated ressources
  70978. */
  70979. dispose(): void;
  70980. private _gatherRenderTargets;
  70981. private _gatherActiveCameraRenderTargets;
  70982. }
  70983. }
  70984. declare module "babylonjs/Shaders/outline.fragment" {
  70985. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70986. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70987. /** @hidden */
  70988. export var outlinePixelShader: {
  70989. name: string;
  70990. shader: string;
  70991. };
  70992. }
  70993. declare module "babylonjs/Shaders/outline.vertex" {
  70994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70995. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70996. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70997. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70998. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70999. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71000. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71001. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71002. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  71003. /** @hidden */
  71004. export var outlineVertexShader: {
  71005. name: string;
  71006. shader: string;
  71007. };
  71008. }
  71009. declare module "babylonjs/Rendering/outlineRenderer" {
  71010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71011. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71012. import { Scene } from "babylonjs/scene";
  71013. import { ISceneComponent } from "babylonjs/sceneComponent";
  71014. import "babylonjs/Shaders/outline.fragment";
  71015. import "babylonjs/Shaders/outline.vertex";
  71016. module "babylonjs/scene" {
  71017. interface Scene {
  71018. /** @hidden */
  71019. _outlineRenderer: OutlineRenderer;
  71020. /**
  71021. * Gets the outline renderer associated with the scene
  71022. * @returns a OutlineRenderer
  71023. */
  71024. getOutlineRenderer(): OutlineRenderer;
  71025. }
  71026. }
  71027. module "babylonjs/Meshes/abstractMesh" {
  71028. interface AbstractMesh {
  71029. /** @hidden (Backing field) */
  71030. _renderOutline: boolean;
  71031. /**
  71032. * Gets or sets a boolean indicating if the outline must be rendered as well
  71033. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71034. */
  71035. renderOutline: boolean;
  71036. /** @hidden (Backing field) */
  71037. _renderOverlay: boolean;
  71038. /**
  71039. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71040. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71041. */
  71042. renderOverlay: boolean;
  71043. }
  71044. }
  71045. /**
  71046. * This class is responsible to draw bothe outline/overlay of meshes.
  71047. * It should not be used directly but through the available method on mesh.
  71048. */
  71049. export class OutlineRenderer implements ISceneComponent {
  71050. /**
  71051. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71052. */
  71053. private static _StencilReference;
  71054. /**
  71055. * The name of the component. Each component must have a unique name.
  71056. */
  71057. name: string;
  71058. /**
  71059. * The scene the component belongs to.
  71060. */
  71061. scene: Scene;
  71062. /**
  71063. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71064. */
  71065. zOffset: number;
  71066. private _engine;
  71067. private _effect;
  71068. private _cachedDefines;
  71069. private _savedDepthWrite;
  71070. /**
  71071. * Instantiates a new outline renderer. (There could be only one per scene).
  71072. * @param scene Defines the scene it belongs to
  71073. */
  71074. constructor(scene: Scene);
  71075. /**
  71076. * Register the component to one instance of a scene.
  71077. */
  71078. register(): void;
  71079. /**
  71080. * Rebuilds the elements related to this component in case of
  71081. * context lost for instance.
  71082. */
  71083. rebuild(): void;
  71084. /**
  71085. * Disposes the component and the associated ressources.
  71086. */
  71087. dispose(): void;
  71088. /**
  71089. * Renders the outline in the canvas.
  71090. * @param subMesh Defines the sumesh to render
  71091. * @param batch Defines the batch of meshes in case of instances
  71092. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71093. */
  71094. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71095. /**
  71096. * Returns whether or not the outline renderer is ready for a given submesh.
  71097. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71098. * @param subMesh Defines the submesh to check readyness for
  71099. * @param useInstances Defines wheter wee are trying to render instances or not
  71100. * @returns true if ready otherwise false
  71101. */
  71102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71103. private _beforeRenderingMesh;
  71104. private _afterRenderingMesh;
  71105. }
  71106. }
  71107. declare module "babylonjs/Rendering/index" {
  71108. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71109. export * from "babylonjs/Rendering/depthRenderer";
  71110. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71111. export * from "babylonjs/Rendering/edgesRenderer";
  71112. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71113. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71114. export * from "babylonjs/Rendering/outlineRenderer";
  71115. export * from "babylonjs/Rendering/renderingGroup";
  71116. export * from "babylonjs/Rendering/renderingManager";
  71117. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71118. }
  71119. declare module "babylonjs/Sprites/ISprites" {
  71120. /**
  71121. * Defines the basic options interface of a Sprite Frame Source Size.
  71122. */
  71123. export interface ISpriteJSONSpriteSourceSize {
  71124. /**
  71125. * number of the original width of the Frame
  71126. */
  71127. w: number;
  71128. /**
  71129. * number of the original height of the Frame
  71130. */
  71131. h: number;
  71132. }
  71133. /**
  71134. * Defines the basic options interface of a Sprite Frame Data.
  71135. */
  71136. export interface ISpriteJSONSpriteFrameData {
  71137. /**
  71138. * number of the x offset of the Frame
  71139. */
  71140. x: number;
  71141. /**
  71142. * number of the y offset of the Frame
  71143. */
  71144. y: number;
  71145. /**
  71146. * number of the width of the Frame
  71147. */
  71148. w: number;
  71149. /**
  71150. * number of the height of the Frame
  71151. */
  71152. h: number;
  71153. }
  71154. /**
  71155. * Defines the basic options interface of a JSON Sprite.
  71156. */
  71157. export interface ISpriteJSONSprite {
  71158. /**
  71159. * string name of the Frame
  71160. */
  71161. filename: string;
  71162. /**
  71163. * ISpriteJSONSpriteFrame basic object of the frame data
  71164. */
  71165. frame: ISpriteJSONSpriteFrameData;
  71166. /**
  71167. * boolean to flag is the frame was rotated.
  71168. */
  71169. rotated: boolean;
  71170. /**
  71171. * boolean to flag is the frame was trimmed.
  71172. */
  71173. trimmed: boolean;
  71174. /**
  71175. * ISpriteJSONSpriteFrame basic object of the source data
  71176. */
  71177. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71178. /**
  71179. * ISpriteJSONSpriteFrame basic object of the source data
  71180. */
  71181. sourceSize: ISpriteJSONSpriteSourceSize;
  71182. }
  71183. /**
  71184. * Defines the basic options interface of a JSON atlas.
  71185. */
  71186. export interface ISpriteJSONAtlas {
  71187. /**
  71188. * Array of objects that contain the frame data.
  71189. */
  71190. frames: Array<ISpriteJSONSprite>;
  71191. /**
  71192. * object basic object containing the sprite meta data.
  71193. */
  71194. meta?: object;
  71195. }
  71196. }
  71197. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71198. /** @hidden */
  71199. export var spriteMapPixelShader: {
  71200. name: string;
  71201. shader: string;
  71202. };
  71203. }
  71204. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71205. /** @hidden */
  71206. export var spriteMapVertexShader: {
  71207. name: string;
  71208. shader: string;
  71209. };
  71210. }
  71211. declare module "babylonjs/Sprites/spriteMap" {
  71212. import { IDisposable, Scene } from "babylonjs/scene";
  71213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71214. import { Texture } from "babylonjs/Materials/Textures/texture";
  71215. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71216. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71217. import "babylonjs/Meshes/Builders/planeBuilder";
  71218. import "babylonjs/Shaders/spriteMap.fragment";
  71219. import "babylonjs/Shaders/spriteMap.vertex";
  71220. /**
  71221. * Defines the basic options interface of a SpriteMap
  71222. */
  71223. export interface ISpriteMapOptions {
  71224. /**
  71225. * Vector2 of the number of cells in the grid.
  71226. */
  71227. stageSize?: Vector2;
  71228. /**
  71229. * Vector2 of the size of the output plane in World Units.
  71230. */
  71231. outputSize?: Vector2;
  71232. /**
  71233. * Vector3 of the position of the output plane in World Units.
  71234. */
  71235. outputPosition?: Vector3;
  71236. /**
  71237. * Vector3 of the rotation of the output plane.
  71238. */
  71239. outputRotation?: Vector3;
  71240. /**
  71241. * number of layers that the system will reserve in resources.
  71242. */
  71243. layerCount?: number;
  71244. /**
  71245. * number of max animation frames a single cell will reserve in resources.
  71246. */
  71247. maxAnimationFrames?: number;
  71248. /**
  71249. * number cell index of the base tile when the system compiles.
  71250. */
  71251. baseTile?: number;
  71252. /**
  71253. * boolean flip the sprite after its been repositioned by the framing data.
  71254. */
  71255. flipU?: boolean;
  71256. /**
  71257. * Vector3 scalar of the global RGB values of the SpriteMap.
  71258. */
  71259. colorMultiply?: Vector3;
  71260. }
  71261. /**
  71262. * Defines the IDisposable interface in order to be cleanable from resources.
  71263. */
  71264. export interface ISpriteMap extends IDisposable {
  71265. /**
  71266. * String name of the SpriteMap.
  71267. */
  71268. name: string;
  71269. /**
  71270. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71271. */
  71272. atlasJSON: ISpriteJSONAtlas;
  71273. /**
  71274. * Texture of the SpriteMap.
  71275. */
  71276. spriteSheet: Texture;
  71277. /**
  71278. * The parameters to initialize the SpriteMap with.
  71279. */
  71280. options: ISpriteMapOptions;
  71281. }
  71282. /**
  71283. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71284. */
  71285. export class SpriteMap implements ISpriteMap {
  71286. /** The Name of the spriteMap */
  71287. name: string;
  71288. /** The JSON file with the frame and meta data */
  71289. atlasJSON: ISpriteJSONAtlas;
  71290. /** The systems Sprite Sheet Texture */
  71291. spriteSheet: Texture;
  71292. /** Arguments passed with the Constructor */
  71293. options: ISpriteMapOptions;
  71294. /** Public Sprite Storage array, parsed from atlasJSON */
  71295. sprites: Array<ISpriteJSONSprite>;
  71296. /** Returns the Number of Sprites in the System */
  71297. get spriteCount(): number;
  71298. /** Returns the Position of Output Plane*/
  71299. get position(): Vector3;
  71300. /** Returns the Position of Output Plane*/
  71301. set position(v: Vector3);
  71302. /** Returns the Rotation of Output Plane*/
  71303. get rotation(): Vector3;
  71304. /** Returns the Rotation of Output Plane*/
  71305. set rotation(v: Vector3);
  71306. /** Sets the AnimationMap*/
  71307. get animationMap(): RawTexture;
  71308. /** Sets the AnimationMap*/
  71309. set animationMap(v: RawTexture);
  71310. /** Scene that the SpriteMap was created in */
  71311. private _scene;
  71312. /** Texture Buffer of Float32 that holds tile frame data*/
  71313. private _frameMap;
  71314. /** Texture Buffers of Float32 that holds tileMap data*/
  71315. private _tileMaps;
  71316. /** Texture Buffer of Float32 that holds Animation Data*/
  71317. private _animationMap;
  71318. /** Custom ShaderMaterial Central to the System*/
  71319. private _material;
  71320. /** Custom ShaderMaterial Central to the System*/
  71321. private _output;
  71322. /** Systems Time Ticker*/
  71323. private _time;
  71324. /**
  71325. * Creates a new SpriteMap
  71326. * @param name defines the SpriteMaps Name
  71327. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71328. * @param spriteSheet is the Texture that the Sprites are on.
  71329. * @param options a basic deployment configuration
  71330. * @param scene The Scene that the map is deployed on
  71331. */
  71332. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71333. /**
  71334. * Returns tileID location
  71335. * @returns Vector2 the cell position ID
  71336. */
  71337. getTileID(): Vector2;
  71338. /**
  71339. * Gets the UV location of the mouse over the SpriteMap.
  71340. * @returns Vector2 the UV position of the mouse interaction
  71341. */
  71342. getMousePosition(): Vector2;
  71343. /**
  71344. * Creates the "frame" texture Buffer
  71345. * -------------------------------------
  71346. * Structure of frames
  71347. * "filename": "Falling-Water-2.png",
  71348. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71349. * "rotated": true,
  71350. * "trimmed": true,
  71351. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71352. * "sourceSize": {"w":32,"h":32}
  71353. * @returns RawTexture of the frameMap
  71354. */
  71355. private _createFrameBuffer;
  71356. /**
  71357. * Creates the tileMap texture Buffer
  71358. * @param buffer normally and array of numbers, or a false to generate from scratch
  71359. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71360. * @returns RawTexture of the tileMap
  71361. */
  71362. private _createTileBuffer;
  71363. /**
  71364. * Modifies the data of the tileMaps
  71365. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71366. * @param pos is the iVector2 Coordinates of the Tile
  71367. * @param tile The SpriteIndex of the new Tile
  71368. */
  71369. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71370. /**
  71371. * Creates the animationMap texture Buffer
  71372. * @param buffer normally and array of numbers, or a false to generate from scratch
  71373. * @returns RawTexture of the animationMap
  71374. */
  71375. private _createTileAnimationBuffer;
  71376. /**
  71377. * Modifies the data of the animationMap
  71378. * @param cellID is the Index of the Sprite
  71379. * @param _frame is the target Animation frame
  71380. * @param toCell is the Target Index of the next frame of the animation
  71381. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71382. * @param speed is a global scalar of the time variable on the map.
  71383. */
  71384. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71385. /**
  71386. * Exports the .tilemaps file
  71387. */
  71388. saveTileMaps(): void;
  71389. /**
  71390. * Imports the .tilemaps file
  71391. * @param url of the .tilemaps file
  71392. */
  71393. loadTileMaps(url: string): void;
  71394. /**
  71395. * Release associated resources
  71396. */
  71397. dispose(): void;
  71398. }
  71399. }
  71400. declare module "babylonjs/Sprites/spritePackedManager" {
  71401. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71402. import { Scene } from "babylonjs/scene";
  71403. /**
  71404. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71405. * @see http://doc.babylonjs.com/babylon101/sprites
  71406. */
  71407. export class SpritePackedManager extends SpriteManager {
  71408. /** defines the packed manager's name */
  71409. name: string;
  71410. /**
  71411. * Creates a new sprite manager from a packed sprite sheet
  71412. * @param name defines the manager's name
  71413. * @param imgUrl defines the sprite sheet url
  71414. * @param capacity defines the maximum allowed number of sprites
  71415. * @param scene defines the hosting scene
  71416. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71417. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71418. * @param samplingMode defines the smapling mode to use with spritesheet
  71419. * @param fromPacked set to true; do not alter
  71420. */
  71421. constructor(
  71422. /** defines the packed manager's name */
  71423. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71424. }
  71425. }
  71426. declare module "babylonjs/Sprites/index" {
  71427. export * from "babylonjs/Sprites/sprite";
  71428. export * from "babylonjs/Sprites/ISprites";
  71429. export * from "babylonjs/Sprites/spriteManager";
  71430. export * from "babylonjs/Sprites/spriteMap";
  71431. export * from "babylonjs/Sprites/spritePackedManager";
  71432. export * from "babylonjs/Sprites/spriteSceneComponent";
  71433. }
  71434. declare module "babylonjs/States/index" {
  71435. export * from "babylonjs/States/alphaCullingState";
  71436. export * from "babylonjs/States/depthCullingState";
  71437. export * from "babylonjs/States/stencilState";
  71438. }
  71439. declare module "babylonjs/Misc/assetsManager" {
  71440. import { Scene } from "babylonjs/scene";
  71441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71442. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71443. import { Skeleton } from "babylonjs/Bones/skeleton";
  71444. import { Observable } from "babylonjs/Misc/observable";
  71445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71446. import { Texture } from "babylonjs/Materials/Textures/texture";
  71447. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71448. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71449. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71450. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71451. /**
  71452. * Defines the list of states available for a task inside a AssetsManager
  71453. */
  71454. export enum AssetTaskState {
  71455. /**
  71456. * Initialization
  71457. */
  71458. INIT = 0,
  71459. /**
  71460. * Running
  71461. */
  71462. RUNNING = 1,
  71463. /**
  71464. * Done
  71465. */
  71466. DONE = 2,
  71467. /**
  71468. * Error
  71469. */
  71470. ERROR = 3
  71471. }
  71472. /**
  71473. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71474. */
  71475. export abstract class AbstractAssetTask {
  71476. /**
  71477. * Task name
  71478. */ name: string;
  71479. /**
  71480. * Callback called when the task is successful
  71481. */
  71482. onSuccess: (task: any) => void;
  71483. /**
  71484. * Callback called when the task is not successful
  71485. */
  71486. onError: (task: any, message?: string, exception?: any) => void;
  71487. /**
  71488. * Creates a new AssetsManager
  71489. * @param name defines the name of the task
  71490. */
  71491. constructor(
  71492. /**
  71493. * Task name
  71494. */ name: string);
  71495. private _isCompleted;
  71496. private _taskState;
  71497. private _errorObject;
  71498. /**
  71499. * Get if the task is completed
  71500. */
  71501. get isCompleted(): boolean;
  71502. /**
  71503. * Gets the current state of the task
  71504. */
  71505. get taskState(): AssetTaskState;
  71506. /**
  71507. * Gets the current error object (if task is in error)
  71508. */
  71509. get errorObject(): {
  71510. message?: string;
  71511. exception?: any;
  71512. };
  71513. /**
  71514. * Internal only
  71515. * @hidden
  71516. */
  71517. _setErrorObject(message?: string, exception?: any): void;
  71518. /**
  71519. * Execute the current task
  71520. * @param scene defines the scene where you want your assets to be loaded
  71521. * @param onSuccess is a callback called when the task is successfully executed
  71522. * @param onError is a callback called if an error occurs
  71523. */
  71524. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71525. /**
  71526. * Execute the current task
  71527. * @param scene defines the scene where you want your assets to be loaded
  71528. * @param onSuccess is a callback called when the task is successfully executed
  71529. * @param onError is a callback called if an error occurs
  71530. */
  71531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71532. /**
  71533. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71534. * This can be used with failed tasks that have the reason for failure fixed.
  71535. */
  71536. reset(): void;
  71537. private onErrorCallback;
  71538. private onDoneCallback;
  71539. }
  71540. /**
  71541. * Define the interface used by progress events raised during assets loading
  71542. */
  71543. export interface IAssetsProgressEvent {
  71544. /**
  71545. * Defines the number of remaining tasks to process
  71546. */
  71547. remainingCount: number;
  71548. /**
  71549. * Defines the total number of tasks
  71550. */
  71551. totalCount: number;
  71552. /**
  71553. * Defines the task that was just processed
  71554. */
  71555. task: AbstractAssetTask;
  71556. }
  71557. /**
  71558. * Class used to share progress information about assets loading
  71559. */
  71560. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71561. /**
  71562. * Defines the number of remaining tasks to process
  71563. */
  71564. remainingCount: number;
  71565. /**
  71566. * Defines the total number of tasks
  71567. */
  71568. totalCount: number;
  71569. /**
  71570. * Defines the task that was just processed
  71571. */
  71572. task: AbstractAssetTask;
  71573. /**
  71574. * Creates a AssetsProgressEvent
  71575. * @param remainingCount defines the number of remaining tasks to process
  71576. * @param totalCount defines the total number of tasks
  71577. * @param task defines the task that was just processed
  71578. */
  71579. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71580. }
  71581. /**
  71582. * Define a task used by AssetsManager to load meshes
  71583. */
  71584. export class MeshAssetTask extends AbstractAssetTask {
  71585. /**
  71586. * Defines the name of the task
  71587. */
  71588. name: string;
  71589. /**
  71590. * Defines the list of mesh's names you want to load
  71591. */
  71592. meshesNames: any;
  71593. /**
  71594. * Defines the root url to use as a base to load your meshes and associated resources
  71595. */
  71596. rootUrl: string;
  71597. /**
  71598. * Defines the filename of the scene to load from
  71599. */
  71600. sceneFilename: string;
  71601. /**
  71602. * Gets the list of loaded meshes
  71603. */
  71604. loadedMeshes: Array<AbstractMesh>;
  71605. /**
  71606. * Gets the list of loaded particle systems
  71607. */
  71608. loadedParticleSystems: Array<IParticleSystem>;
  71609. /**
  71610. * Gets the list of loaded skeletons
  71611. */
  71612. loadedSkeletons: Array<Skeleton>;
  71613. /**
  71614. * Gets the list of loaded animation groups
  71615. */
  71616. loadedAnimationGroups: Array<AnimationGroup>;
  71617. /**
  71618. * Callback called when the task is successful
  71619. */
  71620. onSuccess: (task: MeshAssetTask) => void;
  71621. /**
  71622. * Callback called when the task is successful
  71623. */
  71624. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71625. /**
  71626. * Creates a new MeshAssetTask
  71627. * @param name defines the name of the task
  71628. * @param meshesNames defines the list of mesh's names you want to load
  71629. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71630. * @param sceneFilename defines the filename of the scene to load from
  71631. */
  71632. constructor(
  71633. /**
  71634. * Defines the name of the task
  71635. */
  71636. name: string,
  71637. /**
  71638. * Defines the list of mesh's names you want to load
  71639. */
  71640. meshesNames: any,
  71641. /**
  71642. * Defines the root url to use as a base to load your meshes and associated resources
  71643. */
  71644. rootUrl: string,
  71645. /**
  71646. * Defines the filename of the scene to load from
  71647. */
  71648. sceneFilename: string);
  71649. /**
  71650. * Execute the current task
  71651. * @param scene defines the scene where you want your assets to be loaded
  71652. * @param onSuccess is a callback called when the task is successfully executed
  71653. * @param onError is a callback called if an error occurs
  71654. */
  71655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71656. }
  71657. /**
  71658. * Define a task used by AssetsManager to load text content
  71659. */
  71660. export class TextFileAssetTask extends AbstractAssetTask {
  71661. /**
  71662. * Defines the name of the task
  71663. */
  71664. name: string;
  71665. /**
  71666. * Defines the location of the file to load
  71667. */
  71668. url: string;
  71669. /**
  71670. * Gets the loaded text string
  71671. */
  71672. text: string;
  71673. /**
  71674. * Callback called when the task is successful
  71675. */
  71676. onSuccess: (task: TextFileAssetTask) => void;
  71677. /**
  71678. * Callback called when the task is successful
  71679. */
  71680. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71681. /**
  71682. * Creates a new TextFileAssetTask object
  71683. * @param name defines the name of the task
  71684. * @param url defines the location of the file to load
  71685. */
  71686. constructor(
  71687. /**
  71688. * Defines the name of the task
  71689. */
  71690. name: string,
  71691. /**
  71692. * Defines the location of the file to load
  71693. */
  71694. url: string);
  71695. /**
  71696. * Execute the current task
  71697. * @param scene defines the scene where you want your assets to be loaded
  71698. * @param onSuccess is a callback called when the task is successfully executed
  71699. * @param onError is a callback called if an error occurs
  71700. */
  71701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71702. }
  71703. /**
  71704. * Define a task used by AssetsManager to load binary data
  71705. */
  71706. export class BinaryFileAssetTask extends AbstractAssetTask {
  71707. /**
  71708. * Defines the name of the task
  71709. */
  71710. name: string;
  71711. /**
  71712. * Defines the location of the file to load
  71713. */
  71714. url: string;
  71715. /**
  71716. * Gets the lodaded data (as an array buffer)
  71717. */
  71718. data: ArrayBuffer;
  71719. /**
  71720. * Callback called when the task is successful
  71721. */
  71722. onSuccess: (task: BinaryFileAssetTask) => void;
  71723. /**
  71724. * Callback called when the task is successful
  71725. */
  71726. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71727. /**
  71728. * Creates a new BinaryFileAssetTask object
  71729. * @param name defines the name of the new task
  71730. * @param url defines the location of the file to load
  71731. */
  71732. constructor(
  71733. /**
  71734. * Defines the name of the task
  71735. */
  71736. name: string,
  71737. /**
  71738. * Defines the location of the file to load
  71739. */
  71740. url: string);
  71741. /**
  71742. * Execute the current task
  71743. * @param scene defines the scene where you want your assets to be loaded
  71744. * @param onSuccess is a callback called when the task is successfully executed
  71745. * @param onError is a callback called if an error occurs
  71746. */
  71747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71748. }
  71749. /**
  71750. * Define a task used by AssetsManager to load images
  71751. */
  71752. export class ImageAssetTask extends AbstractAssetTask {
  71753. /**
  71754. * Defines the name of the task
  71755. */
  71756. name: string;
  71757. /**
  71758. * Defines the location of the image to load
  71759. */
  71760. url: string;
  71761. /**
  71762. * Gets the loaded images
  71763. */
  71764. image: HTMLImageElement;
  71765. /**
  71766. * Callback called when the task is successful
  71767. */
  71768. onSuccess: (task: ImageAssetTask) => void;
  71769. /**
  71770. * Callback called when the task is successful
  71771. */
  71772. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71773. /**
  71774. * Creates a new ImageAssetTask
  71775. * @param name defines the name of the task
  71776. * @param url defines the location of the image to load
  71777. */
  71778. constructor(
  71779. /**
  71780. * Defines the name of the task
  71781. */
  71782. name: string,
  71783. /**
  71784. * Defines the location of the image to load
  71785. */
  71786. url: string);
  71787. /**
  71788. * Execute the current task
  71789. * @param scene defines the scene where you want your assets to be loaded
  71790. * @param onSuccess is a callback called when the task is successfully executed
  71791. * @param onError is a callback called if an error occurs
  71792. */
  71793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71794. }
  71795. /**
  71796. * Defines the interface used by texture loading tasks
  71797. */
  71798. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71799. /**
  71800. * Gets the loaded texture
  71801. */
  71802. texture: TEX;
  71803. }
  71804. /**
  71805. * Define a task used by AssetsManager to load 2D textures
  71806. */
  71807. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71808. /**
  71809. * Defines the name of the task
  71810. */
  71811. name: string;
  71812. /**
  71813. * Defines the location of the file to load
  71814. */
  71815. url: string;
  71816. /**
  71817. * Defines if mipmap should not be generated (default is false)
  71818. */
  71819. noMipmap?: boolean | undefined;
  71820. /**
  71821. * Defines if texture must be inverted on Y axis (default is true)
  71822. */
  71823. invertY: boolean;
  71824. /**
  71825. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71826. */
  71827. samplingMode: number;
  71828. /**
  71829. * Gets the loaded texture
  71830. */
  71831. texture: Texture;
  71832. /**
  71833. * Callback called when the task is successful
  71834. */
  71835. onSuccess: (task: TextureAssetTask) => void;
  71836. /**
  71837. * Callback called when the task is successful
  71838. */
  71839. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71840. /**
  71841. * Creates a new TextureAssetTask object
  71842. * @param name defines the name of the task
  71843. * @param url defines the location of the file to load
  71844. * @param noMipmap defines if mipmap should not be generated (default is false)
  71845. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71846. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71847. */
  71848. constructor(
  71849. /**
  71850. * Defines the name of the task
  71851. */
  71852. name: string,
  71853. /**
  71854. * Defines the location of the file to load
  71855. */
  71856. url: string,
  71857. /**
  71858. * Defines if mipmap should not be generated (default is false)
  71859. */
  71860. noMipmap?: boolean | undefined,
  71861. /**
  71862. * Defines if texture must be inverted on Y axis (default is true)
  71863. */
  71864. invertY?: boolean,
  71865. /**
  71866. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71867. */
  71868. samplingMode?: number);
  71869. /**
  71870. * Execute the current task
  71871. * @param scene defines the scene where you want your assets to be loaded
  71872. * @param onSuccess is a callback called when the task is successfully executed
  71873. * @param onError is a callback called if an error occurs
  71874. */
  71875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71876. }
  71877. /**
  71878. * Define a task used by AssetsManager to load cube textures
  71879. */
  71880. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71881. /**
  71882. * Defines the name of the task
  71883. */
  71884. name: string;
  71885. /**
  71886. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71887. */
  71888. url: string;
  71889. /**
  71890. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71891. */
  71892. extensions?: string[] | undefined;
  71893. /**
  71894. * Defines if mipmaps should not be generated (default is false)
  71895. */
  71896. noMipmap?: boolean | undefined;
  71897. /**
  71898. * Defines the explicit list of files (undefined by default)
  71899. */
  71900. files?: string[] | undefined;
  71901. /**
  71902. * Gets the loaded texture
  71903. */
  71904. texture: CubeTexture;
  71905. /**
  71906. * Callback called when the task is successful
  71907. */
  71908. onSuccess: (task: CubeTextureAssetTask) => void;
  71909. /**
  71910. * Callback called when the task is successful
  71911. */
  71912. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71913. /**
  71914. * Creates a new CubeTextureAssetTask
  71915. * @param name defines the name of the task
  71916. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71917. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71918. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71919. * @param files defines the explicit list of files (undefined by default)
  71920. */
  71921. constructor(
  71922. /**
  71923. * Defines the name of the task
  71924. */
  71925. name: string,
  71926. /**
  71927. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71928. */
  71929. url: string,
  71930. /**
  71931. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71932. */
  71933. extensions?: string[] | undefined,
  71934. /**
  71935. * Defines if mipmaps should not be generated (default is false)
  71936. */
  71937. noMipmap?: boolean | undefined,
  71938. /**
  71939. * Defines the explicit list of files (undefined by default)
  71940. */
  71941. files?: string[] | undefined);
  71942. /**
  71943. * Execute the current task
  71944. * @param scene defines the scene where you want your assets to be loaded
  71945. * @param onSuccess is a callback called when the task is successfully executed
  71946. * @param onError is a callback called if an error occurs
  71947. */
  71948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71949. }
  71950. /**
  71951. * Define a task used by AssetsManager to load HDR cube textures
  71952. */
  71953. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71954. /**
  71955. * Defines the name of the task
  71956. */
  71957. name: string;
  71958. /**
  71959. * Defines the location of the file to load
  71960. */
  71961. url: string;
  71962. /**
  71963. * Defines the desired size (the more it increases the longer the generation will be)
  71964. */
  71965. size: number;
  71966. /**
  71967. * Defines if mipmaps should not be generated (default is false)
  71968. */
  71969. noMipmap: boolean;
  71970. /**
  71971. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71972. */
  71973. generateHarmonics: boolean;
  71974. /**
  71975. * 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)
  71976. */
  71977. gammaSpace: boolean;
  71978. /**
  71979. * Internal Use Only
  71980. */
  71981. reserved: boolean;
  71982. /**
  71983. * Gets the loaded texture
  71984. */
  71985. texture: HDRCubeTexture;
  71986. /**
  71987. * Callback called when the task is successful
  71988. */
  71989. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71990. /**
  71991. * Callback called when the task is successful
  71992. */
  71993. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71994. /**
  71995. * Creates a new HDRCubeTextureAssetTask object
  71996. * @param name defines the name of the task
  71997. * @param url defines the location of the file to load
  71998. * @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.
  71999. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72000. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72001. * @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)
  72002. * @param reserved Internal use only
  72003. */
  72004. constructor(
  72005. /**
  72006. * Defines the name of the task
  72007. */
  72008. name: string,
  72009. /**
  72010. * Defines the location of the file to load
  72011. */
  72012. url: string,
  72013. /**
  72014. * Defines the desired size (the more it increases the longer the generation will be)
  72015. */
  72016. size: number,
  72017. /**
  72018. * Defines if mipmaps should not be generated (default is false)
  72019. */
  72020. noMipmap?: boolean,
  72021. /**
  72022. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72023. */
  72024. generateHarmonics?: boolean,
  72025. /**
  72026. * 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)
  72027. */
  72028. gammaSpace?: boolean,
  72029. /**
  72030. * Internal Use Only
  72031. */
  72032. reserved?: boolean);
  72033. /**
  72034. * Execute the current task
  72035. * @param scene defines the scene where you want your assets to be loaded
  72036. * @param onSuccess is a callback called when the task is successfully executed
  72037. * @param onError is a callback called if an error occurs
  72038. */
  72039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72040. }
  72041. /**
  72042. * Define a task used by AssetsManager to load Equirectangular cube textures
  72043. */
  72044. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72045. /**
  72046. * Defines the name of the task
  72047. */
  72048. name: string;
  72049. /**
  72050. * Defines the location of the file to load
  72051. */
  72052. url: string;
  72053. /**
  72054. * Defines the desired size (the more it increases the longer the generation will be)
  72055. */
  72056. size: number;
  72057. /**
  72058. * Defines if mipmaps should not be generated (default is false)
  72059. */
  72060. noMipmap: boolean;
  72061. /**
  72062. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72063. * but the standard material would require them in Gamma space) (default is true)
  72064. */
  72065. gammaSpace: boolean;
  72066. /**
  72067. * Gets the loaded texture
  72068. */
  72069. texture: EquiRectangularCubeTexture;
  72070. /**
  72071. * Callback called when the task is successful
  72072. */
  72073. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72074. /**
  72075. * Callback called when the task is successful
  72076. */
  72077. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72078. /**
  72079. * Creates a new EquiRectangularCubeTextureAssetTask object
  72080. * @param name defines the name of the task
  72081. * @param url defines the location of the file to load
  72082. * @param size defines the desired size (the more it increases the longer the generation will be)
  72083. * If the size is omitted this implies you are using a preprocessed cubemap.
  72084. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72085. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72086. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72087. * (default is true)
  72088. */
  72089. constructor(
  72090. /**
  72091. * Defines the name of the task
  72092. */
  72093. name: string,
  72094. /**
  72095. * Defines the location of the file to load
  72096. */
  72097. url: string,
  72098. /**
  72099. * Defines the desired size (the more it increases the longer the generation will be)
  72100. */
  72101. size: number,
  72102. /**
  72103. * Defines if mipmaps should not be generated (default is false)
  72104. */
  72105. noMipmap?: boolean,
  72106. /**
  72107. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72108. * but the standard material would require them in Gamma space) (default is true)
  72109. */
  72110. gammaSpace?: boolean);
  72111. /**
  72112. * Execute the current task
  72113. * @param scene defines the scene where you want your assets to be loaded
  72114. * @param onSuccess is a callback called when the task is successfully executed
  72115. * @param onError is a callback called if an error occurs
  72116. */
  72117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72118. }
  72119. /**
  72120. * This class can be used to easily import assets into a scene
  72121. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72122. */
  72123. export class AssetsManager {
  72124. private _scene;
  72125. private _isLoading;
  72126. protected _tasks: AbstractAssetTask[];
  72127. protected _waitingTasksCount: number;
  72128. protected _totalTasksCount: number;
  72129. /**
  72130. * Callback called when all tasks are processed
  72131. */
  72132. onFinish: (tasks: AbstractAssetTask[]) => void;
  72133. /**
  72134. * Callback called when a task is successful
  72135. */
  72136. onTaskSuccess: (task: AbstractAssetTask) => void;
  72137. /**
  72138. * Callback called when a task had an error
  72139. */
  72140. onTaskError: (task: AbstractAssetTask) => void;
  72141. /**
  72142. * Callback called when a task is done (whatever the result is)
  72143. */
  72144. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72145. /**
  72146. * Observable called when all tasks are processed
  72147. */
  72148. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72149. /**
  72150. * Observable called when a task had an error
  72151. */
  72152. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72153. /**
  72154. * Observable called when all tasks were executed
  72155. */
  72156. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72157. /**
  72158. * Observable called when a task is done (whatever the result is)
  72159. */
  72160. onProgressObservable: Observable<IAssetsProgressEvent>;
  72161. /**
  72162. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72163. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72164. */
  72165. useDefaultLoadingScreen: boolean;
  72166. /**
  72167. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72168. * when all assets have been downloaded.
  72169. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72170. */
  72171. autoHideLoadingUI: boolean;
  72172. /**
  72173. * Creates a new AssetsManager
  72174. * @param scene defines the scene to work on
  72175. */
  72176. constructor(scene: Scene);
  72177. /**
  72178. * Add a MeshAssetTask to the list of active tasks
  72179. * @param taskName defines the name of the new task
  72180. * @param meshesNames defines the name of meshes to load
  72181. * @param rootUrl defines the root url to use to locate files
  72182. * @param sceneFilename defines the filename of the scene file
  72183. * @returns a new MeshAssetTask object
  72184. */
  72185. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72186. /**
  72187. * Add a TextFileAssetTask to the list of active tasks
  72188. * @param taskName defines the name of the new task
  72189. * @param url defines the url of the file to load
  72190. * @returns a new TextFileAssetTask object
  72191. */
  72192. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72193. /**
  72194. * Add a BinaryFileAssetTask to the list of active tasks
  72195. * @param taskName defines the name of the new task
  72196. * @param url defines the url of the file to load
  72197. * @returns a new BinaryFileAssetTask object
  72198. */
  72199. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72200. /**
  72201. * Add a ImageAssetTask to the list of active tasks
  72202. * @param taskName defines the name of the new task
  72203. * @param url defines the url of the file to load
  72204. * @returns a new ImageAssetTask object
  72205. */
  72206. addImageTask(taskName: string, url: string): ImageAssetTask;
  72207. /**
  72208. * Add a TextureAssetTask to the list of active tasks
  72209. * @param taskName defines the name of the new task
  72210. * @param url defines the url of the file to load
  72211. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72212. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72213. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72214. * @returns a new TextureAssetTask object
  72215. */
  72216. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72217. /**
  72218. * Add a CubeTextureAssetTask to the list of active tasks
  72219. * @param taskName defines the name of the new task
  72220. * @param url defines the url of the file to load
  72221. * @param extensions defines the extension to use to load the cube map (can be null)
  72222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72223. * @param files defines the list of files to load (can be null)
  72224. * @returns a new CubeTextureAssetTask object
  72225. */
  72226. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72227. /**
  72228. *
  72229. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72230. * @param taskName defines the name of the new task
  72231. * @param url defines the url of the file to load
  72232. * @param size defines the size you want for the cubemap (can be null)
  72233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72234. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72235. * @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)
  72236. * @param reserved Internal use only
  72237. * @returns a new HDRCubeTextureAssetTask object
  72238. */
  72239. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72240. /**
  72241. *
  72242. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72243. * @param taskName defines the name of the new task
  72244. * @param url defines the url of the file to load
  72245. * @param size defines the size you want for the cubemap (can be null)
  72246. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72247. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72248. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72249. * @returns a new EquiRectangularCubeTextureAssetTask object
  72250. */
  72251. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72252. /**
  72253. * Remove a task from the assets manager.
  72254. * @param task the task to remove
  72255. */
  72256. removeTask(task: AbstractAssetTask): void;
  72257. private _decreaseWaitingTasksCount;
  72258. private _runTask;
  72259. /**
  72260. * Reset the AssetsManager and remove all tasks
  72261. * @return the current instance of the AssetsManager
  72262. */
  72263. reset(): AssetsManager;
  72264. /**
  72265. * Start the loading process
  72266. * @return the current instance of the AssetsManager
  72267. */
  72268. load(): AssetsManager;
  72269. /**
  72270. * Start the loading process as an async operation
  72271. * @return a promise returning the list of failed tasks
  72272. */
  72273. loadAsync(): Promise<void>;
  72274. }
  72275. }
  72276. declare module "babylonjs/Misc/deferred" {
  72277. /**
  72278. * Wrapper class for promise with external resolve and reject.
  72279. */
  72280. export class Deferred<T> {
  72281. /**
  72282. * The promise associated with this deferred object.
  72283. */
  72284. readonly promise: Promise<T>;
  72285. private _resolve;
  72286. private _reject;
  72287. /**
  72288. * The resolve method of the promise associated with this deferred object.
  72289. */
  72290. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72291. /**
  72292. * The reject method of the promise associated with this deferred object.
  72293. */
  72294. get reject(): (reason?: any) => void;
  72295. /**
  72296. * Constructor for this deferred object.
  72297. */
  72298. constructor();
  72299. }
  72300. }
  72301. declare module "babylonjs/Misc/meshExploder" {
  72302. import { Mesh } from "babylonjs/Meshes/mesh";
  72303. /**
  72304. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72305. */
  72306. export class MeshExploder {
  72307. private _centerMesh;
  72308. private _meshes;
  72309. private _meshesOrigins;
  72310. private _toCenterVectors;
  72311. private _scaledDirection;
  72312. private _newPosition;
  72313. private _centerPosition;
  72314. /**
  72315. * Explodes meshes from a center mesh.
  72316. * @param meshes The meshes to explode.
  72317. * @param centerMesh The mesh to be center of explosion.
  72318. */
  72319. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72320. private _setCenterMesh;
  72321. /**
  72322. * Get class name
  72323. * @returns "MeshExploder"
  72324. */
  72325. getClassName(): string;
  72326. /**
  72327. * "Exploded meshes"
  72328. * @returns Array of meshes with the centerMesh at index 0.
  72329. */
  72330. getMeshes(): Array<Mesh>;
  72331. /**
  72332. * Explodes meshes giving a specific direction
  72333. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72334. */
  72335. explode(direction?: number): void;
  72336. }
  72337. }
  72338. declare module "babylonjs/Misc/filesInput" {
  72339. import { Engine } from "babylonjs/Engines/engine";
  72340. import { Scene } from "babylonjs/scene";
  72341. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72342. /**
  72343. * Class used to help managing file picking and drag'n'drop
  72344. */
  72345. export class FilesInput {
  72346. /**
  72347. * List of files ready to be loaded
  72348. */
  72349. static get FilesToLoad(): {
  72350. [key: string]: File;
  72351. };
  72352. /**
  72353. * Callback called when a file is processed
  72354. */
  72355. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72356. private _engine;
  72357. private _currentScene;
  72358. private _sceneLoadedCallback;
  72359. private _progressCallback;
  72360. private _additionalRenderLoopLogicCallback;
  72361. private _textureLoadingCallback;
  72362. private _startingProcessingFilesCallback;
  72363. private _onReloadCallback;
  72364. private _errorCallback;
  72365. private _elementToMonitor;
  72366. private _sceneFileToLoad;
  72367. private _filesToLoad;
  72368. /**
  72369. * Creates a new FilesInput
  72370. * @param engine defines the rendering engine
  72371. * @param scene defines the hosting scene
  72372. * @param sceneLoadedCallback callback called when scene is loaded
  72373. * @param progressCallback callback called to track progress
  72374. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72375. * @param textureLoadingCallback callback called when a texture is loading
  72376. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72377. * @param onReloadCallback callback called when a reload is requested
  72378. * @param errorCallback callback call if an error occurs
  72379. */
  72380. 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);
  72381. private _dragEnterHandler;
  72382. private _dragOverHandler;
  72383. private _dropHandler;
  72384. /**
  72385. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72386. * @param elementToMonitor defines the DOM element to track
  72387. */
  72388. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72389. /**
  72390. * Release all associated resources
  72391. */
  72392. dispose(): void;
  72393. private renderFunction;
  72394. private drag;
  72395. private drop;
  72396. private _traverseFolder;
  72397. private _processFiles;
  72398. /**
  72399. * Load files from a drop event
  72400. * @param event defines the drop event to use as source
  72401. */
  72402. loadFiles(event: any): void;
  72403. private _processReload;
  72404. /**
  72405. * Reload the current scene from the loaded files
  72406. */
  72407. reload(): void;
  72408. }
  72409. }
  72410. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72411. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72412. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72413. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72414. }
  72415. declare module "babylonjs/Misc/sceneOptimizer" {
  72416. import { Scene, IDisposable } from "babylonjs/scene";
  72417. import { Observable } from "babylonjs/Misc/observable";
  72418. /**
  72419. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72421. */
  72422. export class SceneOptimization {
  72423. /**
  72424. * Defines the priority of this optimization (0 by default which means first in the list)
  72425. */
  72426. priority: number;
  72427. /**
  72428. * Gets a string describing the action executed by the current optimization
  72429. * @returns description string
  72430. */
  72431. getDescription(): string;
  72432. /**
  72433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72434. * @param scene defines the current scene where to apply this optimization
  72435. * @param optimizer defines the current optimizer
  72436. * @returns true if everything that can be done was applied
  72437. */
  72438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72439. /**
  72440. * Creates the SceneOptimization object
  72441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72442. * @param desc defines the description associated with the optimization
  72443. */
  72444. constructor(
  72445. /**
  72446. * Defines the priority of this optimization (0 by default which means first in the list)
  72447. */
  72448. priority?: number);
  72449. }
  72450. /**
  72451. * Defines an optimization used to reduce the size of render target textures
  72452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72453. */
  72454. export class TextureOptimization extends SceneOptimization {
  72455. /**
  72456. * Defines the priority of this optimization (0 by default which means first in the list)
  72457. */
  72458. priority: number;
  72459. /**
  72460. * 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
  72461. */
  72462. maximumSize: number;
  72463. /**
  72464. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72465. */
  72466. step: number;
  72467. /**
  72468. * Gets a string describing the action executed by the current optimization
  72469. * @returns description string
  72470. */
  72471. getDescription(): string;
  72472. /**
  72473. * Creates the TextureOptimization object
  72474. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72475. * @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
  72476. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72477. */
  72478. constructor(
  72479. /**
  72480. * Defines the priority of this optimization (0 by default which means first in the list)
  72481. */
  72482. priority?: number,
  72483. /**
  72484. * 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
  72485. */
  72486. maximumSize?: number,
  72487. /**
  72488. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72489. */
  72490. step?: number);
  72491. /**
  72492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72493. * @param scene defines the current scene where to apply this optimization
  72494. * @param optimizer defines the current optimizer
  72495. * @returns true if everything that can be done was applied
  72496. */
  72497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72498. }
  72499. /**
  72500. * Defines an optimization used to increase or decrease the rendering resolution
  72501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72502. */
  72503. export class HardwareScalingOptimization extends SceneOptimization {
  72504. /**
  72505. * Defines the priority of this optimization (0 by default which means first in the list)
  72506. */
  72507. priority: number;
  72508. /**
  72509. * Defines the maximum scale to use (2 by default)
  72510. */
  72511. maximumScale: number;
  72512. /**
  72513. * Defines the step to use between two passes (0.5 by default)
  72514. */
  72515. step: number;
  72516. private _currentScale;
  72517. private _directionOffset;
  72518. /**
  72519. * Gets a string describing the action executed by the current optimization
  72520. * @return description string
  72521. */
  72522. getDescription(): string;
  72523. /**
  72524. * Creates the HardwareScalingOptimization object
  72525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72526. * @param maximumScale defines the maximum scale to use (2 by default)
  72527. * @param step defines the step to use between two passes (0.5 by default)
  72528. */
  72529. constructor(
  72530. /**
  72531. * Defines the priority of this optimization (0 by default which means first in the list)
  72532. */
  72533. priority?: number,
  72534. /**
  72535. * Defines the maximum scale to use (2 by default)
  72536. */
  72537. maximumScale?: number,
  72538. /**
  72539. * Defines the step to use between two passes (0.5 by default)
  72540. */
  72541. step?: number);
  72542. /**
  72543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72544. * @param scene defines the current scene where to apply this optimization
  72545. * @param optimizer defines the current optimizer
  72546. * @returns true if everything that can be done was applied
  72547. */
  72548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72549. }
  72550. /**
  72551. * Defines an optimization used to remove shadows
  72552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72553. */
  72554. export class ShadowsOptimization extends SceneOptimization {
  72555. /**
  72556. * Gets a string describing the action executed by the current optimization
  72557. * @return description string
  72558. */
  72559. getDescription(): string;
  72560. /**
  72561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72562. * @param scene defines the current scene where to apply this optimization
  72563. * @param optimizer defines the current optimizer
  72564. * @returns true if everything that can be done was applied
  72565. */
  72566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72567. }
  72568. /**
  72569. * Defines an optimization used to turn post-processes off
  72570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72571. */
  72572. export class PostProcessesOptimization extends SceneOptimization {
  72573. /**
  72574. * Gets a string describing the action executed by the current optimization
  72575. * @return description string
  72576. */
  72577. getDescription(): string;
  72578. /**
  72579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72580. * @param scene defines the current scene where to apply this optimization
  72581. * @param optimizer defines the current optimizer
  72582. * @returns true if everything that can be done was applied
  72583. */
  72584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72585. }
  72586. /**
  72587. * Defines an optimization used to turn lens flares off
  72588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72589. */
  72590. export class LensFlaresOptimization extends SceneOptimization {
  72591. /**
  72592. * Gets a string describing the action executed by the current optimization
  72593. * @return description string
  72594. */
  72595. getDescription(): string;
  72596. /**
  72597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72598. * @param scene defines the current scene where to apply this optimization
  72599. * @param optimizer defines the current optimizer
  72600. * @returns true if everything that can be done was applied
  72601. */
  72602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72603. }
  72604. /**
  72605. * Defines an optimization based on user defined callback.
  72606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72607. */
  72608. export class CustomOptimization extends SceneOptimization {
  72609. /**
  72610. * Callback called to apply the custom optimization.
  72611. */
  72612. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72613. /**
  72614. * Callback called to get custom description
  72615. */
  72616. onGetDescription: () => string;
  72617. /**
  72618. * Gets a string describing the action executed by the current optimization
  72619. * @returns description string
  72620. */
  72621. getDescription(): string;
  72622. /**
  72623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72624. * @param scene defines the current scene where to apply this optimization
  72625. * @param optimizer defines the current optimizer
  72626. * @returns true if everything that can be done was applied
  72627. */
  72628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72629. }
  72630. /**
  72631. * Defines an optimization used to turn particles off
  72632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72633. */
  72634. export class ParticlesOptimization extends SceneOptimization {
  72635. /**
  72636. * Gets a string describing the action executed by the current optimization
  72637. * @return description string
  72638. */
  72639. getDescription(): string;
  72640. /**
  72641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72642. * @param scene defines the current scene where to apply this optimization
  72643. * @param optimizer defines the current optimizer
  72644. * @returns true if everything that can be done was applied
  72645. */
  72646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72647. }
  72648. /**
  72649. * Defines an optimization used to turn render targets off
  72650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72651. */
  72652. export class RenderTargetsOptimization extends SceneOptimization {
  72653. /**
  72654. * Gets a string describing the action executed by the current optimization
  72655. * @return description string
  72656. */
  72657. getDescription(): string;
  72658. /**
  72659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72660. * @param scene defines the current scene where to apply this optimization
  72661. * @param optimizer defines the current optimizer
  72662. * @returns true if everything that can be done was applied
  72663. */
  72664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72665. }
  72666. /**
  72667. * Defines an optimization used to merge meshes with compatible materials
  72668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72669. */
  72670. export class MergeMeshesOptimization extends SceneOptimization {
  72671. private static _UpdateSelectionTree;
  72672. /**
  72673. * Gets or sets a boolean which defines if optimization octree has to be updated
  72674. */
  72675. static get UpdateSelectionTree(): boolean;
  72676. /**
  72677. * Gets or sets a boolean which defines if optimization octree has to be updated
  72678. */
  72679. static set UpdateSelectionTree(value: boolean);
  72680. /**
  72681. * Gets a string describing the action executed by the current optimization
  72682. * @return description string
  72683. */
  72684. getDescription(): string;
  72685. private _canBeMerged;
  72686. /**
  72687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72688. * @param scene defines the current scene where to apply this optimization
  72689. * @param optimizer defines the current optimizer
  72690. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72691. * @returns true if everything that can be done was applied
  72692. */
  72693. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72694. }
  72695. /**
  72696. * Defines a list of options used by SceneOptimizer
  72697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72698. */
  72699. export class SceneOptimizerOptions {
  72700. /**
  72701. * Defines the target frame rate to reach (60 by default)
  72702. */
  72703. targetFrameRate: number;
  72704. /**
  72705. * Defines the interval between two checkes (2000ms by default)
  72706. */
  72707. trackerDuration: number;
  72708. /**
  72709. * Gets the list of optimizations to apply
  72710. */
  72711. optimizations: SceneOptimization[];
  72712. /**
  72713. * Creates a new list of options used by SceneOptimizer
  72714. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72715. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72716. */
  72717. constructor(
  72718. /**
  72719. * Defines the target frame rate to reach (60 by default)
  72720. */
  72721. targetFrameRate?: number,
  72722. /**
  72723. * Defines the interval between two checkes (2000ms by default)
  72724. */
  72725. trackerDuration?: number);
  72726. /**
  72727. * Add a new optimization
  72728. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72729. * @returns the current SceneOptimizerOptions
  72730. */
  72731. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72732. /**
  72733. * Add a new custom optimization
  72734. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72735. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72737. * @returns the current SceneOptimizerOptions
  72738. */
  72739. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72740. /**
  72741. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72742. * @param targetFrameRate defines the target frame rate (60 by default)
  72743. * @returns a SceneOptimizerOptions object
  72744. */
  72745. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72746. /**
  72747. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72748. * @param targetFrameRate defines the target frame rate (60 by default)
  72749. * @returns a SceneOptimizerOptions object
  72750. */
  72751. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72752. /**
  72753. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72754. * @param targetFrameRate defines the target frame rate (60 by default)
  72755. * @returns a SceneOptimizerOptions object
  72756. */
  72757. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72758. }
  72759. /**
  72760. * Class used to run optimizations in order to reach a target frame rate
  72761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72762. */
  72763. export class SceneOptimizer implements IDisposable {
  72764. private _isRunning;
  72765. private _options;
  72766. private _scene;
  72767. private _currentPriorityLevel;
  72768. private _targetFrameRate;
  72769. private _trackerDuration;
  72770. private _currentFrameRate;
  72771. private _sceneDisposeObserver;
  72772. private _improvementMode;
  72773. /**
  72774. * Defines an observable called when the optimizer reaches the target frame rate
  72775. */
  72776. onSuccessObservable: Observable<SceneOptimizer>;
  72777. /**
  72778. * Defines an observable called when the optimizer enables an optimization
  72779. */
  72780. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72781. /**
  72782. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72783. */
  72784. onFailureObservable: Observable<SceneOptimizer>;
  72785. /**
  72786. * Gets a boolean indicating if the optimizer is in improvement mode
  72787. */
  72788. get isInImprovementMode(): boolean;
  72789. /**
  72790. * Gets the current priority level (0 at start)
  72791. */
  72792. get currentPriorityLevel(): number;
  72793. /**
  72794. * Gets the current frame rate checked by the SceneOptimizer
  72795. */
  72796. get currentFrameRate(): number;
  72797. /**
  72798. * Gets or sets the current target frame rate (60 by default)
  72799. */
  72800. get targetFrameRate(): number;
  72801. /**
  72802. * Gets or sets the current target frame rate (60 by default)
  72803. */
  72804. set targetFrameRate(value: number);
  72805. /**
  72806. * Gets or sets the current interval between two checks (every 2000ms by default)
  72807. */
  72808. get trackerDuration(): number;
  72809. /**
  72810. * Gets or sets the current interval between two checks (every 2000ms by default)
  72811. */
  72812. set trackerDuration(value: number);
  72813. /**
  72814. * Gets the list of active optimizations
  72815. */
  72816. get optimizations(): SceneOptimization[];
  72817. /**
  72818. * Creates a new SceneOptimizer
  72819. * @param scene defines the scene to work on
  72820. * @param options defines the options to use with the SceneOptimizer
  72821. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72822. * @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)
  72823. */
  72824. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72825. /**
  72826. * Stops the current optimizer
  72827. */
  72828. stop(): void;
  72829. /**
  72830. * Reset the optimizer to initial step (current priority level = 0)
  72831. */
  72832. reset(): void;
  72833. /**
  72834. * Start the optimizer. By default it will try to reach a specific framerate
  72835. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72836. */
  72837. start(): void;
  72838. private _checkCurrentState;
  72839. /**
  72840. * Release all resources
  72841. */
  72842. dispose(): void;
  72843. /**
  72844. * Helper function to create a SceneOptimizer with one single line of code
  72845. * @param scene defines the scene to work on
  72846. * @param options defines the options to use with the SceneOptimizer
  72847. * @param onSuccess defines a callback to call on success
  72848. * @param onFailure defines a callback to call on failure
  72849. * @returns the new SceneOptimizer object
  72850. */
  72851. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72852. }
  72853. }
  72854. declare module "babylonjs/Misc/sceneSerializer" {
  72855. import { Scene } from "babylonjs/scene";
  72856. /**
  72857. * Class used to serialize a scene into a string
  72858. */
  72859. export class SceneSerializer {
  72860. /**
  72861. * Clear cache used by a previous serialization
  72862. */
  72863. static ClearCache(): void;
  72864. /**
  72865. * Serialize a scene into a JSON compatible object
  72866. * @param scene defines the scene to serialize
  72867. * @returns a JSON compatible object
  72868. */
  72869. static Serialize(scene: Scene): any;
  72870. /**
  72871. * Serialize a mesh into a JSON compatible object
  72872. * @param toSerialize defines the mesh to serialize
  72873. * @param withParents defines if parents must be serialized as well
  72874. * @param withChildren defines if children must be serialized as well
  72875. * @returns a JSON compatible object
  72876. */
  72877. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72878. }
  72879. }
  72880. declare module "babylonjs/Misc/textureTools" {
  72881. import { Texture } from "babylonjs/Materials/Textures/texture";
  72882. /**
  72883. * Class used to host texture specific utilities
  72884. */
  72885. export class TextureTools {
  72886. /**
  72887. * Uses the GPU to create a copy texture rescaled at a given size
  72888. * @param texture Texture to copy from
  72889. * @param width defines the desired width
  72890. * @param height defines the desired height
  72891. * @param useBilinearMode defines if bilinear mode has to be used
  72892. * @return the generated texture
  72893. */
  72894. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72895. }
  72896. }
  72897. declare module "babylonjs/Misc/videoRecorder" {
  72898. import { Nullable } from "babylonjs/types";
  72899. import { Engine } from "babylonjs/Engines/engine";
  72900. /**
  72901. * This represents the different options available for the video capture.
  72902. */
  72903. export interface VideoRecorderOptions {
  72904. /** Defines the mime type of the video. */
  72905. mimeType: string;
  72906. /** Defines the FPS the video should be recorded at. */
  72907. fps: number;
  72908. /** Defines the chunk size for the recording data. */
  72909. recordChunckSize: number;
  72910. /** The audio tracks to attach to the recording. */
  72911. audioTracks?: MediaStreamTrack[];
  72912. }
  72913. /**
  72914. * This can help with recording videos from BabylonJS.
  72915. * This is based on the available WebRTC functionalities of the browser.
  72916. *
  72917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72918. */
  72919. export class VideoRecorder {
  72920. private static readonly _defaultOptions;
  72921. /**
  72922. * Returns whether or not the VideoRecorder is available in your browser.
  72923. * @param engine Defines the Babylon Engine.
  72924. * @returns true if supported otherwise false.
  72925. */
  72926. static IsSupported(engine: Engine): boolean;
  72927. private readonly _options;
  72928. private _canvas;
  72929. private _mediaRecorder;
  72930. private _recordedChunks;
  72931. private _fileName;
  72932. private _resolve;
  72933. private _reject;
  72934. /**
  72935. * True when a recording is already in progress.
  72936. */
  72937. get isRecording(): boolean;
  72938. /**
  72939. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72940. * @param engine Defines the BabylonJS Engine you wish to record.
  72941. * @param options Defines options that can be used to customize the capture.
  72942. */
  72943. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72944. /**
  72945. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72946. */
  72947. stopRecording(): void;
  72948. /**
  72949. * Starts recording the canvas for a max duration specified in parameters.
  72950. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72951. * If null no automatic download will start and you can rely on the promise to get the data back.
  72952. * @param maxDuration Defines the maximum recording time in seconds.
  72953. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72954. * @return A promise callback at the end of the recording with the video data in Blob.
  72955. */
  72956. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72957. /**
  72958. * Releases internal resources used during the recording.
  72959. */
  72960. dispose(): void;
  72961. private _handleDataAvailable;
  72962. private _handleError;
  72963. private _handleStop;
  72964. }
  72965. }
  72966. declare module "babylonjs/Misc/screenshotTools" {
  72967. import { Camera } from "babylonjs/Cameras/camera";
  72968. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72969. import { Engine } from "babylonjs/Engines/engine";
  72970. /**
  72971. * Class containing a set of static utilities functions for screenshots
  72972. */
  72973. export class ScreenshotTools {
  72974. /**
  72975. * Captures a screenshot of the current rendering
  72976. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72977. * @param engine defines the rendering engine
  72978. * @param camera defines the source camera
  72979. * @param size This parameter can be set to a single number or to an object with the
  72980. * following (optional) properties: precision, width, height. If a single number is passed,
  72981. * it will be used for both width and height. If an object is passed, the screenshot size
  72982. * will be derived from the parameters. The precision property is a multiplier allowing
  72983. * rendering at a higher or lower resolution
  72984. * @param successCallback defines the callback receives a single parameter which contains the
  72985. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72986. * src parameter of an <img> to display it
  72987. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72988. * Check your browser for supported MIME types
  72989. */
  72990. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72991. /**
  72992. * Captures a screenshot of the current rendering
  72993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72994. * @param engine defines the rendering engine
  72995. * @param camera defines the source camera
  72996. * @param size This parameter can be set to a single number or to an object with the
  72997. * following (optional) properties: precision, width, height. If a single number is passed,
  72998. * it will be used for both width and height. If an object is passed, the screenshot size
  72999. * will be derived from the parameters. The precision property is a multiplier allowing
  73000. * rendering at a higher or lower resolution
  73001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73002. * Check your browser for supported MIME types
  73003. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73004. * to the src parameter of an <img> to display it
  73005. */
  73006. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73007. /**
  73008. * Generates an image screenshot from the specified camera.
  73009. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73010. * @param engine The engine to use for rendering
  73011. * @param camera The camera to use for rendering
  73012. * @param size This parameter can be set to a single number or to an object with the
  73013. * following (optional) properties: precision, width, height. If a single number is passed,
  73014. * it will be used for both width and height. If an object is passed, the screenshot size
  73015. * will be derived from the parameters. The precision property is a multiplier allowing
  73016. * rendering at a higher or lower resolution
  73017. * @param successCallback The callback receives a single parameter which contains the
  73018. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73019. * src parameter of an <img> to display it
  73020. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73021. * Check your browser for supported MIME types
  73022. * @param samples Texture samples (default: 1)
  73023. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73024. * @param fileName A name for for the downloaded file.
  73025. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73026. */
  73027. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73028. /**
  73029. * Generates an image screenshot from the specified camera.
  73030. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73031. * @param engine The engine to use for rendering
  73032. * @param camera The camera to use for rendering
  73033. * @param size This parameter can be set to a single number or to an object with the
  73034. * following (optional) properties: precision, width, height. If a single number is passed,
  73035. * it will be used for both width and height. If an object is passed, the screenshot size
  73036. * will be derived from the parameters. The precision property is a multiplier allowing
  73037. * rendering at a higher or lower resolution
  73038. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73039. * Check your browser for supported MIME types
  73040. * @param samples Texture samples (default: 1)
  73041. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73042. * @param fileName A name for for the downloaded file.
  73043. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73044. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73045. * to the src parameter of an <img> to display it
  73046. */
  73047. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73048. /**
  73049. * Gets height and width for screenshot size
  73050. * @private
  73051. */
  73052. private static _getScreenshotSize;
  73053. }
  73054. }
  73055. declare module "babylonjs/Misc/dataReader" {
  73056. /**
  73057. * Interface for a data buffer
  73058. */
  73059. export interface IDataBuffer {
  73060. /**
  73061. * Reads bytes from the data buffer.
  73062. * @param byteOffset The byte offset to read
  73063. * @param byteLength The byte length to read
  73064. * @returns A promise that resolves when the bytes are read
  73065. */
  73066. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73067. /**
  73068. * The byte length of the buffer.
  73069. */
  73070. readonly byteLength: number;
  73071. }
  73072. /**
  73073. * Utility class for reading from a data buffer
  73074. */
  73075. export class DataReader {
  73076. /**
  73077. * The data buffer associated with this data reader.
  73078. */
  73079. readonly buffer: IDataBuffer;
  73080. /**
  73081. * The current byte offset from the beginning of the data buffer.
  73082. */
  73083. byteOffset: number;
  73084. private _dataView;
  73085. private _dataByteOffset;
  73086. /**
  73087. * Constructor
  73088. * @param buffer The buffer to read
  73089. */
  73090. constructor(buffer: IDataBuffer);
  73091. /**
  73092. * Loads the given byte length.
  73093. * @param byteLength The byte length to load
  73094. * @returns A promise that resolves when the load is complete
  73095. */
  73096. loadAsync(byteLength: number): Promise<void>;
  73097. /**
  73098. * Read a unsigned 32-bit integer from the currently loaded data range.
  73099. * @returns The 32-bit integer read
  73100. */
  73101. readUint32(): number;
  73102. /**
  73103. * Read a byte array from the currently loaded data range.
  73104. * @param byteLength The byte length to read
  73105. * @returns The byte array read
  73106. */
  73107. readUint8Array(byteLength: number): Uint8Array;
  73108. /**
  73109. * Read a string from the currently loaded data range.
  73110. * @param byteLength The byte length to read
  73111. * @returns The string read
  73112. */
  73113. readString(byteLength: number): string;
  73114. /**
  73115. * Skips the given byte length the currently loaded data range.
  73116. * @param byteLength The byte length to skip
  73117. */
  73118. skipBytes(byteLength: number): void;
  73119. }
  73120. }
  73121. declare module "babylonjs/Misc/dataStorage" {
  73122. /**
  73123. * Class for storing data to local storage if available or in-memory storage otherwise
  73124. */
  73125. export class DataStorage {
  73126. private static _Storage;
  73127. private static _GetStorage;
  73128. /**
  73129. * Reads a string from the data storage
  73130. * @param key The key to read
  73131. * @param defaultValue The value if the key doesn't exist
  73132. * @returns The string value
  73133. */
  73134. static ReadString(key: string, defaultValue: string): string;
  73135. /**
  73136. * Writes a string to the data storage
  73137. * @param key The key to write
  73138. * @param value The value to write
  73139. */
  73140. static WriteString(key: string, value: string): void;
  73141. /**
  73142. * Reads a boolean from the data storage
  73143. * @param key The key to read
  73144. * @param defaultValue The value if the key doesn't exist
  73145. * @returns The boolean value
  73146. */
  73147. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73148. /**
  73149. * Writes a boolean to the data storage
  73150. * @param key The key to write
  73151. * @param value The value to write
  73152. */
  73153. static WriteBoolean(key: string, value: boolean): void;
  73154. /**
  73155. * Reads a number from the data storage
  73156. * @param key The key to read
  73157. * @param defaultValue The value if the key doesn't exist
  73158. * @returns The number value
  73159. */
  73160. static ReadNumber(key: string, defaultValue: number): number;
  73161. /**
  73162. * Writes a number to the data storage
  73163. * @param key The key to write
  73164. * @param value The value to write
  73165. */
  73166. static WriteNumber(key: string, value: number): void;
  73167. }
  73168. }
  73169. declare module "babylonjs/Misc/index" {
  73170. export * from "babylonjs/Misc/andOrNotEvaluator";
  73171. export * from "babylonjs/Misc/assetsManager";
  73172. export * from "babylonjs/Misc/basis";
  73173. export * from "babylonjs/Misc/dds";
  73174. export * from "babylonjs/Misc/decorators";
  73175. export * from "babylonjs/Misc/deferred";
  73176. export * from "babylonjs/Misc/environmentTextureTools";
  73177. export * from "babylonjs/Misc/meshExploder";
  73178. export * from "babylonjs/Misc/filesInput";
  73179. export * from "babylonjs/Misc/HighDynamicRange/index";
  73180. export * from "babylonjs/Misc/khronosTextureContainer";
  73181. export * from "babylonjs/Misc/observable";
  73182. export * from "babylonjs/Misc/performanceMonitor";
  73183. export * from "babylonjs/Misc/promise";
  73184. export * from "babylonjs/Misc/sceneOptimizer";
  73185. export * from "babylonjs/Misc/sceneSerializer";
  73186. export * from "babylonjs/Misc/smartArray";
  73187. export * from "babylonjs/Misc/stringDictionary";
  73188. export * from "babylonjs/Misc/tags";
  73189. export * from "babylonjs/Misc/textureTools";
  73190. export * from "babylonjs/Misc/tga";
  73191. export * from "babylonjs/Misc/tools";
  73192. export * from "babylonjs/Misc/videoRecorder";
  73193. export * from "babylonjs/Misc/virtualJoystick";
  73194. export * from "babylonjs/Misc/workerPool";
  73195. export * from "babylonjs/Misc/logger";
  73196. export * from "babylonjs/Misc/typeStore";
  73197. export * from "babylonjs/Misc/filesInputStore";
  73198. export * from "babylonjs/Misc/deepCopier";
  73199. export * from "babylonjs/Misc/pivotTools";
  73200. export * from "babylonjs/Misc/precisionDate";
  73201. export * from "babylonjs/Misc/screenshotTools";
  73202. export * from "babylonjs/Misc/typeStore";
  73203. export * from "babylonjs/Misc/webRequest";
  73204. export * from "babylonjs/Misc/iInspectable";
  73205. export * from "babylonjs/Misc/brdfTextureTools";
  73206. export * from "babylonjs/Misc/rgbdTextureTools";
  73207. export * from "babylonjs/Misc/gradients";
  73208. export * from "babylonjs/Misc/perfCounter";
  73209. export * from "babylonjs/Misc/fileRequest";
  73210. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73211. export * from "babylonjs/Misc/retryStrategy";
  73212. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73213. export * from "babylonjs/Misc/canvasGenerator";
  73214. export * from "babylonjs/Misc/fileTools";
  73215. export * from "babylonjs/Misc/stringTools";
  73216. export * from "babylonjs/Misc/dataReader";
  73217. export * from "babylonjs/Misc/minMaxReducer";
  73218. export * from "babylonjs/Misc/depthReducer";
  73219. export * from "babylonjs/Misc/dataStorage";
  73220. }
  73221. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73222. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73223. import { Observable } from "babylonjs/Misc/observable";
  73224. import { Matrix } from "babylonjs/Maths/math.vector";
  73225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73226. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73227. /**
  73228. * Options used for hit testing
  73229. */
  73230. export interface IWebXRLegacyHitTestOptions {
  73231. /**
  73232. * Only test when user interacted with the scene. Default - hit test every frame
  73233. */
  73234. testOnPointerDownOnly?: boolean;
  73235. /**
  73236. * The node to use to transform the local results to world coordinates
  73237. */
  73238. worldParentNode?: TransformNode;
  73239. }
  73240. /**
  73241. * Interface defining the babylon result of raycasting/hit-test
  73242. */
  73243. export interface IWebXRLegacyHitResult {
  73244. /**
  73245. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73246. */
  73247. transformationMatrix: Matrix;
  73248. /**
  73249. * The native hit test result
  73250. */
  73251. xrHitResult: XRHitResult | XRHitTestResult;
  73252. }
  73253. /**
  73254. * The currently-working hit-test module.
  73255. * Hit test (or Ray-casting) is used to interact with the real world.
  73256. * For further information read here - https://github.com/immersive-web/hit-test
  73257. */
  73258. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73259. /**
  73260. * options to use when constructing this feature
  73261. */
  73262. readonly options: IWebXRLegacyHitTestOptions;
  73263. private _direction;
  73264. private _mat;
  73265. private _onSelectEnabled;
  73266. private _origin;
  73267. /**
  73268. * The module's name
  73269. */
  73270. static readonly Name: string;
  73271. /**
  73272. * The (Babylon) version of this module.
  73273. * This is an integer representing the implementation version.
  73274. * This number does not correspond to the WebXR specs version
  73275. */
  73276. static readonly Version: number;
  73277. /**
  73278. * Populated with the last native XR Hit Results
  73279. */
  73280. lastNativeXRHitResults: XRHitResult[];
  73281. /**
  73282. * Triggered when new babylon (transformed) hit test results are available
  73283. */
  73284. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73285. /**
  73286. * Creates a new instance of the (legacy version) hit test feature
  73287. * @param _xrSessionManager an instance of WebXRSessionManager
  73288. * @param options options to use when constructing this feature
  73289. */
  73290. constructor(_xrSessionManager: WebXRSessionManager,
  73291. /**
  73292. * options to use when constructing this feature
  73293. */
  73294. options?: IWebXRLegacyHitTestOptions);
  73295. /**
  73296. * execute a hit test with an XR Ray
  73297. *
  73298. * @param xrSession a native xrSession that will execute this hit test
  73299. * @param xrRay the ray (position and direction) to use for ray-casting
  73300. * @param referenceSpace native XR reference space to use for the hit-test
  73301. * @param filter filter function that will filter the results
  73302. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73303. */
  73304. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73305. /**
  73306. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73307. * @param event the (select) event to use to select with
  73308. * @param referenceSpace the reference space to use for this hit test
  73309. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73310. */
  73311. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73312. /**
  73313. * attach this feature
  73314. * Will usually be called by the features manager
  73315. *
  73316. * @returns true if successful.
  73317. */
  73318. attach(): boolean;
  73319. /**
  73320. * detach this feature.
  73321. * Will usually be called by the features manager
  73322. *
  73323. * @returns true if successful.
  73324. */
  73325. detach(): boolean;
  73326. /**
  73327. * Dispose this feature and all of the resources attached
  73328. */
  73329. dispose(): void;
  73330. protected _onXRFrame(frame: XRFrame): void;
  73331. private _onHitTestResults;
  73332. private _onSelect;
  73333. }
  73334. }
  73335. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73337. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73338. import { Observable } from "babylonjs/Misc/observable";
  73339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73340. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73341. /**
  73342. * Options used in the plane detector module
  73343. */
  73344. export interface IWebXRPlaneDetectorOptions {
  73345. /**
  73346. * The node to use to transform the local results to world coordinates
  73347. */
  73348. worldParentNode?: TransformNode;
  73349. }
  73350. /**
  73351. * A babylon interface for a WebXR plane.
  73352. * A Plane is actually a polygon, built from N points in space
  73353. *
  73354. * Supported in chrome 79, not supported in canary 81 ATM
  73355. */
  73356. export interface IWebXRPlane {
  73357. /**
  73358. * a babylon-assigned ID for this polygon
  73359. */
  73360. id: number;
  73361. /**
  73362. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73363. */
  73364. polygonDefinition: Array<Vector3>;
  73365. /**
  73366. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73367. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73368. */
  73369. transformationMatrix: Matrix;
  73370. /**
  73371. * the native xr-plane object
  73372. */
  73373. xrPlane: XRPlane;
  73374. }
  73375. /**
  73376. * The plane detector is used to detect planes in the real world when in AR
  73377. * For more information see https://github.com/immersive-web/real-world-geometry/
  73378. */
  73379. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73380. private _options;
  73381. private _detectedPlanes;
  73382. private _enabled;
  73383. private _lastFrameDetected;
  73384. /**
  73385. * The module's name
  73386. */
  73387. static readonly Name: string;
  73388. /**
  73389. * The (Babylon) version of this module.
  73390. * This is an integer representing the implementation version.
  73391. * This number does not correspond to the WebXR specs version
  73392. */
  73393. static readonly Version: number;
  73394. /**
  73395. * Observers registered here will be executed when a new plane was added to the session
  73396. */
  73397. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73398. /**
  73399. * Observers registered here will be executed when a plane is no longer detected in the session
  73400. */
  73401. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73402. /**
  73403. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73404. * This can execute N times every frame
  73405. */
  73406. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73407. /**
  73408. * construct a new Plane Detector
  73409. * @param _xrSessionManager an instance of xr Session manager
  73410. * @param _options configuration to use when constructing this feature
  73411. */
  73412. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73413. /**
  73414. * Dispose this feature and all of the resources attached
  73415. */
  73416. dispose(): void;
  73417. protected _onXRFrame(frame: XRFrame): void;
  73418. private _init;
  73419. private _updatePlaneWithXRPlane;
  73420. /**
  73421. * avoiding using Array.find for global support.
  73422. * @param xrPlane the plane to find in the array
  73423. */
  73424. private findIndexInPlaneArray;
  73425. }
  73426. }
  73427. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73428. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73429. import { Observable } from "babylonjs/Misc/observable";
  73430. import { Matrix } from "babylonjs/Maths/math.vector";
  73431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73432. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73433. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73434. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73435. /**
  73436. * Configuration options of the anchor system
  73437. */
  73438. export interface IWebXRAnchorSystemOptions {
  73439. /**
  73440. * Should a new anchor be added every time a select event is triggered
  73441. */
  73442. addAnchorOnSelect?: boolean;
  73443. /**
  73444. * should the anchor system use plane detection.
  73445. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73446. */
  73447. usePlaneDetection?: boolean;
  73448. /**
  73449. * a node that will be used to convert local to world coordinates
  73450. */
  73451. worldParentNode?: TransformNode;
  73452. }
  73453. /**
  73454. * A babylon container for an XR Anchor
  73455. */
  73456. export interface IWebXRAnchor {
  73457. /**
  73458. * A babylon-assigned ID for this anchor
  73459. */
  73460. id: number;
  73461. /**
  73462. * Transformation matrix to apply to an object attached to this anchor
  73463. */
  73464. transformationMatrix: Matrix;
  73465. /**
  73466. * The native anchor object
  73467. */
  73468. xrAnchor: XRAnchor;
  73469. }
  73470. /**
  73471. * An implementation of the anchor system of WebXR.
  73472. * Note that the current documented implementation is not available in any browser. Future implementations
  73473. * will use the frame to create an anchor and not the session or a detected plane
  73474. * For further information see https://github.com/immersive-web/anchors/
  73475. */
  73476. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73477. private _options;
  73478. private _enabled;
  73479. private _hitTestModule;
  73480. private _lastFrameDetected;
  73481. private _onSelect;
  73482. private _planeDetector;
  73483. private _trackedAnchors;
  73484. /**
  73485. * The module's name
  73486. */
  73487. static readonly Name: string;
  73488. /**
  73489. * The (Babylon) version of this module.
  73490. * This is an integer representing the implementation version.
  73491. * This number does not correspond to the WebXR specs version
  73492. */
  73493. static readonly Version: number;
  73494. /**
  73495. * Observers registered here will be executed when a new anchor was added to the session
  73496. */
  73497. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73498. /**
  73499. * Observers registered here will be executed when an anchor was removed from the session
  73500. */
  73501. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73502. /**
  73503. * Observers registered here will be executed when an existing anchor updates
  73504. * This can execute N times every frame
  73505. */
  73506. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73507. /**
  73508. * constructs a new anchor system
  73509. * @param _xrSessionManager an instance of WebXRSessionManager
  73510. * @param _options configuration object for this feature
  73511. */
  73512. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73513. /**
  73514. * Add anchor at a specific XR point.
  73515. *
  73516. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73517. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73518. * @returns a promise the fulfills when the anchor was created
  73519. */
  73520. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73521. /**
  73522. * attach this feature
  73523. * Will usually be called by the features manager
  73524. *
  73525. * @returns true if successful.
  73526. */
  73527. attach(): boolean;
  73528. /**
  73529. * detach this feature.
  73530. * Will usually be called by the features manager
  73531. *
  73532. * @returns true if successful.
  73533. */
  73534. detach(): boolean;
  73535. /**
  73536. * Dispose this feature and all of the resources attached
  73537. */
  73538. dispose(): void;
  73539. /**
  73540. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73541. * @param hitTestModule the hit-test module to use.
  73542. */
  73543. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73544. /**
  73545. * set the plane detector to use in order to create anchors from frames
  73546. * @param planeDetector the plane-detector module to use
  73547. * @param enable enable plane-anchors. default is true
  73548. */
  73549. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73550. protected _onXRFrame(frame: XRFrame): void;
  73551. /**
  73552. * avoiding using Array.find for global support.
  73553. * @param xrAnchor the plane to find in the array
  73554. */
  73555. private _findIndexInAnchorArray;
  73556. private _updateAnchorWithXRFrame;
  73557. }
  73558. }
  73559. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73560. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73562. import { Observable } from "babylonjs/Misc/observable";
  73563. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73564. /**
  73565. * Options interface for the background remover plugin
  73566. */
  73567. export interface IWebXRBackgroundRemoverOptions {
  73568. /**
  73569. * Further background meshes to disable when entering AR
  73570. */
  73571. backgroundMeshes?: AbstractMesh[];
  73572. /**
  73573. * flags to configure the removal of the environment helper.
  73574. * If not set, the entire background will be removed. If set, flags should be set as well.
  73575. */
  73576. environmentHelperRemovalFlags?: {
  73577. /**
  73578. * Should the skybox be removed (default false)
  73579. */
  73580. skyBox?: boolean;
  73581. /**
  73582. * Should the ground be removed (default false)
  73583. */
  73584. ground?: boolean;
  73585. };
  73586. /**
  73587. * don't disable the environment helper
  73588. */
  73589. ignoreEnvironmentHelper?: boolean;
  73590. }
  73591. /**
  73592. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73593. */
  73594. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73595. /**
  73596. * read-only options to be used in this module
  73597. */
  73598. readonly options: IWebXRBackgroundRemoverOptions;
  73599. /**
  73600. * The module's name
  73601. */
  73602. static readonly Name: string;
  73603. /**
  73604. * The (Babylon) version of this module.
  73605. * This is an integer representing the implementation version.
  73606. * This number does not correspond to the WebXR specs version
  73607. */
  73608. static readonly Version: number;
  73609. /**
  73610. * registered observers will be triggered when the background state changes
  73611. */
  73612. onBackgroundStateChangedObservable: Observable<boolean>;
  73613. /**
  73614. * constructs a new background remover module
  73615. * @param _xrSessionManager the session manager for this module
  73616. * @param options read-only options to be used in this module
  73617. */
  73618. constructor(_xrSessionManager: WebXRSessionManager,
  73619. /**
  73620. * read-only options to be used in this module
  73621. */
  73622. options?: IWebXRBackgroundRemoverOptions);
  73623. /**
  73624. * attach this feature
  73625. * Will usually be called by the features manager
  73626. *
  73627. * @returns true if successful.
  73628. */
  73629. attach(): boolean;
  73630. /**
  73631. * detach this feature.
  73632. * Will usually be called by the features manager
  73633. *
  73634. * @returns true if successful.
  73635. */
  73636. detach(): boolean;
  73637. /**
  73638. * Dispose this feature and all of the resources attached
  73639. */
  73640. dispose(): void;
  73641. protected _onXRFrame(_xrFrame: XRFrame): void;
  73642. private _setBackgroundState;
  73643. }
  73644. }
  73645. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73646. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73647. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73648. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73649. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73650. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73651. import { Nullable } from "babylonjs/types";
  73652. /**
  73653. * Options for the controller physics feature
  73654. */
  73655. export class IWebXRControllerPhysicsOptions {
  73656. /**
  73657. * Should the headset get its own impostor
  73658. */
  73659. enableHeadsetImpostor?: boolean;
  73660. /**
  73661. * Optional parameters for the headset impostor
  73662. */
  73663. headsetImpostorParams?: {
  73664. /**
  73665. * The type of impostor to create. Default is sphere
  73666. */
  73667. impostorType: number;
  73668. /**
  73669. * the size of the impostor. Defaults to 10cm
  73670. */
  73671. impostorSize?: number | {
  73672. width: number;
  73673. height: number;
  73674. depth: number;
  73675. };
  73676. /**
  73677. * Friction definitions
  73678. */
  73679. friction?: number;
  73680. /**
  73681. * Restitution
  73682. */
  73683. restitution?: number;
  73684. };
  73685. /**
  73686. * The physics properties of the future impostors
  73687. */
  73688. physicsProperties?: {
  73689. /**
  73690. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73691. * Note that this requires a physics engine that supports mesh impostors!
  73692. */
  73693. useControllerMesh?: boolean;
  73694. /**
  73695. * The type of impostor to create. Default is sphere
  73696. */
  73697. impostorType?: number;
  73698. /**
  73699. * the size of the impostor. Defaults to 10cm
  73700. */
  73701. impostorSize?: number | {
  73702. width: number;
  73703. height: number;
  73704. depth: number;
  73705. };
  73706. /**
  73707. * Friction definitions
  73708. */
  73709. friction?: number;
  73710. /**
  73711. * Restitution
  73712. */
  73713. restitution?: number;
  73714. };
  73715. /**
  73716. * the xr input to use with this pointer selection
  73717. */
  73718. xrInput: WebXRInput;
  73719. }
  73720. /**
  73721. * Add physics impostor to your webxr controllers,
  73722. * including naive calculation of their linear and angular velocity
  73723. */
  73724. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73725. private readonly _options;
  73726. private _attachController;
  73727. private _controllers;
  73728. private _debugMode;
  73729. private _delta;
  73730. private _headsetImpostor?;
  73731. private _headsetMesh?;
  73732. private _lastTimestamp;
  73733. private _tmpQuaternion;
  73734. private _tmpVector;
  73735. /**
  73736. * The module's name
  73737. */
  73738. static readonly Name: string;
  73739. /**
  73740. * The (Babylon) version of this module.
  73741. * This is an integer representing the implementation version.
  73742. * This number does not correspond to the webxr specs version
  73743. */
  73744. static readonly Version: number;
  73745. /**
  73746. * Construct a new Controller Physics Feature
  73747. * @param _xrSessionManager the corresponding xr session manager
  73748. * @param _options options to create this feature with
  73749. */
  73750. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73751. /**
  73752. * @hidden
  73753. * enable debugging - will show console outputs and the impostor mesh
  73754. */
  73755. _enablePhysicsDebug(): void;
  73756. /**
  73757. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73758. * @param xrController the controller to add
  73759. */
  73760. addController(xrController: WebXRInputSource): void;
  73761. /**
  73762. * attach this feature
  73763. * Will usually be called by the features manager
  73764. *
  73765. * @returns true if successful.
  73766. */
  73767. attach(): boolean;
  73768. /**
  73769. * detach this feature.
  73770. * Will usually be called by the features manager
  73771. *
  73772. * @returns true if successful.
  73773. */
  73774. detach(): boolean;
  73775. /**
  73776. * Get the headset impostor, if enabled
  73777. * @returns the impostor
  73778. */
  73779. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73780. /**
  73781. * Get the physics impostor of a specific controller.
  73782. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73783. * @param controller the controller or the controller id of which to get the impostor
  73784. * @returns the impostor or null
  73785. */
  73786. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73787. /**
  73788. * Update the physics properties provided in the constructor
  73789. * @param newProperties the new properties object
  73790. */
  73791. setPhysicsProperties(newProperties: {
  73792. impostorType?: number;
  73793. impostorSize?: number | {
  73794. width: number;
  73795. height: number;
  73796. depth: number;
  73797. };
  73798. friction?: number;
  73799. restitution?: number;
  73800. }): void;
  73801. protected _onXRFrame(_xrFrame: any): void;
  73802. private _detachController;
  73803. }
  73804. }
  73805. declare module "babylonjs/XR/features/WebXRHitTest" {
  73806. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73807. import { Observable } from "babylonjs/Misc/observable";
  73808. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73809. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73810. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73811. /**
  73812. * Options used for hit testing (version 2)
  73813. */
  73814. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73815. /**
  73816. * Do not create a permanent hit test. Will usually be used when only
  73817. * transient inputs are needed.
  73818. */
  73819. disablePermanentHitTest?: boolean;
  73820. /**
  73821. * Enable transient (for example touch-based) hit test inspections
  73822. */
  73823. enableTransientHitTest?: boolean;
  73824. /**
  73825. * Offset ray for the permanent hit test
  73826. */
  73827. offsetRay?: Vector3;
  73828. /**
  73829. * Offset ray for the transient hit test
  73830. */
  73831. transientOffsetRay?: Vector3;
  73832. /**
  73833. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73834. */
  73835. useReferenceSpace?: boolean;
  73836. }
  73837. /**
  73838. * Interface defining the babylon result of hit-test
  73839. */
  73840. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73841. /**
  73842. * The input source that generated this hit test (if transient)
  73843. */
  73844. inputSource?: XRInputSource;
  73845. /**
  73846. * Is this a transient hit test
  73847. */
  73848. isTransient?: boolean;
  73849. /**
  73850. * Position of the hit test result
  73851. */
  73852. position: Vector3;
  73853. /**
  73854. * Rotation of the hit test result
  73855. */
  73856. rotationQuaternion: Quaternion;
  73857. }
  73858. /**
  73859. * The currently-working hit-test module.
  73860. * Hit test (or Ray-casting) is used to interact with the real world.
  73861. * For further information read here - https://github.com/immersive-web/hit-test
  73862. *
  73863. * Tested on chrome (mobile) 80.
  73864. */
  73865. export class WebXRHitTest extends WebXRAbstractFeature {
  73866. /**
  73867. * options to use when constructing this feature
  73868. */
  73869. readonly options: IWebXRHitTestOptions;
  73870. private _tmpMat;
  73871. private _tmpPos;
  73872. private _tmpQuat;
  73873. private _transientXrHitTestSource;
  73874. private _xrHitTestSource;
  73875. private initHitTestSource;
  73876. /**
  73877. * The module's name
  73878. */
  73879. static readonly Name: string;
  73880. /**
  73881. * The (Babylon) version of this module.
  73882. * This is an integer representing the implementation version.
  73883. * This number does not correspond to the WebXR specs version
  73884. */
  73885. static readonly Version: number;
  73886. /**
  73887. * When set to true, each hit test will have its own position/rotation objects
  73888. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73889. * the developers will clone them or copy them as they see fit.
  73890. */
  73891. autoCloneTransformation: boolean;
  73892. /**
  73893. * Populated with the last native XR Hit Results
  73894. */
  73895. lastNativeXRHitResults: XRHitResult[];
  73896. /**
  73897. * Triggered when new babylon (transformed) hit test results are available
  73898. */
  73899. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73900. /**
  73901. * Use this to temporarily pause hit test checks.
  73902. */
  73903. paused: boolean;
  73904. /**
  73905. * Creates a new instance of the hit test feature
  73906. * @param _xrSessionManager an instance of WebXRSessionManager
  73907. * @param options options to use when constructing this feature
  73908. */
  73909. constructor(_xrSessionManager: WebXRSessionManager,
  73910. /**
  73911. * options to use when constructing this feature
  73912. */
  73913. options?: IWebXRHitTestOptions);
  73914. /**
  73915. * attach this feature
  73916. * Will usually be called by the features manager
  73917. *
  73918. * @returns true if successful.
  73919. */
  73920. attach(): boolean;
  73921. /**
  73922. * detach this feature.
  73923. * Will usually be called by the features manager
  73924. *
  73925. * @returns true if successful.
  73926. */
  73927. detach(): boolean;
  73928. /**
  73929. * Dispose this feature and all of the resources attached
  73930. */
  73931. dispose(): void;
  73932. protected _onXRFrame(frame: XRFrame): void;
  73933. private _processWebXRHitTestResult;
  73934. }
  73935. }
  73936. declare module "babylonjs/XR/features/index" {
  73937. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73938. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73939. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73940. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73941. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73942. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73943. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73944. export * from "babylonjs/XR/features/WebXRHitTest";
  73945. }
  73946. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73947. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73949. import { Scene } from "babylonjs/scene";
  73950. /**
  73951. * The motion controller class for all microsoft mixed reality controllers
  73952. */
  73953. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73954. protected readonly _mapping: {
  73955. defaultButton: {
  73956. valueNodeName: string;
  73957. unpressedNodeName: string;
  73958. pressedNodeName: string;
  73959. };
  73960. defaultAxis: {
  73961. valueNodeName: string;
  73962. minNodeName: string;
  73963. maxNodeName: string;
  73964. };
  73965. buttons: {
  73966. "xr-standard-trigger": {
  73967. rootNodeName: string;
  73968. componentProperty: string;
  73969. states: string[];
  73970. };
  73971. "xr-standard-squeeze": {
  73972. rootNodeName: string;
  73973. componentProperty: string;
  73974. states: string[];
  73975. };
  73976. "xr-standard-touchpad": {
  73977. rootNodeName: string;
  73978. labelAnchorNodeName: string;
  73979. touchPointNodeName: string;
  73980. };
  73981. "xr-standard-thumbstick": {
  73982. rootNodeName: string;
  73983. componentProperty: string;
  73984. states: string[];
  73985. };
  73986. };
  73987. axes: {
  73988. "xr-standard-touchpad": {
  73989. "x-axis": {
  73990. rootNodeName: string;
  73991. };
  73992. "y-axis": {
  73993. rootNodeName: string;
  73994. };
  73995. };
  73996. "xr-standard-thumbstick": {
  73997. "x-axis": {
  73998. rootNodeName: string;
  73999. };
  74000. "y-axis": {
  74001. rootNodeName: string;
  74002. };
  74003. };
  74004. };
  74005. };
  74006. /**
  74007. * The base url used to load the left and right controller models
  74008. */
  74009. static MODEL_BASE_URL: string;
  74010. /**
  74011. * The name of the left controller model file
  74012. */
  74013. static MODEL_LEFT_FILENAME: string;
  74014. /**
  74015. * The name of the right controller model file
  74016. */
  74017. static MODEL_RIGHT_FILENAME: string;
  74018. profileId: string;
  74019. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74020. protected _getFilenameAndPath(): {
  74021. filename: string;
  74022. path: string;
  74023. };
  74024. protected _getModelLoadingConstraints(): boolean;
  74025. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74026. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74027. protected _updateModel(): void;
  74028. }
  74029. }
  74030. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74031. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74033. import { Scene } from "babylonjs/scene";
  74034. /**
  74035. * The motion controller class for oculus touch (quest, rift).
  74036. * This class supports legacy mapping as well the standard xr mapping
  74037. */
  74038. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74039. private _forceLegacyControllers;
  74040. private _modelRootNode;
  74041. /**
  74042. * The base url used to load the left and right controller models
  74043. */
  74044. static MODEL_BASE_URL: string;
  74045. /**
  74046. * The name of the left controller model file
  74047. */
  74048. static MODEL_LEFT_FILENAME: string;
  74049. /**
  74050. * The name of the right controller model file
  74051. */
  74052. static MODEL_RIGHT_FILENAME: string;
  74053. /**
  74054. * Base Url for the Quest controller model.
  74055. */
  74056. static QUEST_MODEL_BASE_URL: string;
  74057. profileId: string;
  74058. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74059. protected _getFilenameAndPath(): {
  74060. filename: string;
  74061. path: string;
  74062. };
  74063. protected _getModelLoadingConstraints(): boolean;
  74064. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74065. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74066. protected _updateModel(): void;
  74067. /**
  74068. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74069. * between the touch and touch 2.
  74070. */
  74071. private _isQuest;
  74072. }
  74073. }
  74074. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74075. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74076. import { Scene } from "babylonjs/scene";
  74077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74078. /**
  74079. * The motion controller class for the standard HTC-Vive controllers
  74080. */
  74081. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74082. private _modelRootNode;
  74083. /**
  74084. * The base url used to load the left and right controller models
  74085. */
  74086. static MODEL_BASE_URL: string;
  74087. /**
  74088. * File name for the controller model.
  74089. */
  74090. static MODEL_FILENAME: string;
  74091. profileId: string;
  74092. /**
  74093. * Create a new Vive motion controller object
  74094. * @param scene the scene to use to create this controller
  74095. * @param gamepadObject the corresponding gamepad object
  74096. * @param handness the handness of the controller
  74097. */
  74098. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74099. protected _getFilenameAndPath(): {
  74100. filename: string;
  74101. path: string;
  74102. };
  74103. protected _getModelLoadingConstraints(): boolean;
  74104. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74105. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74106. protected _updateModel(): void;
  74107. }
  74108. }
  74109. declare module "babylonjs/XR/motionController/index" {
  74110. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74111. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74112. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74113. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74114. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74115. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74116. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74117. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74118. }
  74119. declare module "babylonjs/XR/index" {
  74120. export * from "babylonjs/XR/webXRCamera";
  74121. export * from "babylonjs/XR/webXREnterExitUI";
  74122. export * from "babylonjs/XR/webXRExperienceHelper";
  74123. export * from "babylonjs/XR/webXRInput";
  74124. export * from "babylonjs/XR/webXRInputSource";
  74125. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74126. export * from "babylonjs/XR/webXRTypes";
  74127. export * from "babylonjs/XR/webXRSessionManager";
  74128. export * from "babylonjs/XR/webXRDefaultExperience";
  74129. export * from "babylonjs/XR/webXRFeaturesManager";
  74130. export * from "babylonjs/XR/features/index";
  74131. export * from "babylonjs/XR/motionController/index";
  74132. }
  74133. declare module "babylonjs/index" {
  74134. export * from "babylonjs/abstractScene";
  74135. export * from "babylonjs/Actions/index";
  74136. export * from "babylonjs/Animations/index";
  74137. export * from "babylonjs/assetContainer";
  74138. export * from "babylonjs/Audio/index";
  74139. export * from "babylonjs/Behaviors/index";
  74140. export * from "babylonjs/Bones/index";
  74141. export * from "babylonjs/Cameras/index";
  74142. export * from "babylonjs/Collisions/index";
  74143. export * from "babylonjs/Culling/index";
  74144. export * from "babylonjs/Debug/index";
  74145. export * from "babylonjs/Engines/index";
  74146. export * from "babylonjs/Events/index";
  74147. export * from "babylonjs/Gamepads/index";
  74148. export * from "babylonjs/Gizmos/index";
  74149. export * from "babylonjs/Helpers/index";
  74150. export * from "babylonjs/Instrumentation/index";
  74151. export * from "babylonjs/Layers/index";
  74152. export * from "babylonjs/LensFlares/index";
  74153. export * from "babylonjs/Lights/index";
  74154. export * from "babylonjs/Loading/index";
  74155. export * from "babylonjs/Materials/index";
  74156. export * from "babylonjs/Maths/index";
  74157. export * from "babylonjs/Meshes/index";
  74158. export * from "babylonjs/Morph/index";
  74159. export * from "babylonjs/Navigation/index";
  74160. export * from "babylonjs/node";
  74161. export * from "babylonjs/Offline/index";
  74162. export * from "babylonjs/Particles/index";
  74163. export * from "babylonjs/Physics/index";
  74164. export * from "babylonjs/PostProcesses/index";
  74165. export * from "babylonjs/Probes/index";
  74166. export * from "babylonjs/Rendering/index";
  74167. export * from "babylonjs/scene";
  74168. export * from "babylonjs/sceneComponent";
  74169. export * from "babylonjs/Sprites/index";
  74170. export * from "babylonjs/States/index";
  74171. export * from "babylonjs/Misc/index";
  74172. export * from "babylonjs/XR/index";
  74173. export * from "babylonjs/types";
  74174. }
  74175. declare module "babylonjs/Animations/pathCursor" {
  74176. import { Vector3 } from "babylonjs/Maths/math.vector";
  74177. import { Path2 } from "babylonjs/Maths/math.path";
  74178. /**
  74179. * A cursor which tracks a point on a path
  74180. */
  74181. export class PathCursor {
  74182. private path;
  74183. /**
  74184. * Stores path cursor callbacks for when an onchange event is triggered
  74185. */
  74186. private _onchange;
  74187. /**
  74188. * The value of the path cursor
  74189. */
  74190. value: number;
  74191. /**
  74192. * The animation array of the path cursor
  74193. */
  74194. animations: Animation[];
  74195. /**
  74196. * Initializes the path cursor
  74197. * @param path The path to track
  74198. */
  74199. constructor(path: Path2);
  74200. /**
  74201. * Gets the cursor point on the path
  74202. * @returns A point on the path cursor at the cursor location
  74203. */
  74204. getPoint(): Vector3;
  74205. /**
  74206. * Moves the cursor ahead by the step amount
  74207. * @param step The amount to move the cursor forward
  74208. * @returns This path cursor
  74209. */
  74210. moveAhead(step?: number): PathCursor;
  74211. /**
  74212. * Moves the cursor behind by the step amount
  74213. * @param step The amount to move the cursor back
  74214. * @returns This path cursor
  74215. */
  74216. moveBack(step?: number): PathCursor;
  74217. /**
  74218. * Moves the cursor by the step amount
  74219. * If the step amount is greater than one, an exception is thrown
  74220. * @param step The amount to move the cursor
  74221. * @returns This path cursor
  74222. */
  74223. move(step: number): PathCursor;
  74224. /**
  74225. * Ensures that the value is limited between zero and one
  74226. * @returns This path cursor
  74227. */
  74228. private ensureLimits;
  74229. /**
  74230. * Runs onchange callbacks on change (used by the animation engine)
  74231. * @returns This path cursor
  74232. */
  74233. private raiseOnChange;
  74234. /**
  74235. * Executes a function on change
  74236. * @param f A path cursor onchange callback
  74237. * @returns This path cursor
  74238. */
  74239. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74240. }
  74241. }
  74242. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74245. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74246. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74247. }
  74248. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74249. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74250. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74251. }
  74252. declare module "babylonjs/Engines/Processors/index" {
  74253. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74254. export * from "babylonjs/Engines/Processors/Expressions/index";
  74255. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74256. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74257. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74258. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74259. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74260. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74261. }
  74262. declare module "babylonjs/Legacy/legacy" {
  74263. import * as Babylon from "babylonjs/index";
  74264. export * from "babylonjs/index";
  74265. }
  74266. declare module "babylonjs/Shaders/blur.fragment" {
  74267. /** @hidden */
  74268. export var blurPixelShader: {
  74269. name: string;
  74270. shader: string;
  74271. };
  74272. }
  74273. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74274. /** @hidden */
  74275. export var pointCloudVertexDeclaration: {
  74276. name: string;
  74277. shader: string;
  74278. };
  74279. }
  74280. declare module "babylonjs" {
  74281. export * from "babylonjs/Legacy/legacy";
  74282. }
  74283. declare module BABYLON {
  74284. /** Alias type for value that can be null */
  74285. export type Nullable<T> = T | null;
  74286. /**
  74287. * Alias type for number that are floats
  74288. * @ignorenaming
  74289. */
  74290. export type float = number;
  74291. /**
  74292. * Alias type for number that are doubles.
  74293. * @ignorenaming
  74294. */
  74295. export type double = number;
  74296. /**
  74297. * Alias type for number that are integer
  74298. * @ignorenaming
  74299. */
  74300. export type int = number;
  74301. /** Alias type for number array or Float32Array */
  74302. export type FloatArray = number[] | Float32Array;
  74303. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74304. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74305. /**
  74306. * Alias for types that can be used by a Buffer or VertexBuffer.
  74307. */
  74308. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74309. /**
  74310. * Alias type for primitive types
  74311. * @ignorenaming
  74312. */
  74313. type Primitive = undefined | null | boolean | string | number | Function;
  74314. /**
  74315. * Type modifier to make all the properties of an object Readonly
  74316. */
  74317. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74318. /**
  74319. * Type modifier to make all the properties of an object Readonly recursively
  74320. */
  74321. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74322. /**
  74323. * Type modifier to make object properties readonly.
  74324. */
  74325. export type DeepImmutableObject<T> = {
  74326. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74327. };
  74328. /** @hidden */
  74329. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74330. }
  74331. }
  74332. declare module BABYLON {
  74333. /**
  74334. * A class serves as a medium between the observable and its observers
  74335. */
  74336. export class EventState {
  74337. /**
  74338. * Create a new EventState
  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. */
  74344. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74345. /**
  74346. * Initialize the current event state
  74347. * @param mask defines the mask associated with this state
  74348. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74349. * @param target defines the original target of the state
  74350. * @param currentTarget defines the current target of the state
  74351. * @returns the current event state
  74352. */
  74353. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74354. /**
  74355. * An Observer can set this property to true to prevent subsequent observers of being notified
  74356. */
  74357. skipNextObservers: boolean;
  74358. /**
  74359. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74360. */
  74361. mask: number;
  74362. /**
  74363. * The object that originally notified the event
  74364. */
  74365. target?: any;
  74366. /**
  74367. * The current object in the bubbling phase
  74368. */
  74369. currentTarget?: any;
  74370. /**
  74371. * This will be populated with the return value of the last function that was executed.
  74372. * If it is the first function in the callback chain it will be the event data.
  74373. */
  74374. lastReturnValue?: any;
  74375. }
  74376. /**
  74377. * Represent an Observer registered to a given Observable object.
  74378. */
  74379. export class Observer<T> {
  74380. /**
  74381. * Defines the callback to call when the observer is notified
  74382. */
  74383. callback: (eventData: T, eventState: EventState) => void;
  74384. /**
  74385. * Defines the mask of the observer (used to filter notifications)
  74386. */
  74387. mask: number;
  74388. /**
  74389. * Defines the current scope used to restore the JS context
  74390. */
  74391. scope: any;
  74392. /** @hidden */
  74393. _willBeUnregistered: boolean;
  74394. /**
  74395. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74396. */
  74397. unregisterOnNextCall: boolean;
  74398. /**
  74399. * Creates a new observer
  74400. * @param callback defines the callback to call when the observer is notified
  74401. * @param mask defines the mask of the observer (used to filter notifications)
  74402. * @param scope defines the current scope used to restore the JS context
  74403. */
  74404. constructor(
  74405. /**
  74406. * Defines the callback to call when the observer is notified
  74407. */
  74408. callback: (eventData: T, eventState: EventState) => void,
  74409. /**
  74410. * Defines the mask of the observer (used to filter notifications)
  74411. */
  74412. mask: number,
  74413. /**
  74414. * Defines the current scope used to restore the JS context
  74415. */
  74416. scope?: any);
  74417. }
  74418. /**
  74419. * Represent a list of observers registered to multiple Observables object.
  74420. */
  74421. export class MultiObserver<T> {
  74422. private _observers;
  74423. private _observables;
  74424. /**
  74425. * Release associated resources
  74426. */
  74427. dispose(): void;
  74428. /**
  74429. * Raise a callback when one of the observable will notify
  74430. * @param observables defines a list of observables to watch
  74431. * @param callback defines the callback to call on notification
  74432. * @param mask defines the mask used to filter notifications
  74433. * @param scope defines the current scope used to restore the JS context
  74434. * @returns the new MultiObserver
  74435. */
  74436. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74437. }
  74438. /**
  74439. * The Observable class is a simple implementation of the Observable pattern.
  74440. *
  74441. * 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.
  74442. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74443. * 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).
  74444. * 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.
  74445. */
  74446. export class Observable<T> {
  74447. private _observers;
  74448. private _eventState;
  74449. private _onObserverAdded;
  74450. /**
  74451. * Gets the list of observers
  74452. */
  74453. get observers(): Array<Observer<T>>;
  74454. /**
  74455. * Creates a new observable
  74456. * @param onObserverAdded defines a callback to call when a new observer is added
  74457. */
  74458. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74459. /**
  74460. * Create a new Observer with the specified callback
  74461. * @param callback the callback that will be executed for that Observer
  74462. * @param mask the mask used to filter observers
  74463. * @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.
  74464. * @param scope optional scope for the callback to be called from
  74465. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74466. * @returns the new observer created for the callback
  74467. */
  74468. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74469. /**
  74470. * Create a new Observer with the specified callback and unregisters after the next notification
  74471. * @param callback the callback that will be executed for that Observer
  74472. * @returns the new observer created for the callback
  74473. */
  74474. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74475. /**
  74476. * Remove an Observer from the Observable object
  74477. * @param observer the instance of the Observer to remove
  74478. * @returns false if it doesn't belong to this Observable
  74479. */
  74480. remove(observer: Nullable<Observer<T>>): boolean;
  74481. /**
  74482. * Remove a callback from the Observable object
  74483. * @param callback the callback to remove
  74484. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74485. * @returns false if it doesn't belong to this Observable
  74486. */
  74487. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74488. private _deferUnregister;
  74489. private _remove;
  74490. /**
  74491. * Moves the observable to the top of the observer list making it get called first when notified
  74492. * @param observer the observer to move
  74493. */
  74494. makeObserverTopPriority(observer: Observer<T>): void;
  74495. /**
  74496. * Moves the observable to the bottom of the observer list making it get called last when notified
  74497. * @param observer the observer to move
  74498. */
  74499. makeObserverBottomPriority(observer: Observer<T>): void;
  74500. /**
  74501. * Notify all Observers by calling their respective callback with the given data
  74502. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74503. * @param eventData defines the data to send to all observers
  74504. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74505. * @param target defines the original target of the state
  74506. * @param currentTarget defines the current target of the state
  74507. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74508. */
  74509. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74510. /**
  74511. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74512. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74513. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74514. * and it is crucial that all callbacks will be executed.
  74515. * The order of the callbacks is kept, callbacks are not executed parallel.
  74516. *
  74517. * @param eventData The data to be sent to each callback
  74518. * @param mask is used to filter observers defaults to -1
  74519. * @param target defines the callback target (see EventState)
  74520. * @param currentTarget defines he current object in the bubbling phase
  74521. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74522. */
  74523. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74524. /**
  74525. * Notify a specific observer
  74526. * @param observer defines the observer to notify
  74527. * @param eventData defines the data to be sent to each callback
  74528. * @param mask is used to filter observers defaults to -1
  74529. */
  74530. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74531. /**
  74532. * Gets a boolean indicating if the observable has at least one observer
  74533. * @returns true is the Observable has at least one Observer registered
  74534. */
  74535. hasObservers(): boolean;
  74536. /**
  74537. * Clear the list of observers
  74538. */
  74539. clear(): void;
  74540. /**
  74541. * Clone the current observable
  74542. * @returns a new observable
  74543. */
  74544. clone(): Observable<T>;
  74545. /**
  74546. * Does this observable handles observer registered with a given mask
  74547. * @param mask defines the mask to be tested
  74548. * @return whether or not one observer registered with the given mask is handeled
  74549. **/
  74550. hasSpecificMask(mask?: number): boolean;
  74551. }
  74552. }
  74553. declare module BABYLON {
  74554. /**
  74555. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74556. * Babylon.js
  74557. */
  74558. export class DomManagement {
  74559. /**
  74560. * Checks if the window object exists
  74561. * @returns true if the window object exists
  74562. */
  74563. static IsWindowObjectExist(): boolean;
  74564. /**
  74565. * Checks if the navigator object exists
  74566. * @returns true if the navigator object exists
  74567. */
  74568. static IsNavigatorAvailable(): boolean;
  74569. /**
  74570. * Check if the document object exists
  74571. * @returns true if the document object exists
  74572. */
  74573. static IsDocumentAvailable(): boolean;
  74574. /**
  74575. * Extracts text content from a DOM element hierarchy
  74576. * @param element defines the root element
  74577. * @returns a string
  74578. */
  74579. static GetDOMTextContent(element: HTMLElement): string;
  74580. }
  74581. }
  74582. declare module BABYLON {
  74583. /**
  74584. * Logger used througouht the application to allow configuration of
  74585. * the log level required for the messages.
  74586. */
  74587. export class Logger {
  74588. /**
  74589. * No log
  74590. */
  74591. static readonly NoneLogLevel: number;
  74592. /**
  74593. * Only message logs
  74594. */
  74595. static readonly MessageLogLevel: number;
  74596. /**
  74597. * Only warning logs
  74598. */
  74599. static readonly WarningLogLevel: number;
  74600. /**
  74601. * Only error logs
  74602. */
  74603. static readonly ErrorLogLevel: number;
  74604. /**
  74605. * All logs
  74606. */
  74607. static readonly AllLogLevel: number;
  74608. private static _LogCache;
  74609. /**
  74610. * Gets a value indicating the number of loading errors
  74611. * @ignorenaming
  74612. */
  74613. static errorsCount: number;
  74614. /**
  74615. * Callback called when a new log is added
  74616. */
  74617. static OnNewCacheEntry: (entry: string) => void;
  74618. private static _AddLogEntry;
  74619. private static _FormatMessage;
  74620. private static _LogDisabled;
  74621. private static _LogEnabled;
  74622. private static _WarnDisabled;
  74623. private static _WarnEnabled;
  74624. private static _ErrorDisabled;
  74625. private static _ErrorEnabled;
  74626. /**
  74627. * Log a message to the console
  74628. */
  74629. static Log: (message: string) => void;
  74630. /**
  74631. * Write a warning message to the console
  74632. */
  74633. static Warn: (message: string) => void;
  74634. /**
  74635. * Write an error message to the console
  74636. */
  74637. static Error: (message: string) => void;
  74638. /**
  74639. * Gets current log cache (list of logs)
  74640. */
  74641. static get LogCache(): string;
  74642. /**
  74643. * Clears the log cache
  74644. */
  74645. static ClearLogCache(): void;
  74646. /**
  74647. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74648. */
  74649. static set LogLevels(level: number);
  74650. }
  74651. }
  74652. declare module BABYLON {
  74653. /** @hidden */
  74654. export class _TypeStore {
  74655. /** @hidden */
  74656. static RegisteredTypes: {
  74657. [key: string]: Object;
  74658. };
  74659. /** @hidden */
  74660. static GetClass(fqdn: string): any;
  74661. }
  74662. }
  74663. declare module BABYLON {
  74664. /**
  74665. * Helper to manipulate strings
  74666. */
  74667. export class StringTools {
  74668. /**
  74669. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74670. * @param str Source string
  74671. * @param suffix Suffix to search for in the source string
  74672. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74673. */
  74674. static EndsWith(str: string, suffix: string): boolean;
  74675. /**
  74676. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74677. * @param str Source string
  74678. * @param suffix Suffix to search for in the source string
  74679. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74680. */
  74681. static StartsWith(str: string, suffix: string): boolean;
  74682. /**
  74683. * Decodes a buffer into a string
  74684. * @param buffer The buffer to decode
  74685. * @returns The decoded string
  74686. */
  74687. static Decode(buffer: Uint8Array | Uint16Array): string;
  74688. /**
  74689. * Encode a buffer to a base64 string
  74690. * @param buffer defines the buffer to encode
  74691. * @returns the encoded string
  74692. */
  74693. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74694. /**
  74695. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74696. * @param num the number to convert and pad
  74697. * @param length the expected length of the string
  74698. * @returns the padded string
  74699. */
  74700. static PadNumber(num: number, length: number): string;
  74701. }
  74702. }
  74703. declare module BABYLON {
  74704. /**
  74705. * Class containing a set of static utilities functions for deep copy.
  74706. */
  74707. export class DeepCopier {
  74708. /**
  74709. * Tries to copy an object by duplicating every property
  74710. * @param source defines the source object
  74711. * @param destination defines the target object
  74712. * @param doNotCopyList defines a list of properties to avoid
  74713. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74714. */
  74715. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74716. }
  74717. }
  74718. declare module BABYLON {
  74719. /**
  74720. * Class containing a set of static utilities functions for precision date
  74721. */
  74722. export class PrecisionDate {
  74723. /**
  74724. * Gets either window.performance.now() if supported or Date.now() else
  74725. */
  74726. static get Now(): number;
  74727. }
  74728. }
  74729. declare module BABYLON {
  74730. /** @hidden */
  74731. export class _DevTools {
  74732. static WarnImport(name: string): string;
  74733. }
  74734. }
  74735. declare module BABYLON {
  74736. /**
  74737. * Interface used to define the mechanism to get data from the network
  74738. */
  74739. export interface IWebRequest {
  74740. /**
  74741. * Returns client's response url
  74742. */
  74743. responseURL: string;
  74744. /**
  74745. * Returns client's status
  74746. */
  74747. status: number;
  74748. /**
  74749. * Returns client's status as a text
  74750. */
  74751. statusText: string;
  74752. }
  74753. }
  74754. declare module BABYLON {
  74755. /**
  74756. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74757. */
  74758. export class WebRequest implements IWebRequest {
  74759. private _xhr;
  74760. /**
  74761. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74762. * i.e. when loading files, where the server/service expects an Authorization header
  74763. */
  74764. static CustomRequestHeaders: {
  74765. [key: string]: string;
  74766. };
  74767. /**
  74768. * Add callback functions in this array to update all the requests before they get sent to the network
  74769. */
  74770. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74771. private _injectCustomRequestHeaders;
  74772. /**
  74773. * Gets or sets a function to be called when loading progress changes
  74774. */
  74775. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74776. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74777. /**
  74778. * Returns client's state
  74779. */
  74780. get readyState(): number;
  74781. /**
  74782. * Returns client's status
  74783. */
  74784. get status(): number;
  74785. /**
  74786. * Returns client's status as a text
  74787. */
  74788. get statusText(): string;
  74789. /**
  74790. * Returns client's response
  74791. */
  74792. get response(): any;
  74793. /**
  74794. * Returns client's response url
  74795. */
  74796. get responseURL(): string;
  74797. /**
  74798. * Returns client's response as text
  74799. */
  74800. get responseText(): string;
  74801. /**
  74802. * Gets or sets the expected response type
  74803. */
  74804. get responseType(): XMLHttpRequestResponseType;
  74805. set responseType(value: XMLHttpRequestResponseType);
  74806. /** @hidden */
  74807. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74808. /** @hidden */
  74809. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74810. /**
  74811. * Cancels any network activity
  74812. */
  74813. abort(): void;
  74814. /**
  74815. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74816. * @param body defines an optional request body
  74817. */
  74818. send(body?: Document | BodyInit | null): void;
  74819. /**
  74820. * Sets the request method, request URL
  74821. * @param method defines the method to use (GET, POST, etc..)
  74822. * @param url defines the url to connect with
  74823. */
  74824. open(method: string, url: string): void;
  74825. /**
  74826. * Sets the value of a request header.
  74827. * @param name The name of the header whose value is to be set
  74828. * @param value The value to set as the body of the header
  74829. */
  74830. setRequestHeader(name: string, value: string): void;
  74831. /**
  74832. * Get the string containing the text of a particular header's value.
  74833. * @param name The name of the header
  74834. * @returns The string containing the text of the given header name
  74835. */
  74836. getResponseHeader(name: string): Nullable<string>;
  74837. }
  74838. }
  74839. declare module BABYLON {
  74840. /**
  74841. * File request interface
  74842. */
  74843. export interface IFileRequest {
  74844. /**
  74845. * Raised when the request is complete (success or error).
  74846. */
  74847. onCompleteObservable: Observable<IFileRequest>;
  74848. /**
  74849. * Aborts the request for a file.
  74850. */
  74851. abort: () => void;
  74852. }
  74853. }
  74854. declare module BABYLON {
  74855. /**
  74856. * Define options used to create a render target texture
  74857. */
  74858. export class RenderTargetCreationOptions {
  74859. /**
  74860. * Specifies is mipmaps must be generated
  74861. */
  74862. generateMipMaps?: boolean;
  74863. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74864. generateDepthBuffer?: boolean;
  74865. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74866. generateStencilBuffer?: boolean;
  74867. /** Defines texture type (int by default) */
  74868. type?: number;
  74869. /** Defines sampling mode (trilinear by default) */
  74870. samplingMode?: number;
  74871. /** Defines format (RGBA by default) */
  74872. format?: number;
  74873. }
  74874. }
  74875. declare module BABYLON {
  74876. /** Defines the cross module used constants to avoid circular dependncies */
  74877. export class Constants {
  74878. /** Defines that alpha blending is disabled */
  74879. static readonly ALPHA_DISABLE: number;
  74880. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74881. static readonly ALPHA_ADD: number;
  74882. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74883. static readonly ALPHA_COMBINE: number;
  74884. /** Defines that alpha blending is DEST - SRC * DEST */
  74885. static readonly ALPHA_SUBTRACT: number;
  74886. /** Defines that alpha blending is SRC * DEST */
  74887. static readonly ALPHA_MULTIPLY: number;
  74888. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74889. static readonly ALPHA_MAXIMIZED: number;
  74890. /** Defines that alpha blending is SRC + DEST */
  74891. static readonly ALPHA_ONEONE: number;
  74892. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74893. static readonly ALPHA_PREMULTIPLIED: number;
  74894. /**
  74895. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74896. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74897. */
  74898. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74899. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74900. static readonly ALPHA_INTERPOLATE: number;
  74901. /**
  74902. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74903. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74904. */
  74905. static readonly ALPHA_SCREENMODE: number;
  74906. /**
  74907. * Defines that alpha blending is SRC + DST
  74908. * Alpha will be set to SRC ALPHA + DST ALPHA
  74909. */
  74910. static readonly ALPHA_ONEONE_ONEONE: number;
  74911. /**
  74912. * Defines that alpha blending is SRC * DST ALPHA + DST
  74913. * Alpha will be set to 0
  74914. */
  74915. static readonly ALPHA_ALPHATOCOLOR: number;
  74916. /**
  74917. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74918. */
  74919. static readonly ALPHA_REVERSEONEMINUS: number;
  74920. /**
  74921. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74922. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74923. */
  74924. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74925. /**
  74926. * Defines that alpha blending is SRC + DST
  74927. * Alpha will be set to SRC ALPHA
  74928. */
  74929. static readonly ALPHA_ONEONE_ONEZERO: number;
  74930. /**
  74931. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74932. * Alpha will be set to DST ALPHA
  74933. */
  74934. static readonly ALPHA_EXCLUSION: number;
  74935. /** Defines that alpha blending equation a SUM */
  74936. static readonly ALPHA_EQUATION_ADD: number;
  74937. /** Defines that alpha blending equation a SUBSTRACTION */
  74938. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74939. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74940. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74941. /** Defines that alpha blending equation a MAX operation */
  74942. static readonly ALPHA_EQUATION_MAX: number;
  74943. /** Defines that alpha blending equation a MIN operation */
  74944. static readonly ALPHA_EQUATION_MIN: number;
  74945. /**
  74946. * Defines that alpha blending equation a DARKEN operation:
  74947. * It takes the min of the src and sums the alpha channels.
  74948. */
  74949. static readonly ALPHA_EQUATION_DARKEN: number;
  74950. /** Defines that the ressource is not delayed*/
  74951. static readonly DELAYLOADSTATE_NONE: number;
  74952. /** Defines that the ressource was successfully delay loaded */
  74953. static readonly DELAYLOADSTATE_LOADED: number;
  74954. /** Defines that the ressource is currently delay loading */
  74955. static readonly DELAYLOADSTATE_LOADING: number;
  74956. /** Defines that the ressource is delayed and has not started loading */
  74957. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74959. static readonly NEVER: number;
  74960. /** 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 */
  74961. static readonly ALWAYS: number;
  74962. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74963. static readonly LESS: number;
  74964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74965. static readonly EQUAL: number;
  74966. /** 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 */
  74967. static readonly LEQUAL: number;
  74968. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74969. static readonly GREATER: number;
  74970. /** 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 */
  74971. static readonly GEQUAL: number;
  74972. /** 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 */
  74973. static readonly NOTEQUAL: number;
  74974. /** Passed to stencilOperation to specify that stencil value must be kept */
  74975. static readonly KEEP: number;
  74976. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74977. static readonly REPLACE: number;
  74978. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74979. static readonly INCR: number;
  74980. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74981. static readonly DECR: number;
  74982. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74983. static readonly INVERT: number;
  74984. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74985. static readonly INCR_WRAP: number;
  74986. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74987. static readonly DECR_WRAP: number;
  74988. /** Texture is not repeating outside of 0..1 UVs */
  74989. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74990. /** Texture is repeating outside of 0..1 UVs */
  74991. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74992. /** Texture is repeating and mirrored */
  74993. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74994. /** ALPHA */
  74995. static readonly TEXTUREFORMAT_ALPHA: number;
  74996. /** LUMINANCE */
  74997. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74998. /** LUMINANCE_ALPHA */
  74999. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  75000. /** RGB */
  75001. static readonly TEXTUREFORMAT_RGB: number;
  75002. /** RGBA */
  75003. static readonly TEXTUREFORMAT_RGBA: number;
  75004. /** RED */
  75005. static readonly TEXTUREFORMAT_RED: number;
  75006. /** RED (2nd reference) */
  75007. static readonly TEXTUREFORMAT_R: number;
  75008. /** RG */
  75009. static readonly TEXTUREFORMAT_RG: number;
  75010. /** RED_INTEGER */
  75011. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  75012. /** RED_INTEGER (2nd reference) */
  75013. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75014. /** RG_INTEGER */
  75015. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75016. /** RGB_INTEGER */
  75017. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75018. /** RGBA_INTEGER */
  75019. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75020. /** UNSIGNED_BYTE */
  75021. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75022. /** UNSIGNED_BYTE (2nd reference) */
  75023. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75024. /** FLOAT */
  75025. static readonly TEXTURETYPE_FLOAT: number;
  75026. /** HALF_FLOAT */
  75027. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75028. /** BYTE */
  75029. static readonly TEXTURETYPE_BYTE: number;
  75030. /** SHORT */
  75031. static readonly TEXTURETYPE_SHORT: number;
  75032. /** UNSIGNED_SHORT */
  75033. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75034. /** INT */
  75035. static readonly TEXTURETYPE_INT: number;
  75036. /** UNSIGNED_INT */
  75037. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75038. /** UNSIGNED_SHORT_4_4_4_4 */
  75039. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75040. /** UNSIGNED_SHORT_5_5_5_1 */
  75041. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75042. /** UNSIGNED_SHORT_5_6_5 */
  75043. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75044. /** UNSIGNED_INT_2_10_10_10_REV */
  75045. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75046. /** UNSIGNED_INT_24_8 */
  75047. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75048. /** UNSIGNED_INT_10F_11F_11F_REV */
  75049. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75050. /** UNSIGNED_INT_5_9_9_9_REV */
  75051. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75052. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75053. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75054. /** nearest is mag = nearest and min = nearest and no mip */
  75055. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75056. /** mag = nearest and min = nearest and mip = none */
  75057. static readonly TEXTURE_NEAREST_NEAREST: number;
  75058. /** Bilinear is mag = linear and min = linear and no mip */
  75059. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75060. /** mag = linear and min = linear and mip = none */
  75061. static readonly TEXTURE_LINEAR_LINEAR: number;
  75062. /** Trilinear is mag = linear and min = linear and mip = linear */
  75063. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75064. /** Trilinear is mag = linear and min = linear and mip = linear */
  75065. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75066. /** mag = nearest and min = nearest and mip = nearest */
  75067. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75068. /** mag = nearest and min = linear and mip = nearest */
  75069. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75070. /** mag = nearest and min = linear and mip = linear */
  75071. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75072. /** mag = nearest and min = linear and mip = none */
  75073. static readonly TEXTURE_NEAREST_LINEAR: number;
  75074. /** nearest is mag = nearest and min = nearest and mip = linear */
  75075. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75076. /** mag = linear and min = nearest and mip = nearest */
  75077. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75078. /** mag = linear and min = nearest and mip = linear */
  75079. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75080. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75081. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75082. /** mag = linear and min = nearest and mip = none */
  75083. static readonly TEXTURE_LINEAR_NEAREST: number;
  75084. /** Explicit coordinates mode */
  75085. static readonly TEXTURE_EXPLICIT_MODE: number;
  75086. /** Spherical coordinates mode */
  75087. static readonly TEXTURE_SPHERICAL_MODE: number;
  75088. /** Planar coordinates mode */
  75089. static readonly TEXTURE_PLANAR_MODE: number;
  75090. /** Cubic coordinates mode */
  75091. static readonly TEXTURE_CUBIC_MODE: number;
  75092. /** Projection coordinates mode */
  75093. static readonly TEXTURE_PROJECTION_MODE: number;
  75094. /** Skybox coordinates mode */
  75095. static readonly TEXTURE_SKYBOX_MODE: number;
  75096. /** Inverse Cubic coordinates mode */
  75097. static readonly TEXTURE_INVCUBIC_MODE: number;
  75098. /** Equirectangular coordinates mode */
  75099. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75100. /** Equirectangular Fixed coordinates mode */
  75101. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75102. /** Equirectangular Fixed Mirrored coordinates mode */
  75103. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75104. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75105. static readonly SCALEMODE_FLOOR: number;
  75106. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75107. static readonly SCALEMODE_NEAREST: number;
  75108. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75109. static readonly SCALEMODE_CEILING: number;
  75110. /**
  75111. * The dirty texture flag value
  75112. */
  75113. static readonly MATERIAL_TextureDirtyFlag: number;
  75114. /**
  75115. * The dirty light flag value
  75116. */
  75117. static readonly MATERIAL_LightDirtyFlag: number;
  75118. /**
  75119. * The dirty fresnel flag value
  75120. */
  75121. static readonly MATERIAL_FresnelDirtyFlag: number;
  75122. /**
  75123. * The dirty attribute flag value
  75124. */
  75125. static readonly MATERIAL_AttributesDirtyFlag: number;
  75126. /**
  75127. * The dirty misc flag value
  75128. */
  75129. static readonly MATERIAL_MiscDirtyFlag: number;
  75130. /**
  75131. * The all dirty flag value
  75132. */
  75133. static readonly MATERIAL_AllDirtyFlag: number;
  75134. /**
  75135. * Returns the triangle fill mode
  75136. */
  75137. static readonly MATERIAL_TriangleFillMode: number;
  75138. /**
  75139. * Returns the wireframe mode
  75140. */
  75141. static readonly MATERIAL_WireFrameFillMode: number;
  75142. /**
  75143. * Returns the point fill mode
  75144. */
  75145. static readonly MATERIAL_PointFillMode: number;
  75146. /**
  75147. * Returns the point list draw mode
  75148. */
  75149. static readonly MATERIAL_PointListDrawMode: number;
  75150. /**
  75151. * Returns the line list draw mode
  75152. */
  75153. static readonly MATERIAL_LineListDrawMode: number;
  75154. /**
  75155. * Returns the line loop draw mode
  75156. */
  75157. static readonly MATERIAL_LineLoopDrawMode: number;
  75158. /**
  75159. * Returns the line strip draw mode
  75160. */
  75161. static readonly MATERIAL_LineStripDrawMode: number;
  75162. /**
  75163. * Returns the triangle strip draw mode
  75164. */
  75165. static readonly MATERIAL_TriangleStripDrawMode: number;
  75166. /**
  75167. * Returns the triangle fan draw mode
  75168. */
  75169. static readonly MATERIAL_TriangleFanDrawMode: number;
  75170. /**
  75171. * Stores the clock-wise side orientation
  75172. */
  75173. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75174. /**
  75175. * Stores the counter clock-wise side orientation
  75176. */
  75177. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75178. /**
  75179. * Nothing
  75180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75181. */
  75182. static readonly ACTION_NothingTrigger: number;
  75183. /**
  75184. * On pick
  75185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75186. */
  75187. static readonly ACTION_OnPickTrigger: number;
  75188. /**
  75189. * On left pick
  75190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75191. */
  75192. static readonly ACTION_OnLeftPickTrigger: number;
  75193. /**
  75194. * On right pick
  75195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75196. */
  75197. static readonly ACTION_OnRightPickTrigger: number;
  75198. /**
  75199. * On center pick
  75200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75201. */
  75202. static readonly ACTION_OnCenterPickTrigger: number;
  75203. /**
  75204. * On pick down
  75205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75206. */
  75207. static readonly ACTION_OnPickDownTrigger: number;
  75208. /**
  75209. * On double pick
  75210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75211. */
  75212. static readonly ACTION_OnDoublePickTrigger: number;
  75213. /**
  75214. * On pick up
  75215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75216. */
  75217. static readonly ACTION_OnPickUpTrigger: number;
  75218. /**
  75219. * On pick out.
  75220. * This trigger will only be raised if you also declared a OnPickDown
  75221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75222. */
  75223. static readonly ACTION_OnPickOutTrigger: number;
  75224. /**
  75225. * On long press
  75226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75227. */
  75228. static readonly ACTION_OnLongPressTrigger: number;
  75229. /**
  75230. * On pointer over
  75231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75232. */
  75233. static readonly ACTION_OnPointerOverTrigger: number;
  75234. /**
  75235. * On pointer out
  75236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75237. */
  75238. static readonly ACTION_OnPointerOutTrigger: number;
  75239. /**
  75240. * On every frame
  75241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75242. */
  75243. static readonly ACTION_OnEveryFrameTrigger: number;
  75244. /**
  75245. * On intersection enter
  75246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75247. */
  75248. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75249. /**
  75250. * On intersection exit
  75251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75252. */
  75253. static readonly ACTION_OnIntersectionExitTrigger: number;
  75254. /**
  75255. * On key down
  75256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75257. */
  75258. static readonly ACTION_OnKeyDownTrigger: number;
  75259. /**
  75260. * On key up
  75261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75262. */
  75263. static readonly ACTION_OnKeyUpTrigger: number;
  75264. /**
  75265. * Billboard mode will only apply to Y axis
  75266. */
  75267. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75268. /**
  75269. * Billboard mode will apply to all axes
  75270. */
  75271. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75272. /**
  75273. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75274. */
  75275. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75276. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75277. * Test order :
  75278. * Is the bounding sphere outside the frustum ?
  75279. * If not, are the bounding box vertices outside the frustum ?
  75280. * It not, then the cullable object is in the frustum.
  75281. */
  75282. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75283. /** Culling strategy : Bounding Sphere Only.
  75284. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75285. * It's also less accurate than the standard because some not visible objects can still be selected.
  75286. * Test : is the bounding sphere outside the frustum ?
  75287. * If not, then the cullable object is in the frustum.
  75288. */
  75289. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75290. /** Culling strategy : Optimistic Inclusion.
  75291. * This in an inclusion test first, then the standard exclusion test.
  75292. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75293. * 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.
  75294. * Anyway, it's as accurate as the standard strategy.
  75295. * Test :
  75296. * Is the cullable object bounding sphere center in the frustum ?
  75297. * If not, apply the default culling strategy.
  75298. */
  75299. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75300. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75301. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75302. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75303. * 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.
  75304. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75305. * Test :
  75306. * Is the cullable object bounding sphere center in the frustum ?
  75307. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75308. */
  75309. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75310. /**
  75311. * No logging while loading
  75312. */
  75313. static readonly SCENELOADER_NO_LOGGING: number;
  75314. /**
  75315. * Minimal logging while loading
  75316. */
  75317. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75318. /**
  75319. * Summary logging while loading
  75320. */
  75321. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75322. /**
  75323. * Detailled logging while loading
  75324. */
  75325. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75326. }
  75327. }
  75328. declare module BABYLON {
  75329. /**
  75330. * This represents the required contract to create a new type of texture loader.
  75331. */
  75332. export interface IInternalTextureLoader {
  75333. /**
  75334. * Defines wether the loader supports cascade loading the different faces.
  75335. */
  75336. supportCascades: boolean;
  75337. /**
  75338. * This returns if the loader support the current file information.
  75339. * @param extension defines the file extension of the file being loaded
  75340. * @returns true if the loader can load the specified file
  75341. */
  75342. canLoad(extension: string): boolean;
  75343. /**
  75344. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75345. * @param data contains the texture data
  75346. * @param texture defines the BabylonJS internal texture
  75347. * @param createPolynomials will be true if polynomials have been requested
  75348. * @param onLoad defines the callback to trigger once the texture is ready
  75349. * @param onError defines the callback to trigger in case of error
  75350. */
  75351. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75352. /**
  75353. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75354. * @param data contains the texture data
  75355. * @param texture defines the BabylonJS internal texture
  75356. * @param callback defines the method to call once ready to upload
  75357. */
  75358. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75359. }
  75360. }
  75361. declare module BABYLON {
  75362. /**
  75363. * Class used to store and describe the pipeline context associated with an effect
  75364. */
  75365. export interface IPipelineContext {
  75366. /**
  75367. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75368. */
  75369. isAsync: boolean;
  75370. /**
  75371. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75372. */
  75373. isReady: boolean;
  75374. /** @hidden */
  75375. _getVertexShaderCode(): string | null;
  75376. /** @hidden */
  75377. _getFragmentShaderCode(): string | null;
  75378. /** @hidden */
  75379. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75380. }
  75381. }
  75382. declare module BABYLON {
  75383. /**
  75384. * Class used to store gfx data (like WebGLBuffer)
  75385. */
  75386. export class DataBuffer {
  75387. /**
  75388. * Gets or sets the number of objects referencing this buffer
  75389. */
  75390. references: number;
  75391. /** Gets or sets the size of the underlying buffer */
  75392. capacity: number;
  75393. /**
  75394. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75395. */
  75396. is32Bits: boolean;
  75397. /**
  75398. * Gets the underlying buffer
  75399. */
  75400. get underlyingResource(): any;
  75401. }
  75402. }
  75403. declare module BABYLON {
  75404. /** @hidden */
  75405. export interface IShaderProcessor {
  75406. attributeProcessor?: (attribute: string) => string;
  75407. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75408. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75409. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75410. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75411. lineProcessor?: (line: string, isFragment: boolean) => string;
  75412. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75413. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75414. }
  75415. }
  75416. declare module BABYLON {
  75417. /** @hidden */
  75418. export interface ProcessingOptions {
  75419. defines: string[];
  75420. indexParameters: any;
  75421. isFragment: boolean;
  75422. shouldUseHighPrecisionShader: boolean;
  75423. supportsUniformBuffers: boolean;
  75424. shadersRepository: string;
  75425. includesShadersStore: {
  75426. [key: string]: string;
  75427. };
  75428. processor?: IShaderProcessor;
  75429. version: string;
  75430. platformName: string;
  75431. lookForClosingBracketForUniformBuffer?: boolean;
  75432. }
  75433. }
  75434. declare module BABYLON {
  75435. /** @hidden */
  75436. export class ShaderCodeNode {
  75437. line: string;
  75438. children: ShaderCodeNode[];
  75439. additionalDefineKey?: string;
  75440. additionalDefineValue?: string;
  75441. isValid(preprocessors: {
  75442. [key: string]: string;
  75443. }): boolean;
  75444. process(preprocessors: {
  75445. [key: string]: string;
  75446. }, options: ProcessingOptions): string;
  75447. }
  75448. }
  75449. declare module BABYLON {
  75450. /** @hidden */
  75451. export class ShaderCodeCursor {
  75452. private _lines;
  75453. lineIndex: number;
  75454. get currentLine(): string;
  75455. get canRead(): boolean;
  75456. set lines(value: string[]);
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /** @hidden */
  75461. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75462. process(preprocessors: {
  75463. [key: string]: string;
  75464. }, options: ProcessingOptions): string;
  75465. }
  75466. }
  75467. declare module BABYLON {
  75468. /** @hidden */
  75469. export class ShaderDefineExpression {
  75470. isTrue(preprocessors: {
  75471. [key: string]: string;
  75472. }): boolean;
  75473. private static _OperatorPriority;
  75474. private static _Stack;
  75475. static postfixToInfix(postfix: string[]): string;
  75476. static infixToPostfix(infix: string): string[];
  75477. }
  75478. }
  75479. declare module BABYLON {
  75480. /** @hidden */
  75481. export class ShaderCodeTestNode extends ShaderCodeNode {
  75482. testExpression: ShaderDefineExpression;
  75483. isValid(preprocessors: {
  75484. [key: string]: string;
  75485. }): boolean;
  75486. }
  75487. }
  75488. declare module BABYLON {
  75489. /** @hidden */
  75490. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75491. define: string;
  75492. not: boolean;
  75493. constructor(define: string, not?: boolean);
  75494. isTrue(preprocessors: {
  75495. [key: string]: string;
  75496. }): boolean;
  75497. }
  75498. }
  75499. declare module BABYLON {
  75500. /** @hidden */
  75501. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75502. leftOperand: ShaderDefineExpression;
  75503. rightOperand: ShaderDefineExpression;
  75504. isTrue(preprocessors: {
  75505. [key: string]: string;
  75506. }): boolean;
  75507. }
  75508. }
  75509. declare module BABYLON {
  75510. /** @hidden */
  75511. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75512. leftOperand: ShaderDefineExpression;
  75513. rightOperand: ShaderDefineExpression;
  75514. isTrue(preprocessors: {
  75515. [key: string]: string;
  75516. }): boolean;
  75517. }
  75518. }
  75519. declare module BABYLON {
  75520. /** @hidden */
  75521. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75522. define: string;
  75523. operand: string;
  75524. testValue: string;
  75525. constructor(define: string, operand: string, testValue: string);
  75526. isTrue(preprocessors: {
  75527. [key: string]: string;
  75528. }): boolean;
  75529. }
  75530. }
  75531. declare module BABYLON {
  75532. /**
  75533. * Class used to enable access to offline support
  75534. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75535. */
  75536. export interface IOfflineProvider {
  75537. /**
  75538. * Gets a boolean indicating if scene must be saved in the database
  75539. */
  75540. enableSceneOffline: boolean;
  75541. /**
  75542. * Gets a boolean indicating if textures must be saved in the database
  75543. */
  75544. enableTexturesOffline: boolean;
  75545. /**
  75546. * Open the offline support and make it available
  75547. * @param successCallback defines the callback to call on success
  75548. * @param errorCallback defines the callback to call on error
  75549. */
  75550. open(successCallback: () => void, errorCallback: () => void): void;
  75551. /**
  75552. * Loads an image from the offline support
  75553. * @param url defines the url to load from
  75554. * @param image defines the target DOM image
  75555. */
  75556. loadImage(url: string, image: HTMLImageElement): void;
  75557. /**
  75558. * Loads a file from offline support
  75559. * @param url defines the URL to load from
  75560. * @param sceneLoaded defines a callback to call on success
  75561. * @param progressCallBack defines a callback to call when progress changed
  75562. * @param errorCallback defines a callback to call on error
  75563. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75564. */
  75565. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75566. }
  75567. }
  75568. declare module BABYLON {
  75569. /**
  75570. * Class used to help managing file picking and drag'n'drop
  75571. * File Storage
  75572. */
  75573. export class FilesInputStore {
  75574. /**
  75575. * List of files ready to be loaded
  75576. */
  75577. static FilesToLoad: {
  75578. [key: string]: File;
  75579. };
  75580. }
  75581. }
  75582. declare module BABYLON {
  75583. /**
  75584. * Class used to define a retry strategy when error happens while loading assets
  75585. */
  75586. export class RetryStrategy {
  75587. /**
  75588. * Function used to defines an exponential back off strategy
  75589. * @param maxRetries defines the maximum number of retries (3 by default)
  75590. * @param baseInterval defines the interval between retries
  75591. * @returns the strategy function to use
  75592. */
  75593. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75594. }
  75595. }
  75596. declare module BABYLON {
  75597. /**
  75598. * @ignore
  75599. * Application error to support additional information when loading a file
  75600. */
  75601. export abstract class BaseError extends Error {
  75602. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /** @ignore */
  75607. export class LoadFileError extends BaseError {
  75608. request?: WebRequest;
  75609. file?: File;
  75610. /**
  75611. * Creates a new LoadFileError
  75612. * @param message defines the message of the error
  75613. * @param request defines the optional web request
  75614. * @param file defines the optional file
  75615. */
  75616. constructor(message: string, object?: WebRequest | File);
  75617. }
  75618. /** @ignore */
  75619. export class RequestFileError extends BaseError {
  75620. request: WebRequest;
  75621. /**
  75622. * Creates a new LoadFileError
  75623. * @param message defines the message of the error
  75624. * @param request defines the optional web request
  75625. */
  75626. constructor(message: string, request: WebRequest);
  75627. }
  75628. /** @ignore */
  75629. export class ReadFileError extends BaseError {
  75630. file: File;
  75631. /**
  75632. * Creates a new ReadFileError
  75633. * @param message defines the message of the error
  75634. * @param file defines the optional file
  75635. */
  75636. constructor(message: string, file: File);
  75637. }
  75638. /**
  75639. * @hidden
  75640. */
  75641. export class FileTools {
  75642. /**
  75643. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75644. */
  75645. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75646. /**
  75647. * Gets or sets the base URL to use to load assets
  75648. */
  75649. static BaseUrl: string;
  75650. /**
  75651. * Default behaviour for cors in the application.
  75652. * It can be a string if the expected behavior is identical in the entire app.
  75653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75654. */
  75655. static CorsBehavior: string | ((url: string | string[]) => string);
  75656. /**
  75657. * Gets or sets a function used to pre-process url before using them to load assets
  75658. */
  75659. static PreprocessUrl: (url: string) => string;
  75660. /**
  75661. * Removes unwanted characters from an url
  75662. * @param url defines the url to clean
  75663. * @returns the cleaned url
  75664. */
  75665. private static _CleanUrl;
  75666. /**
  75667. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75668. * @param url define the url we are trying
  75669. * @param element define the dom element where to configure the cors policy
  75670. */
  75671. static SetCorsBehavior(url: string | string[], element: {
  75672. crossOrigin: string | null;
  75673. }): void;
  75674. /**
  75675. * Loads an image as an HTMLImageElement.
  75676. * @param input url string, ArrayBuffer, or Blob to load
  75677. * @param onLoad callback called when the image successfully loads
  75678. * @param onError callback called when the image fails to load
  75679. * @param offlineProvider offline provider for caching
  75680. * @param mimeType optional mime type
  75681. * @returns the HTMLImageElement of the loaded image
  75682. */
  75683. 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>;
  75684. /**
  75685. * Reads a file from a File object
  75686. * @param file defines the file to load
  75687. * @param onSuccess defines the callback to call when data is loaded
  75688. * @param onProgress defines the callback to call during loading process
  75689. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75690. * @param onError defines the callback to call when an error occurs
  75691. * @returns a file request object
  75692. */
  75693. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75694. /**
  75695. * Loads a file from a url
  75696. * @param url url to load
  75697. * @param onSuccess callback called when the file successfully loads
  75698. * @param onProgress callback called while file is loading (if the server supports this mode)
  75699. * @param offlineProvider defines the offline provider for caching
  75700. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75701. * @param onError callback called when the file fails to load
  75702. * @returns a file request object
  75703. */
  75704. 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;
  75705. /**
  75706. * Loads a file
  75707. * @param url url to load
  75708. * @param onSuccess callback called when the file successfully loads
  75709. * @param onProgress callback called while file is loading (if the server supports this mode)
  75710. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75711. * @param onError callback called when the file fails to load
  75712. * @param onOpened callback called when the web request is opened
  75713. * @returns a file request object
  75714. */
  75715. 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;
  75716. /**
  75717. * Checks if the loaded document was accessed via `file:`-Protocol.
  75718. * @returns boolean
  75719. */
  75720. static IsFileURL(): boolean;
  75721. }
  75722. }
  75723. declare module BABYLON {
  75724. /** @hidden */
  75725. export class ShaderProcessor {
  75726. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75727. private static _ProcessPrecision;
  75728. private static _ExtractOperation;
  75729. private static _BuildSubExpression;
  75730. private static _BuildExpression;
  75731. private static _MoveCursorWithinIf;
  75732. private static _MoveCursor;
  75733. private static _EvaluatePreProcessors;
  75734. private static _PreparePreProcessors;
  75735. private static _ProcessShaderConversion;
  75736. private static _ProcessIncludes;
  75737. /**
  75738. * Loads a file from a url
  75739. * @param url url to load
  75740. * @param onSuccess callback called when the file successfully loads
  75741. * @param onProgress callback called while file is loading (if the server supports this mode)
  75742. * @param offlineProvider defines the offline provider for caching
  75743. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75744. * @param onError callback called when the file fails to load
  75745. * @returns a file request object
  75746. * @hidden
  75747. */
  75748. 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;
  75749. }
  75750. }
  75751. declare module BABYLON {
  75752. /**
  75753. * @hidden
  75754. */
  75755. export interface IColor4Like {
  75756. r: float;
  75757. g: float;
  75758. b: float;
  75759. a: float;
  75760. }
  75761. /**
  75762. * @hidden
  75763. */
  75764. export interface IColor3Like {
  75765. r: float;
  75766. g: float;
  75767. b: float;
  75768. }
  75769. /**
  75770. * @hidden
  75771. */
  75772. export interface IVector4Like {
  75773. x: float;
  75774. y: float;
  75775. z: float;
  75776. w: float;
  75777. }
  75778. /**
  75779. * @hidden
  75780. */
  75781. export interface IVector3Like {
  75782. x: float;
  75783. y: float;
  75784. z: float;
  75785. }
  75786. /**
  75787. * @hidden
  75788. */
  75789. export interface IVector2Like {
  75790. x: float;
  75791. y: float;
  75792. }
  75793. /**
  75794. * @hidden
  75795. */
  75796. export interface IMatrixLike {
  75797. toArray(): DeepImmutable<Float32Array>;
  75798. updateFlag: int;
  75799. }
  75800. /**
  75801. * @hidden
  75802. */
  75803. export interface IViewportLike {
  75804. x: float;
  75805. y: float;
  75806. width: float;
  75807. height: float;
  75808. }
  75809. /**
  75810. * @hidden
  75811. */
  75812. export interface IPlaneLike {
  75813. normal: IVector3Like;
  75814. d: float;
  75815. normalize(): void;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. /**
  75820. * Interface used to define common properties for effect fallbacks
  75821. */
  75822. export interface IEffectFallbacks {
  75823. /**
  75824. * Removes the defines that should be removed when falling back.
  75825. * @param currentDefines defines the current define statements for the shader.
  75826. * @param effect defines the current effect we try to compile
  75827. * @returns The resulting defines with defines of the current rank removed.
  75828. */
  75829. reduce(currentDefines: string, effect: Effect): string;
  75830. /**
  75831. * Removes the fallback from the bound mesh.
  75832. */
  75833. unBindMesh(): void;
  75834. /**
  75835. * Checks to see if more fallbacks are still availible.
  75836. */
  75837. hasMoreFallbacks: boolean;
  75838. }
  75839. }
  75840. declare module BABYLON {
  75841. /**
  75842. * Class used to evalaute queries containing `and` and `or` operators
  75843. */
  75844. export class AndOrNotEvaluator {
  75845. /**
  75846. * Evaluate a query
  75847. * @param query defines the query to evaluate
  75848. * @param evaluateCallback defines the callback used to filter result
  75849. * @returns true if the query matches
  75850. */
  75851. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75852. private static _HandleParenthesisContent;
  75853. private static _SimplifyNegation;
  75854. }
  75855. }
  75856. declare module BABYLON {
  75857. /**
  75858. * Class used to store custom tags
  75859. */
  75860. export class Tags {
  75861. /**
  75862. * Adds support for tags on the given object
  75863. * @param obj defines the object to use
  75864. */
  75865. static EnableFor(obj: any): void;
  75866. /**
  75867. * Removes tags support
  75868. * @param obj defines the object to use
  75869. */
  75870. static DisableFor(obj: any): void;
  75871. /**
  75872. * Gets a boolean indicating if the given object has tags
  75873. * @param obj defines the object to use
  75874. * @returns a boolean
  75875. */
  75876. static HasTags(obj: any): boolean;
  75877. /**
  75878. * Gets the tags available on a given object
  75879. * @param obj defines the object to use
  75880. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75881. * @returns the tags
  75882. */
  75883. static GetTags(obj: any, asString?: boolean): any;
  75884. /**
  75885. * Adds tags to an object
  75886. * @param obj defines the object to use
  75887. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75888. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75889. */
  75890. static AddTagsTo(obj: any, tagsString: string): void;
  75891. /**
  75892. * @hidden
  75893. */
  75894. static _AddTagTo(obj: any, tag: string): void;
  75895. /**
  75896. * Removes specific tags from a specific object
  75897. * @param obj defines the object to use
  75898. * @param tagsString defines the tags to remove
  75899. */
  75900. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75901. /**
  75902. * @hidden
  75903. */
  75904. static _RemoveTagFrom(obj: any, tag: string): void;
  75905. /**
  75906. * Defines if tags hosted on an object match a given query
  75907. * @param obj defines the object to use
  75908. * @param tagsQuery defines the tag query
  75909. * @returns a boolean
  75910. */
  75911. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75912. }
  75913. }
  75914. declare module BABYLON {
  75915. /**
  75916. * Scalar computation library
  75917. */
  75918. export class Scalar {
  75919. /**
  75920. * Two pi constants convenient for computation.
  75921. */
  75922. static TwoPi: number;
  75923. /**
  75924. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75925. * @param a number
  75926. * @param b number
  75927. * @param epsilon (default = 1.401298E-45)
  75928. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75929. */
  75930. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75931. /**
  75932. * Returns a string : the upper case translation of the number i to hexadecimal.
  75933. * @param i number
  75934. * @returns the upper case translation of the number i to hexadecimal.
  75935. */
  75936. static ToHex(i: number): string;
  75937. /**
  75938. * Returns -1 if value is negative and +1 is value is positive.
  75939. * @param value the value
  75940. * @returns the value itself if it's equal to zero.
  75941. */
  75942. static Sign(value: number): number;
  75943. /**
  75944. * Returns the value itself if it's between min and max.
  75945. * Returns min if the value is lower than min.
  75946. * Returns max if the value is greater than max.
  75947. * @param value the value to clmap
  75948. * @param min the min value to clamp to (default: 0)
  75949. * @param max the max value to clamp to (default: 1)
  75950. * @returns the clamped value
  75951. */
  75952. static Clamp(value: number, min?: number, max?: number): number;
  75953. /**
  75954. * the log2 of value.
  75955. * @param value the value to compute log2 of
  75956. * @returns the log2 of value.
  75957. */
  75958. static Log2(value: number): number;
  75959. /**
  75960. * Loops the value, so that it is never larger than length and never smaller than 0.
  75961. *
  75962. * This is similar to the modulo operator but it works with floating point numbers.
  75963. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75964. * With t = 5 and length = 2.5, the result would be 0.0.
  75965. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75966. * @param value the value
  75967. * @param length the length
  75968. * @returns the looped value
  75969. */
  75970. static Repeat(value: number, length: number): number;
  75971. /**
  75972. * Normalize the value between 0.0 and 1.0 using min and max values
  75973. * @param value value to normalize
  75974. * @param min max to normalize between
  75975. * @param max min to normalize between
  75976. * @returns the normalized value
  75977. */
  75978. static Normalize(value: number, min: number, max: number): number;
  75979. /**
  75980. * Denormalize the value from 0.0 and 1.0 using min and max values
  75981. * @param normalized value to denormalize
  75982. * @param min max to denormalize between
  75983. * @param max min to denormalize between
  75984. * @returns the denormalized value
  75985. */
  75986. static Denormalize(normalized: number, min: number, max: number): number;
  75987. /**
  75988. * Calculates the shortest difference between two given angles given in degrees.
  75989. * @param current current angle in degrees
  75990. * @param target target angle in degrees
  75991. * @returns the delta
  75992. */
  75993. static DeltaAngle(current: number, target: number): number;
  75994. /**
  75995. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75996. * @param tx value
  75997. * @param length length
  75998. * @returns The returned value will move back and forth between 0 and length
  75999. */
  76000. static PingPong(tx: number, length: number): number;
  76001. /**
  76002. * Interpolates between min and max with smoothing at the limits.
  76003. *
  76004. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  76005. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  76006. * @param from from
  76007. * @param to to
  76008. * @param tx value
  76009. * @returns the smooth stepped value
  76010. */
  76011. static SmoothStep(from: number, to: number, tx: number): number;
  76012. /**
  76013. * Moves a value current towards target.
  76014. *
  76015. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76016. * Negative values of maxDelta pushes the value away from target.
  76017. * @param current current value
  76018. * @param target target value
  76019. * @param maxDelta max distance to move
  76020. * @returns resulting value
  76021. */
  76022. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76023. /**
  76024. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76025. *
  76026. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76027. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76028. * @param current current value
  76029. * @param target target value
  76030. * @param maxDelta max distance to move
  76031. * @returns resulting angle
  76032. */
  76033. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76034. /**
  76035. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76036. * @param start start value
  76037. * @param end target value
  76038. * @param amount amount to lerp between
  76039. * @returns the lerped value
  76040. */
  76041. static Lerp(start: number, end: number, amount: number): number;
  76042. /**
  76043. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76044. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76045. * @param start start value
  76046. * @param end target value
  76047. * @param amount amount to lerp between
  76048. * @returns the lerped value
  76049. */
  76050. static LerpAngle(start: number, end: number, amount: number): number;
  76051. /**
  76052. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76053. * @param a start value
  76054. * @param b target value
  76055. * @param value value between a and b
  76056. * @returns the inverseLerp value
  76057. */
  76058. static InverseLerp(a: number, b: number, value: number): number;
  76059. /**
  76060. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76061. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76062. * @param value1 spline value
  76063. * @param tangent1 spline value
  76064. * @param value2 spline value
  76065. * @param tangent2 spline value
  76066. * @param amount input value
  76067. * @returns hermite result
  76068. */
  76069. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76070. /**
  76071. * Returns a random float number between and min and max values
  76072. * @param min min value of random
  76073. * @param max max value of random
  76074. * @returns random value
  76075. */
  76076. static RandomRange(min: number, max: number): number;
  76077. /**
  76078. * This function returns percentage of a number in a given range.
  76079. *
  76080. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76081. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76082. * @param number to convert to percentage
  76083. * @param min min range
  76084. * @param max max range
  76085. * @returns the percentage
  76086. */
  76087. static RangeToPercent(number: number, min: number, max: number): number;
  76088. /**
  76089. * This function returns number that corresponds to the percentage in a given range.
  76090. *
  76091. * PercentToRange(0.34,0,100) will return 34.
  76092. * @param percent to convert to number
  76093. * @param min min range
  76094. * @param max max range
  76095. * @returns the number
  76096. */
  76097. static PercentToRange(percent: number, min: number, max: number): number;
  76098. /**
  76099. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76100. * @param angle The angle to normalize in radian.
  76101. * @return The converted angle.
  76102. */
  76103. static NormalizeRadians(angle: number): number;
  76104. }
  76105. }
  76106. declare module BABYLON {
  76107. /**
  76108. * Constant used to convert a value to gamma space
  76109. * @ignorenaming
  76110. */
  76111. export const ToGammaSpace: number;
  76112. /**
  76113. * Constant used to convert a value to linear space
  76114. * @ignorenaming
  76115. */
  76116. export const ToLinearSpace = 2.2;
  76117. /**
  76118. * Constant used to define the minimal number value in Babylon.js
  76119. * @ignorenaming
  76120. */
  76121. let Epsilon: number;
  76122. }
  76123. declare module BABYLON {
  76124. /**
  76125. * Class used to represent a viewport on screen
  76126. */
  76127. export class Viewport {
  76128. /** viewport left coordinate */
  76129. x: number;
  76130. /** viewport top coordinate */
  76131. y: number;
  76132. /**viewport width */
  76133. width: number;
  76134. /** viewport height */
  76135. height: number;
  76136. /**
  76137. * Creates a Viewport object located at (x, y) and sized (width, height)
  76138. * @param x defines viewport left coordinate
  76139. * @param y defines viewport top coordinate
  76140. * @param width defines the viewport width
  76141. * @param height defines the viewport height
  76142. */
  76143. constructor(
  76144. /** viewport left coordinate */
  76145. x: number,
  76146. /** viewport top coordinate */
  76147. y: number,
  76148. /**viewport width */
  76149. width: number,
  76150. /** viewport height */
  76151. height: number);
  76152. /**
  76153. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76154. * @param renderWidth defines the rendering width
  76155. * @param renderHeight defines the rendering height
  76156. * @returns a new Viewport
  76157. */
  76158. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76159. /**
  76160. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76161. * @param renderWidth defines the rendering width
  76162. * @param renderHeight defines the rendering height
  76163. * @param ref defines the target viewport
  76164. * @returns the current viewport
  76165. */
  76166. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76167. /**
  76168. * Returns a new Viewport copied from the current one
  76169. * @returns a new Viewport
  76170. */
  76171. clone(): Viewport;
  76172. }
  76173. }
  76174. declare module BABYLON {
  76175. /**
  76176. * Class containing a set of static utilities functions for arrays.
  76177. */
  76178. export class ArrayTools {
  76179. /**
  76180. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76181. * @param size the number of element to construct and put in the array
  76182. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76183. * @returns a new array filled with new objects
  76184. */
  76185. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76186. }
  76187. }
  76188. declare module BABYLON {
  76189. /**
  76190. * Class representing a vector containing 2 coordinates
  76191. */
  76192. export class Vector2 {
  76193. /** defines the first coordinate */
  76194. x: number;
  76195. /** defines the second coordinate */
  76196. y: number;
  76197. /**
  76198. * Creates a new Vector2 from the given x and y coordinates
  76199. * @param x defines the first coordinate
  76200. * @param y defines the second coordinate
  76201. */
  76202. constructor(
  76203. /** defines the first coordinate */
  76204. x?: number,
  76205. /** defines the second coordinate */
  76206. y?: number);
  76207. /**
  76208. * Gets a string with the Vector2 coordinates
  76209. * @returns a string with the Vector2 coordinates
  76210. */
  76211. toString(): string;
  76212. /**
  76213. * Gets class name
  76214. * @returns the string "Vector2"
  76215. */
  76216. getClassName(): string;
  76217. /**
  76218. * Gets current vector hash code
  76219. * @returns the Vector2 hash code as a number
  76220. */
  76221. getHashCode(): number;
  76222. /**
  76223. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76224. * @param array defines the source array
  76225. * @param index defines the offset in source array
  76226. * @returns the current Vector2
  76227. */
  76228. toArray(array: FloatArray, index?: number): Vector2;
  76229. /**
  76230. * Copy the current vector to an array
  76231. * @returns a new array with 2 elements: the Vector2 coordinates.
  76232. */
  76233. asArray(): number[];
  76234. /**
  76235. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76236. * @param source defines the source Vector2
  76237. * @returns the current updated Vector2
  76238. */
  76239. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76240. /**
  76241. * Sets the Vector2 coordinates with the given floats
  76242. * @param x defines the first coordinate
  76243. * @param y defines the second coordinate
  76244. * @returns the current updated Vector2
  76245. */
  76246. copyFromFloats(x: number, y: number): Vector2;
  76247. /**
  76248. * Sets the Vector2 coordinates with the given floats
  76249. * @param x defines the first coordinate
  76250. * @param y defines the second coordinate
  76251. * @returns the current updated Vector2
  76252. */
  76253. set(x: number, y: number): Vector2;
  76254. /**
  76255. * Add another vector with the current one
  76256. * @param otherVector defines the other vector
  76257. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76258. */
  76259. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76260. /**
  76261. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76262. * @param otherVector defines the other vector
  76263. * @param result defines the target vector
  76264. * @returns the unmodified current Vector2
  76265. */
  76266. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76267. /**
  76268. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76269. * @param otherVector defines the other vector
  76270. * @returns the current updated Vector2
  76271. */
  76272. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76273. /**
  76274. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76275. * @param otherVector defines the other vector
  76276. * @returns a new Vector2
  76277. */
  76278. addVector3(otherVector: Vector3): Vector2;
  76279. /**
  76280. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76281. * @param otherVector defines the other vector
  76282. * @returns a new Vector2
  76283. */
  76284. subtract(otherVector: Vector2): Vector2;
  76285. /**
  76286. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76287. * @param otherVector defines the other vector
  76288. * @param result defines the target vector
  76289. * @returns the unmodified current Vector2
  76290. */
  76291. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76292. /**
  76293. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76294. * @param otherVector defines the other vector
  76295. * @returns the current updated Vector2
  76296. */
  76297. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76298. /**
  76299. * Multiplies in place the current Vector2 coordinates by the given ones
  76300. * @param otherVector defines the other vector
  76301. * @returns the current updated Vector2
  76302. */
  76303. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76304. /**
  76305. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76306. * @param otherVector defines the other vector
  76307. * @returns a new Vector2
  76308. */
  76309. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76310. /**
  76311. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76312. * @param otherVector defines the other vector
  76313. * @param result defines the target vector
  76314. * @returns the unmodified current Vector2
  76315. */
  76316. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76317. /**
  76318. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76319. * @param x defines the first coordinate
  76320. * @param y defines the second coordinate
  76321. * @returns a new Vector2
  76322. */
  76323. multiplyByFloats(x: number, y: number): Vector2;
  76324. /**
  76325. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76326. * @param otherVector defines the other vector
  76327. * @returns a new Vector2
  76328. */
  76329. divide(otherVector: Vector2): Vector2;
  76330. /**
  76331. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76332. * @param otherVector defines the other vector
  76333. * @param result defines the target vector
  76334. * @returns the unmodified current Vector2
  76335. */
  76336. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76337. /**
  76338. * Divides the current Vector2 coordinates by the given ones
  76339. * @param otherVector defines the other vector
  76340. * @returns the current updated Vector2
  76341. */
  76342. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76343. /**
  76344. * Gets a new Vector2 with current Vector2 negated coordinates
  76345. * @returns a new Vector2
  76346. */
  76347. negate(): Vector2;
  76348. /**
  76349. * Negate this vector in place
  76350. * @returns this
  76351. */
  76352. negateInPlace(): Vector2;
  76353. /**
  76354. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76355. * @param result defines the Vector3 object where to store the result
  76356. * @returns the current Vector2
  76357. */
  76358. negateToRef(result: Vector2): Vector2;
  76359. /**
  76360. * Multiply the Vector2 coordinates by scale
  76361. * @param scale defines the scaling factor
  76362. * @returns the current updated Vector2
  76363. */
  76364. scaleInPlace(scale: number): Vector2;
  76365. /**
  76366. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76367. * @param scale defines the scaling factor
  76368. * @returns a new Vector2
  76369. */
  76370. scale(scale: number): Vector2;
  76371. /**
  76372. * Scale the current Vector2 values by a factor to a given Vector2
  76373. * @param scale defines the scale factor
  76374. * @param result defines the Vector2 object where to store the result
  76375. * @returns the unmodified current Vector2
  76376. */
  76377. scaleToRef(scale: number, result: Vector2): Vector2;
  76378. /**
  76379. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76380. * @param scale defines the scale factor
  76381. * @param result defines the Vector2 object where to store the result
  76382. * @returns the unmodified current Vector2
  76383. */
  76384. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76385. /**
  76386. * Gets a boolean if two vectors are equals
  76387. * @param otherVector defines the other vector
  76388. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76389. */
  76390. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76391. /**
  76392. * Gets a boolean if two vectors are equals (using an epsilon value)
  76393. * @param otherVector defines the other vector
  76394. * @param epsilon defines the minimal distance to consider equality
  76395. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76396. */
  76397. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76398. /**
  76399. * Gets a new Vector2 from current Vector2 floored values
  76400. * @returns a new Vector2
  76401. */
  76402. floor(): Vector2;
  76403. /**
  76404. * Gets a new Vector2 from current Vector2 floored values
  76405. * @returns a new Vector2
  76406. */
  76407. fract(): Vector2;
  76408. /**
  76409. * Gets the length of the vector
  76410. * @returns the vector length (float)
  76411. */
  76412. length(): number;
  76413. /**
  76414. * Gets the vector squared length
  76415. * @returns the vector squared length (float)
  76416. */
  76417. lengthSquared(): number;
  76418. /**
  76419. * Normalize the vector
  76420. * @returns the current updated Vector2
  76421. */
  76422. normalize(): Vector2;
  76423. /**
  76424. * Gets a new Vector2 copied from the Vector2
  76425. * @returns a new Vector2
  76426. */
  76427. clone(): Vector2;
  76428. /**
  76429. * Gets a new Vector2(0, 0)
  76430. * @returns a new Vector2
  76431. */
  76432. static Zero(): Vector2;
  76433. /**
  76434. * Gets a new Vector2(1, 1)
  76435. * @returns a new Vector2
  76436. */
  76437. static One(): Vector2;
  76438. /**
  76439. * Gets a new Vector2 set from the given index element of the given array
  76440. * @param array defines the data source
  76441. * @param offset defines the offset in the data source
  76442. * @returns a new Vector2
  76443. */
  76444. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76445. /**
  76446. * Sets "result" from the given index element of the given array
  76447. * @param array defines the data source
  76448. * @param offset defines the offset in the data source
  76449. * @param result defines the target vector
  76450. */
  76451. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76452. /**
  76453. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76454. * @param value1 defines 1st point of control
  76455. * @param value2 defines 2nd point of control
  76456. * @param value3 defines 3rd point of control
  76457. * @param value4 defines 4th point of control
  76458. * @param amount defines the interpolation factor
  76459. * @returns a new Vector2
  76460. */
  76461. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76462. /**
  76463. * 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".
  76464. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76465. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76466. * @param value defines the value to clamp
  76467. * @param min defines the lower limit
  76468. * @param max defines the upper limit
  76469. * @returns a new Vector2
  76470. */
  76471. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76472. /**
  76473. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76474. * @param value1 defines the 1st control point
  76475. * @param tangent1 defines the outgoing tangent
  76476. * @param value2 defines the 2nd control point
  76477. * @param tangent2 defines the incoming tangent
  76478. * @param amount defines the interpolation factor
  76479. * @returns a new Vector2
  76480. */
  76481. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76482. /**
  76483. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76484. * @param start defines the start vector
  76485. * @param end defines the end vector
  76486. * @param amount defines the interpolation factor
  76487. * @returns a new Vector2
  76488. */
  76489. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76490. /**
  76491. * Gets the dot product of the vector "left" and the vector "right"
  76492. * @param left defines first vector
  76493. * @param right defines second vector
  76494. * @returns the dot product (float)
  76495. */
  76496. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76497. /**
  76498. * Returns a new Vector2 equal to the normalized given vector
  76499. * @param vector defines the vector to normalize
  76500. * @returns a new Vector2
  76501. */
  76502. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76503. /**
  76504. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76505. * @param left defines 1st vector
  76506. * @param right defines 2nd vector
  76507. * @returns a new Vector2
  76508. */
  76509. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76510. /**
  76511. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76512. * @param left defines 1st vector
  76513. * @param right defines 2nd vector
  76514. * @returns a new Vector2
  76515. */
  76516. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76517. /**
  76518. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76519. * @param vector defines the vector to transform
  76520. * @param transformation defines the matrix to apply
  76521. * @returns a new Vector2
  76522. */
  76523. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76524. /**
  76525. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76526. * @param vector defines the vector to transform
  76527. * @param transformation defines the matrix to apply
  76528. * @param result defines the target vector
  76529. */
  76530. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76531. /**
  76532. * Determines if a given vector is included in a triangle
  76533. * @param p defines the vector to test
  76534. * @param p0 defines 1st triangle point
  76535. * @param p1 defines 2nd triangle point
  76536. * @param p2 defines 3rd triangle point
  76537. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76538. */
  76539. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76540. /**
  76541. * Gets the distance between the vectors "value1" and "value2"
  76542. * @param value1 defines first vector
  76543. * @param value2 defines second vector
  76544. * @returns the distance between vectors
  76545. */
  76546. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76547. /**
  76548. * Returns the squared distance between the vectors "value1" and "value2"
  76549. * @param value1 defines first vector
  76550. * @param value2 defines second vector
  76551. * @returns the squared distance between vectors
  76552. */
  76553. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76554. /**
  76555. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76556. * @param value1 defines first vector
  76557. * @param value2 defines second vector
  76558. * @returns a new Vector2
  76559. */
  76560. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76561. /**
  76562. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76563. * @param p defines the middle point
  76564. * @param segA defines one point of the segment
  76565. * @param segB defines the other point of the segment
  76566. * @returns the shortest distance
  76567. */
  76568. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76569. }
  76570. /**
  76571. * Class used to store (x,y,z) vector representation
  76572. * A Vector3 is the main object used in 3D geometry
  76573. * It can represent etiher the coordinates of a point the space, either a direction
  76574. * Reminder: js uses a left handed forward facing system
  76575. */
  76576. export class Vector3 {
  76577. /**
  76578. * Defines the first coordinates (on X axis)
  76579. */
  76580. x: number;
  76581. /**
  76582. * Defines the second coordinates (on Y axis)
  76583. */
  76584. y: number;
  76585. /**
  76586. * Defines the third coordinates (on Z axis)
  76587. */
  76588. z: number;
  76589. private static _UpReadOnly;
  76590. private static _ZeroReadOnly;
  76591. /**
  76592. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76593. * @param x defines the first coordinates (on X axis)
  76594. * @param y defines the second coordinates (on Y axis)
  76595. * @param z defines the third coordinates (on Z axis)
  76596. */
  76597. constructor(
  76598. /**
  76599. * Defines the first coordinates (on X axis)
  76600. */
  76601. x?: number,
  76602. /**
  76603. * Defines the second coordinates (on Y axis)
  76604. */
  76605. y?: number,
  76606. /**
  76607. * Defines the third coordinates (on Z axis)
  76608. */
  76609. z?: number);
  76610. /**
  76611. * Creates a string representation of the Vector3
  76612. * @returns a string with the Vector3 coordinates.
  76613. */
  76614. toString(): string;
  76615. /**
  76616. * Gets the class name
  76617. * @returns the string "Vector3"
  76618. */
  76619. getClassName(): string;
  76620. /**
  76621. * Creates the Vector3 hash code
  76622. * @returns a number which tends to be unique between Vector3 instances
  76623. */
  76624. getHashCode(): number;
  76625. /**
  76626. * Creates an array containing three elements : the coordinates of the Vector3
  76627. * @returns a new array of numbers
  76628. */
  76629. asArray(): number[];
  76630. /**
  76631. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76632. * @param array defines the destination array
  76633. * @param index defines the offset in the destination array
  76634. * @returns the current Vector3
  76635. */
  76636. toArray(array: FloatArray, index?: number): Vector3;
  76637. /**
  76638. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76639. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76640. */
  76641. toQuaternion(): Quaternion;
  76642. /**
  76643. * Adds the given vector to the current Vector3
  76644. * @param otherVector defines the second operand
  76645. * @returns the current updated Vector3
  76646. */
  76647. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76648. /**
  76649. * Adds the given coordinates to the current Vector3
  76650. * @param x defines the x coordinate of the operand
  76651. * @param y defines the y coordinate of the operand
  76652. * @param z defines the z coordinate of the operand
  76653. * @returns the current updated Vector3
  76654. */
  76655. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76656. /**
  76657. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76658. * @param otherVector defines the second operand
  76659. * @returns the resulting Vector3
  76660. */
  76661. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76662. /**
  76663. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76664. * @param otherVector defines the second operand
  76665. * @param result defines the Vector3 object where to store the result
  76666. * @returns the current Vector3
  76667. */
  76668. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76669. /**
  76670. * Subtract the given vector from the current Vector3
  76671. * @param otherVector defines the second operand
  76672. * @returns the current updated Vector3
  76673. */
  76674. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76675. /**
  76676. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76677. * @param otherVector defines the second operand
  76678. * @returns the resulting Vector3
  76679. */
  76680. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76681. /**
  76682. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76683. * @param otherVector defines the second operand
  76684. * @param result defines the Vector3 object where to store the result
  76685. * @returns the current Vector3
  76686. */
  76687. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76688. /**
  76689. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76690. * @param x defines the x coordinate of the operand
  76691. * @param y defines the y coordinate of the operand
  76692. * @param z defines the z coordinate of the operand
  76693. * @returns the resulting Vector3
  76694. */
  76695. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76696. /**
  76697. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76698. * @param x defines the x coordinate of the operand
  76699. * @param y defines the y coordinate of the operand
  76700. * @param z defines the z coordinate of the operand
  76701. * @param result defines the Vector3 object where to store the result
  76702. * @returns the current Vector3
  76703. */
  76704. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76705. /**
  76706. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76707. * @returns a new Vector3
  76708. */
  76709. negate(): Vector3;
  76710. /**
  76711. * Negate this vector in place
  76712. * @returns this
  76713. */
  76714. negateInPlace(): Vector3;
  76715. /**
  76716. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76717. * @param result defines the Vector3 object where to store the result
  76718. * @returns the current Vector3
  76719. */
  76720. negateToRef(result: Vector3): Vector3;
  76721. /**
  76722. * Multiplies the Vector3 coordinates by the float "scale"
  76723. * @param scale defines the multiplier factor
  76724. * @returns the current updated Vector3
  76725. */
  76726. scaleInPlace(scale: number): Vector3;
  76727. /**
  76728. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76729. * @param scale defines the multiplier factor
  76730. * @returns a new Vector3
  76731. */
  76732. scale(scale: number): Vector3;
  76733. /**
  76734. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76735. * @param scale defines the multiplier factor
  76736. * @param result defines the Vector3 object where to store the result
  76737. * @returns the current Vector3
  76738. */
  76739. scaleToRef(scale: number, result: Vector3): Vector3;
  76740. /**
  76741. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76742. * @param scale defines the scale factor
  76743. * @param result defines the Vector3 object where to store the result
  76744. * @returns the unmodified current Vector3
  76745. */
  76746. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76747. /**
  76748. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76749. * @param otherVector defines the second operand
  76750. * @returns true if both vectors are equals
  76751. */
  76752. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76753. /**
  76754. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76755. * @param otherVector defines the second operand
  76756. * @param epsilon defines the minimal distance to define values as equals
  76757. * @returns true if both vectors are distant less than epsilon
  76758. */
  76759. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76760. /**
  76761. * Returns true if the current Vector3 coordinates equals the given floats
  76762. * @param x defines the x coordinate of the operand
  76763. * @param y defines the y coordinate of the operand
  76764. * @param z defines the z coordinate of the operand
  76765. * @returns true if both vectors are equals
  76766. */
  76767. equalsToFloats(x: number, y: number, z: number): boolean;
  76768. /**
  76769. * Multiplies the current Vector3 coordinates by the given ones
  76770. * @param otherVector defines the second operand
  76771. * @returns the current updated Vector3
  76772. */
  76773. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76774. /**
  76775. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76776. * @param otherVector defines the second operand
  76777. * @returns the new Vector3
  76778. */
  76779. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76780. /**
  76781. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76782. * @param otherVector defines the second operand
  76783. * @param result defines the Vector3 object where to store the result
  76784. * @returns the current Vector3
  76785. */
  76786. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76787. /**
  76788. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76789. * @param x defines the x coordinate of the operand
  76790. * @param y defines the y coordinate of the operand
  76791. * @param z defines the z coordinate of the operand
  76792. * @returns the new Vector3
  76793. */
  76794. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76795. /**
  76796. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76797. * @param otherVector defines the second operand
  76798. * @returns the new Vector3
  76799. */
  76800. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76801. /**
  76802. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76803. * @param otherVector defines the second operand
  76804. * @param result defines the Vector3 object where to store the result
  76805. * @returns the current Vector3
  76806. */
  76807. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76808. /**
  76809. * Divides the current Vector3 coordinates by the given ones.
  76810. * @param otherVector defines the second operand
  76811. * @returns the current updated Vector3
  76812. */
  76813. divideInPlace(otherVector: Vector3): Vector3;
  76814. /**
  76815. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76816. * @param other defines the second operand
  76817. * @returns the current updated Vector3
  76818. */
  76819. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76820. /**
  76821. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76822. * @param other defines the second operand
  76823. * @returns the current updated Vector3
  76824. */
  76825. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76826. /**
  76827. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76828. * @param x defines the x coordinate of the operand
  76829. * @param y defines the y coordinate of the operand
  76830. * @param z defines the z coordinate of the operand
  76831. * @returns the current updated Vector3
  76832. */
  76833. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76834. /**
  76835. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76836. * @param x defines the x coordinate of the operand
  76837. * @param y defines the y coordinate of the operand
  76838. * @param z defines the z coordinate of the operand
  76839. * @returns the current updated Vector3
  76840. */
  76841. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76842. /**
  76843. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76844. * Check if is non uniform within a certain amount of decimal places to account for this
  76845. * @param epsilon the amount the values can differ
  76846. * @returns if the the vector is non uniform to a certain number of decimal places
  76847. */
  76848. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76849. /**
  76850. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76851. */
  76852. get isNonUniform(): boolean;
  76853. /**
  76854. * Gets a new Vector3 from current Vector3 floored values
  76855. * @returns a new Vector3
  76856. */
  76857. floor(): Vector3;
  76858. /**
  76859. * Gets a new Vector3 from current Vector3 floored values
  76860. * @returns a new Vector3
  76861. */
  76862. fract(): Vector3;
  76863. /**
  76864. * Gets the length of the Vector3
  76865. * @returns the length of the Vector3
  76866. */
  76867. length(): number;
  76868. /**
  76869. * Gets the squared length of the Vector3
  76870. * @returns squared length of the Vector3
  76871. */
  76872. lengthSquared(): number;
  76873. /**
  76874. * Normalize the current Vector3.
  76875. * Please note that this is an in place operation.
  76876. * @returns the current updated Vector3
  76877. */
  76878. normalize(): Vector3;
  76879. /**
  76880. * Reorders the x y z properties of the vector in place
  76881. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76882. * @returns the current updated vector
  76883. */
  76884. reorderInPlace(order: string): this;
  76885. /**
  76886. * Rotates the vector around 0,0,0 by a quaternion
  76887. * @param quaternion the rotation quaternion
  76888. * @param result vector to store the result
  76889. * @returns the resulting vector
  76890. */
  76891. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76892. /**
  76893. * Rotates a vector around a given point
  76894. * @param quaternion the rotation quaternion
  76895. * @param point the point to rotate around
  76896. * @param result vector to store the result
  76897. * @returns the resulting vector
  76898. */
  76899. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76900. /**
  76901. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76902. * The cross product is then orthogonal to both current and "other"
  76903. * @param other defines the right operand
  76904. * @returns the cross product
  76905. */
  76906. cross(other: Vector3): Vector3;
  76907. /**
  76908. * Normalize the current Vector3 with the given input length.
  76909. * Please note that this is an in place operation.
  76910. * @param len the length of the vector
  76911. * @returns the current updated Vector3
  76912. */
  76913. normalizeFromLength(len: number): Vector3;
  76914. /**
  76915. * Normalize the current Vector3 to a new vector
  76916. * @returns the new Vector3
  76917. */
  76918. normalizeToNew(): Vector3;
  76919. /**
  76920. * Normalize the current Vector3 to the reference
  76921. * @param reference define the Vector3 to update
  76922. * @returns the updated Vector3
  76923. */
  76924. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76925. /**
  76926. * Creates a new Vector3 copied from the current Vector3
  76927. * @returns the new Vector3
  76928. */
  76929. clone(): Vector3;
  76930. /**
  76931. * Copies the given vector coordinates to the current Vector3 ones
  76932. * @param source defines the source Vector3
  76933. * @returns the current updated Vector3
  76934. */
  76935. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76936. /**
  76937. * Copies the given floats to the current Vector3 coordinates
  76938. * @param x defines the x coordinate of the operand
  76939. * @param y defines the y coordinate of the operand
  76940. * @param z defines the z coordinate of the operand
  76941. * @returns the current updated Vector3
  76942. */
  76943. copyFromFloats(x: number, y: number, z: number): Vector3;
  76944. /**
  76945. * Copies the given floats to the current Vector3 coordinates
  76946. * @param x defines the x coordinate of the operand
  76947. * @param y defines the y coordinate of the operand
  76948. * @param z defines the z coordinate of the operand
  76949. * @returns the current updated Vector3
  76950. */
  76951. set(x: number, y: number, z: number): Vector3;
  76952. /**
  76953. * Copies the given float to the current Vector3 coordinates
  76954. * @param v defines the x, y and z coordinates of the operand
  76955. * @returns the current updated Vector3
  76956. */
  76957. setAll(v: number): Vector3;
  76958. /**
  76959. * Get the clip factor between two vectors
  76960. * @param vector0 defines the first operand
  76961. * @param vector1 defines the second operand
  76962. * @param axis defines the axis to use
  76963. * @param size defines the size along the axis
  76964. * @returns the clip factor
  76965. */
  76966. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76967. /**
  76968. * Get angle between two vectors
  76969. * @param vector0 angle between vector0 and vector1
  76970. * @param vector1 angle between vector0 and vector1
  76971. * @param normal direction of the normal
  76972. * @return the angle between vector0 and vector1
  76973. */
  76974. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76975. /**
  76976. * Returns a new Vector3 set from the index "offset" of the given array
  76977. * @param array defines the source array
  76978. * @param offset defines the offset in the source array
  76979. * @returns the new Vector3
  76980. */
  76981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76982. /**
  76983. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76984. * @param array defines the source array
  76985. * @param offset defines the offset in the source array
  76986. * @returns the new Vector3
  76987. * @deprecated Please use FromArray instead.
  76988. */
  76989. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76990. /**
  76991. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76992. * @param array defines the source array
  76993. * @param offset defines the offset in the source array
  76994. * @param result defines the Vector3 where to store the result
  76995. */
  76996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76997. /**
  76998. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76999. * @param array defines the source array
  77000. * @param offset defines the offset in the source array
  77001. * @param result defines the Vector3 where to store the result
  77002. * @deprecated Please use FromArrayToRef instead.
  77003. */
  77004. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  77005. /**
  77006. * Sets the given vector "result" with the given floats.
  77007. * @param x defines the x coordinate of the source
  77008. * @param y defines the y coordinate of the source
  77009. * @param z defines the z coordinate of the source
  77010. * @param result defines the Vector3 where to store the result
  77011. */
  77012. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77013. /**
  77014. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77015. * @returns a new empty Vector3
  77016. */
  77017. static Zero(): Vector3;
  77018. /**
  77019. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77020. * @returns a new unit Vector3
  77021. */
  77022. static One(): Vector3;
  77023. /**
  77024. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77025. * @returns a new up Vector3
  77026. */
  77027. static Up(): Vector3;
  77028. /**
  77029. * Gets a up Vector3 that must not be updated
  77030. */
  77031. static get UpReadOnly(): DeepImmutable<Vector3>;
  77032. /**
  77033. * Gets a zero Vector3 that must not be updated
  77034. */
  77035. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77036. /**
  77037. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77038. * @returns a new down Vector3
  77039. */
  77040. static Down(): Vector3;
  77041. /**
  77042. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77043. * @returns a new forward Vector3
  77044. */
  77045. static Forward(): Vector3;
  77046. /**
  77047. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77048. * @returns a new forward Vector3
  77049. */
  77050. static Backward(): Vector3;
  77051. /**
  77052. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77053. * @returns a new right Vector3
  77054. */
  77055. static Right(): Vector3;
  77056. /**
  77057. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77058. * @returns a new left Vector3
  77059. */
  77060. static Left(): Vector3;
  77061. /**
  77062. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77063. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77064. * @param vector defines the Vector3 to transform
  77065. * @param transformation defines the transformation matrix
  77066. * @returns the transformed Vector3
  77067. */
  77068. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77069. /**
  77070. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77071. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77072. * @param vector defines the Vector3 to transform
  77073. * @param transformation defines the transformation matrix
  77074. * @param result defines the Vector3 where to store the result
  77075. */
  77076. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77077. /**
  77078. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77079. * This method computes tranformed coordinates only, not transformed direction vectors
  77080. * @param x define the x coordinate of the source vector
  77081. * @param y define the y coordinate of the source vector
  77082. * @param z define the z coordinate of the source vector
  77083. * @param transformation defines the transformation matrix
  77084. * @param result defines the Vector3 where to store the result
  77085. */
  77086. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77087. /**
  77088. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77089. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77090. * @param vector defines the Vector3 to transform
  77091. * @param transformation defines the transformation matrix
  77092. * @returns the new Vector3
  77093. */
  77094. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77095. /**
  77096. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77097. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77098. * @param vector defines the Vector3 to transform
  77099. * @param transformation defines the transformation matrix
  77100. * @param result defines the Vector3 where to store the result
  77101. */
  77102. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77103. /**
  77104. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77105. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77106. * @param x define the x coordinate of the source vector
  77107. * @param y define the y coordinate of the source vector
  77108. * @param z define the z coordinate of the source vector
  77109. * @param transformation defines the transformation matrix
  77110. * @param result defines the Vector3 where to store the result
  77111. */
  77112. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77113. /**
  77114. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77115. * @param value1 defines the first control point
  77116. * @param value2 defines the second control point
  77117. * @param value3 defines the third control point
  77118. * @param value4 defines the fourth control point
  77119. * @param amount defines the amount on the spline to use
  77120. * @returns the new Vector3
  77121. */
  77122. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77123. /**
  77124. * 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"
  77125. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77126. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77127. * @param value defines the current value
  77128. * @param min defines the lower range value
  77129. * @param max defines the upper range value
  77130. * @returns the new Vector3
  77131. */
  77132. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77133. /**
  77134. * 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"
  77135. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77136. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77137. * @param value defines the current value
  77138. * @param min defines the lower range value
  77139. * @param max defines the upper range value
  77140. * @param result defines the Vector3 where to store the result
  77141. */
  77142. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77143. /**
  77144. * Checks if a given vector is inside a specific range
  77145. * @param v defines the vector to test
  77146. * @param min defines the minimum range
  77147. * @param max defines the maximum range
  77148. */
  77149. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77150. /**
  77151. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77152. * @param value1 defines the first control point
  77153. * @param tangent1 defines the first tangent vector
  77154. * @param value2 defines the second control point
  77155. * @param tangent2 defines the second tangent vector
  77156. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77157. * @returns the new Vector3
  77158. */
  77159. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77160. /**
  77161. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77162. * @param start defines the start value
  77163. * @param end defines the end value
  77164. * @param amount max defines amount between both (between 0 and 1)
  77165. * @returns the new Vector3
  77166. */
  77167. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77168. /**
  77169. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77170. * @param start defines the start value
  77171. * @param end defines the end value
  77172. * @param amount max defines amount between both (between 0 and 1)
  77173. * @param result defines the Vector3 where to store the result
  77174. */
  77175. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77176. /**
  77177. * Returns the dot product (float) between the vectors "left" and "right"
  77178. * @param left defines the left operand
  77179. * @param right defines the right operand
  77180. * @returns the dot product
  77181. */
  77182. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77183. /**
  77184. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77185. * The cross product is then orthogonal to both "left" and "right"
  77186. * @param left defines the left operand
  77187. * @param right defines the right operand
  77188. * @returns the cross product
  77189. */
  77190. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77191. /**
  77192. * Sets the given vector "result" with the cross product of "left" and "right"
  77193. * The cross product is then orthogonal to both "left" and "right"
  77194. * @param left defines the left operand
  77195. * @param right defines the right operand
  77196. * @param result defines the Vector3 where to store the result
  77197. */
  77198. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77199. /**
  77200. * Returns a new Vector3 as the normalization of the given vector
  77201. * @param vector defines the Vector3 to normalize
  77202. * @returns the new Vector3
  77203. */
  77204. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77205. /**
  77206. * Sets the given vector "result" with the normalization of the given first vector
  77207. * @param vector defines the Vector3 to normalize
  77208. * @param result defines the Vector3 where to store the result
  77209. */
  77210. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77211. /**
  77212. * Project a Vector3 onto screen space
  77213. * @param vector defines the Vector3 to project
  77214. * @param world defines the world matrix to use
  77215. * @param transform defines the transform (view x projection) matrix to use
  77216. * @param viewport defines the screen viewport to use
  77217. * @returns the new Vector3
  77218. */
  77219. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77220. /** @hidden */
  77221. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77222. /**
  77223. * Unproject from screen space to object space
  77224. * @param source defines the screen space Vector3 to use
  77225. * @param viewportWidth defines the current width of the viewport
  77226. * @param viewportHeight defines the current height of the viewport
  77227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77228. * @param transform defines the transform (view x projection) matrix to use
  77229. * @returns the new Vector3
  77230. */
  77231. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77232. /**
  77233. * Unproject from screen space to object space
  77234. * @param source defines the screen space Vector3 to use
  77235. * @param viewportWidth defines the current width of the viewport
  77236. * @param viewportHeight defines the current height of the viewport
  77237. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77238. * @param view defines the view matrix to use
  77239. * @param projection defines the projection matrix to use
  77240. * @returns the new Vector3
  77241. */
  77242. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77243. /**
  77244. * Unproject from screen space to object space
  77245. * @param source defines the screen space Vector3 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 UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77254. /**
  77255. * Unproject from screen space to object space
  77256. * @param sourceX defines the screen space x coordinate to use
  77257. * @param sourceY defines the screen space y coordinate to use
  77258. * @param sourceZ defines the screen space z coordinate to use
  77259. * @param viewportWidth defines the current width of the viewport
  77260. * @param viewportHeight defines the current height of the viewport
  77261. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77262. * @param view defines the view matrix to use
  77263. * @param projection defines the projection matrix to use
  77264. * @param result defines the Vector3 where to store the result
  77265. */
  77266. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77267. /**
  77268. * Gets the minimal coordinate values between two Vector3
  77269. * @param left defines the first operand
  77270. * @param right defines the second operand
  77271. * @returns the new Vector3
  77272. */
  77273. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77274. /**
  77275. * Gets the maximal coordinate values between two Vector3
  77276. * @param left defines the first operand
  77277. * @param right defines the second operand
  77278. * @returns the new Vector3
  77279. */
  77280. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77281. /**
  77282. * Returns the distance between the vectors "value1" and "value2"
  77283. * @param value1 defines the first operand
  77284. * @param value2 defines the second operand
  77285. * @returns the distance
  77286. */
  77287. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77288. /**
  77289. * Returns the squared distance between the vectors "value1" and "value2"
  77290. * @param value1 defines the first operand
  77291. * @param value2 defines the second operand
  77292. * @returns the squared distance
  77293. */
  77294. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77295. /**
  77296. * Returns a new Vector3 located at the center between "value1" and "value2"
  77297. * @param value1 defines the first operand
  77298. * @param value2 defines the second operand
  77299. * @returns the new Vector3
  77300. */
  77301. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77302. /**
  77303. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77304. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77305. * to something in order to rotate it from its local system to the given target system
  77306. * Note: axis1, axis2 and axis3 are normalized during this operation
  77307. * @param axis1 defines the first axis
  77308. * @param axis2 defines the second axis
  77309. * @param axis3 defines the third axis
  77310. * @returns a new Vector3
  77311. */
  77312. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77313. /**
  77314. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77315. * @param axis1 defines the first axis
  77316. * @param axis2 defines the second axis
  77317. * @param axis3 defines the third axis
  77318. * @param ref defines the Vector3 where to store the result
  77319. */
  77320. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77321. }
  77322. /**
  77323. * Vector4 class created for EulerAngle class conversion to Quaternion
  77324. */
  77325. export class Vector4 {
  77326. /** x value of the vector */
  77327. x: number;
  77328. /** y value of the vector */
  77329. y: number;
  77330. /** z value of the vector */
  77331. z: number;
  77332. /** w value of the vector */
  77333. w: number;
  77334. /**
  77335. * Creates a Vector4 object from the given floats.
  77336. * @param x x value of the vector
  77337. * @param y y value of the vector
  77338. * @param z z value of the vector
  77339. * @param w w value of the vector
  77340. */
  77341. constructor(
  77342. /** x value of the vector */
  77343. x: number,
  77344. /** y value of the vector */
  77345. y: number,
  77346. /** z value of the vector */
  77347. z: number,
  77348. /** w value of the vector */
  77349. w: number);
  77350. /**
  77351. * Returns the string with the Vector4 coordinates.
  77352. * @returns a string containing all the vector values
  77353. */
  77354. toString(): string;
  77355. /**
  77356. * Returns the string "Vector4".
  77357. * @returns "Vector4"
  77358. */
  77359. getClassName(): string;
  77360. /**
  77361. * Returns the Vector4 hash code.
  77362. * @returns a unique hash code
  77363. */
  77364. getHashCode(): number;
  77365. /**
  77366. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77367. * @returns the resulting array
  77368. */
  77369. asArray(): number[];
  77370. /**
  77371. * Populates the given array from the given index with the Vector4 coordinates.
  77372. * @param array array to populate
  77373. * @param index index of the array to start at (default: 0)
  77374. * @returns the Vector4.
  77375. */
  77376. toArray(array: FloatArray, index?: number): Vector4;
  77377. /**
  77378. * Adds the given vector to the current Vector4.
  77379. * @param otherVector the vector to add
  77380. * @returns the updated Vector4.
  77381. */
  77382. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77383. /**
  77384. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77385. * @param otherVector the vector to add
  77386. * @returns the resulting vector
  77387. */
  77388. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77389. /**
  77390. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77391. * @param otherVector the vector to add
  77392. * @param result the vector to store the result
  77393. * @returns the current Vector4.
  77394. */
  77395. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77396. /**
  77397. * Subtract in place the given vector from the current Vector4.
  77398. * @param otherVector the vector to subtract
  77399. * @returns the updated Vector4.
  77400. */
  77401. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77402. /**
  77403. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77404. * @param otherVector the vector to add
  77405. * @returns the new vector with the result
  77406. */
  77407. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77408. /**
  77409. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77410. * @param otherVector the vector to subtract
  77411. * @param result the vector to store the result
  77412. * @returns the current Vector4.
  77413. */
  77414. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77415. /**
  77416. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77417. */
  77418. /**
  77419. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77420. * @param x value to subtract
  77421. * @param y value to subtract
  77422. * @param z value to subtract
  77423. * @param w value to subtract
  77424. * @returns new vector containing the result
  77425. */
  77426. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77427. /**
  77428. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77429. * @param x value to subtract
  77430. * @param y value to subtract
  77431. * @param z value to subtract
  77432. * @param w value to subtract
  77433. * @param result the vector to store the result in
  77434. * @returns the current Vector4.
  77435. */
  77436. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77437. /**
  77438. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77439. * @returns a new vector with the negated values
  77440. */
  77441. negate(): Vector4;
  77442. /**
  77443. * Negate this vector in place
  77444. * @returns this
  77445. */
  77446. negateInPlace(): Vector4;
  77447. /**
  77448. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77449. * @param result defines the Vector3 object where to store the result
  77450. * @returns the current Vector4
  77451. */
  77452. negateToRef(result: Vector4): Vector4;
  77453. /**
  77454. * Multiplies the current Vector4 coordinates by scale (float).
  77455. * @param scale the number to scale with
  77456. * @returns the updated Vector4.
  77457. */
  77458. scaleInPlace(scale: number): Vector4;
  77459. /**
  77460. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77461. * @param scale the number to scale with
  77462. * @returns a new vector with the result
  77463. */
  77464. scale(scale: number): Vector4;
  77465. /**
  77466. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77467. * @param scale the number to scale with
  77468. * @param result a vector to store the result in
  77469. * @returns the current Vector4.
  77470. */
  77471. scaleToRef(scale: number, result: Vector4): Vector4;
  77472. /**
  77473. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77474. * @param scale defines the scale factor
  77475. * @param result defines the Vector4 object where to store the result
  77476. * @returns the unmodified current Vector4
  77477. */
  77478. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77479. /**
  77480. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77481. * @param otherVector the vector to compare against
  77482. * @returns true if they are equal
  77483. */
  77484. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77485. /**
  77486. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77487. * @param otherVector vector to compare against
  77488. * @param epsilon (Default: very small number)
  77489. * @returns true if they are equal
  77490. */
  77491. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77492. /**
  77493. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77494. * @param x x value to compare against
  77495. * @param y y value to compare against
  77496. * @param z z value to compare against
  77497. * @param w w value to compare against
  77498. * @returns true if equal
  77499. */
  77500. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77501. /**
  77502. * Multiplies in place the current Vector4 by the given one.
  77503. * @param otherVector vector to multiple with
  77504. * @returns the updated Vector4.
  77505. */
  77506. multiplyInPlace(otherVector: Vector4): Vector4;
  77507. /**
  77508. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77509. * @param otherVector vector to multiple with
  77510. * @returns resulting new vector
  77511. */
  77512. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77513. /**
  77514. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77515. * @param otherVector vector to multiple with
  77516. * @param result vector to store the result
  77517. * @returns the current Vector4.
  77518. */
  77519. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77520. /**
  77521. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77522. * @param x x value multiply with
  77523. * @param y y value multiply with
  77524. * @param z z value multiply with
  77525. * @param w w value multiply with
  77526. * @returns resulting new vector
  77527. */
  77528. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77529. /**
  77530. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77531. * @param otherVector vector to devide with
  77532. * @returns resulting new vector
  77533. */
  77534. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77535. /**
  77536. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77537. * @param otherVector vector to devide with
  77538. * @param result vector to store the result
  77539. * @returns the current Vector4.
  77540. */
  77541. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77542. /**
  77543. * Divides the current Vector3 coordinates by the given ones.
  77544. * @param otherVector vector to devide with
  77545. * @returns the updated Vector3.
  77546. */
  77547. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77548. /**
  77549. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77550. * @param other defines the second operand
  77551. * @returns the current updated Vector4
  77552. */
  77553. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77554. /**
  77555. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77556. * @param other defines the second operand
  77557. * @returns the current updated Vector4
  77558. */
  77559. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77560. /**
  77561. * Gets a new Vector4 from current Vector4 floored values
  77562. * @returns a new Vector4
  77563. */
  77564. floor(): Vector4;
  77565. /**
  77566. * Gets a new Vector4 from current Vector3 floored values
  77567. * @returns a new Vector4
  77568. */
  77569. fract(): Vector4;
  77570. /**
  77571. * Returns the Vector4 length (float).
  77572. * @returns the length
  77573. */
  77574. length(): number;
  77575. /**
  77576. * Returns the Vector4 squared length (float).
  77577. * @returns the length squared
  77578. */
  77579. lengthSquared(): number;
  77580. /**
  77581. * Normalizes in place the Vector4.
  77582. * @returns the updated Vector4.
  77583. */
  77584. normalize(): Vector4;
  77585. /**
  77586. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77587. * @returns this converted to a new vector3
  77588. */
  77589. toVector3(): Vector3;
  77590. /**
  77591. * Returns a new Vector4 copied from the current one.
  77592. * @returns the new cloned vector
  77593. */
  77594. clone(): Vector4;
  77595. /**
  77596. * Updates the current Vector4 with the given one coordinates.
  77597. * @param source the source vector to copy from
  77598. * @returns the updated Vector4.
  77599. */
  77600. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77601. /**
  77602. * Updates the current Vector4 coordinates with the given floats.
  77603. * @param x float to copy from
  77604. * @param y float to copy from
  77605. * @param z float to copy from
  77606. * @param w float to copy from
  77607. * @returns the updated Vector4.
  77608. */
  77609. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77610. /**
  77611. * Updates the current Vector4 coordinates with the given floats.
  77612. * @param x float to set from
  77613. * @param y float to set from
  77614. * @param z float to set from
  77615. * @param w float to set from
  77616. * @returns the updated Vector4.
  77617. */
  77618. set(x: number, y: number, z: number, w: number): Vector4;
  77619. /**
  77620. * Copies the given float to the current Vector3 coordinates
  77621. * @param v defines the x, y, z and w coordinates of the operand
  77622. * @returns the current updated Vector3
  77623. */
  77624. setAll(v: number): Vector4;
  77625. /**
  77626. * Returns a new Vector4 set from the starting index of the given array.
  77627. * @param array the array to pull values from
  77628. * @param offset the offset into the array to start at
  77629. * @returns the new vector
  77630. */
  77631. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77632. /**
  77633. * Updates the given vector "result" from the starting index of the given array.
  77634. * @param array the array to pull values from
  77635. * @param offset the offset into the array to start at
  77636. * @param result the vector to store the result in
  77637. */
  77638. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77639. /**
  77640. * Updates the given vector "result" from the starting index of the given Float32Array.
  77641. * @param array the array to pull values from
  77642. * @param offset the offset into the array to start at
  77643. * @param result the vector to store the result in
  77644. */
  77645. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77646. /**
  77647. * Updates the given vector "result" coordinates from the given floats.
  77648. * @param x float to set from
  77649. * @param y float to set from
  77650. * @param z float to set from
  77651. * @param w float to set from
  77652. * @param result the vector to the floats in
  77653. */
  77654. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77655. /**
  77656. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77657. * @returns the new vector
  77658. */
  77659. static Zero(): Vector4;
  77660. /**
  77661. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77662. * @returns the new vector
  77663. */
  77664. static One(): Vector4;
  77665. /**
  77666. * Returns a new normalized Vector4 from the given one.
  77667. * @param vector the vector to normalize
  77668. * @returns the vector
  77669. */
  77670. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77671. /**
  77672. * Updates the given vector "result" from the normalization of the given one.
  77673. * @param vector the vector to normalize
  77674. * @param result the vector to store the result in
  77675. */
  77676. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77677. /**
  77678. * Returns a vector with the minimum values from the left and right vectors
  77679. * @param left left vector to minimize
  77680. * @param right right vector to minimize
  77681. * @returns a new vector with the minimum of the left and right vector values
  77682. */
  77683. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77684. /**
  77685. * Returns a vector with the maximum values from the left and right vectors
  77686. * @param left left vector to maximize
  77687. * @param right right vector to maximize
  77688. * @returns a new vector with the maximum of the left and right vector values
  77689. */
  77690. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77691. /**
  77692. * Returns the distance (float) between the vectors "value1" and "value2".
  77693. * @param value1 value to calulate the distance between
  77694. * @param value2 value to calulate the distance between
  77695. * @return the distance between the two vectors
  77696. */
  77697. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77698. /**
  77699. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77700. * @param value1 value to calulate the distance between
  77701. * @param value2 value to calulate the distance between
  77702. * @return the distance between the two vectors squared
  77703. */
  77704. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77705. /**
  77706. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77707. * @param value1 value to calulate the center between
  77708. * @param value2 value to calulate the center between
  77709. * @return the center between the two vectors
  77710. */
  77711. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77712. /**
  77713. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77714. * This methods computes transformed normalized direction vectors only.
  77715. * @param vector the vector to transform
  77716. * @param transformation the transformation matrix to apply
  77717. * @returns the new vector
  77718. */
  77719. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77720. /**
  77721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77722. * This methods computes transformed normalized direction vectors only.
  77723. * @param vector the vector to transform
  77724. * @param transformation the transformation matrix to apply
  77725. * @param result the vector to store the result in
  77726. */
  77727. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77728. /**
  77729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77730. * This methods computes transformed normalized direction vectors only.
  77731. * @param x value to transform
  77732. * @param y value to transform
  77733. * @param z value to transform
  77734. * @param w value to transform
  77735. * @param transformation the transformation matrix to apply
  77736. * @param result the vector to store the results in
  77737. */
  77738. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77739. /**
  77740. * Creates a new Vector4 from a Vector3
  77741. * @param source defines the source data
  77742. * @param w defines the 4th component (default is 0)
  77743. * @returns a new Vector4
  77744. */
  77745. static FromVector3(source: Vector3, w?: number): Vector4;
  77746. }
  77747. /**
  77748. * Class used to store quaternion data
  77749. * @see https://en.wikipedia.org/wiki/Quaternion
  77750. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77751. */
  77752. export class Quaternion {
  77753. /** defines the first component (0 by default) */
  77754. x: number;
  77755. /** defines the second component (0 by default) */
  77756. y: number;
  77757. /** defines the third component (0 by default) */
  77758. z: number;
  77759. /** defines the fourth component (1.0 by default) */
  77760. w: number;
  77761. /**
  77762. * Creates a new Quaternion from the given floats
  77763. * @param x defines the first component (0 by default)
  77764. * @param y defines the second component (0 by default)
  77765. * @param z defines the third component (0 by default)
  77766. * @param w defines the fourth component (1.0 by default)
  77767. */
  77768. constructor(
  77769. /** defines the first component (0 by default) */
  77770. x?: number,
  77771. /** defines the second component (0 by default) */
  77772. y?: number,
  77773. /** defines the third component (0 by default) */
  77774. z?: number,
  77775. /** defines the fourth component (1.0 by default) */
  77776. w?: number);
  77777. /**
  77778. * Gets a string representation for the current quaternion
  77779. * @returns a string with the Quaternion coordinates
  77780. */
  77781. toString(): string;
  77782. /**
  77783. * Gets the class name of the quaternion
  77784. * @returns the string "Quaternion"
  77785. */
  77786. getClassName(): string;
  77787. /**
  77788. * Gets a hash code for this quaternion
  77789. * @returns the quaternion hash code
  77790. */
  77791. getHashCode(): number;
  77792. /**
  77793. * Copy the quaternion to an array
  77794. * @returns a new array populated with 4 elements from the quaternion coordinates
  77795. */
  77796. asArray(): number[];
  77797. /**
  77798. * Check if two quaternions are equals
  77799. * @param otherQuaternion defines the second operand
  77800. * @return true if the current quaternion and the given one coordinates are strictly equals
  77801. */
  77802. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77803. /**
  77804. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77805. * @param otherQuaternion defines the other quaternion
  77806. * @param epsilon defines the minimal distance to consider equality
  77807. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77808. */
  77809. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77810. /**
  77811. * Clone the current quaternion
  77812. * @returns a new quaternion copied from the current one
  77813. */
  77814. clone(): Quaternion;
  77815. /**
  77816. * Copy a quaternion to the current one
  77817. * @param other defines the other quaternion
  77818. * @returns the updated current quaternion
  77819. */
  77820. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77821. /**
  77822. * Updates the current quaternion with the given float coordinates
  77823. * @param x defines the x coordinate
  77824. * @param y defines the y coordinate
  77825. * @param z defines the z coordinate
  77826. * @param w defines the w coordinate
  77827. * @returns the updated current quaternion
  77828. */
  77829. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77830. /**
  77831. * Updates the current quaternion from the given float coordinates
  77832. * @param x defines the x coordinate
  77833. * @param y defines the y coordinate
  77834. * @param z defines the z coordinate
  77835. * @param w defines the w coordinate
  77836. * @returns the updated current quaternion
  77837. */
  77838. set(x: number, y: number, z: number, w: number): Quaternion;
  77839. /**
  77840. * Adds two quaternions
  77841. * @param other defines the second operand
  77842. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77843. */
  77844. add(other: DeepImmutable<Quaternion>): Quaternion;
  77845. /**
  77846. * Add a quaternion to the current one
  77847. * @param other defines the quaternion to add
  77848. * @returns the current quaternion
  77849. */
  77850. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77851. /**
  77852. * Subtract two quaternions
  77853. * @param other defines the second operand
  77854. * @returns a new quaternion as the subtraction result of the given one from the current one
  77855. */
  77856. subtract(other: Quaternion): Quaternion;
  77857. /**
  77858. * Multiplies the current quaternion by a scale factor
  77859. * @param value defines the scale factor
  77860. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77861. */
  77862. scale(value: number): Quaternion;
  77863. /**
  77864. * Scale the current quaternion values by a factor and stores 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. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77870. /**
  77871. * Multiplies in place the current quaternion by a scale factor
  77872. * @param value defines the scale factor
  77873. * @returns the current modified quaternion
  77874. */
  77875. scaleInPlace(value: number): Quaternion;
  77876. /**
  77877. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77878. * @param scale defines the scale factor
  77879. * @param result defines the Quaternion object where to store the result
  77880. * @returns the unmodified current quaternion
  77881. */
  77882. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77883. /**
  77884. * Multiplies two quaternions
  77885. * @param q1 defines the second operand
  77886. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77887. */
  77888. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77889. /**
  77890. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77891. * @param q1 defines the second operand
  77892. * @param result defines the target quaternion
  77893. * @returns the current quaternion
  77894. */
  77895. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77896. /**
  77897. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77898. * @param q1 defines the second operand
  77899. * @returns the currentupdated quaternion
  77900. */
  77901. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77902. /**
  77903. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77904. * @param ref defines the target quaternion
  77905. * @returns the current quaternion
  77906. */
  77907. conjugateToRef(ref: Quaternion): Quaternion;
  77908. /**
  77909. * Conjugates in place (1-q) the current quaternion
  77910. * @returns the current updated quaternion
  77911. */
  77912. conjugateInPlace(): Quaternion;
  77913. /**
  77914. * Conjugates in place (1-q) the current quaternion
  77915. * @returns a new quaternion
  77916. */
  77917. conjugate(): Quaternion;
  77918. /**
  77919. * Gets length of current quaternion
  77920. * @returns the quaternion length (float)
  77921. */
  77922. length(): number;
  77923. /**
  77924. * Normalize in place the current quaternion
  77925. * @returns the current updated quaternion
  77926. */
  77927. normalize(): Quaternion;
  77928. /**
  77929. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77930. * @param order is a reserved parameter and is ignore for now
  77931. * @returns a new Vector3 containing the Euler angles
  77932. */
  77933. toEulerAngles(order?: string): Vector3;
  77934. /**
  77935. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77936. * @param result defines the vector which will be filled with the Euler angles
  77937. * @param order is a reserved parameter and is ignore for now
  77938. * @returns the current unchanged quaternion
  77939. */
  77940. toEulerAnglesToRef(result: Vector3): Quaternion;
  77941. /**
  77942. * Updates the given rotation matrix with the current quaternion values
  77943. * @param result defines the target matrix
  77944. * @returns the current unchanged quaternion
  77945. */
  77946. toRotationMatrix(result: Matrix): Quaternion;
  77947. /**
  77948. * Updates the current quaternion from the given rotation matrix values
  77949. * @param matrix defines the source matrix
  77950. * @returns the current updated quaternion
  77951. */
  77952. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77953. /**
  77954. * Creates a new quaternion from a rotation matrix
  77955. * @param matrix defines the source matrix
  77956. * @returns a new quaternion created from the given rotation matrix values
  77957. */
  77958. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77959. /**
  77960. * Updates the given quaternion with the given rotation matrix values
  77961. * @param matrix defines the source matrix
  77962. * @param result defines the target quaternion
  77963. */
  77964. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77965. /**
  77966. * Returns the dot product (float) between the quaternions "left" and "right"
  77967. * @param left defines the left operand
  77968. * @param right defines the right operand
  77969. * @returns the dot product
  77970. */
  77971. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77972. /**
  77973. * Checks if the two quaternions are close to each other
  77974. * @param quat0 defines the first quaternion to check
  77975. * @param quat1 defines the second quaternion to check
  77976. * @returns true if the two quaternions are close to each other
  77977. */
  77978. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77979. /**
  77980. * Creates an empty quaternion
  77981. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77982. */
  77983. static Zero(): Quaternion;
  77984. /**
  77985. * Inverse a given quaternion
  77986. * @param q defines the source quaternion
  77987. * @returns a new quaternion as the inverted current quaternion
  77988. */
  77989. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77990. /**
  77991. * Inverse a given quaternion
  77992. * @param q defines the source quaternion
  77993. * @param result the quaternion the result will be stored in
  77994. * @returns the result quaternion
  77995. */
  77996. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77997. /**
  77998. * Creates an identity quaternion
  77999. * @returns the identity quaternion
  78000. */
  78001. static Identity(): Quaternion;
  78002. /**
  78003. * Gets a boolean indicating if the given quaternion is identity
  78004. * @param quaternion defines the quaternion to check
  78005. * @returns true if the quaternion is identity
  78006. */
  78007. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  78008. /**
  78009. * Creates a quaternion from a rotation around an axis
  78010. * @param axis defines the axis to use
  78011. * @param angle defines the angle to use
  78012. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78013. */
  78014. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78015. /**
  78016. * Creates a rotation around an axis and stores it into the given quaternion
  78017. * @param axis defines the axis to use
  78018. * @param angle defines the angle to use
  78019. * @param result defines the target quaternion
  78020. * @returns the target quaternion
  78021. */
  78022. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78023. /**
  78024. * Creates a new quaternion from data stored into an array
  78025. * @param array defines the data source
  78026. * @param offset defines the offset in the source array where the data starts
  78027. * @returns a new quaternion
  78028. */
  78029. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78030. /**
  78031. * Updates the given quaternion "result" from the starting index of the given array.
  78032. * @param array the array to pull values from
  78033. * @param offset the offset into the array to start at
  78034. * @param result the quaternion to store the result in
  78035. */
  78036. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78037. /**
  78038. * Create a quaternion from Euler rotation angles
  78039. * @param x Pitch
  78040. * @param y Yaw
  78041. * @param z Roll
  78042. * @returns the new Quaternion
  78043. */
  78044. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78045. /**
  78046. * Updates a quaternion from Euler rotation angles
  78047. * @param x Pitch
  78048. * @param y Yaw
  78049. * @param z Roll
  78050. * @param result the quaternion to store the result
  78051. * @returns the updated quaternion
  78052. */
  78053. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78054. /**
  78055. * Create a quaternion from Euler rotation vector
  78056. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78057. * @returns the new Quaternion
  78058. */
  78059. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78060. /**
  78061. * Updates a quaternion from Euler rotation vector
  78062. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78063. * @param result the quaternion to store the result
  78064. * @returns the updated quaternion
  78065. */
  78066. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78067. /**
  78068. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78069. * @param yaw defines the rotation around Y axis
  78070. * @param pitch defines the rotation around X axis
  78071. * @param roll defines the rotation around Z axis
  78072. * @returns the new quaternion
  78073. */
  78074. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78075. /**
  78076. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78077. * @param yaw defines the rotation around Y axis
  78078. * @param pitch defines the rotation around X axis
  78079. * @param roll defines the rotation around Z axis
  78080. * @param result defines the target quaternion
  78081. */
  78082. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78083. /**
  78084. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78085. * @param alpha defines the rotation around first axis
  78086. * @param beta defines the rotation around second axis
  78087. * @param gamma defines the rotation around third axis
  78088. * @returns the new quaternion
  78089. */
  78090. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78091. /**
  78092. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78093. * @param alpha defines the rotation around first axis
  78094. * @param beta defines the rotation around second axis
  78095. * @param gamma defines the rotation around third axis
  78096. * @param result defines the target quaternion
  78097. */
  78098. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78099. /**
  78100. * 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)
  78101. * @param axis1 defines the first axis
  78102. * @param axis2 defines the second axis
  78103. * @param axis3 defines the third axis
  78104. * @returns the new quaternion
  78105. */
  78106. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78107. /**
  78108. * 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
  78109. * @param axis1 defines the first axis
  78110. * @param axis2 defines the second axis
  78111. * @param axis3 defines the third axis
  78112. * @param ref defines the target quaternion
  78113. */
  78114. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78115. /**
  78116. * Interpolates between two quaternions
  78117. * @param left defines first quaternion
  78118. * @param right defines second quaternion
  78119. * @param amount defines the gradient to use
  78120. * @returns the new interpolated quaternion
  78121. */
  78122. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78123. /**
  78124. * Interpolates between two quaternions and stores it into a target quaternion
  78125. * @param left defines first quaternion
  78126. * @param right defines second quaternion
  78127. * @param amount defines the gradient to use
  78128. * @param result defines the target quaternion
  78129. */
  78130. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78131. /**
  78132. * Interpolate between two quaternions using Hermite interpolation
  78133. * @param value1 defines first quaternion
  78134. * @param tangent1 defines the incoming tangent
  78135. * @param value2 defines second quaternion
  78136. * @param tangent2 defines the outgoing tangent
  78137. * @param amount defines the target quaternion
  78138. * @returns the new interpolated quaternion
  78139. */
  78140. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78141. }
  78142. /**
  78143. * Class used to store matrix data (4x4)
  78144. */
  78145. export class Matrix {
  78146. private static _updateFlagSeed;
  78147. private static _identityReadOnly;
  78148. private _isIdentity;
  78149. private _isIdentityDirty;
  78150. private _isIdentity3x2;
  78151. private _isIdentity3x2Dirty;
  78152. /**
  78153. * Gets the update flag of the matrix which is an unique number for the matrix.
  78154. * It will be incremented every time the matrix data change.
  78155. * You can use it to speed the comparison between two versions of the same matrix.
  78156. */
  78157. updateFlag: number;
  78158. private readonly _m;
  78159. /**
  78160. * Gets the internal data of the matrix
  78161. */
  78162. get m(): DeepImmutable<Float32Array>;
  78163. /** @hidden */
  78164. _markAsUpdated(): void;
  78165. /** @hidden */
  78166. private _updateIdentityStatus;
  78167. /**
  78168. * Creates an empty matrix (filled with zeros)
  78169. */
  78170. constructor();
  78171. /**
  78172. * Check if the current matrix is identity
  78173. * @returns true is the matrix is the identity matrix
  78174. */
  78175. isIdentity(): boolean;
  78176. /**
  78177. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78178. * @returns true is the matrix is the identity matrix
  78179. */
  78180. isIdentityAs3x2(): boolean;
  78181. /**
  78182. * Gets the determinant of the matrix
  78183. * @returns the matrix determinant
  78184. */
  78185. determinant(): number;
  78186. /**
  78187. * Returns the matrix as a Float32Array
  78188. * @returns the matrix underlying array
  78189. */
  78190. toArray(): DeepImmutable<Float32Array>;
  78191. /**
  78192. * Returns the matrix as a Float32Array
  78193. * @returns the matrix underlying array.
  78194. */
  78195. asArray(): DeepImmutable<Float32Array>;
  78196. /**
  78197. * Inverts the current matrix in place
  78198. * @returns the current inverted matrix
  78199. */
  78200. invert(): Matrix;
  78201. /**
  78202. * Sets all the matrix elements to zero
  78203. * @returns the current matrix
  78204. */
  78205. reset(): Matrix;
  78206. /**
  78207. * Adds the current matrix with a second one
  78208. * @param other defines the matrix to add
  78209. * @returns a new matrix as the addition of the current matrix and the given one
  78210. */
  78211. add(other: DeepImmutable<Matrix>): Matrix;
  78212. /**
  78213. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78214. * @param other defines the matrix to add
  78215. * @param result defines the target matrix
  78216. * @returns the current matrix
  78217. */
  78218. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78219. /**
  78220. * Adds in place the given matrix to the current matrix
  78221. * @param other defines the second operand
  78222. * @returns the current updated matrix
  78223. */
  78224. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78225. /**
  78226. * Sets the given matrix to the current inverted Matrix
  78227. * @param other defines the target matrix
  78228. * @returns the unmodified current matrix
  78229. */
  78230. invertToRef(other: Matrix): Matrix;
  78231. /**
  78232. * add a value at the specified position in the current Matrix
  78233. * @param index the index of the value within the matrix. between 0 and 15.
  78234. * @param value the value to be added
  78235. * @returns the current updated matrix
  78236. */
  78237. addAtIndex(index: number, value: number): Matrix;
  78238. /**
  78239. * mutiply the specified position in the current Matrix by a value
  78240. * @param index the index of the value within the matrix. between 0 and 15.
  78241. * @param value the value to be added
  78242. * @returns the current updated matrix
  78243. */
  78244. multiplyAtIndex(index: number, value: number): Matrix;
  78245. /**
  78246. * Inserts the translation vector (using 3 floats) in the current matrix
  78247. * @param x defines the 1st component of the translation
  78248. * @param y defines the 2nd component of the translation
  78249. * @param z defines the 3rd component of the translation
  78250. * @returns the current updated matrix
  78251. */
  78252. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78253. /**
  78254. * Adds the translation vector (using 3 floats) in the current matrix
  78255. * @param x defines the 1st component of the translation
  78256. * @param y defines the 2nd component of the translation
  78257. * @param z defines the 3rd component of the translation
  78258. * @returns the current updated matrix
  78259. */
  78260. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78261. /**
  78262. * Inserts the translation vector in the current matrix
  78263. * @param vector3 defines the translation to insert
  78264. * @returns the current updated matrix
  78265. */
  78266. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78267. /**
  78268. * Gets the translation value of the current matrix
  78269. * @returns a new Vector3 as the extracted translation from the matrix
  78270. */
  78271. getTranslation(): Vector3;
  78272. /**
  78273. * Fill a Vector3 with the extracted translation from the matrix
  78274. * @param result defines the Vector3 where to store the translation
  78275. * @returns the current matrix
  78276. */
  78277. getTranslationToRef(result: Vector3): Matrix;
  78278. /**
  78279. * Remove rotation and scaling part from the matrix
  78280. * @returns the updated matrix
  78281. */
  78282. removeRotationAndScaling(): Matrix;
  78283. /**
  78284. * Multiply two matrices
  78285. * @param other defines the second operand
  78286. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78287. */
  78288. multiply(other: DeepImmutable<Matrix>): Matrix;
  78289. /**
  78290. * Copy the current matrix from the given one
  78291. * @param other defines the source matrix
  78292. * @returns the current updated matrix
  78293. */
  78294. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78295. /**
  78296. * Populates the given array from the starting index with the current matrix values
  78297. * @param array defines the target array
  78298. * @param offset defines the offset in the target array where to start storing values
  78299. * @returns the current matrix
  78300. */
  78301. copyToArray(array: Float32Array, offset?: number): Matrix;
  78302. /**
  78303. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78304. * @param other defines the second operand
  78305. * @param result defines the matrix where to store the multiplication
  78306. * @returns the current matrix
  78307. */
  78308. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78309. /**
  78310. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78311. * @param other defines the second operand
  78312. * @param result defines the array where to store the multiplication
  78313. * @param offset defines the offset in the target array where to start storing values
  78314. * @returns the current matrix
  78315. */
  78316. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78317. /**
  78318. * Check equality between this matrix and a second one
  78319. * @param value defines the second matrix to compare
  78320. * @returns true is the current matrix and the given one values are strictly equal
  78321. */
  78322. equals(value: DeepImmutable<Matrix>): boolean;
  78323. /**
  78324. * Clone the current matrix
  78325. * @returns a new matrix from the current matrix
  78326. */
  78327. clone(): Matrix;
  78328. /**
  78329. * Returns the name of the current matrix class
  78330. * @returns the string "Matrix"
  78331. */
  78332. getClassName(): string;
  78333. /**
  78334. * Gets the hash code of the current matrix
  78335. * @returns the hash code
  78336. */
  78337. getHashCode(): number;
  78338. /**
  78339. * Decomposes the current Matrix into a translation, rotation and scaling components
  78340. * @param scale defines the scale vector3 given as a reference to update
  78341. * @param rotation defines the rotation quaternion given as a reference to update
  78342. * @param translation defines the translation vector3 given as a reference to update
  78343. * @returns true if operation was successful
  78344. */
  78345. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78346. /**
  78347. * Gets specific row of the matrix
  78348. * @param index defines the number of the row to get
  78349. * @returns the index-th row of the current matrix as a new Vector4
  78350. */
  78351. getRow(index: number): Nullable<Vector4>;
  78352. /**
  78353. * Sets the index-th row of the current matrix to the vector4 values
  78354. * @param index defines the number of the row to set
  78355. * @param row defines the target vector4
  78356. * @returns the updated current matrix
  78357. */
  78358. setRow(index: number, row: Vector4): Matrix;
  78359. /**
  78360. * Compute the transpose of the matrix
  78361. * @returns the new transposed matrix
  78362. */
  78363. transpose(): Matrix;
  78364. /**
  78365. * Compute the transpose of the matrix and store it in a given matrix
  78366. * @param result defines the target matrix
  78367. * @returns the current matrix
  78368. */
  78369. transposeToRef(result: Matrix): Matrix;
  78370. /**
  78371. * Sets the index-th row of the current matrix with the given 4 x float values
  78372. * @param index defines the row index
  78373. * @param x defines the x component to set
  78374. * @param y defines the y component to set
  78375. * @param z defines the z component to set
  78376. * @param w defines the w component to set
  78377. * @returns the updated current matrix
  78378. */
  78379. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78380. /**
  78381. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78382. * @param scale defines the scale factor
  78383. * @returns a new matrix
  78384. */
  78385. scale(scale: number): Matrix;
  78386. /**
  78387. * Scale the current matrix values by a factor to a given result matrix
  78388. * @param scale defines the scale factor
  78389. * @param result defines the matrix to store the result
  78390. * @returns the current matrix
  78391. */
  78392. scaleToRef(scale: number, result: Matrix): Matrix;
  78393. /**
  78394. * Scale the current matrix values by a factor and add the result to a given matrix
  78395. * @param scale defines the scale factor
  78396. * @param result defines the Matrix to store the result
  78397. * @returns the current matrix
  78398. */
  78399. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78400. /**
  78401. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78402. * @param ref matrix to store the result
  78403. */
  78404. toNormalMatrix(ref: Matrix): void;
  78405. /**
  78406. * Gets only rotation part of the current matrix
  78407. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78408. */
  78409. getRotationMatrix(): Matrix;
  78410. /**
  78411. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78412. * @param result defines the target matrix to store data to
  78413. * @returns the current matrix
  78414. */
  78415. getRotationMatrixToRef(result: Matrix): Matrix;
  78416. /**
  78417. * Toggles model matrix from being right handed to left handed in place and vice versa
  78418. */
  78419. toggleModelMatrixHandInPlace(): void;
  78420. /**
  78421. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78422. */
  78423. toggleProjectionMatrixHandInPlace(): void;
  78424. /**
  78425. * Creates a matrix from an array
  78426. * @param array defines the source array
  78427. * @param offset defines an offset in the source array
  78428. * @returns a new Matrix set from the starting index of the given array
  78429. */
  78430. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78431. /**
  78432. * Copy the content of an array into a given matrix
  78433. * @param array defines the source array
  78434. * @param offset defines an offset in the source array
  78435. * @param result defines the target matrix
  78436. */
  78437. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78438. /**
  78439. * Stores an array into a matrix after having multiplied each component by a given factor
  78440. * @param array defines the source array
  78441. * @param offset defines the offset in the source array
  78442. * @param scale defines the scaling factor
  78443. * @param result defines the target matrix
  78444. */
  78445. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78446. /**
  78447. * Gets an identity matrix that must not be updated
  78448. */
  78449. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78450. /**
  78451. * Stores a list of values (16) inside a given matrix
  78452. * @param initialM11 defines 1st value of 1st row
  78453. * @param initialM12 defines 2nd value of 1st row
  78454. * @param initialM13 defines 3rd value of 1st row
  78455. * @param initialM14 defines 4th value of 1st row
  78456. * @param initialM21 defines 1st value of 2nd row
  78457. * @param initialM22 defines 2nd value of 2nd row
  78458. * @param initialM23 defines 3rd value of 2nd row
  78459. * @param initialM24 defines 4th value of 2nd row
  78460. * @param initialM31 defines 1st value of 3rd row
  78461. * @param initialM32 defines 2nd value of 3rd row
  78462. * @param initialM33 defines 3rd value of 3rd row
  78463. * @param initialM34 defines 4th value of 3rd row
  78464. * @param initialM41 defines 1st value of 4th row
  78465. * @param initialM42 defines 2nd value of 4th row
  78466. * @param initialM43 defines 3rd value of 4th row
  78467. * @param initialM44 defines 4th value of 4th row
  78468. * @param result defines the target matrix
  78469. */
  78470. 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;
  78471. /**
  78472. * Creates new matrix from a list of values (16)
  78473. * @param initialM11 defines 1st value of 1st row
  78474. * @param initialM12 defines 2nd value of 1st row
  78475. * @param initialM13 defines 3rd value of 1st row
  78476. * @param initialM14 defines 4th value of 1st row
  78477. * @param initialM21 defines 1st value of 2nd row
  78478. * @param initialM22 defines 2nd value of 2nd row
  78479. * @param initialM23 defines 3rd value of 2nd row
  78480. * @param initialM24 defines 4th value of 2nd row
  78481. * @param initialM31 defines 1st value of 3rd row
  78482. * @param initialM32 defines 2nd value of 3rd row
  78483. * @param initialM33 defines 3rd value of 3rd row
  78484. * @param initialM34 defines 4th value of 3rd row
  78485. * @param initialM41 defines 1st value of 4th row
  78486. * @param initialM42 defines 2nd value of 4th row
  78487. * @param initialM43 defines 3rd value of 4th row
  78488. * @param initialM44 defines 4th value of 4th row
  78489. * @returns the new matrix
  78490. */
  78491. 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;
  78492. /**
  78493. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78494. * @param scale defines the scale vector3
  78495. * @param rotation defines the rotation quaternion
  78496. * @param translation defines the translation vector3
  78497. * @returns a new matrix
  78498. */
  78499. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78500. /**
  78501. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78502. * @param scale defines the scale vector3
  78503. * @param rotation defines the rotation quaternion
  78504. * @param translation defines the translation vector3
  78505. * @param result defines the target matrix
  78506. */
  78507. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78508. /**
  78509. * Creates a new identity matrix
  78510. * @returns a new identity matrix
  78511. */
  78512. static Identity(): Matrix;
  78513. /**
  78514. * Creates a new identity matrix and stores the result in a given matrix
  78515. * @param result defines the target matrix
  78516. */
  78517. static IdentityToRef(result: Matrix): void;
  78518. /**
  78519. * Creates a new zero matrix
  78520. * @returns a new zero matrix
  78521. */
  78522. static Zero(): Matrix;
  78523. /**
  78524. * Creates a new rotation matrix for "angle" radians around the X axis
  78525. * @param angle defines the angle (in radians) to use
  78526. * @return the new matrix
  78527. */
  78528. static RotationX(angle: number): Matrix;
  78529. /**
  78530. * Creates a new matrix as the invert of a given matrix
  78531. * @param source defines the source matrix
  78532. * @returns the new matrix
  78533. */
  78534. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78535. /**
  78536. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78537. * @param angle defines the angle (in radians) to use
  78538. * @param result defines the target matrix
  78539. */
  78540. static RotationXToRef(angle: number, result: Matrix): void;
  78541. /**
  78542. * Creates a new rotation matrix for "angle" radians around the Y axis
  78543. * @param angle defines the angle (in radians) to use
  78544. * @return the new matrix
  78545. */
  78546. static RotationY(angle: number): Matrix;
  78547. /**
  78548. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78549. * @param angle defines the angle (in radians) to use
  78550. * @param result defines the target matrix
  78551. */
  78552. static RotationYToRef(angle: number, result: Matrix): void;
  78553. /**
  78554. * Creates a new rotation matrix for "angle" radians around the Z axis
  78555. * @param angle defines the angle (in radians) to use
  78556. * @return the new matrix
  78557. */
  78558. static RotationZ(angle: number): Matrix;
  78559. /**
  78560. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78561. * @param angle defines the angle (in radians) to use
  78562. * @param result defines the target matrix
  78563. */
  78564. static RotationZToRef(angle: number, result: Matrix): void;
  78565. /**
  78566. * Creates a new rotation matrix for "angle" radians around the given axis
  78567. * @param axis defines the axis to use
  78568. * @param angle defines the angle (in radians) to use
  78569. * @return the new matrix
  78570. */
  78571. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78572. /**
  78573. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78574. * @param axis defines the axis to use
  78575. * @param angle defines the angle (in radians) to use
  78576. * @param result defines the target matrix
  78577. */
  78578. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78579. /**
  78580. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78581. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78582. * @param from defines the vector to align
  78583. * @param to defines the vector to align to
  78584. * @param result defines the target matrix
  78585. */
  78586. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78587. /**
  78588. * Creates a rotation matrix
  78589. * @param yaw defines the yaw angle in radians (Y axis)
  78590. * @param pitch defines the pitch angle in radians (X axis)
  78591. * @param roll defines the roll angle in radians (X axis)
  78592. * @returns the new rotation matrix
  78593. */
  78594. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78595. /**
  78596. * Creates a rotation matrix and stores it in a given matrix
  78597. * @param yaw defines the yaw angle in radians (Y axis)
  78598. * @param pitch defines the pitch angle in radians (X axis)
  78599. * @param roll defines the roll angle in radians (X axis)
  78600. * @param result defines the target matrix
  78601. */
  78602. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78603. /**
  78604. * Creates a scaling matrix
  78605. * @param x defines the scale factor on X axis
  78606. * @param y defines the scale factor on Y axis
  78607. * @param z defines the scale factor on Z axis
  78608. * @returns the new matrix
  78609. */
  78610. static Scaling(x: number, y: number, z: number): Matrix;
  78611. /**
  78612. * Creates a scaling matrix and stores it in a given matrix
  78613. * @param x defines the scale factor on X axis
  78614. * @param y defines the scale factor on Y axis
  78615. * @param z defines the scale factor on Z axis
  78616. * @param result defines the target matrix
  78617. */
  78618. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78619. /**
  78620. * Creates a translation matrix
  78621. * @param x defines the translation on X axis
  78622. * @param y defines the translation on Y axis
  78623. * @param z defines the translationon Z axis
  78624. * @returns the new matrix
  78625. */
  78626. static Translation(x: number, y: number, z: number): Matrix;
  78627. /**
  78628. * Creates a translation matrix and stores it in a given matrix
  78629. * @param x defines the translation on X axis
  78630. * @param y defines the translation on Y axis
  78631. * @param z defines the translationon Z axis
  78632. * @param result defines the target matrix
  78633. */
  78634. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78635. /**
  78636. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78637. * @param startValue defines the start value
  78638. * @param endValue defines the end value
  78639. * @param gradient defines the gradient factor
  78640. * @returns the new matrix
  78641. */
  78642. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78643. /**
  78644. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78645. * @param startValue defines the start value
  78646. * @param endValue defines the end value
  78647. * @param gradient defines the gradient factor
  78648. * @param result defines the Matrix object where to store data
  78649. */
  78650. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78651. /**
  78652. * Builds a new matrix whose values are computed by:
  78653. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78654. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78655. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78656. * @param startValue defines the first matrix
  78657. * @param endValue defines the second matrix
  78658. * @param gradient defines the gradient between the two matrices
  78659. * @returns the new matrix
  78660. */
  78661. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78662. /**
  78663. * Update a matrix to values which are computed by:
  78664. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78665. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78666. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78667. * @param startValue defines the first matrix
  78668. * @param endValue defines the second matrix
  78669. * @param gradient defines the gradient between the two matrices
  78670. * @param result defines the target matrix
  78671. */
  78672. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78673. /**
  78674. * 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"
  78675. * This function works in left handed mode
  78676. * @param eye defines the final position of the entity
  78677. * @param target defines where the entity should look at
  78678. * @param up defines the up vector for the entity
  78679. * @returns the new matrix
  78680. */
  78681. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78682. /**
  78683. * 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".
  78684. * This function works in left handed mode
  78685. * @param eye defines the final position of the entity
  78686. * @param target defines where the entity should look at
  78687. * @param up defines the up vector for the entity
  78688. * @param result defines the target matrix
  78689. */
  78690. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78691. /**
  78692. * 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"
  78693. * This function works in right handed mode
  78694. * @param eye defines the final position of the entity
  78695. * @param target defines where the entity should look at
  78696. * @param up defines the up vector for the entity
  78697. * @returns the new matrix
  78698. */
  78699. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78700. /**
  78701. * 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".
  78702. * This function works in right handed mode
  78703. * @param eye defines the final position of the entity
  78704. * @param target defines where the entity should look at
  78705. * @param up defines the up vector for the entity
  78706. * @param result defines the target matrix
  78707. */
  78708. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78709. /**
  78710. * Create a left-handed orthographic projection matrix
  78711. * @param width defines the viewport width
  78712. * @param height defines the viewport height
  78713. * @param znear defines the near clip plane
  78714. * @param zfar defines the far clip plane
  78715. * @returns a new matrix as a left-handed orthographic projection matrix
  78716. */
  78717. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78718. /**
  78719. * Store a left-handed orthographic projection to a given matrix
  78720. * @param width defines the viewport width
  78721. * @param height defines the viewport height
  78722. * @param znear defines the near clip plane
  78723. * @param zfar defines the far clip plane
  78724. * @param result defines the target matrix
  78725. */
  78726. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78727. /**
  78728. * Create a left-handed orthographic projection matrix
  78729. * @param left defines the viewport left coordinate
  78730. * @param right defines the viewport right coordinate
  78731. * @param bottom defines the viewport bottom coordinate
  78732. * @param top defines the viewport top coordinate
  78733. * @param znear defines the near clip plane
  78734. * @param zfar defines the far clip plane
  78735. * @returns a new matrix as a left-handed orthographic projection matrix
  78736. */
  78737. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78738. /**
  78739. * Stores a left-handed orthographic projection into a given matrix
  78740. * @param left defines the viewport left coordinate
  78741. * @param right defines the viewport right coordinate
  78742. * @param bottom defines the viewport bottom coordinate
  78743. * @param top defines the viewport top coordinate
  78744. * @param znear defines the near clip plane
  78745. * @param zfar defines the far clip plane
  78746. * @param result defines the target matrix
  78747. */
  78748. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78749. /**
  78750. * Creates a right-handed orthographic projection matrix
  78751. * @param left defines the viewport left coordinate
  78752. * @param right defines the viewport right coordinate
  78753. * @param bottom defines the viewport bottom coordinate
  78754. * @param top defines the viewport top coordinate
  78755. * @param znear defines the near clip plane
  78756. * @param zfar defines the far clip plane
  78757. * @returns a new matrix as a right-handed orthographic projection matrix
  78758. */
  78759. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78760. /**
  78761. * Stores a right-handed orthographic projection into a given matrix
  78762. * @param left defines the viewport left coordinate
  78763. * @param right defines the viewport right coordinate
  78764. * @param bottom defines the viewport bottom coordinate
  78765. * @param top defines the viewport top coordinate
  78766. * @param znear defines the near clip plane
  78767. * @param zfar defines the far clip plane
  78768. * @param result defines the target matrix
  78769. */
  78770. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78771. /**
  78772. * Creates a left-handed perspective projection matrix
  78773. * @param width defines the viewport width
  78774. * @param height defines the viewport height
  78775. * @param znear defines the near clip plane
  78776. * @param zfar defines the far clip plane
  78777. * @returns a new matrix as a left-handed perspective projection matrix
  78778. */
  78779. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78780. /**
  78781. * Creates a left-handed perspective projection matrix
  78782. * @param fov defines the horizontal field of view
  78783. * @param aspect defines the aspect ratio
  78784. * @param znear defines the near clip plane
  78785. * @param zfar defines the far clip plane
  78786. * @returns a new matrix as a left-handed perspective projection matrix
  78787. */
  78788. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78789. /**
  78790. * Stores a left-handed perspective projection into a given matrix
  78791. * @param fov defines the horizontal field of view
  78792. * @param aspect defines the aspect ratio
  78793. * @param znear defines the near clip plane
  78794. * @param zfar defines the far clip plane
  78795. * @param result defines the target matrix
  78796. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78797. */
  78798. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78799. /**
  78800. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78801. * @param fov defines the horizontal field of view
  78802. * @param aspect defines the aspect ratio
  78803. * @param znear defines the near clip plane
  78804. * @param zfar not used as infinity is used as far clip
  78805. * @param result defines the target matrix
  78806. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78807. */
  78808. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78809. /**
  78810. * Creates a right-handed perspective projection matrix
  78811. * @param fov defines the horizontal field of view
  78812. * @param aspect defines the aspect ratio
  78813. * @param znear defines the near clip plane
  78814. * @param zfar defines the far clip plane
  78815. * @returns a new matrix as a right-handed perspective projection matrix
  78816. */
  78817. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78818. /**
  78819. * Stores a right-handed perspective projection into a given matrix
  78820. * @param fov defines the horizontal field of view
  78821. * @param aspect defines the aspect ratio
  78822. * @param znear defines the near clip plane
  78823. * @param zfar defines the far clip plane
  78824. * @param result defines the target matrix
  78825. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78826. */
  78827. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78828. /**
  78829. * Stores a right-handed perspective projection into a given matrix
  78830. * @param fov defines the horizontal field of view
  78831. * @param aspect defines the aspect ratio
  78832. * @param znear defines the near clip plane
  78833. * @param zfar not used as infinity is used as far clip
  78834. * @param result defines the target matrix
  78835. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78836. */
  78837. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78838. /**
  78839. * Stores a perspective projection for WebVR info a given matrix
  78840. * @param fov defines the field of view
  78841. * @param znear defines the near clip plane
  78842. * @param zfar defines the far clip plane
  78843. * @param result defines the target matrix
  78844. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78845. */
  78846. static PerspectiveFovWebVRToRef(fov: {
  78847. upDegrees: number;
  78848. downDegrees: number;
  78849. leftDegrees: number;
  78850. rightDegrees: number;
  78851. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78852. /**
  78853. * Computes a complete transformation matrix
  78854. * @param viewport defines the viewport to use
  78855. * @param world defines the world matrix
  78856. * @param view defines the view matrix
  78857. * @param projection defines the projection matrix
  78858. * @param zmin defines the near clip plane
  78859. * @param zmax defines the far clip plane
  78860. * @returns the transformation matrix
  78861. */
  78862. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78863. /**
  78864. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78865. * @param matrix defines the matrix to use
  78866. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78867. */
  78868. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78869. /**
  78870. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78871. * @param matrix defines the matrix to use
  78872. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78873. */
  78874. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78875. /**
  78876. * Compute the transpose of a given matrix
  78877. * @param matrix defines the matrix to transpose
  78878. * @returns the new matrix
  78879. */
  78880. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78881. /**
  78882. * Compute the transpose of a matrix and store it in a target matrix
  78883. * @param matrix defines the matrix to transpose
  78884. * @param result defines the target matrix
  78885. */
  78886. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78887. /**
  78888. * Computes a reflection matrix from a plane
  78889. * @param plane defines the reflection plane
  78890. * @returns a new matrix
  78891. */
  78892. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78893. /**
  78894. * Computes a reflection matrix from a plane
  78895. * @param plane defines the reflection plane
  78896. * @param result defines the target matrix
  78897. */
  78898. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78899. /**
  78900. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78901. * @param xaxis defines the value of the 1st axis
  78902. * @param yaxis defines the value of the 2nd axis
  78903. * @param zaxis defines the value of the 3rd axis
  78904. * @param result defines the target matrix
  78905. */
  78906. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78907. /**
  78908. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78909. * @param quat defines the quaternion to use
  78910. * @param result defines the target matrix
  78911. */
  78912. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78913. }
  78914. /**
  78915. * @hidden
  78916. */
  78917. export class TmpVectors {
  78918. static Vector2: Vector2[];
  78919. static Vector3: Vector3[];
  78920. static Vector4: Vector4[];
  78921. static Quaternion: Quaternion[];
  78922. static Matrix: Matrix[];
  78923. }
  78924. }
  78925. declare module BABYLON {
  78926. /**
  78927. * Defines potential orientation for back face culling
  78928. */
  78929. export enum Orientation {
  78930. /**
  78931. * Clockwise
  78932. */
  78933. CW = 0,
  78934. /** Counter clockwise */
  78935. CCW = 1
  78936. }
  78937. /** Class used to represent a Bezier curve */
  78938. export class BezierCurve {
  78939. /**
  78940. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78941. * @param t defines the time
  78942. * @param x1 defines the left coordinate on X axis
  78943. * @param y1 defines the left coordinate on Y axis
  78944. * @param x2 defines the right coordinate on X axis
  78945. * @param y2 defines the right coordinate on Y axis
  78946. * @returns the interpolated value
  78947. */
  78948. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78949. }
  78950. /**
  78951. * Defines angle representation
  78952. */
  78953. export class Angle {
  78954. private _radians;
  78955. /**
  78956. * Creates an Angle object of "radians" radians (float).
  78957. * @param radians the angle in radians
  78958. */
  78959. constructor(radians: number);
  78960. /**
  78961. * Get value in degrees
  78962. * @returns the Angle value in degrees (float)
  78963. */
  78964. degrees(): number;
  78965. /**
  78966. * Get value in radians
  78967. * @returns the Angle value in radians (float)
  78968. */
  78969. radians(): number;
  78970. /**
  78971. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78972. * @param a defines first vector
  78973. * @param b defines second vector
  78974. * @returns a new Angle
  78975. */
  78976. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78977. /**
  78978. * Gets a new Angle object from the given float in radians
  78979. * @param radians defines the angle value in radians
  78980. * @returns a new Angle
  78981. */
  78982. static FromRadians(radians: number): Angle;
  78983. /**
  78984. * Gets a new Angle object from the given float in degrees
  78985. * @param degrees defines the angle value in degrees
  78986. * @returns a new Angle
  78987. */
  78988. static FromDegrees(degrees: number): Angle;
  78989. }
  78990. /**
  78991. * This represents an arc in a 2d space.
  78992. */
  78993. export class Arc2 {
  78994. /** Defines the start point of the arc */
  78995. startPoint: Vector2;
  78996. /** Defines the mid point of the arc */
  78997. midPoint: Vector2;
  78998. /** Defines the end point of the arc */
  78999. endPoint: Vector2;
  79000. /**
  79001. * Defines the center point of the arc.
  79002. */
  79003. centerPoint: Vector2;
  79004. /**
  79005. * Defines the radius of the arc.
  79006. */
  79007. radius: number;
  79008. /**
  79009. * Defines the angle of the arc (from mid point to end point).
  79010. */
  79011. angle: Angle;
  79012. /**
  79013. * Defines the start angle of the arc (from start point to middle point).
  79014. */
  79015. startAngle: Angle;
  79016. /**
  79017. * Defines the orientation of the arc (clock wise/counter clock wise).
  79018. */
  79019. orientation: Orientation;
  79020. /**
  79021. * Creates an Arc object from the three given points : start, middle and end.
  79022. * @param startPoint Defines the start point of the arc
  79023. * @param midPoint Defines the midlle point of the arc
  79024. * @param endPoint Defines the end point of the arc
  79025. */
  79026. constructor(
  79027. /** Defines the start point of the arc */
  79028. startPoint: Vector2,
  79029. /** Defines the mid point of the arc */
  79030. midPoint: Vector2,
  79031. /** Defines the end point of the arc */
  79032. endPoint: Vector2);
  79033. }
  79034. /**
  79035. * Represents a 2D path made up of multiple 2D points
  79036. */
  79037. export class Path2 {
  79038. private _points;
  79039. private _length;
  79040. /**
  79041. * If the path start and end point are the same
  79042. */
  79043. closed: boolean;
  79044. /**
  79045. * Creates a Path2 object from the starting 2D coordinates x and y.
  79046. * @param x the starting points x value
  79047. * @param y the starting points y value
  79048. */
  79049. constructor(x: number, y: number);
  79050. /**
  79051. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79052. * @param x the added points x value
  79053. * @param y the added points y value
  79054. * @returns the updated Path2.
  79055. */
  79056. addLineTo(x: number, y: number): Path2;
  79057. /**
  79058. * 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.
  79059. * @param midX middle point x value
  79060. * @param midY middle point y value
  79061. * @param endX end point x value
  79062. * @param endY end point y value
  79063. * @param numberOfSegments (default: 36)
  79064. * @returns the updated Path2.
  79065. */
  79066. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79067. /**
  79068. * Closes the Path2.
  79069. * @returns the Path2.
  79070. */
  79071. close(): Path2;
  79072. /**
  79073. * Gets the sum of the distance between each sequential point in the path
  79074. * @returns the Path2 total length (float).
  79075. */
  79076. length(): number;
  79077. /**
  79078. * Gets the points which construct the path
  79079. * @returns the Path2 internal array of points.
  79080. */
  79081. getPoints(): Vector2[];
  79082. /**
  79083. * Retreives the point at the distance aways from the starting point
  79084. * @param normalizedLengthPosition the length along the path to retreive the point from
  79085. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79086. */
  79087. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79088. /**
  79089. * Creates a new path starting from an x and y position
  79090. * @param x starting x value
  79091. * @param y starting y value
  79092. * @returns a new Path2 starting at the coordinates (x, y).
  79093. */
  79094. static StartingAt(x: number, y: number): Path2;
  79095. }
  79096. /**
  79097. * Represents a 3D path made up of multiple 3D points
  79098. */
  79099. export class Path3D {
  79100. /**
  79101. * an array of Vector3, the curve axis of the Path3D
  79102. */
  79103. path: Vector3[];
  79104. private _curve;
  79105. private _distances;
  79106. private _tangents;
  79107. private _normals;
  79108. private _binormals;
  79109. private _raw;
  79110. private _alignTangentsWithPath;
  79111. private readonly _pointAtData;
  79112. /**
  79113. * new Path3D(path, normal, raw)
  79114. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79115. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79116. * @param path an array of Vector3, the curve axis of the Path3D
  79117. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79118. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79119. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79120. */
  79121. constructor(
  79122. /**
  79123. * an array of Vector3, the curve axis of the Path3D
  79124. */
  79125. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79126. /**
  79127. * Returns the Path3D array of successive Vector3 designing its curve.
  79128. * @returns the Path3D array of successive Vector3 designing its curve.
  79129. */
  79130. getCurve(): Vector3[];
  79131. /**
  79132. * Returns the Path3D array of successive Vector3 designing its curve.
  79133. * @returns the Path3D array of successive Vector3 designing its curve.
  79134. */
  79135. getPoints(): Vector3[];
  79136. /**
  79137. * @returns the computed length (float) of the path.
  79138. */
  79139. length(): number;
  79140. /**
  79141. * Returns an array populated with tangent vectors on each Path3D curve point.
  79142. * @returns an array populated with tangent vectors on each Path3D curve point.
  79143. */
  79144. getTangents(): Vector3[];
  79145. /**
  79146. * Returns an array populated with normal vectors on each Path3D curve point.
  79147. * @returns an array populated with normal vectors on each Path3D curve point.
  79148. */
  79149. getNormals(): Vector3[];
  79150. /**
  79151. * Returns an array populated with binormal vectors on each Path3D curve point.
  79152. * @returns an array populated with binormal vectors on each Path3D curve point.
  79153. */
  79154. getBinormals(): Vector3[];
  79155. /**
  79156. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79157. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79158. */
  79159. getDistances(): number[];
  79160. /**
  79161. * Returns an interpolated point along this path
  79162. * @param position the position of the point along this path, from 0.0 to 1.0
  79163. * @returns a new Vector3 as the point
  79164. */
  79165. getPointAt(position: number): Vector3;
  79166. /**
  79167. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79168. * @param position the position of the point along this path, from 0.0 to 1.0
  79169. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79170. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79171. */
  79172. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79173. /**
  79174. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79175. * @param position the position of the point along this path, from 0.0 to 1.0
  79176. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79177. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79178. */
  79179. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79180. /**
  79181. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79182. * @param position the position of the point along this path, from 0.0 to 1.0
  79183. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79184. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79185. */
  79186. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79187. /**
  79188. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  79189. * @param position the position of the point along this path, from 0.0 to 1.0
  79190. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79191. */
  79192. getDistanceAt(position: number): number;
  79193. /**
  79194. * Returns the array index of the previous point of an interpolated point along this path
  79195. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79196. * @returns the array index
  79197. */
  79198. getPreviousPointIndexAt(position: number): number;
  79199. /**
  79200. * 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)
  79201. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79202. * @returns the sub position
  79203. */
  79204. getSubPositionAt(position: number): number;
  79205. /**
  79206. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79207. * @param target the vector of which to get the closest position to
  79208. * @returns the position of the closest virtual point on this path to the target vector
  79209. */
  79210. getClosestPositionTo(target: Vector3): number;
  79211. /**
  79212. * Returns a sub path (slice) of this path
  79213. * @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
  79214. * @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
  79215. * @returns a sub path (slice) of this path
  79216. */
  79217. slice(start?: number, end?: number): Path3D;
  79218. /**
  79219. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79220. * @param path path which all values are copied into the curves points
  79221. * @param firstNormal which should be projected onto the curve
  79222. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79223. * @returns the same object updated.
  79224. */
  79225. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79226. private _compute;
  79227. private _getFirstNonNullVector;
  79228. private _getLastNonNullVector;
  79229. private _normalVector;
  79230. /**
  79231. * Updates the point at data for an interpolated point along this curve
  79232. * @param position the position of the point along this curve, from 0.0 to 1.0
  79233. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79234. * @returns the (updated) point at data
  79235. */
  79236. private _updatePointAtData;
  79237. /**
  79238. * Updates the point at data from the specified parameters
  79239. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79240. * @param point the interpolated point
  79241. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79242. */
  79243. private _setPointAtData;
  79244. /**
  79245. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79246. */
  79247. private _updateInterpolationMatrix;
  79248. }
  79249. /**
  79250. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79251. * A Curve3 is designed from a series of successive Vector3.
  79252. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79253. */
  79254. export class Curve3 {
  79255. private _points;
  79256. private _length;
  79257. /**
  79258. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79259. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79260. * @param v1 (Vector3) the control point
  79261. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79262. * @param nbPoints (integer) the wanted number of points in the curve
  79263. * @returns the created Curve3
  79264. */
  79265. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79266. /**
  79267. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79268. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79269. * @param v1 (Vector3) the first control point
  79270. * @param v2 (Vector3) the second control point
  79271. * @param v3 (Vector3) the end point of the Cubic Bezier
  79272. * @param nbPoints (integer) the wanted number of points in the curve
  79273. * @returns the created Curve3
  79274. */
  79275. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79276. /**
  79277. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79278. * @param p1 (Vector3) the origin point of the Hermite Spline
  79279. * @param t1 (Vector3) the tangent vector at the origin point
  79280. * @param p2 (Vector3) the end point of the Hermite Spline
  79281. * @param t2 (Vector3) the tangent vector at the end point
  79282. * @param nbPoints (integer) the wanted number of points in the curve
  79283. * @returns the created Curve3
  79284. */
  79285. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79286. /**
  79287. * Returns a Curve3 object along a CatmullRom Spline curve :
  79288. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79289. * @param nbPoints (integer) the wanted number of points between each curve control points
  79290. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79291. * @returns the created Curve3
  79292. */
  79293. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79294. /**
  79295. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79296. * A Curve3 is designed from a series of successive Vector3.
  79297. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79298. * @param points points which make up the curve
  79299. */
  79300. constructor(points: Vector3[]);
  79301. /**
  79302. * @returns the Curve3 stored array of successive Vector3
  79303. */
  79304. getPoints(): Vector3[];
  79305. /**
  79306. * @returns the computed length (float) of the curve.
  79307. */
  79308. length(): number;
  79309. /**
  79310. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79311. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79312. * curveA and curveB keep unchanged.
  79313. * @param curve the curve to continue from this curve
  79314. * @returns the newly constructed curve
  79315. */
  79316. continue(curve: DeepImmutable<Curve3>): Curve3;
  79317. private _computeLength;
  79318. }
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * This represents the main contract an easing function should follow.
  79323. * Easing functions are used throughout the animation system.
  79324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79325. */
  79326. export interface IEasingFunction {
  79327. /**
  79328. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79329. * of the easing function.
  79330. * The link below provides some of the most common examples of easing functions.
  79331. * @see https://easings.net/
  79332. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79333. * @returns the corresponding value on the curve defined by the easing function
  79334. */
  79335. ease(gradient: number): number;
  79336. }
  79337. /**
  79338. * Base class used for every default easing function.
  79339. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79340. */
  79341. export class EasingFunction implements IEasingFunction {
  79342. /**
  79343. * Interpolation follows the mathematical formula associated with the easing function.
  79344. */
  79345. static readonly EASINGMODE_EASEIN: number;
  79346. /**
  79347. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79348. */
  79349. static readonly EASINGMODE_EASEOUT: number;
  79350. /**
  79351. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79352. */
  79353. static readonly EASINGMODE_EASEINOUT: number;
  79354. private _easingMode;
  79355. /**
  79356. * Sets the easing mode of the current function.
  79357. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79358. */
  79359. setEasingMode(easingMode: number): void;
  79360. /**
  79361. * Gets the current easing mode.
  79362. * @returns the easing mode
  79363. */
  79364. getEasingMode(): number;
  79365. /**
  79366. * @hidden
  79367. */
  79368. easeInCore(gradient: number): number;
  79369. /**
  79370. * Given an input gradient between 0 and 1, this returns the corresponding value
  79371. * of the easing function.
  79372. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79373. * @returns the corresponding value on the curve defined by the easing function
  79374. */
  79375. ease(gradient: number): number;
  79376. }
  79377. /**
  79378. * Easing function with a circle shape (see link below).
  79379. * @see https://easings.net/#easeInCirc
  79380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79381. */
  79382. export class CircleEase extends EasingFunction implements IEasingFunction {
  79383. /** @hidden */
  79384. easeInCore(gradient: number): number;
  79385. }
  79386. /**
  79387. * Easing function with a ease back shape (see link below).
  79388. * @see https://easings.net/#easeInBack
  79389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79390. */
  79391. export class BackEase extends EasingFunction implements IEasingFunction {
  79392. /** Defines the amplitude of the function */
  79393. amplitude: number;
  79394. /**
  79395. * Instantiates a back ease easing
  79396. * @see https://easings.net/#easeInBack
  79397. * @param amplitude Defines the amplitude of the function
  79398. */
  79399. constructor(
  79400. /** Defines the amplitude of the function */
  79401. amplitude?: number);
  79402. /** @hidden */
  79403. easeInCore(gradient: number): number;
  79404. }
  79405. /**
  79406. * Easing function with a bouncing shape (see link below).
  79407. * @see https://easings.net/#easeInBounce
  79408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79409. */
  79410. export class BounceEase extends EasingFunction implements IEasingFunction {
  79411. /** Defines the number of bounces */
  79412. bounces: number;
  79413. /** Defines the amplitude of the bounce */
  79414. bounciness: number;
  79415. /**
  79416. * Instantiates a bounce easing
  79417. * @see https://easings.net/#easeInBounce
  79418. * @param bounces Defines the number of bounces
  79419. * @param bounciness Defines the amplitude of the bounce
  79420. */
  79421. constructor(
  79422. /** Defines the number of bounces */
  79423. bounces?: number,
  79424. /** Defines the amplitude of the bounce */
  79425. bounciness?: number);
  79426. /** @hidden */
  79427. easeInCore(gradient: number): number;
  79428. }
  79429. /**
  79430. * Easing function with a power of 3 shape (see link below).
  79431. * @see https://easings.net/#easeInCubic
  79432. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79433. */
  79434. export class CubicEase extends EasingFunction implements IEasingFunction {
  79435. /** @hidden */
  79436. easeInCore(gradient: number): number;
  79437. }
  79438. /**
  79439. * Easing function with an elastic shape (see link below).
  79440. * @see https://easings.net/#easeInElastic
  79441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79442. */
  79443. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79444. /** Defines the number of oscillations*/
  79445. oscillations: number;
  79446. /** Defines the amplitude of the oscillations*/
  79447. springiness: number;
  79448. /**
  79449. * Instantiates an elastic easing function
  79450. * @see https://easings.net/#easeInElastic
  79451. * @param oscillations Defines the number of oscillations
  79452. * @param springiness Defines the amplitude of the oscillations
  79453. */
  79454. constructor(
  79455. /** Defines the number of oscillations*/
  79456. oscillations?: number,
  79457. /** Defines the amplitude of the oscillations*/
  79458. springiness?: number);
  79459. /** @hidden */
  79460. easeInCore(gradient: number): number;
  79461. }
  79462. /**
  79463. * Easing function with an exponential shape (see link below).
  79464. * @see https://easings.net/#easeInExpo
  79465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79466. */
  79467. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79468. /** Defines the exponent of the function */
  79469. exponent: number;
  79470. /**
  79471. * Instantiates an exponential easing function
  79472. * @see https://easings.net/#easeInExpo
  79473. * @param exponent Defines the exponent of the function
  79474. */
  79475. constructor(
  79476. /** Defines the exponent of the function */
  79477. exponent?: number);
  79478. /** @hidden */
  79479. easeInCore(gradient: number): number;
  79480. }
  79481. /**
  79482. * Easing function with a power shape (see link below).
  79483. * @see https://easings.net/#easeInQuad
  79484. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79485. */
  79486. export class PowerEase extends EasingFunction implements IEasingFunction {
  79487. /** Defines the power of the function */
  79488. power: number;
  79489. /**
  79490. * Instantiates an power base easing function
  79491. * @see https://easings.net/#easeInQuad
  79492. * @param power Defines the power of the function
  79493. */
  79494. constructor(
  79495. /** Defines the power of the function */
  79496. power?: number);
  79497. /** @hidden */
  79498. easeInCore(gradient: number): number;
  79499. }
  79500. /**
  79501. * Easing function with a power of 2 shape (see link below).
  79502. * @see https://easings.net/#easeInQuad
  79503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79504. */
  79505. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79506. /** @hidden */
  79507. easeInCore(gradient: number): number;
  79508. }
  79509. /**
  79510. * Easing function with a power of 4 shape (see link below).
  79511. * @see https://easings.net/#easeInQuart
  79512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79513. */
  79514. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79515. /** @hidden */
  79516. easeInCore(gradient: number): number;
  79517. }
  79518. /**
  79519. * Easing function with a power of 5 shape (see link below).
  79520. * @see https://easings.net/#easeInQuint
  79521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79522. */
  79523. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79524. /** @hidden */
  79525. easeInCore(gradient: number): number;
  79526. }
  79527. /**
  79528. * Easing function with a sin shape (see link below).
  79529. * @see https://easings.net/#easeInSine
  79530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79531. */
  79532. export class SineEase extends EasingFunction implements IEasingFunction {
  79533. /** @hidden */
  79534. easeInCore(gradient: number): number;
  79535. }
  79536. /**
  79537. * Easing function with a bezier shape (see link below).
  79538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79540. */
  79541. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79542. /** Defines the x component of the start tangent in the bezier curve */
  79543. x1: number;
  79544. /** Defines the y component of the start tangent in the bezier curve */
  79545. y1: number;
  79546. /** Defines the x component of the end tangent in the bezier curve */
  79547. x2: number;
  79548. /** Defines the y component of the end tangent in the bezier curve */
  79549. y2: number;
  79550. /**
  79551. * Instantiates a bezier function
  79552. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79553. * @param x1 Defines the x component of the start tangent in the bezier curve
  79554. * @param y1 Defines the y component of the start tangent in the bezier curve
  79555. * @param x2 Defines the x component of the end tangent in the bezier curve
  79556. * @param y2 Defines the y component of the end tangent in the bezier curve
  79557. */
  79558. constructor(
  79559. /** Defines the x component of the start tangent in the bezier curve */
  79560. x1?: number,
  79561. /** Defines the y component of the start tangent in the bezier curve */
  79562. y1?: number,
  79563. /** Defines the x component of the end tangent in the bezier curve */
  79564. x2?: number,
  79565. /** Defines the y component of the end tangent in the bezier curve */
  79566. y2?: number);
  79567. /** @hidden */
  79568. easeInCore(gradient: number): number;
  79569. }
  79570. }
  79571. declare module BABYLON {
  79572. /**
  79573. * Class used to hold a RBG color
  79574. */
  79575. export class Color3 {
  79576. /**
  79577. * Defines the red component (between 0 and 1, default is 0)
  79578. */
  79579. r: number;
  79580. /**
  79581. * Defines the green component (between 0 and 1, default is 0)
  79582. */
  79583. g: number;
  79584. /**
  79585. * Defines the blue component (between 0 and 1, default is 0)
  79586. */
  79587. b: number;
  79588. /**
  79589. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79590. * @param r defines the red component (between 0 and 1, default is 0)
  79591. * @param g defines the green component (between 0 and 1, default is 0)
  79592. * @param b defines the blue component (between 0 and 1, default is 0)
  79593. */
  79594. constructor(
  79595. /**
  79596. * Defines the red component (between 0 and 1, default is 0)
  79597. */
  79598. r?: number,
  79599. /**
  79600. * Defines the green component (between 0 and 1, default is 0)
  79601. */
  79602. g?: number,
  79603. /**
  79604. * Defines the blue component (between 0 and 1, default is 0)
  79605. */
  79606. b?: number);
  79607. /**
  79608. * Creates a string with the Color3 current values
  79609. * @returns the string representation of the Color3 object
  79610. */
  79611. toString(): string;
  79612. /**
  79613. * Returns the string "Color3"
  79614. * @returns "Color3"
  79615. */
  79616. getClassName(): string;
  79617. /**
  79618. * Compute the Color3 hash code
  79619. * @returns an unique number that can be used to hash Color3 objects
  79620. */
  79621. getHashCode(): number;
  79622. /**
  79623. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79624. * @param array defines the array where to store the r,g,b components
  79625. * @param index defines an optional index in the target array to define where to start storing values
  79626. * @returns the current Color3 object
  79627. */
  79628. toArray(array: FloatArray, index?: number): Color3;
  79629. /**
  79630. * Returns a new Color4 object from the current Color3 and the given alpha
  79631. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79632. * @returns a new Color4 object
  79633. */
  79634. toColor4(alpha?: number): Color4;
  79635. /**
  79636. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79637. * @returns the new array
  79638. */
  79639. asArray(): number[];
  79640. /**
  79641. * Returns the luminance value
  79642. * @returns a float value
  79643. */
  79644. toLuminance(): number;
  79645. /**
  79646. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79647. * @param otherColor defines the second operand
  79648. * @returns the new Color3 object
  79649. */
  79650. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79651. /**
  79652. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79653. * @param otherColor defines the second operand
  79654. * @param result defines the Color3 object where to store the result
  79655. * @returns the current Color3
  79656. */
  79657. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79658. /**
  79659. * Determines equality between Color3 objects
  79660. * @param otherColor defines the second operand
  79661. * @returns true if the rgb values are equal to the given ones
  79662. */
  79663. equals(otherColor: DeepImmutable<Color3>): boolean;
  79664. /**
  79665. * Determines equality between the current Color3 object and a set of r,b,g values
  79666. * @param r defines the red component to check
  79667. * @param g defines the green component to check
  79668. * @param b defines the blue component to check
  79669. * @returns true if the rgb values are equal to the given ones
  79670. */
  79671. equalsFloats(r: number, g: number, b: number): boolean;
  79672. /**
  79673. * Multiplies in place each rgb value by scale
  79674. * @param scale defines the scaling factor
  79675. * @returns the updated Color3
  79676. */
  79677. scale(scale: number): Color3;
  79678. /**
  79679. * Multiplies the rgb values by scale and stores the result into "result"
  79680. * @param scale defines the scaling factor
  79681. * @param result defines the Color3 object where to store the result
  79682. * @returns the unmodified current Color3
  79683. */
  79684. scaleToRef(scale: number, result: Color3): Color3;
  79685. /**
  79686. * Scale the current Color3 values by a factor and add the result to a given Color3
  79687. * @param scale defines the scale factor
  79688. * @param result defines color to store the result into
  79689. * @returns the unmodified current Color3
  79690. */
  79691. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79692. /**
  79693. * Clamps the rgb values by the min and max values and stores the result into "result"
  79694. * @param min defines minimum clamping value (default is 0)
  79695. * @param max defines maximum clamping value (default is 1)
  79696. * @param result defines color to store the result into
  79697. * @returns the original Color3
  79698. */
  79699. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79700. /**
  79701. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79702. * @param otherColor defines the second operand
  79703. * @returns the new Color3
  79704. */
  79705. add(otherColor: DeepImmutable<Color3>): Color3;
  79706. /**
  79707. * Stores the result of the addition of the current Color3 and given one 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. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79713. /**
  79714. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79715. * @param otherColor defines the second operand
  79716. * @returns the new Color3
  79717. */
  79718. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79719. /**
  79720. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79721. * @param otherColor defines the second operand
  79722. * @param result defines Color3 object to store the result into
  79723. * @returns the unmodified current Color3
  79724. */
  79725. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79726. /**
  79727. * Copy the current object
  79728. * @returns a new Color3 copied the current one
  79729. */
  79730. clone(): Color3;
  79731. /**
  79732. * Copies the rgb values from the source in the current Color3
  79733. * @param source defines the source Color3 object
  79734. * @returns the updated Color3 object
  79735. */
  79736. copyFrom(source: DeepImmutable<Color3>): Color3;
  79737. /**
  79738. * Updates the Color3 rgb values from the given floats
  79739. * @param r defines the red component to read from
  79740. * @param g defines the green component to read from
  79741. * @param b defines the blue component to read from
  79742. * @returns the current Color3 object
  79743. */
  79744. copyFromFloats(r: number, g: number, b: number): Color3;
  79745. /**
  79746. * Updates the Color3 rgb values from the given floats
  79747. * @param r defines the red component to read from
  79748. * @param g defines the green component to read from
  79749. * @param b defines the blue component to read from
  79750. * @returns the current Color3 object
  79751. */
  79752. set(r: number, g: number, b: number): Color3;
  79753. /**
  79754. * Compute the Color3 hexadecimal code as a string
  79755. * @returns a string containing the hexadecimal representation of the Color3 object
  79756. */
  79757. toHexString(): string;
  79758. /**
  79759. * Computes a new Color3 converted from the current one to linear space
  79760. * @returns a new Color3 object
  79761. */
  79762. toLinearSpace(): Color3;
  79763. /**
  79764. * Converts current color in rgb space to HSV values
  79765. * @returns a new color3 representing the HSV values
  79766. */
  79767. toHSV(): Color3;
  79768. /**
  79769. * Converts current color in rgb space to HSV values
  79770. * @param result defines the Color3 where to store the HSV values
  79771. */
  79772. toHSVToRef(result: Color3): void;
  79773. /**
  79774. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79775. * @param convertedColor defines the Color3 object where to store the linear space version
  79776. * @returns the unmodified Color3
  79777. */
  79778. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79779. /**
  79780. * Computes a new Color3 converted from the current one to gamma space
  79781. * @returns a new Color3 object
  79782. */
  79783. toGammaSpace(): Color3;
  79784. /**
  79785. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79786. * @param convertedColor defines the Color3 object where to store the gamma space version
  79787. * @returns the unmodified Color3
  79788. */
  79789. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79790. private static _BlackReadOnly;
  79791. /**
  79792. * Convert Hue, saturation and value to a Color3 (RGB)
  79793. * @param hue defines the hue
  79794. * @param saturation defines the saturation
  79795. * @param value defines the value
  79796. * @param result defines the Color3 where to store the RGB values
  79797. */
  79798. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79799. /**
  79800. * Creates a new Color3 from the string containing valid hexadecimal values
  79801. * @param hex defines a string containing valid hexadecimal values
  79802. * @returns a new Color3 object
  79803. */
  79804. static FromHexString(hex: string): Color3;
  79805. /**
  79806. * Creates a new Color3 from the starting index of the given array
  79807. * @param array defines the source array
  79808. * @param offset defines an offset in the source array
  79809. * @returns a new Color3 object
  79810. */
  79811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79812. /**
  79813. * Creates a new Color3 from integer values (< 256)
  79814. * @param r defines the red component to read from (value between 0 and 255)
  79815. * @param g defines the green component to read from (value between 0 and 255)
  79816. * @param b defines the blue component to read from (value between 0 and 255)
  79817. * @returns a new Color3 object
  79818. */
  79819. static FromInts(r: number, g: number, b: number): Color3;
  79820. /**
  79821. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79822. * @param start defines the start Color3 value
  79823. * @param end defines the end Color3 value
  79824. * @param amount defines the gradient value between start and end
  79825. * @returns a new Color3 object
  79826. */
  79827. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79828. /**
  79829. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79830. * @param left defines the start value
  79831. * @param right defines the end value
  79832. * @param amount defines the gradient factor
  79833. * @param result defines the Color3 object where to store the result
  79834. */
  79835. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79836. /**
  79837. * Returns a Color3 value containing a red color
  79838. * @returns a new Color3 object
  79839. */
  79840. static Red(): Color3;
  79841. /**
  79842. * Returns a Color3 value containing a green color
  79843. * @returns a new Color3 object
  79844. */
  79845. static Green(): Color3;
  79846. /**
  79847. * Returns a Color3 value containing a blue color
  79848. * @returns a new Color3 object
  79849. */
  79850. static Blue(): Color3;
  79851. /**
  79852. * Returns a Color3 value containing a black color
  79853. * @returns a new Color3 object
  79854. */
  79855. static Black(): Color3;
  79856. /**
  79857. * Gets a Color3 value containing a black color that must not be updated
  79858. */
  79859. static get BlackReadOnly(): DeepImmutable<Color3>;
  79860. /**
  79861. * Returns a Color3 value containing a white color
  79862. * @returns a new Color3 object
  79863. */
  79864. static White(): Color3;
  79865. /**
  79866. * Returns a Color3 value containing a purple color
  79867. * @returns a new Color3 object
  79868. */
  79869. static Purple(): Color3;
  79870. /**
  79871. * Returns a Color3 value containing a magenta color
  79872. * @returns a new Color3 object
  79873. */
  79874. static Magenta(): Color3;
  79875. /**
  79876. * Returns a Color3 value containing a yellow color
  79877. * @returns a new Color3 object
  79878. */
  79879. static Yellow(): Color3;
  79880. /**
  79881. * Returns a Color3 value containing a gray color
  79882. * @returns a new Color3 object
  79883. */
  79884. static Gray(): Color3;
  79885. /**
  79886. * Returns a Color3 value containing a teal color
  79887. * @returns a new Color3 object
  79888. */
  79889. static Teal(): Color3;
  79890. /**
  79891. * Returns a Color3 value containing a random color
  79892. * @returns a new Color3 object
  79893. */
  79894. static Random(): Color3;
  79895. }
  79896. /**
  79897. * Class used to hold a RBGA color
  79898. */
  79899. export class Color4 {
  79900. /**
  79901. * Defines the red component (between 0 and 1, default is 0)
  79902. */
  79903. r: number;
  79904. /**
  79905. * Defines the green component (between 0 and 1, default is 0)
  79906. */
  79907. g: number;
  79908. /**
  79909. * Defines the blue component (between 0 and 1, default is 0)
  79910. */
  79911. b: number;
  79912. /**
  79913. * Defines the alpha component (between 0 and 1, default is 1)
  79914. */
  79915. a: number;
  79916. /**
  79917. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79918. * @param r defines the red component (between 0 and 1, default is 0)
  79919. * @param g defines the green component (between 0 and 1, default is 0)
  79920. * @param b defines the blue component (between 0 and 1, default is 0)
  79921. * @param a defines the alpha component (between 0 and 1, default is 1)
  79922. */
  79923. constructor(
  79924. /**
  79925. * Defines the red component (between 0 and 1, default is 0)
  79926. */
  79927. r?: number,
  79928. /**
  79929. * Defines the green component (between 0 and 1, default is 0)
  79930. */
  79931. g?: number,
  79932. /**
  79933. * Defines the blue component (between 0 and 1, default is 0)
  79934. */
  79935. b?: number,
  79936. /**
  79937. * Defines the alpha component (between 0 and 1, default is 1)
  79938. */
  79939. a?: number);
  79940. /**
  79941. * Adds in place the given Color4 values to the current Color4 object
  79942. * @param right defines the second operand
  79943. * @returns the current updated Color4 object
  79944. */
  79945. addInPlace(right: DeepImmutable<Color4>): Color4;
  79946. /**
  79947. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79948. * @returns the new array
  79949. */
  79950. asArray(): number[];
  79951. /**
  79952. * Stores from the starting index in the given array the Color4 successive values
  79953. * @param array defines the array where to store the r,g,b components
  79954. * @param index defines an optional index in the target array to define where to start storing values
  79955. * @returns the current Color4 object
  79956. */
  79957. toArray(array: number[], index?: number): Color4;
  79958. /**
  79959. * Determines equality between Color4 objects
  79960. * @param otherColor defines the second operand
  79961. * @returns true if the rgba values are equal to the given ones
  79962. */
  79963. equals(otherColor: DeepImmutable<Color4>): boolean;
  79964. /**
  79965. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79966. * @param right defines the second operand
  79967. * @returns a new Color4 object
  79968. */
  79969. add(right: DeepImmutable<Color4>): Color4;
  79970. /**
  79971. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79972. * @param right defines the second operand
  79973. * @returns a new Color4 object
  79974. */
  79975. subtract(right: DeepImmutable<Color4>): Color4;
  79976. /**
  79977. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79978. * @param right defines the second operand
  79979. * @param result defines the Color4 object where to store the result
  79980. * @returns the current Color4 object
  79981. */
  79982. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79983. /**
  79984. * Creates a new Color4 with the current Color4 values multiplied by scale
  79985. * @param scale defines the scaling factor to apply
  79986. * @returns a new Color4 object
  79987. */
  79988. scale(scale: number): Color4;
  79989. /**
  79990. * Multiplies the current Color4 values by scale and stores the result in "result"
  79991. * @param scale defines the scaling factor to apply
  79992. * @param result defines the Color4 object where to store the result
  79993. * @returns the current unmodified Color4
  79994. */
  79995. scaleToRef(scale: number, result: Color4): Color4;
  79996. /**
  79997. * Scale the current Color4 values by a factor and add the result to a given Color4
  79998. * @param scale defines the scale factor
  79999. * @param result defines the Color4 object where to store the result
  80000. * @returns the unmodified current Color4
  80001. */
  80002. scaleAndAddToRef(scale: number, result: Color4): Color4;
  80003. /**
  80004. * Clamps the rgb values by the min and max values and stores the result into "result"
  80005. * @param min defines minimum clamping value (default is 0)
  80006. * @param max defines maximum clamping value (default is 1)
  80007. * @param result defines color to store the result into.
  80008. * @returns the cuurent Color4
  80009. */
  80010. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  80011. /**
  80012. * Multipy an Color4 value by another and return a new Color4 object
  80013. * @param color defines the Color4 value to multiply by
  80014. * @returns a new Color4 object
  80015. */
  80016. multiply(color: Color4): Color4;
  80017. /**
  80018. * Multipy a Color4 value by another and push the result in a reference value
  80019. * @param color defines the Color4 value to multiply by
  80020. * @param result defines the Color4 to fill the result in
  80021. * @returns the result Color4
  80022. */
  80023. multiplyToRef(color: Color4, result: Color4): Color4;
  80024. /**
  80025. * Creates a string with the Color4 current values
  80026. * @returns the string representation of the Color4 object
  80027. */
  80028. toString(): string;
  80029. /**
  80030. * Returns the string "Color4"
  80031. * @returns "Color4"
  80032. */
  80033. getClassName(): string;
  80034. /**
  80035. * Compute the Color4 hash code
  80036. * @returns an unique number that can be used to hash Color4 objects
  80037. */
  80038. getHashCode(): number;
  80039. /**
  80040. * Creates a new Color4 copied from the current one
  80041. * @returns a new Color4 object
  80042. */
  80043. clone(): Color4;
  80044. /**
  80045. * Copies the given Color4 values into the current one
  80046. * @param source defines the source Color4 object
  80047. * @returns the current updated Color4 object
  80048. */
  80049. copyFrom(source: Color4): Color4;
  80050. /**
  80051. * Copies the given float values into the current one
  80052. * @param r defines the red component to read from
  80053. * @param g defines the green component to read from
  80054. * @param b defines the blue component to read from
  80055. * @param a defines the alpha component to read from
  80056. * @returns the current updated Color4 object
  80057. */
  80058. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80059. /**
  80060. * Copies the given float values into the current one
  80061. * @param r defines the red component to read from
  80062. * @param g defines the green component to read from
  80063. * @param b defines the blue component to read from
  80064. * @param a defines the alpha component to read from
  80065. * @returns the current updated Color4 object
  80066. */
  80067. set(r: number, g: number, b: number, a: number): Color4;
  80068. /**
  80069. * Compute the Color4 hexadecimal code as a string
  80070. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80071. * @returns a string containing the hexadecimal representation of the Color4 object
  80072. */
  80073. toHexString(returnAsColor3?: boolean): string;
  80074. /**
  80075. * Computes a new Color4 converted from the current one to linear space
  80076. * @returns a new Color4 object
  80077. */
  80078. toLinearSpace(): Color4;
  80079. /**
  80080. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80081. * @param convertedColor defines the Color4 object where to store the linear space version
  80082. * @returns the unmodified Color4
  80083. */
  80084. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80085. /**
  80086. * Computes a new Color4 converted from the current one to gamma space
  80087. * @returns a new Color4 object
  80088. */
  80089. toGammaSpace(): Color4;
  80090. /**
  80091. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80092. * @param convertedColor defines the Color4 object where to store the gamma space version
  80093. * @returns the unmodified Color4
  80094. */
  80095. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80096. /**
  80097. * Creates a new Color4 from the string containing valid hexadecimal values
  80098. * @param hex defines a string containing valid hexadecimal values
  80099. * @returns a new Color4 object
  80100. */
  80101. static FromHexString(hex: string): Color4;
  80102. /**
  80103. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80104. * @param left defines the start value
  80105. * @param right defines the end value
  80106. * @param amount defines the gradient factor
  80107. * @returns a new Color4 object
  80108. */
  80109. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80110. /**
  80111. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80112. * @param left defines the start value
  80113. * @param right defines the end value
  80114. * @param amount defines the gradient factor
  80115. * @param result defines the Color4 object where to store data
  80116. */
  80117. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80118. /**
  80119. * Creates a new Color4 from a Color3 and an alpha value
  80120. * @param color3 defines the source Color3 to read from
  80121. * @param alpha defines the alpha component (1.0 by default)
  80122. * @returns a new Color4 object
  80123. */
  80124. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80125. /**
  80126. * Creates a new Color4 from the starting index element of the given array
  80127. * @param array defines the source array to read from
  80128. * @param offset defines the offset in the source array
  80129. * @returns a new Color4 object
  80130. */
  80131. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80132. /**
  80133. * Creates a new Color3 from integer values (< 256)
  80134. * @param r defines the red component to read from (value between 0 and 255)
  80135. * @param g defines the green component to read from (value between 0 and 255)
  80136. * @param b defines the blue component to read from (value between 0 and 255)
  80137. * @param a defines the alpha component to read from (value between 0 and 255)
  80138. * @returns a new Color3 object
  80139. */
  80140. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80141. /**
  80142. * Check the content of a given array and convert it to an array containing RGBA data
  80143. * If the original array was already containing count * 4 values then it is returned directly
  80144. * @param colors defines the array to check
  80145. * @param count defines the number of RGBA data to expect
  80146. * @returns an array containing count * 4 values (RGBA)
  80147. */
  80148. static CheckColors4(colors: number[], count: number): number[];
  80149. }
  80150. /**
  80151. * @hidden
  80152. */
  80153. export class TmpColors {
  80154. static Color3: Color3[];
  80155. static Color4: Color4[];
  80156. }
  80157. }
  80158. declare module BABYLON {
  80159. /**
  80160. * Defines an interface which represents an animation key frame
  80161. */
  80162. export interface IAnimationKey {
  80163. /**
  80164. * Frame of the key frame
  80165. */
  80166. frame: number;
  80167. /**
  80168. * Value at the specifies key frame
  80169. */
  80170. value: any;
  80171. /**
  80172. * The input tangent for the cubic hermite spline
  80173. */
  80174. inTangent?: any;
  80175. /**
  80176. * The output tangent for the cubic hermite spline
  80177. */
  80178. outTangent?: any;
  80179. /**
  80180. * The animation interpolation type
  80181. */
  80182. interpolation?: AnimationKeyInterpolation;
  80183. }
  80184. /**
  80185. * Enum for the animation key frame interpolation type
  80186. */
  80187. export enum AnimationKeyInterpolation {
  80188. /**
  80189. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80190. */
  80191. STEP = 1
  80192. }
  80193. }
  80194. declare module BABYLON {
  80195. /**
  80196. * Represents the range of an animation
  80197. */
  80198. export class AnimationRange {
  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. * Initializes the range of an animation
  80207. * @param name The name of the animation range
  80208. * @param from The starting frame of the animation
  80209. * @param to The ending frame of the animation
  80210. */
  80211. constructor(
  80212. /**The name of the animation range**/
  80213. name: string,
  80214. /**The starting frame of the animation */
  80215. from: number,
  80216. /**The ending frame of the animation*/
  80217. to: number);
  80218. /**
  80219. * Makes a copy of the animation range
  80220. * @returns A copy of the animation range
  80221. */
  80222. clone(): AnimationRange;
  80223. }
  80224. }
  80225. declare module BABYLON {
  80226. /**
  80227. * Composed of a frame, and an action function
  80228. */
  80229. export class AnimationEvent {
  80230. /** The frame for which the event is triggered **/
  80231. frame: number;
  80232. /** The event to perform when triggered **/
  80233. action: (currentFrame: number) => void;
  80234. /** Specifies if the event should be triggered only once**/
  80235. onlyOnce?: boolean | undefined;
  80236. /**
  80237. * Specifies if the animation event is done
  80238. */
  80239. isDone: boolean;
  80240. /**
  80241. * Initializes the animation event
  80242. * @param frame The frame for which the event is triggered
  80243. * @param action The event to perform when triggered
  80244. * @param onlyOnce Specifies if the event should be triggered only once
  80245. */
  80246. constructor(
  80247. /** The frame for which the event is triggered **/
  80248. frame: number,
  80249. /** The event to perform when triggered **/
  80250. action: (currentFrame: number) => void,
  80251. /** Specifies if the event should be triggered only once**/
  80252. onlyOnce?: boolean | undefined);
  80253. /** @hidden */
  80254. _clone(): AnimationEvent;
  80255. }
  80256. }
  80257. declare module BABYLON {
  80258. /**
  80259. * Interface used to define a behavior
  80260. */
  80261. export interface Behavior<T> {
  80262. /** gets or sets behavior's name */
  80263. name: string;
  80264. /**
  80265. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80266. */
  80267. init(): void;
  80268. /**
  80269. * Called when the behavior is attached to a target
  80270. * @param target defines the target where the behavior is attached to
  80271. */
  80272. attach(target: T): void;
  80273. /**
  80274. * Called when the behavior is detached from its target
  80275. */
  80276. detach(): void;
  80277. }
  80278. /**
  80279. * Interface implemented by classes supporting behaviors
  80280. */
  80281. export interface IBehaviorAware<T> {
  80282. /**
  80283. * Attach a behavior
  80284. * @param behavior defines the behavior to attach
  80285. * @returns the current host
  80286. */
  80287. addBehavior(behavior: Behavior<T>): T;
  80288. /**
  80289. * Remove a behavior from the current object
  80290. * @param behavior defines the behavior to detach
  80291. * @returns the current host
  80292. */
  80293. removeBehavior(behavior: Behavior<T>): T;
  80294. /**
  80295. * Gets a behavior using its name to search
  80296. * @param name defines the name to search
  80297. * @returns the behavior or null if not found
  80298. */
  80299. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80300. }
  80301. }
  80302. declare module BABYLON {
  80303. /**
  80304. * Defines an array and its length.
  80305. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80306. */
  80307. export interface ISmartArrayLike<T> {
  80308. /**
  80309. * The data of the array.
  80310. */
  80311. data: Array<T>;
  80312. /**
  80313. * The active length of the array.
  80314. */
  80315. length: number;
  80316. }
  80317. /**
  80318. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80319. */
  80320. export class SmartArray<T> implements ISmartArrayLike<T> {
  80321. /**
  80322. * The full set of data from the array.
  80323. */
  80324. data: Array<T>;
  80325. /**
  80326. * The active length of the array.
  80327. */
  80328. length: number;
  80329. protected _id: number;
  80330. /**
  80331. * Instantiates a Smart Array.
  80332. * @param capacity defines the default capacity of the array.
  80333. */
  80334. constructor(capacity: number);
  80335. /**
  80336. * Pushes a value at the end of the active data.
  80337. * @param value defines the object to push in the array.
  80338. */
  80339. push(value: T): void;
  80340. /**
  80341. * Iterates over the active data and apply the lambda to them.
  80342. * @param func defines the action to apply on each value.
  80343. */
  80344. forEach(func: (content: T) => void): void;
  80345. /**
  80346. * Sorts the full sets of data.
  80347. * @param compareFn defines the comparison function to apply.
  80348. */
  80349. sort(compareFn: (a: T, b: T) => number): void;
  80350. /**
  80351. * Resets the active data to an empty array.
  80352. */
  80353. reset(): void;
  80354. /**
  80355. * Releases all the data from the array as well as the array.
  80356. */
  80357. dispose(): void;
  80358. /**
  80359. * Concats the active data with a given array.
  80360. * @param array defines the data to concatenate with.
  80361. */
  80362. concat(array: any): void;
  80363. /**
  80364. * Returns the position of a value in the active data.
  80365. * @param value defines the value to find the index for
  80366. * @returns the index if found in the active data otherwise -1
  80367. */
  80368. indexOf(value: T): number;
  80369. /**
  80370. * Returns whether an element is part of the active data.
  80371. * @param value defines the value to look for
  80372. * @returns true if found in the active data otherwise false
  80373. */
  80374. contains(value: T): boolean;
  80375. private static _GlobalId;
  80376. }
  80377. /**
  80378. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80379. * The data in this array can only be present once
  80380. */
  80381. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80382. private _duplicateId;
  80383. /**
  80384. * Pushes a value at the end of the active data.
  80385. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80386. * @param value defines the object to push in the array.
  80387. */
  80388. push(value: T): void;
  80389. /**
  80390. * Pushes a value at the end of the active data.
  80391. * If the data is already present, it won t be added again
  80392. * @param value defines the object to push in the array.
  80393. * @returns true if added false if it was already present
  80394. */
  80395. pushNoDuplicate(value: T): boolean;
  80396. /**
  80397. * Resets the active data to an empty array.
  80398. */
  80399. reset(): void;
  80400. /**
  80401. * Concats the active data with a given array.
  80402. * This ensures no dupplicate will be present in the result.
  80403. * @param array defines the data to concatenate with.
  80404. */
  80405. concatWithNoDuplicate(array: any): void;
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. /**
  80410. * @ignore
  80411. * This is a list of all the different input types that are available in the application.
  80412. * Fo instance: ArcRotateCameraGamepadInput...
  80413. */
  80414. export var CameraInputTypes: {};
  80415. /**
  80416. * This is the contract to implement in order to create a new input class.
  80417. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80418. */
  80419. export interface ICameraInput<TCamera extends Camera> {
  80420. /**
  80421. * Defines the camera the input is attached to.
  80422. */
  80423. camera: Nullable<TCamera>;
  80424. /**
  80425. * Gets the class name of the current intput.
  80426. * @returns the class name
  80427. */
  80428. getClassName(): string;
  80429. /**
  80430. * Get the friendly name associated with the input class.
  80431. * @returns the input friendly name
  80432. */
  80433. getSimpleName(): string;
  80434. /**
  80435. * Attach the input controls to a specific dom element to get the input from.
  80436. * @param element Defines the element the controls should be listened from
  80437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80438. */
  80439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80440. /**
  80441. * Detach the current controls from the specified dom element.
  80442. * @param element Defines the element to stop listening the inputs from
  80443. */
  80444. detachControl(element: Nullable<HTMLElement>): void;
  80445. /**
  80446. * Update the current camera state depending on the inputs that have been used this frame.
  80447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80448. */
  80449. checkInputs?: () => void;
  80450. }
  80451. /**
  80452. * Represents a map of input types to input instance or input index to input instance.
  80453. */
  80454. export interface CameraInputsMap<TCamera extends Camera> {
  80455. /**
  80456. * Accessor to the input by input type.
  80457. */
  80458. [name: string]: ICameraInput<TCamera>;
  80459. /**
  80460. * Accessor to the input by input index.
  80461. */
  80462. [idx: number]: ICameraInput<TCamera>;
  80463. }
  80464. /**
  80465. * This represents the input manager used within a camera.
  80466. * It helps dealing with all the different kind of input attached to a camera.
  80467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80468. */
  80469. export class CameraInputsManager<TCamera extends Camera> {
  80470. /**
  80471. * Defines the list of inputs attahed to the camera.
  80472. */
  80473. attached: CameraInputsMap<TCamera>;
  80474. /**
  80475. * Defines the dom element the camera is collecting inputs from.
  80476. * This is null if the controls have not been attached.
  80477. */
  80478. attachedElement: Nullable<HTMLElement>;
  80479. /**
  80480. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80481. */
  80482. noPreventDefault: boolean;
  80483. /**
  80484. * Defined the camera the input manager belongs to.
  80485. */
  80486. camera: TCamera;
  80487. /**
  80488. * Update the current camera state depending on the inputs that have been used this frame.
  80489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80490. */
  80491. checkInputs: () => void;
  80492. /**
  80493. * Instantiate a new Camera Input Manager.
  80494. * @param camera Defines the camera the input manager blongs to
  80495. */
  80496. constructor(camera: TCamera);
  80497. /**
  80498. * Add an input method to a camera
  80499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80500. * @param input camera input method
  80501. */
  80502. add(input: ICameraInput<TCamera>): void;
  80503. /**
  80504. * Remove a specific input method from a camera
  80505. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80506. * @param inputToRemove camera input method
  80507. */
  80508. remove(inputToRemove: ICameraInput<TCamera>): void;
  80509. /**
  80510. * Remove a specific input type from a camera
  80511. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80512. * @param inputType the type of the input to remove
  80513. */
  80514. removeByType(inputType: string): void;
  80515. private _addCheckInputs;
  80516. /**
  80517. * Attach the input controls to the currently attached dom element to listen the events from.
  80518. * @param input Defines the input to attach
  80519. */
  80520. attachInput(input: ICameraInput<TCamera>): void;
  80521. /**
  80522. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80523. * @param element Defines the dom element to collect the events from
  80524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80525. */
  80526. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80527. /**
  80528. * Detach the current manager inputs controls from a specific dom element.
  80529. * @param element Defines the dom element to collect the events from
  80530. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80531. */
  80532. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80533. /**
  80534. * Rebuild the dynamic inputCheck function from the current list of
  80535. * defined inputs in the manager.
  80536. */
  80537. rebuildInputCheck(): void;
  80538. /**
  80539. * Remove all attached input methods from a camera
  80540. */
  80541. clear(): void;
  80542. /**
  80543. * Serialize the current input manager attached to a camera.
  80544. * This ensures than once parsed,
  80545. * the input associated to the camera will be identical to the current ones
  80546. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80547. */
  80548. serialize(serializedCamera: any): void;
  80549. /**
  80550. * Parses an input manager serialized JSON to restore the previous list of inputs
  80551. * and states associated to a camera.
  80552. * @param parsedCamera Defines the JSON to parse
  80553. */
  80554. parse(parsedCamera: any): void;
  80555. }
  80556. }
  80557. declare module BABYLON {
  80558. /**
  80559. * Class used to store data that will be store in GPU memory
  80560. */
  80561. export class Buffer {
  80562. private _engine;
  80563. private _buffer;
  80564. /** @hidden */
  80565. _data: Nullable<DataArray>;
  80566. private _updatable;
  80567. private _instanced;
  80568. private _divisor;
  80569. /**
  80570. * Gets the byte stride.
  80571. */
  80572. readonly byteStride: number;
  80573. /**
  80574. * Constructor
  80575. * @param engine the engine
  80576. * @param data the data to use for this buffer
  80577. * @param updatable whether the data is updatable
  80578. * @param stride the stride (optional)
  80579. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80580. * @param instanced whether the buffer is instanced (optional)
  80581. * @param useBytes set to true if the stride in in bytes (optional)
  80582. * @param divisor sets an optional divisor for instances (1 by default)
  80583. */
  80584. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80585. /**
  80586. * Create a new VertexBuffer based on the current buffer
  80587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80588. * @param offset defines offset in the buffer (0 by default)
  80589. * @param size defines the size in floats of attributes (position is 3 for instance)
  80590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80591. * @param instanced defines if the vertex buffer contains indexed data
  80592. * @param useBytes defines if the offset and stride are in bytes *
  80593. * @param divisor sets an optional divisor for instances (1 by default)
  80594. * @returns the new vertex buffer
  80595. */
  80596. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80597. /**
  80598. * Gets a boolean indicating if the Buffer is updatable?
  80599. * @returns true if the buffer is updatable
  80600. */
  80601. isUpdatable(): boolean;
  80602. /**
  80603. * Gets current buffer's data
  80604. * @returns a DataArray or null
  80605. */
  80606. getData(): Nullable<DataArray>;
  80607. /**
  80608. * Gets underlying native buffer
  80609. * @returns underlying native buffer
  80610. */
  80611. getBuffer(): Nullable<DataBuffer>;
  80612. /**
  80613. * Gets the stride in float32 units (i.e. byte stride / 4).
  80614. * May not be an integer if the byte stride is not divisible by 4.
  80615. * @returns the stride in float32 units
  80616. * @deprecated Please use byteStride instead.
  80617. */
  80618. getStrideSize(): number;
  80619. /**
  80620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80621. * @param data defines the data to store
  80622. */
  80623. create(data?: Nullable<DataArray>): void;
  80624. /** @hidden */
  80625. _rebuild(): void;
  80626. /**
  80627. * Update current buffer data
  80628. * @param data defines the data to store
  80629. */
  80630. update(data: DataArray): void;
  80631. /**
  80632. * Updates the data directly.
  80633. * @param data the new data
  80634. * @param offset the new offset
  80635. * @param vertexCount the vertex count (optional)
  80636. * @param useBytes set to true if the offset is in bytes
  80637. */
  80638. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80639. /**
  80640. * Release all resources
  80641. */
  80642. dispose(): void;
  80643. }
  80644. /**
  80645. * Specialized buffer used to store vertex data
  80646. */
  80647. export class VertexBuffer {
  80648. /** @hidden */
  80649. _buffer: Buffer;
  80650. private _kind;
  80651. private _size;
  80652. private _ownsBuffer;
  80653. private _instanced;
  80654. private _instanceDivisor;
  80655. /**
  80656. * The byte type.
  80657. */
  80658. static readonly BYTE: number;
  80659. /**
  80660. * The unsigned byte type.
  80661. */
  80662. static readonly UNSIGNED_BYTE: number;
  80663. /**
  80664. * The short type.
  80665. */
  80666. static readonly SHORT: number;
  80667. /**
  80668. * The unsigned short type.
  80669. */
  80670. static readonly UNSIGNED_SHORT: number;
  80671. /**
  80672. * The integer type.
  80673. */
  80674. static readonly INT: number;
  80675. /**
  80676. * The unsigned integer type.
  80677. */
  80678. static readonly UNSIGNED_INT: number;
  80679. /**
  80680. * The float type.
  80681. */
  80682. static readonly FLOAT: number;
  80683. /**
  80684. * Gets or sets the instance divisor when in instanced mode
  80685. */
  80686. get instanceDivisor(): number;
  80687. set instanceDivisor(value: number);
  80688. /**
  80689. * Gets the byte stride.
  80690. */
  80691. readonly byteStride: number;
  80692. /**
  80693. * Gets the byte offset.
  80694. */
  80695. readonly byteOffset: number;
  80696. /**
  80697. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80698. */
  80699. readonly normalized: boolean;
  80700. /**
  80701. * Gets the data type of each component in the array.
  80702. */
  80703. readonly type: number;
  80704. /**
  80705. * Constructor
  80706. * @param engine the engine
  80707. * @param data the data to use for this vertex buffer
  80708. * @param kind the vertex buffer kind
  80709. * @param updatable whether the data is updatable
  80710. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80711. * @param stride the stride (optional)
  80712. * @param instanced whether the buffer is instanced (optional)
  80713. * @param offset the offset of the data (optional)
  80714. * @param size the number of components (optional)
  80715. * @param type the type of the component (optional)
  80716. * @param normalized whether the data contains normalized data (optional)
  80717. * @param useBytes set to true if stride and offset are in bytes (optional)
  80718. * @param divisor defines the instance divisor to use (1 by default)
  80719. */
  80720. 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);
  80721. /** @hidden */
  80722. _rebuild(): void;
  80723. /**
  80724. * Returns the kind of the VertexBuffer (string)
  80725. * @returns a string
  80726. */
  80727. getKind(): string;
  80728. /**
  80729. * Gets a boolean indicating if the VertexBuffer is updatable?
  80730. * @returns true if the buffer is updatable
  80731. */
  80732. isUpdatable(): boolean;
  80733. /**
  80734. * Gets current buffer's data
  80735. * @returns a DataArray or null
  80736. */
  80737. getData(): Nullable<DataArray>;
  80738. /**
  80739. * Gets underlying native buffer
  80740. * @returns underlying native buffer
  80741. */
  80742. getBuffer(): Nullable<DataBuffer>;
  80743. /**
  80744. * Gets the stride in float32 units (i.e. byte stride / 4).
  80745. * May not be an integer if the byte stride is not divisible by 4.
  80746. * @returns the stride in float32 units
  80747. * @deprecated Please use byteStride instead.
  80748. */
  80749. getStrideSize(): number;
  80750. /**
  80751. * Returns the offset as a multiple of the type byte length.
  80752. * @returns the offset in bytes
  80753. * @deprecated Please use byteOffset instead.
  80754. */
  80755. getOffset(): number;
  80756. /**
  80757. * Returns the number of components per vertex attribute (integer)
  80758. * @returns the size in float
  80759. */
  80760. getSize(): number;
  80761. /**
  80762. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80763. * @returns true if this buffer is instanced
  80764. */
  80765. getIsInstanced(): boolean;
  80766. /**
  80767. * Returns the instancing divisor, zero for non-instanced (integer).
  80768. * @returns a number
  80769. */
  80770. getInstanceDivisor(): number;
  80771. /**
  80772. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80773. * @param data defines the data to store
  80774. */
  80775. create(data?: DataArray): void;
  80776. /**
  80777. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80778. * This function will create a new buffer if the current one is not updatable
  80779. * @param data defines the data to store
  80780. */
  80781. update(data: DataArray): void;
  80782. /**
  80783. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80784. * Returns the directly updated WebGLBuffer.
  80785. * @param data the new data
  80786. * @param offset the new offset
  80787. * @param useBytes set to true if the offset is in bytes
  80788. */
  80789. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80790. /**
  80791. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80792. */
  80793. dispose(): void;
  80794. /**
  80795. * Enumerates each value of this vertex buffer as numbers.
  80796. * @param count the number of values to enumerate
  80797. * @param callback the callback function called for each value
  80798. */
  80799. forEach(count: number, callback: (value: number, index: number) => void): void;
  80800. /**
  80801. * Positions
  80802. */
  80803. static readonly PositionKind: string;
  80804. /**
  80805. * Normals
  80806. */
  80807. static readonly NormalKind: string;
  80808. /**
  80809. * Tangents
  80810. */
  80811. static readonly TangentKind: string;
  80812. /**
  80813. * Texture coordinates
  80814. */
  80815. static readonly UVKind: string;
  80816. /**
  80817. * Texture coordinates 2
  80818. */
  80819. static readonly UV2Kind: string;
  80820. /**
  80821. * Texture coordinates 3
  80822. */
  80823. static readonly UV3Kind: string;
  80824. /**
  80825. * Texture coordinates 4
  80826. */
  80827. static readonly UV4Kind: string;
  80828. /**
  80829. * Texture coordinates 5
  80830. */
  80831. static readonly UV5Kind: string;
  80832. /**
  80833. * Texture coordinates 6
  80834. */
  80835. static readonly UV6Kind: string;
  80836. /**
  80837. * Colors
  80838. */
  80839. static readonly ColorKind: string;
  80840. /**
  80841. * Matrix indices (for bones)
  80842. */
  80843. static readonly MatricesIndicesKind: string;
  80844. /**
  80845. * Matrix weights (for bones)
  80846. */
  80847. static readonly MatricesWeightsKind: string;
  80848. /**
  80849. * Additional matrix indices (for bones)
  80850. */
  80851. static readonly MatricesIndicesExtraKind: string;
  80852. /**
  80853. * Additional matrix weights (for bones)
  80854. */
  80855. static readonly MatricesWeightsExtraKind: string;
  80856. /**
  80857. * Deduces the stride given a kind.
  80858. * @param kind The kind string to deduce
  80859. * @returns The deduced stride
  80860. */
  80861. static DeduceStride(kind: string): number;
  80862. /**
  80863. * Gets the byte length of the given type.
  80864. * @param type the type
  80865. * @returns the number of bytes
  80866. */
  80867. static GetTypeByteLength(type: number): number;
  80868. /**
  80869. * Enumerates each value of the given parameters as numbers.
  80870. * @param data the data to enumerate
  80871. * @param byteOffset the byte offset of the data
  80872. * @param byteStride the byte stride of the data
  80873. * @param componentCount the number of components per element
  80874. * @param componentType the type of the component
  80875. * @param count the number of values to enumerate
  80876. * @param normalized whether the data is normalized
  80877. * @param callback the callback function called for each value
  80878. */
  80879. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80880. private static _GetFloatValue;
  80881. }
  80882. }
  80883. declare module BABYLON {
  80884. /**
  80885. * @hidden
  80886. */
  80887. export class IntersectionInfo {
  80888. bu: Nullable<number>;
  80889. bv: Nullable<number>;
  80890. distance: number;
  80891. faceId: number;
  80892. subMeshId: number;
  80893. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80894. }
  80895. }
  80896. declare module BABYLON {
  80897. /**
  80898. * Represens a plane by the equation ax + by + cz + d = 0
  80899. */
  80900. export class Plane {
  80901. private static _TmpMatrix;
  80902. /**
  80903. * Normal of the plane (a,b,c)
  80904. */
  80905. normal: Vector3;
  80906. /**
  80907. * d component of the plane
  80908. */
  80909. d: number;
  80910. /**
  80911. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80912. * @param a a component of the plane
  80913. * @param b b component of the plane
  80914. * @param c c component of the plane
  80915. * @param d d component of the plane
  80916. */
  80917. constructor(a: number, b: number, c: number, d: number);
  80918. /**
  80919. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80920. */
  80921. asArray(): number[];
  80922. /**
  80923. * @returns a new plane copied from the current Plane.
  80924. */
  80925. clone(): Plane;
  80926. /**
  80927. * @returns the string "Plane".
  80928. */
  80929. getClassName(): string;
  80930. /**
  80931. * @returns the Plane hash code.
  80932. */
  80933. getHashCode(): number;
  80934. /**
  80935. * Normalize the current Plane in place.
  80936. * @returns the updated Plane.
  80937. */
  80938. normalize(): Plane;
  80939. /**
  80940. * Applies a transformation the plane and returns the result
  80941. * @param transformation the transformation matrix to be applied to the plane
  80942. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80943. */
  80944. transform(transformation: DeepImmutable<Matrix>): Plane;
  80945. /**
  80946. * Calcualtte the dot product between the point and the plane normal
  80947. * @param point point to calculate the dot product with
  80948. * @returns the dot product (float) of the point coordinates and the plane normal.
  80949. */
  80950. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80951. /**
  80952. * Updates the current Plane from the plane defined by the three given points.
  80953. * @param point1 one of the points used to contruct the plane
  80954. * @param point2 one of the points used to contruct the plane
  80955. * @param point3 one of the points used to contruct the plane
  80956. * @returns the updated Plane.
  80957. */
  80958. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80959. /**
  80960. * Checks if the plane is facing a given direction
  80961. * @param direction the direction to check if the plane is facing
  80962. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80963. * @returns True is the vector "direction" is the same side than the plane normal.
  80964. */
  80965. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80966. /**
  80967. * Calculates the distance to a point
  80968. * @param point point to calculate distance to
  80969. * @returns the signed distance (float) from the given point to the Plane.
  80970. */
  80971. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80972. /**
  80973. * Creates a plane from an array
  80974. * @param array the array to create a plane from
  80975. * @returns a new Plane from the given array.
  80976. */
  80977. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80978. /**
  80979. * Creates a plane from three points
  80980. * @param point1 point used to create the plane
  80981. * @param point2 point used to create the plane
  80982. * @param point3 point used to create the plane
  80983. * @returns a new Plane defined by the three given points.
  80984. */
  80985. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80986. /**
  80987. * Creates a plane from an origin point and a normal
  80988. * @param origin origin of the plane to be constructed
  80989. * @param normal normal of the plane to be constructed
  80990. * @returns a new Plane the normal vector to this plane at the given origin point.
  80991. * Note : the vector "normal" is updated because normalized.
  80992. */
  80993. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80994. /**
  80995. * Calculates the distance from a plane and a point
  80996. * @param origin origin of the plane to be constructed
  80997. * @param normal normal of the plane to be constructed
  80998. * @param point point to calculate distance to
  80999. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81000. */
  81001. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81002. }
  81003. }
  81004. declare module BABYLON {
  81005. /**
  81006. * Class used to store bounding sphere information
  81007. */
  81008. export class BoundingSphere {
  81009. /**
  81010. * Gets the center of the bounding sphere in local space
  81011. */
  81012. readonly center: Vector3;
  81013. /**
  81014. * Radius of the bounding sphere in local space
  81015. */
  81016. radius: number;
  81017. /**
  81018. * Gets the center of the bounding sphere in world space
  81019. */
  81020. readonly centerWorld: Vector3;
  81021. /**
  81022. * Radius of the bounding sphere in world space
  81023. */
  81024. radiusWorld: number;
  81025. /**
  81026. * Gets the minimum vector in local space
  81027. */
  81028. readonly minimum: Vector3;
  81029. /**
  81030. * Gets the maximum vector in local space
  81031. */
  81032. readonly maximum: Vector3;
  81033. private _worldMatrix;
  81034. private static readonly TmpVector3;
  81035. /**
  81036. * Creates a new bounding sphere
  81037. * @param min defines the minimum vector (in local space)
  81038. * @param max defines the maximum vector (in local space)
  81039. * @param worldMatrix defines the new world matrix
  81040. */
  81041. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81042. /**
  81043. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81044. * @param min defines the new minimum vector (in local space)
  81045. * @param max defines the new maximum vector (in local space)
  81046. * @param worldMatrix defines the new world matrix
  81047. */
  81048. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81049. /**
  81050. * Scale the current bounding sphere by applying a scale factor
  81051. * @param factor defines the scale factor to apply
  81052. * @returns the current bounding box
  81053. */
  81054. scale(factor: number): BoundingSphere;
  81055. /**
  81056. * Gets the world matrix of the bounding box
  81057. * @returns a matrix
  81058. */
  81059. getWorldMatrix(): DeepImmutable<Matrix>;
  81060. /** @hidden */
  81061. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81062. /**
  81063. * Tests if the bounding sphere is intersecting the frustum planes
  81064. * @param frustumPlanes defines the frustum planes to test
  81065. * @returns true if there is an intersection
  81066. */
  81067. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81068. /**
  81069. * Tests if the bounding sphere center is in between the frustum planes.
  81070. * Used for optimistic fast inclusion.
  81071. * @param frustumPlanes defines the frustum planes to test
  81072. * @returns true if the sphere center is in between the frustum planes
  81073. */
  81074. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81075. /**
  81076. * Tests if a point is inside the bounding sphere
  81077. * @param point defines the point to test
  81078. * @returns true if the point is inside the bounding sphere
  81079. */
  81080. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81081. /**
  81082. * Checks if two sphere intersct
  81083. * @param sphere0 sphere 0
  81084. * @param sphere1 sphere 1
  81085. * @returns true if the speres intersect
  81086. */
  81087. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Class used to store bounding box information
  81093. */
  81094. export class BoundingBox implements ICullable {
  81095. /**
  81096. * Gets the 8 vectors representing the bounding box in local space
  81097. */
  81098. readonly vectors: Vector3[];
  81099. /**
  81100. * Gets the center of the bounding box in local space
  81101. */
  81102. readonly center: Vector3;
  81103. /**
  81104. * Gets the center of the bounding box in world space
  81105. */
  81106. readonly centerWorld: Vector3;
  81107. /**
  81108. * Gets the extend size in local space
  81109. */
  81110. readonly extendSize: Vector3;
  81111. /**
  81112. * Gets the extend size in world space
  81113. */
  81114. readonly extendSizeWorld: Vector3;
  81115. /**
  81116. * Gets the OBB (object bounding box) directions
  81117. */
  81118. readonly directions: Vector3[];
  81119. /**
  81120. * Gets the 8 vectors representing the bounding box in world space
  81121. */
  81122. readonly vectorsWorld: Vector3[];
  81123. /**
  81124. * Gets the minimum vector in world space
  81125. */
  81126. readonly minimumWorld: Vector3;
  81127. /**
  81128. * Gets the maximum vector in world space
  81129. */
  81130. readonly maximumWorld: Vector3;
  81131. /**
  81132. * Gets the minimum vector in local space
  81133. */
  81134. readonly minimum: Vector3;
  81135. /**
  81136. * Gets the maximum vector in local space
  81137. */
  81138. readonly maximum: Vector3;
  81139. private _worldMatrix;
  81140. private static readonly TmpVector3;
  81141. /**
  81142. * @hidden
  81143. */
  81144. _tag: number;
  81145. /**
  81146. * Creates a new bounding box
  81147. * @param min defines the minimum vector (in local space)
  81148. * @param max defines the maximum vector (in local space)
  81149. * @param worldMatrix defines the new world matrix
  81150. */
  81151. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81152. /**
  81153. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81154. * @param min defines the new minimum vector (in local space)
  81155. * @param max defines the new maximum vector (in local space)
  81156. * @param worldMatrix defines the new world matrix
  81157. */
  81158. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81159. /**
  81160. * Scale the current bounding box by applying a scale factor
  81161. * @param factor defines the scale factor to apply
  81162. * @returns the current bounding box
  81163. */
  81164. scale(factor: number): BoundingBox;
  81165. /**
  81166. * Gets the world matrix of the bounding box
  81167. * @returns a matrix
  81168. */
  81169. getWorldMatrix(): DeepImmutable<Matrix>;
  81170. /** @hidden */
  81171. _update(world: DeepImmutable<Matrix>): void;
  81172. /**
  81173. * Tests if the bounding box is intersecting the frustum planes
  81174. * @param frustumPlanes defines the frustum planes to test
  81175. * @returns true if there is an intersection
  81176. */
  81177. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81178. /**
  81179. * Tests if the bounding box is entirely inside the frustum planes
  81180. * @param frustumPlanes defines the frustum planes to test
  81181. * @returns true if there is an inclusion
  81182. */
  81183. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81184. /**
  81185. * Tests if a point is inside the bounding box
  81186. * @param point defines the point to test
  81187. * @returns true if the point is inside the bounding box
  81188. */
  81189. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81190. /**
  81191. * Tests if the bounding box intersects with a bounding sphere
  81192. * @param sphere defines the sphere to test
  81193. * @returns true if there is an intersection
  81194. */
  81195. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81196. /**
  81197. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81198. * @param min defines the min vector to use
  81199. * @param max defines the max vector to use
  81200. * @returns true if there is an intersection
  81201. */
  81202. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81203. /**
  81204. * Tests if two bounding boxes are intersections
  81205. * @param box0 defines the first box to test
  81206. * @param box1 defines the second box to test
  81207. * @returns true if there is an intersection
  81208. */
  81209. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81210. /**
  81211. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81212. * @param minPoint defines the minimum vector of the bounding box
  81213. * @param maxPoint defines the maximum vector of the bounding box
  81214. * @param sphereCenter defines the sphere center
  81215. * @param sphereRadius defines the sphere radius
  81216. * @returns true if there is an intersection
  81217. */
  81218. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81219. /**
  81220. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81221. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81222. * @param frustumPlanes defines the frustum planes to test
  81223. * @return true if there is an inclusion
  81224. */
  81225. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81226. /**
  81227. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81228. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81229. * @param frustumPlanes defines the frustum planes to test
  81230. * @return true if there is an intersection
  81231. */
  81232. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81233. }
  81234. }
  81235. declare module BABYLON {
  81236. /** @hidden */
  81237. export class Collider {
  81238. /** Define if a collision was found */
  81239. collisionFound: boolean;
  81240. /**
  81241. * Define last intersection point in local space
  81242. */
  81243. intersectionPoint: Vector3;
  81244. /**
  81245. * Define last collided mesh
  81246. */
  81247. collidedMesh: Nullable<AbstractMesh>;
  81248. private _collisionPoint;
  81249. private _planeIntersectionPoint;
  81250. private _tempVector;
  81251. private _tempVector2;
  81252. private _tempVector3;
  81253. private _tempVector4;
  81254. private _edge;
  81255. private _baseToVertex;
  81256. private _destinationPoint;
  81257. private _slidePlaneNormal;
  81258. private _displacementVector;
  81259. /** @hidden */
  81260. _radius: Vector3;
  81261. /** @hidden */
  81262. _retry: number;
  81263. private _velocity;
  81264. private _basePoint;
  81265. private _epsilon;
  81266. /** @hidden */
  81267. _velocityWorldLength: number;
  81268. /** @hidden */
  81269. _basePointWorld: Vector3;
  81270. private _velocityWorld;
  81271. private _normalizedVelocity;
  81272. /** @hidden */
  81273. _initialVelocity: Vector3;
  81274. /** @hidden */
  81275. _initialPosition: Vector3;
  81276. private _nearestDistance;
  81277. private _collisionMask;
  81278. get collisionMask(): number;
  81279. set collisionMask(mask: number);
  81280. /**
  81281. * Gets the plane normal used to compute the sliding response (in local space)
  81282. */
  81283. get slidePlaneNormal(): Vector3;
  81284. /** @hidden */
  81285. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81286. /** @hidden */
  81287. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81288. /** @hidden */
  81289. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81290. /** @hidden */
  81291. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81292. /** @hidden */
  81293. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81294. /** @hidden */
  81295. _getResponse(pos: Vector3, vel: Vector3): void;
  81296. }
  81297. }
  81298. declare module BABYLON {
  81299. /**
  81300. * Interface for cullable objects
  81301. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81302. */
  81303. export interface ICullable {
  81304. /**
  81305. * Checks if the object or part of the object is in the frustum
  81306. * @param frustumPlanes Camera near/planes
  81307. * @returns true if the object is in frustum otherwise false
  81308. */
  81309. isInFrustum(frustumPlanes: Plane[]): boolean;
  81310. /**
  81311. * Checks if a cullable object (mesh...) is in the camera frustum
  81312. * Unlike isInFrustum this cheks the full bounding box
  81313. * @param frustumPlanes Camera near/planes
  81314. * @returns true if the object is in frustum otherwise false
  81315. */
  81316. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81317. }
  81318. /**
  81319. * Info for a bounding data of a mesh
  81320. */
  81321. export class BoundingInfo implements ICullable {
  81322. /**
  81323. * Bounding box for the mesh
  81324. */
  81325. readonly boundingBox: BoundingBox;
  81326. /**
  81327. * Bounding sphere for the mesh
  81328. */
  81329. readonly boundingSphere: BoundingSphere;
  81330. private _isLocked;
  81331. private static readonly TmpVector3;
  81332. /**
  81333. * Constructs bounding info
  81334. * @param minimum min vector of the bounding box/sphere
  81335. * @param maximum max vector of the bounding box/sphere
  81336. * @param worldMatrix defines the new world matrix
  81337. */
  81338. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81339. /**
  81340. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81341. * @param min defines the new minimum vector (in local space)
  81342. * @param max defines the new maximum vector (in local space)
  81343. * @param worldMatrix defines the new world matrix
  81344. */
  81345. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81346. /**
  81347. * min vector of the bounding box/sphere
  81348. */
  81349. get minimum(): Vector3;
  81350. /**
  81351. * max vector of the bounding box/sphere
  81352. */
  81353. get maximum(): Vector3;
  81354. /**
  81355. * If the info is locked and won't be updated to avoid perf overhead
  81356. */
  81357. get isLocked(): boolean;
  81358. set isLocked(value: boolean);
  81359. /**
  81360. * Updates the bounding sphere and box
  81361. * @param world world matrix to be used to update
  81362. */
  81363. update(world: DeepImmutable<Matrix>): void;
  81364. /**
  81365. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81366. * @param center New center of the bounding info
  81367. * @param extend New extend of the bounding info
  81368. * @returns the current bounding info
  81369. */
  81370. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81371. /**
  81372. * Scale the current bounding info by applying a scale factor
  81373. * @param factor defines the scale factor to apply
  81374. * @returns the current bounding info
  81375. */
  81376. scale(factor: number): BoundingInfo;
  81377. /**
  81378. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81379. * @param frustumPlanes defines the frustum to test
  81380. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81381. * @returns true if the bounding info is in the frustum planes
  81382. */
  81383. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81384. /**
  81385. * Gets the world distance between the min and max points of the bounding box
  81386. */
  81387. get diagonalLength(): number;
  81388. /**
  81389. * Checks if a cullable object (mesh...) is in the camera frustum
  81390. * Unlike isInFrustum this cheks the full bounding box
  81391. * @param frustumPlanes Camera near/planes
  81392. * @returns true if the object is in frustum otherwise false
  81393. */
  81394. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81395. /** @hidden */
  81396. _checkCollision(collider: Collider): boolean;
  81397. /**
  81398. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81399. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81400. * @param point the point to check intersection with
  81401. * @returns if the point intersects
  81402. */
  81403. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81404. /**
  81405. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81406. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81407. * @param boundingInfo the bounding info to check intersection with
  81408. * @param precise if the intersection should be done using OBB
  81409. * @returns if the bounding info intersects
  81410. */
  81411. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81412. }
  81413. }
  81414. declare module BABYLON {
  81415. /**
  81416. * Extracts minimum and maximum values from a list of indexed positions
  81417. * @param positions defines the positions to use
  81418. * @param indices defines the indices to the positions
  81419. * @param indexStart defines the start index
  81420. * @param indexCount defines the end index
  81421. * @param bias defines bias value to add to the result
  81422. * @return minimum and maximum values
  81423. */
  81424. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81425. minimum: Vector3;
  81426. maximum: Vector3;
  81427. };
  81428. /**
  81429. * Extracts minimum and maximum values from a list of positions
  81430. * @param positions defines the positions to use
  81431. * @param start defines the start index in the positions array
  81432. * @param count defines the number of positions to handle
  81433. * @param bias defines bias value to add to the result
  81434. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81435. * @return minimum and maximum values
  81436. */
  81437. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81438. minimum: Vector3;
  81439. maximum: Vector3;
  81440. };
  81441. }
  81442. declare module BABYLON {
  81443. /** @hidden */
  81444. export class WebGLDataBuffer extends DataBuffer {
  81445. private _buffer;
  81446. constructor(resource: WebGLBuffer);
  81447. get underlyingResource(): any;
  81448. }
  81449. }
  81450. declare module BABYLON {
  81451. /** @hidden */
  81452. export class WebGLPipelineContext implements IPipelineContext {
  81453. engine: ThinEngine;
  81454. program: Nullable<WebGLProgram>;
  81455. context?: WebGLRenderingContext;
  81456. vertexShader?: WebGLShader;
  81457. fragmentShader?: WebGLShader;
  81458. isParallelCompiled: boolean;
  81459. onCompiled?: () => void;
  81460. transformFeedback?: WebGLTransformFeedback | null;
  81461. vertexCompilationError: Nullable<string>;
  81462. fragmentCompilationError: Nullable<string>;
  81463. programLinkError: Nullable<string>;
  81464. programValidationError: Nullable<string>;
  81465. get isAsync(): boolean;
  81466. get isReady(): boolean;
  81467. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81468. _getVertexShaderCode(): string | null;
  81469. _getFragmentShaderCode(): string | null;
  81470. }
  81471. }
  81472. declare module BABYLON {
  81473. interface ThinEngine {
  81474. /**
  81475. * Create an uniform buffer
  81476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81477. * @param elements defines the content of the uniform buffer
  81478. * @returns the webGL uniform buffer
  81479. */
  81480. createUniformBuffer(elements: FloatArray): DataBuffer;
  81481. /**
  81482. * Create a dynamic uniform buffer
  81483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81484. * @param elements defines the content of the uniform buffer
  81485. * @returns the webGL uniform buffer
  81486. */
  81487. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81488. /**
  81489. * Update an existing uniform buffer
  81490. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81491. * @param uniformBuffer defines the target uniform buffer
  81492. * @param elements defines the content to update
  81493. * @param offset defines the offset in the uniform buffer where update should start
  81494. * @param count defines the size of the data to update
  81495. */
  81496. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81497. /**
  81498. * Bind an uniform buffer to the current webGL context
  81499. * @param buffer defines the buffer to bind
  81500. */
  81501. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81502. /**
  81503. * Bind a buffer to the current webGL context at a given location
  81504. * @param buffer defines the buffer to bind
  81505. * @param location defines the index where to bind the buffer
  81506. */
  81507. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81508. /**
  81509. * Bind a specific block at a given index in a specific shader program
  81510. * @param pipelineContext defines the pipeline context to use
  81511. * @param blockName defines the block name
  81512. * @param index defines the index where to bind the block
  81513. */
  81514. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /**
  81519. * Uniform buffer objects.
  81520. *
  81521. * Handles blocks of uniform on the GPU.
  81522. *
  81523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81524. *
  81525. * For more information, please refer to :
  81526. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81527. */
  81528. export class UniformBuffer {
  81529. private _engine;
  81530. private _buffer;
  81531. private _data;
  81532. private _bufferData;
  81533. private _dynamic?;
  81534. private _uniformLocations;
  81535. private _uniformSizes;
  81536. private _uniformLocationPointer;
  81537. private _needSync;
  81538. private _noUBO;
  81539. private _currentEffect;
  81540. /** @hidden */
  81541. _alreadyBound: boolean;
  81542. private static _MAX_UNIFORM_SIZE;
  81543. private static _tempBuffer;
  81544. /**
  81545. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81546. * This is dynamic to allow compat with webgl 1 and 2.
  81547. * You will need to pass the name of the uniform as well as the value.
  81548. */
  81549. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81550. /**
  81551. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81552. * This is dynamic to allow compat with webgl 1 and 2.
  81553. * You will need to pass the name of the uniform as well as the value.
  81554. */
  81555. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81556. /**
  81557. * Lambda to Update a single float in a uniform buffer.
  81558. * This is dynamic to allow compat with webgl 1 and 2.
  81559. * You will need to pass the name of the uniform as well as the value.
  81560. */
  81561. updateFloat: (name: string, x: number) => void;
  81562. /**
  81563. * Lambda to Update a vec2 of float in a uniform buffer.
  81564. * This is dynamic to allow compat with webgl 1 and 2.
  81565. * You will need to pass the name of the uniform as well as the value.
  81566. */
  81567. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81568. /**
  81569. * Lambda to Update a vec3 of float in a uniform buffer.
  81570. * This is dynamic to allow compat with webgl 1 and 2.
  81571. * You will need to pass the name of the uniform as well as the value.
  81572. */
  81573. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81574. /**
  81575. * Lambda to Update a vec4 of float in a uniform buffer.
  81576. * This is dynamic to allow compat with webgl 1 and 2.
  81577. * You will need to pass the name of the uniform as well as the value.
  81578. */
  81579. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81580. /**
  81581. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81582. * This is dynamic to allow compat with webgl 1 and 2.
  81583. * You will need to pass the name of the uniform as well as the value.
  81584. */
  81585. updateMatrix: (name: string, mat: Matrix) => void;
  81586. /**
  81587. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81588. * This is dynamic to allow compat with webgl 1 and 2.
  81589. * You will need to pass the name of the uniform as well as the value.
  81590. */
  81591. updateVector3: (name: string, vector: Vector3) => void;
  81592. /**
  81593. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81594. * This is dynamic to allow compat with webgl 1 and 2.
  81595. * You will need to pass the name of the uniform as well as the value.
  81596. */
  81597. updateVector4: (name: string, vector: Vector4) => void;
  81598. /**
  81599. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81600. * This is dynamic to allow compat with webgl 1 and 2.
  81601. * You will need to pass the name of the uniform as well as the value.
  81602. */
  81603. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81604. /**
  81605. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81606. * This is dynamic to allow compat with webgl 1 and 2.
  81607. * You will need to pass the name of the uniform as well as the value.
  81608. */
  81609. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81610. /**
  81611. * Instantiates a new Uniform buffer objects.
  81612. *
  81613. * Handles blocks of uniform on the GPU.
  81614. *
  81615. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81616. *
  81617. * For more information, please refer to :
  81618. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81619. * @param engine Define the engine the buffer is associated with
  81620. * @param data Define the data contained in the buffer
  81621. * @param dynamic Define if the buffer is updatable
  81622. */
  81623. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81624. /**
  81625. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81626. * or just falling back on setUniformXXX calls.
  81627. */
  81628. get useUbo(): boolean;
  81629. /**
  81630. * Indicates if the WebGL underlying uniform buffer is in sync
  81631. * with the javascript cache data.
  81632. */
  81633. get isSync(): boolean;
  81634. /**
  81635. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81636. * Also, a dynamic UniformBuffer will disable cache verification and always
  81637. * update the underlying WebGL uniform buffer to the GPU.
  81638. * @returns if Dynamic, otherwise false
  81639. */
  81640. isDynamic(): boolean;
  81641. /**
  81642. * The data cache on JS side.
  81643. * @returns the underlying data as a float array
  81644. */
  81645. getData(): Float32Array;
  81646. /**
  81647. * The underlying WebGL Uniform buffer.
  81648. * @returns the webgl buffer
  81649. */
  81650. getBuffer(): Nullable<DataBuffer>;
  81651. /**
  81652. * std140 layout specifies how to align data within an UBO structure.
  81653. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81654. * for specs.
  81655. */
  81656. private _fillAlignment;
  81657. /**
  81658. * Adds an uniform in the buffer.
  81659. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81660. * for the layout to be correct !
  81661. * @param name Name of the uniform, as used in the uniform block in the shader.
  81662. * @param size Data size, or data directly.
  81663. */
  81664. addUniform(name: string, size: number | number[]): void;
  81665. /**
  81666. * Adds a Matrix 4x4 to the uniform buffer.
  81667. * @param name Name of the uniform, as used in the uniform block in the shader.
  81668. * @param mat A 4x4 matrix.
  81669. */
  81670. addMatrix(name: string, mat: Matrix): void;
  81671. /**
  81672. * Adds a vec2 to the uniform buffer.
  81673. * @param name Name of the uniform, as used in the uniform block in the shader.
  81674. * @param x Define the x component value of the vec2
  81675. * @param y Define the y component value of the vec2
  81676. */
  81677. addFloat2(name: string, x: number, y: number): void;
  81678. /**
  81679. * Adds a vec3 to the uniform buffer.
  81680. * @param name Name of the uniform, as used in the uniform block in the shader.
  81681. * @param x Define the x component value of the vec3
  81682. * @param y Define the y component value of the vec3
  81683. * @param z Define the z component value of the vec3
  81684. */
  81685. addFloat3(name: string, x: number, y: number, z: 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 color Define the vec3 from a Color
  81690. */
  81691. addColor3(name: string, color: Color3): void;
  81692. /**
  81693. * Adds a vec4 to the uniform buffer.
  81694. * @param name Name of the uniform, as used in the uniform block in the shader.
  81695. * @param color Define the rgb components from a Color
  81696. * @param alpha Define the a component of the vec4
  81697. */
  81698. addColor4(name: string, color: Color3, alpha: number): void;
  81699. /**
  81700. * Adds a vec3 to the uniform buffer.
  81701. * @param name Name of the uniform, as used in the uniform block in the shader.
  81702. * @param vector Define the vec3 components from a Vector
  81703. */
  81704. addVector3(name: string, vector: Vector3): void;
  81705. /**
  81706. * Adds a Matrix 3x3 to the uniform buffer.
  81707. * @param name Name of the uniform, as used in the uniform block in the shader.
  81708. */
  81709. addMatrix3x3(name: string): void;
  81710. /**
  81711. * Adds a Matrix 2x2 to the uniform buffer.
  81712. * @param name Name of the uniform, as used in the uniform block in the shader.
  81713. */
  81714. addMatrix2x2(name: string): void;
  81715. /**
  81716. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81717. */
  81718. create(): void;
  81719. /** @hidden */
  81720. _rebuild(): void;
  81721. /**
  81722. * Updates the WebGL Uniform Buffer on the GPU.
  81723. * If the `dynamic` flag is set to true, no cache comparison is done.
  81724. * Otherwise, the buffer will be updated only if the cache differs.
  81725. */
  81726. update(): void;
  81727. /**
  81728. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81729. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81730. * @param data Define the flattened data
  81731. * @param size Define the size of the data.
  81732. */
  81733. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81734. private _valueCache;
  81735. private _cacheMatrix;
  81736. private _updateMatrix3x3ForUniform;
  81737. private _updateMatrix3x3ForEffect;
  81738. private _updateMatrix2x2ForEffect;
  81739. private _updateMatrix2x2ForUniform;
  81740. private _updateFloatForEffect;
  81741. private _updateFloatForUniform;
  81742. private _updateFloat2ForEffect;
  81743. private _updateFloat2ForUniform;
  81744. private _updateFloat3ForEffect;
  81745. private _updateFloat3ForUniform;
  81746. private _updateFloat4ForEffect;
  81747. private _updateFloat4ForUniform;
  81748. private _updateMatrixForEffect;
  81749. private _updateMatrixForUniform;
  81750. private _updateVector3ForEffect;
  81751. private _updateVector3ForUniform;
  81752. private _updateVector4ForEffect;
  81753. private _updateVector4ForUniform;
  81754. private _updateColor3ForEffect;
  81755. private _updateColor3ForUniform;
  81756. private _updateColor4ForEffect;
  81757. private _updateColor4ForUniform;
  81758. /**
  81759. * Sets a sampler uniform on the effect.
  81760. * @param name Define the name of the sampler.
  81761. * @param texture Define the texture to set in the sampler
  81762. */
  81763. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81764. /**
  81765. * Directly updates the value of the uniform in the cache AND on the GPU.
  81766. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81767. * @param data Define the flattened data
  81768. */
  81769. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81770. /**
  81771. * Binds this uniform buffer to an effect.
  81772. * @param effect Define the effect to bind the buffer to
  81773. * @param name Name of the uniform block in the shader.
  81774. */
  81775. bindToEffect(effect: Effect, name: string): void;
  81776. /**
  81777. * Disposes the uniform buffer.
  81778. */
  81779. dispose(): void;
  81780. }
  81781. }
  81782. declare module BABYLON {
  81783. /**
  81784. * Enum that determines the text-wrapping mode to use.
  81785. */
  81786. export enum InspectableType {
  81787. /**
  81788. * Checkbox for booleans
  81789. */
  81790. Checkbox = 0,
  81791. /**
  81792. * Sliders for numbers
  81793. */
  81794. Slider = 1,
  81795. /**
  81796. * Vector3
  81797. */
  81798. Vector3 = 2,
  81799. /**
  81800. * Quaternions
  81801. */
  81802. Quaternion = 3,
  81803. /**
  81804. * Color3
  81805. */
  81806. Color3 = 4,
  81807. /**
  81808. * String
  81809. */
  81810. String = 5
  81811. }
  81812. /**
  81813. * Interface used to define custom inspectable properties.
  81814. * This interface is used by the inspector to display custom property grids
  81815. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81816. */
  81817. export interface IInspectable {
  81818. /**
  81819. * Gets the label to display
  81820. */
  81821. label: string;
  81822. /**
  81823. * Gets the name of the property to edit
  81824. */
  81825. propertyName: string;
  81826. /**
  81827. * Gets the type of the editor to use
  81828. */
  81829. type: InspectableType;
  81830. /**
  81831. * Gets the minimum value of the property when using in "slider" mode
  81832. */
  81833. min?: number;
  81834. /**
  81835. * Gets the maximum value of the property when using in "slider" mode
  81836. */
  81837. max?: number;
  81838. /**
  81839. * Gets the setp to use when using in "slider" mode
  81840. */
  81841. step?: number;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. /**
  81846. * Class used to provide helper for timing
  81847. */
  81848. export class TimingTools {
  81849. /**
  81850. * Polyfill for setImmediate
  81851. * @param action defines the action to execute after the current execution block
  81852. */
  81853. static SetImmediate(action: () => void): void;
  81854. }
  81855. }
  81856. declare module BABYLON {
  81857. /**
  81858. * Class used to enable instatition of objects by class name
  81859. */
  81860. export class InstantiationTools {
  81861. /**
  81862. * Use this object to register external classes like custom textures or material
  81863. * to allow the laoders to instantiate them
  81864. */
  81865. static RegisteredExternalClasses: {
  81866. [key: string]: Object;
  81867. };
  81868. /**
  81869. * Tries to instantiate a new object from a given class name
  81870. * @param className defines the class name to instantiate
  81871. * @returns the new object or null if the system was not able to do the instantiation
  81872. */
  81873. static Instantiate(className: string): any;
  81874. }
  81875. }
  81876. declare module BABYLON {
  81877. /**
  81878. * Define options used to create a depth texture
  81879. */
  81880. export class DepthTextureCreationOptions {
  81881. /** Specifies whether or not a stencil should be allocated in the texture */
  81882. generateStencil?: boolean;
  81883. /** Specifies whether or not bilinear filtering is enable on the texture */
  81884. bilinearFiltering?: boolean;
  81885. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81886. comparisonFunction?: number;
  81887. /** Specifies if the created texture is a cube texture */
  81888. isCube?: boolean;
  81889. }
  81890. }
  81891. declare module BABYLON {
  81892. interface ThinEngine {
  81893. /**
  81894. * Creates a depth stencil cube texture.
  81895. * This is only available in WebGL 2.
  81896. * @param size The size of face edge in the cube texture.
  81897. * @param options The options defining the cube texture.
  81898. * @returns The cube texture
  81899. */
  81900. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81901. /**
  81902. * Creates a cube texture
  81903. * @param rootUrl defines the url where the files to load is located
  81904. * @param scene defines the current scene
  81905. * @param files defines the list of files to load (1 per face)
  81906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81907. * @param onLoad defines an optional callback raised when the texture is loaded
  81908. * @param onError defines an optional callback raised if there is an issue to load the texture
  81909. * @param format defines the format of the data
  81910. * @param forcedExtension defines the extension to use to pick the right loader
  81911. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81912. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81913. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81914. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81915. * @returns the cube texture as an InternalTexture
  81916. */
  81917. 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;
  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. * @returns the cube texture as an InternalTexture
  81929. */
  81930. 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;
  81931. /**
  81932. * Creates a cube texture
  81933. * @param rootUrl defines the url where the files to load is located
  81934. * @param scene defines the current scene
  81935. * @param files defines the list of files to load (1 per face)
  81936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81937. * @param onLoad defines an optional callback raised when the texture is loaded
  81938. * @param onError defines an optional callback raised if there is an issue to load the texture
  81939. * @param format defines the format of the data
  81940. * @param forcedExtension defines the extension to use to pick the right loader
  81941. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81944. * @returns the cube texture as an InternalTexture
  81945. */
  81946. 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;
  81947. /** @hidden */
  81948. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81949. /** @hidden */
  81950. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81951. /** @hidden */
  81952. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81953. /** @hidden */
  81954. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81955. /**
  81956. * @hidden
  81957. */
  81958. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * Class for creating a cube texture
  81964. */
  81965. export class CubeTexture extends BaseTexture {
  81966. private _delayedOnLoad;
  81967. /**
  81968. * Observable triggered once the texture has been loaded.
  81969. */
  81970. onLoadObservable: Observable<CubeTexture>;
  81971. /**
  81972. * The url of the texture
  81973. */
  81974. url: string;
  81975. /**
  81976. * Gets or sets the center of the bounding box associated with the cube texture.
  81977. * It must define where the camera used to render the texture was set
  81978. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81979. */
  81980. boundingBoxPosition: Vector3;
  81981. private _boundingBoxSize;
  81982. /**
  81983. * Gets or sets the size of the bounding box associated with the cube texture
  81984. * When defined, the cubemap will switch to local mode
  81985. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81986. * @example https://www.babylonjs-playground.com/#RNASML
  81987. */
  81988. set boundingBoxSize(value: Vector3);
  81989. /**
  81990. * Returns the bounding box size
  81991. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81992. */
  81993. get boundingBoxSize(): Vector3;
  81994. protected _rotationY: number;
  81995. /**
  81996. * Sets texture matrix rotation angle around Y axis in radians.
  81997. */
  81998. set rotationY(value: number);
  81999. /**
  82000. * Gets texture matrix rotation angle around Y axis radians.
  82001. */
  82002. get rotationY(): number;
  82003. /**
  82004. * Are mip maps generated for this texture or not.
  82005. */
  82006. get noMipmap(): boolean;
  82007. private _noMipmap;
  82008. private _files;
  82009. protected _forcedExtension: Nullable<string>;
  82010. private _extensions;
  82011. private _textureMatrix;
  82012. private _format;
  82013. private _createPolynomials;
  82014. /** @hidden */
  82015. _prefiltered: boolean;
  82016. /**
  82017. * Creates a cube texture from an array of image urls
  82018. * @param files defines an array of image urls
  82019. * @param scene defines the hosting scene
  82020. * @param noMipmap specifies if mip maps are not used
  82021. * @returns a cube texture
  82022. */
  82023. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82024. /**
  82025. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82026. * @param url defines the url of the prefiltered texture
  82027. * @param scene defines the scene the texture is attached to
  82028. * @param forcedExtension defines the extension of the file if different from the url
  82029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82030. * @return the prefiltered texture
  82031. */
  82032. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82033. /**
  82034. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82035. * as prefiltered data.
  82036. * @param rootUrl defines the url of the texture or the root name of the six images
  82037. * @param scene defines the scene the texture is attached to
  82038. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82039. * @param noMipmap defines if mipmaps should be created or not
  82040. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82041. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82042. * @param onError defines a callback triggered in case of error during load
  82043. * @param format defines the internal format to use for the texture once loaded
  82044. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82045. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82046. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82047. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82048. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82049. * @return the cube texture
  82050. */
  82051. 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);
  82052. /**
  82053. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82054. */
  82055. get isPrefiltered(): boolean;
  82056. /**
  82057. * Get the current class name of the texture useful for serialization or dynamic coding.
  82058. * @returns "CubeTexture"
  82059. */
  82060. getClassName(): string;
  82061. /**
  82062. * Update the url (and optional buffer) of this texture if url was null during construction.
  82063. * @param url the url of the texture
  82064. * @param forcedExtension defines the extension to use
  82065. * @param onLoad callback called when the texture is loaded (defaults to null)
  82066. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82067. */
  82068. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82069. /**
  82070. * Delays loading of the cube texture
  82071. * @param forcedExtension defines the extension to use
  82072. */
  82073. delayLoad(forcedExtension?: string): void;
  82074. /**
  82075. * Returns the reflection texture matrix
  82076. * @returns the reflection texture matrix
  82077. */
  82078. getReflectionTextureMatrix(): Matrix;
  82079. /**
  82080. * Sets the reflection texture matrix
  82081. * @param value Reflection texture matrix
  82082. */
  82083. setReflectionTextureMatrix(value: Matrix): void;
  82084. /**
  82085. * Parses text to create a cube texture
  82086. * @param parsedTexture define the serialized text to read from
  82087. * @param scene defines the hosting scene
  82088. * @param rootUrl defines the root url of the cube texture
  82089. * @returns a cube texture
  82090. */
  82091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82092. /**
  82093. * Makes a clone, or deep copy, of the cube texture
  82094. * @returns a new cube texture
  82095. */
  82096. clone(): CubeTexture;
  82097. }
  82098. }
  82099. declare module BABYLON {
  82100. /**
  82101. * Manages the defines for the Material
  82102. */
  82103. export class MaterialDefines {
  82104. /** @hidden */
  82105. protected _keys: string[];
  82106. private _isDirty;
  82107. /** @hidden */
  82108. _renderId: number;
  82109. /** @hidden */
  82110. _areLightsDirty: boolean;
  82111. /** @hidden */
  82112. _areLightsDisposed: boolean;
  82113. /** @hidden */
  82114. _areAttributesDirty: boolean;
  82115. /** @hidden */
  82116. _areTexturesDirty: boolean;
  82117. /** @hidden */
  82118. _areFresnelDirty: boolean;
  82119. /** @hidden */
  82120. _areMiscDirty: boolean;
  82121. /** @hidden */
  82122. _areImageProcessingDirty: boolean;
  82123. /** @hidden */
  82124. _normals: boolean;
  82125. /** @hidden */
  82126. _uvs: boolean;
  82127. /** @hidden */
  82128. _needNormals: boolean;
  82129. /** @hidden */
  82130. _needUVs: boolean;
  82131. [id: string]: any;
  82132. /**
  82133. * Specifies if the material needs to be re-calculated
  82134. */
  82135. get isDirty(): boolean;
  82136. /**
  82137. * Marks the material to indicate that it has been re-calculated
  82138. */
  82139. markAsProcessed(): void;
  82140. /**
  82141. * Marks the material to indicate that it needs to be re-calculated
  82142. */
  82143. markAsUnprocessed(): void;
  82144. /**
  82145. * Marks the material to indicate all of its defines need to be re-calculated
  82146. */
  82147. markAllAsDirty(): void;
  82148. /**
  82149. * Marks the material to indicate that image processing needs to be re-calculated
  82150. */
  82151. markAsImageProcessingDirty(): void;
  82152. /**
  82153. * Marks the material to indicate the lights need to be re-calculated
  82154. * @param disposed Defines whether the light is dirty due to dispose or not
  82155. */
  82156. markAsLightDirty(disposed?: boolean): void;
  82157. /**
  82158. * Marks the attribute state as changed
  82159. */
  82160. markAsAttributesDirty(): void;
  82161. /**
  82162. * Marks the texture state as changed
  82163. */
  82164. markAsTexturesDirty(): void;
  82165. /**
  82166. * Marks the fresnel state as changed
  82167. */
  82168. markAsFresnelDirty(): void;
  82169. /**
  82170. * Marks the misc state as changed
  82171. */
  82172. markAsMiscDirty(): void;
  82173. /**
  82174. * Rebuilds the material defines
  82175. */
  82176. rebuild(): void;
  82177. /**
  82178. * Specifies if two material defines are equal
  82179. * @param other - A material define instance to compare to
  82180. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82181. */
  82182. isEqual(other: MaterialDefines): boolean;
  82183. /**
  82184. * Clones this instance's defines to another instance
  82185. * @param other - material defines to clone values to
  82186. */
  82187. cloneTo(other: MaterialDefines): void;
  82188. /**
  82189. * Resets the material define values
  82190. */
  82191. reset(): void;
  82192. /**
  82193. * Converts the material define values to a string
  82194. * @returns - String of material define information
  82195. */
  82196. toString(): string;
  82197. }
  82198. }
  82199. declare module BABYLON {
  82200. /**
  82201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82203. * 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;
  82204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82205. */
  82206. export class ColorCurves {
  82207. private _dirty;
  82208. private _tempColor;
  82209. private _globalCurve;
  82210. private _highlightsCurve;
  82211. private _midtonesCurve;
  82212. private _shadowsCurve;
  82213. private _positiveCurve;
  82214. private _negativeCurve;
  82215. private _globalHue;
  82216. private _globalDensity;
  82217. private _globalSaturation;
  82218. private _globalExposure;
  82219. /**
  82220. * Gets the global Hue value.
  82221. * 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).
  82222. */
  82223. get globalHue(): number;
  82224. /**
  82225. * Sets the global Hue value.
  82226. * 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).
  82227. */
  82228. set globalHue(value: number);
  82229. /**
  82230. * Gets the global Density value.
  82231. * 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.
  82232. * Values less than zero provide a filter of opposite hue.
  82233. */
  82234. get globalDensity(): number;
  82235. /**
  82236. * Sets the global Density value.
  82237. * 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.
  82238. * Values less than zero provide a filter of opposite hue.
  82239. */
  82240. set globalDensity(value: number);
  82241. /**
  82242. * Gets the global Saturation value.
  82243. * 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.
  82244. */
  82245. get globalSaturation(): number;
  82246. /**
  82247. * Sets the global Saturation value.
  82248. * 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.
  82249. */
  82250. set globalSaturation(value: number);
  82251. /**
  82252. * Gets the global Exposure value.
  82253. * 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.
  82254. */
  82255. get globalExposure(): number;
  82256. /**
  82257. * Sets the global Exposure value.
  82258. * 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.
  82259. */
  82260. set globalExposure(value: number);
  82261. private _highlightsHue;
  82262. private _highlightsDensity;
  82263. private _highlightsSaturation;
  82264. private _highlightsExposure;
  82265. /**
  82266. * Gets the highlights Hue value.
  82267. * 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).
  82268. */
  82269. get highlightsHue(): number;
  82270. /**
  82271. * Sets the highlights Hue value.
  82272. * 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).
  82273. */
  82274. set highlightsHue(value: number);
  82275. /**
  82276. * Gets the highlights Density value.
  82277. * 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.
  82278. * Values less than zero provide a filter of opposite hue.
  82279. */
  82280. get highlightsDensity(): number;
  82281. /**
  82282. * Sets the highlights Density value.
  82283. * 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.
  82284. * Values less than zero provide a filter of opposite hue.
  82285. */
  82286. set highlightsDensity(value: number);
  82287. /**
  82288. * Gets the highlights Saturation value.
  82289. * 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.
  82290. */
  82291. get highlightsSaturation(): number;
  82292. /**
  82293. * Sets the highlights Saturation value.
  82294. * 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.
  82295. */
  82296. set highlightsSaturation(value: number);
  82297. /**
  82298. * Gets the highlights Exposure value.
  82299. * 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.
  82300. */
  82301. get highlightsExposure(): number;
  82302. /**
  82303. * Sets the highlights Exposure value.
  82304. * 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.
  82305. */
  82306. set highlightsExposure(value: number);
  82307. private _midtonesHue;
  82308. private _midtonesDensity;
  82309. private _midtonesSaturation;
  82310. private _midtonesExposure;
  82311. /**
  82312. * Gets the midtones Hue value.
  82313. * 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).
  82314. */
  82315. get midtonesHue(): number;
  82316. /**
  82317. * Sets the midtones Hue value.
  82318. * 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).
  82319. */
  82320. set midtonesHue(value: number);
  82321. /**
  82322. * Gets the midtones Density value.
  82323. * 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.
  82324. * Values less than zero provide a filter of opposite hue.
  82325. */
  82326. get midtonesDensity(): number;
  82327. /**
  82328. * Sets the midtones Density value.
  82329. * 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.
  82330. * Values less than zero provide a filter of opposite hue.
  82331. */
  82332. set midtonesDensity(value: number);
  82333. /**
  82334. * Gets the midtones Saturation value.
  82335. * 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.
  82336. */
  82337. get midtonesSaturation(): number;
  82338. /**
  82339. * Sets the midtones Saturation value.
  82340. * 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.
  82341. */
  82342. set midtonesSaturation(value: number);
  82343. /**
  82344. * Gets the midtones Exposure value.
  82345. * 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.
  82346. */
  82347. get midtonesExposure(): number;
  82348. /**
  82349. * Sets the midtones Exposure value.
  82350. * 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.
  82351. */
  82352. set midtonesExposure(value: number);
  82353. private _shadowsHue;
  82354. private _shadowsDensity;
  82355. private _shadowsSaturation;
  82356. private _shadowsExposure;
  82357. /**
  82358. * Gets the shadows Hue value.
  82359. * 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).
  82360. */
  82361. get shadowsHue(): number;
  82362. /**
  82363. * Sets the shadows Hue value.
  82364. * 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).
  82365. */
  82366. set shadowsHue(value: number);
  82367. /**
  82368. * Gets the shadows Density value.
  82369. * 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.
  82370. * Values less than zero provide a filter of opposite hue.
  82371. */
  82372. get shadowsDensity(): number;
  82373. /**
  82374. * Sets the shadows Density value.
  82375. * 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.
  82376. * Values less than zero provide a filter of opposite hue.
  82377. */
  82378. set shadowsDensity(value: number);
  82379. /**
  82380. * Gets the shadows Saturation value.
  82381. * 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.
  82382. */
  82383. get shadowsSaturation(): number;
  82384. /**
  82385. * Sets the shadows Saturation value.
  82386. * 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.
  82387. */
  82388. set shadowsSaturation(value: number);
  82389. /**
  82390. * Gets the shadows Exposure value.
  82391. * 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.
  82392. */
  82393. get shadowsExposure(): number;
  82394. /**
  82395. * Sets the shadows Exposure value.
  82396. * 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.
  82397. */
  82398. set shadowsExposure(value: number);
  82399. /**
  82400. * Returns the class name
  82401. * @returns The class name
  82402. */
  82403. getClassName(): string;
  82404. /**
  82405. * Binds the color curves to the shader.
  82406. * @param colorCurves The color curve to bind
  82407. * @param effect The effect to bind to
  82408. * @param positiveUniform The positive uniform shader parameter
  82409. * @param neutralUniform The neutral uniform shader parameter
  82410. * @param negativeUniform The negative uniform shader parameter
  82411. */
  82412. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82413. /**
  82414. * Prepare the list of uniforms associated with the ColorCurves effects.
  82415. * @param uniformsList The list of uniforms used in the effect
  82416. */
  82417. static PrepareUniforms(uniformsList: string[]): void;
  82418. /**
  82419. * Returns color grading data based on a hue, density, saturation and exposure value.
  82420. * @param filterHue The hue of the color filter.
  82421. * @param filterDensity The density of the color filter.
  82422. * @param saturation The saturation.
  82423. * @param exposure The exposure.
  82424. * @param result The result data container.
  82425. */
  82426. private getColorGradingDataToRef;
  82427. /**
  82428. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82429. * @param value The input slider value in range [-100,100].
  82430. * @returns Adjusted value.
  82431. */
  82432. private static applyColorGradingSliderNonlinear;
  82433. /**
  82434. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82435. * @param hue The hue (H) input.
  82436. * @param saturation The saturation (S) input.
  82437. * @param brightness The brightness (B) input.
  82438. * @result An RGBA color represented as Vector4.
  82439. */
  82440. private static fromHSBToRef;
  82441. /**
  82442. * Returns a value clamped between min and max
  82443. * @param value The value to clamp
  82444. * @param min The minimum of value
  82445. * @param max The maximum of value
  82446. * @returns The clamped value.
  82447. */
  82448. private static clamp;
  82449. /**
  82450. * Clones the current color curve instance.
  82451. * @return The cloned curves
  82452. */
  82453. clone(): ColorCurves;
  82454. /**
  82455. * Serializes the current color curve instance to a json representation.
  82456. * @return a JSON representation
  82457. */
  82458. serialize(): any;
  82459. /**
  82460. * Parses the color curve from a json representation.
  82461. * @param source the JSON source to parse
  82462. * @return The parsed curves
  82463. */
  82464. static Parse(source: any): ColorCurves;
  82465. }
  82466. }
  82467. declare module BABYLON {
  82468. /**
  82469. * Interface to follow in your material defines to integrate easily the
  82470. * Image proccessing functions.
  82471. * @hidden
  82472. */
  82473. export interface IImageProcessingConfigurationDefines {
  82474. IMAGEPROCESSING: boolean;
  82475. VIGNETTE: boolean;
  82476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82477. VIGNETTEBLENDMODEOPAQUE: boolean;
  82478. TONEMAPPING: boolean;
  82479. TONEMAPPING_ACES: boolean;
  82480. CONTRAST: boolean;
  82481. EXPOSURE: boolean;
  82482. COLORCURVES: boolean;
  82483. COLORGRADING: boolean;
  82484. COLORGRADING3D: boolean;
  82485. SAMPLER3DGREENDEPTH: boolean;
  82486. SAMPLER3DBGRMAP: boolean;
  82487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82488. }
  82489. /**
  82490. * @hidden
  82491. */
  82492. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82493. IMAGEPROCESSING: boolean;
  82494. VIGNETTE: boolean;
  82495. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82496. VIGNETTEBLENDMODEOPAQUE: boolean;
  82497. TONEMAPPING: boolean;
  82498. TONEMAPPING_ACES: boolean;
  82499. CONTRAST: boolean;
  82500. COLORCURVES: boolean;
  82501. COLORGRADING: boolean;
  82502. COLORGRADING3D: boolean;
  82503. SAMPLER3DGREENDEPTH: boolean;
  82504. SAMPLER3DBGRMAP: boolean;
  82505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82506. EXPOSURE: boolean;
  82507. constructor();
  82508. }
  82509. /**
  82510. * This groups together the common properties used for image processing either in direct forward pass
  82511. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82512. * or not.
  82513. */
  82514. export class ImageProcessingConfiguration {
  82515. /**
  82516. * Default tone mapping applied in BabylonJS.
  82517. */
  82518. static readonly TONEMAPPING_STANDARD: number;
  82519. /**
  82520. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82521. * to other engines rendering to increase portability.
  82522. */
  82523. static readonly TONEMAPPING_ACES: number;
  82524. /**
  82525. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82526. */
  82527. colorCurves: Nullable<ColorCurves>;
  82528. private _colorCurvesEnabled;
  82529. /**
  82530. * Gets wether the color curves effect is enabled.
  82531. */
  82532. get colorCurvesEnabled(): boolean;
  82533. /**
  82534. * Sets wether the color curves effect is enabled.
  82535. */
  82536. set colorCurvesEnabled(value: boolean);
  82537. private _colorGradingTexture;
  82538. /**
  82539. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82540. */
  82541. get colorGradingTexture(): Nullable<BaseTexture>;
  82542. /**
  82543. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82544. */
  82545. set colorGradingTexture(value: Nullable<BaseTexture>);
  82546. private _colorGradingEnabled;
  82547. /**
  82548. * Gets wether the color grading effect is enabled.
  82549. */
  82550. get colorGradingEnabled(): boolean;
  82551. /**
  82552. * Sets wether the color grading effect is enabled.
  82553. */
  82554. set colorGradingEnabled(value: boolean);
  82555. private _colorGradingWithGreenDepth;
  82556. /**
  82557. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82558. */
  82559. get colorGradingWithGreenDepth(): boolean;
  82560. /**
  82561. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82562. */
  82563. set colorGradingWithGreenDepth(value: boolean);
  82564. private _colorGradingBGR;
  82565. /**
  82566. * Gets wether the color grading texture contains BGR values.
  82567. */
  82568. get colorGradingBGR(): boolean;
  82569. /**
  82570. * Sets wether the color grading texture contains BGR values.
  82571. */
  82572. set colorGradingBGR(value: boolean);
  82573. /** @hidden */
  82574. _exposure: number;
  82575. /**
  82576. * Gets the Exposure used in the effect.
  82577. */
  82578. get exposure(): number;
  82579. /**
  82580. * Sets the Exposure used in the effect.
  82581. */
  82582. set exposure(value: number);
  82583. private _toneMappingEnabled;
  82584. /**
  82585. * Gets wether the tone mapping effect is enabled.
  82586. */
  82587. get toneMappingEnabled(): boolean;
  82588. /**
  82589. * Sets wether the tone mapping effect is enabled.
  82590. */
  82591. set toneMappingEnabled(value: boolean);
  82592. private _toneMappingType;
  82593. /**
  82594. * Gets the type of tone mapping effect.
  82595. */
  82596. get toneMappingType(): number;
  82597. /**
  82598. * Sets the type of tone mapping effect used in BabylonJS.
  82599. */
  82600. set toneMappingType(value: number);
  82601. protected _contrast: number;
  82602. /**
  82603. * Gets the contrast used in the effect.
  82604. */
  82605. get contrast(): number;
  82606. /**
  82607. * Sets the contrast used in the effect.
  82608. */
  82609. set contrast(value: number);
  82610. /**
  82611. * Vignette stretch size.
  82612. */
  82613. vignetteStretch: number;
  82614. /**
  82615. * Vignette centre X Offset.
  82616. */
  82617. vignetteCentreX: number;
  82618. /**
  82619. * Vignette centre Y Offset.
  82620. */
  82621. vignetteCentreY: number;
  82622. /**
  82623. * Vignette weight or intensity of the vignette effect.
  82624. */
  82625. vignetteWeight: number;
  82626. /**
  82627. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82628. * if vignetteEnabled is set to true.
  82629. */
  82630. vignetteColor: Color4;
  82631. /**
  82632. * Camera field of view used by the Vignette effect.
  82633. */
  82634. vignetteCameraFov: number;
  82635. private _vignetteBlendMode;
  82636. /**
  82637. * Gets the vignette blend mode allowing different kind of effect.
  82638. */
  82639. get vignetteBlendMode(): number;
  82640. /**
  82641. * Sets the vignette blend mode allowing different kind of effect.
  82642. */
  82643. set vignetteBlendMode(value: number);
  82644. private _vignetteEnabled;
  82645. /**
  82646. * Gets wether the vignette effect is enabled.
  82647. */
  82648. get vignetteEnabled(): boolean;
  82649. /**
  82650. * Sets wether the vignette effect is enabled.
  82651. */
  82652. set vignetteEnabled(value: boolean);
  82653. private _applyByPostProcess;
  82654. /**
  82655. * Gets wether the image processing is applied through a post process or not.
  82656. */
  82657. get applyByPostProcess(): boolean;
  82658. /**
  82659. * Sets wether the image processing is applied through a post process or not.
  82660. */
  82661. set applyByPostProcess(value: boolean);
  82662. private _isEnabled;
  82663. /**
  82664. * Gets wether the image processing is enabled or not.
  82665. */
  82666. get isEnabled(): boolean;
  82667. /**
  82668. * Sets wether the image processing is enabled or not.
  82669. */
  82670. set isEnabled(value: boolean);
  82671. /**
  82672. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82673. */
  82674. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82675. /**
  82676. * Method called each time the image processing information changes requires to recompile the effect.
  82677. */
  82678. protected _updateParameters(): void;
  82679. /**
  82680. * Gets the current class name.
  82681. * @return "ImageProcessingConfiguration"
  82682. */
  82683. getClassName(): string;
  82684. /**
  82685. * Prepare the list of uniforms associated with the Image Processing effects.
  82686. * @param uniforms The list of uniforms used in the effect
  82687. * @param defines the list of defines currently in use
  82688. */
  82689. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82690. /**
  82691. * Prepare the list of samplers associated with the Image Processing effects.
  82692. * @param samplersList The list of uniforms used in the effect
  82693. * @param defines the list of defines currently in use
  82694. */
  82695. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82696. /**
  82697. * Prepare the list of defines associated to the shader.
  82698. * @param defines the list of defines to complete
  82699. * @param forPostProcess Define if we are currently in post process mode or not
  82700. */
  82701. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82702. /**
  82703. * Returns true if all the image processing information are ready.
  82704. * @returns True if ready, otherwise, false
  82705. */
  82706. isReady(): boolean;
  82707. /**
  82708. * Binds the image processing to the shader.
  82709. * @param effect The effect to bind to
  82710. * @param overrideAspectRatio Override the aspect ratio of the effect
  82711. */
  82712. bind(effect: Effect, overrideAspectRatio?: number): void;
  82713. /**
  82714. * Clones the current image processing instance.
  82715. * @return The cloned image processing
  82716. */
  82717. clone(): ImageProcessingConfiguration;
  82718. /**
  82719. * Serializes the current image processing instance to a json representation.
  82720. * @return a JSON representation
  82721. */
  82722. serialize(): any;
  82723. /**
  82724. * Parses the image processing from a json representation.
  82725. * @param source the JSON source to parse
  82726. * @return The parsed image processing
  82727. */
  82728. static Parse(source: any): ImageProcessingConfiguration;
  82729. private static _VIGNETTEMODE_MULTIPLY;
  82730. private static _VIGNETTEMODE_OPAQUE;
  82731. /**
  82732. * Used to apply the vignette as a mix with the pixel color.
  82733. */
  82734. static get VIGNETTEMODE_MULTIPLY(): number;
  82735. /**
  82736. * Used to apply the vignette as a replacement of the pixel color.
  82737. */
  82738. static get VIGNETTEMODE_OPAQUE(): number;
  82739. }
  82740. }
  82741. declare module BABYLON {
  82742. /** @hidden */
  82743. export var postprocessVertexShader: {
  82744. name: string;
  82745. shader: string;
  82746. };
  82747. }
  82748. declare module BABYLON {
  82749. interface ThinEngine {
  82750. /**
  82751. * Creates a new render target texture
  82752. * @param size defines the size of the texture
  82753. * @param options defines the options used to create the texture
  82754. * @returns a new render target texture stored in an InternalTexture
  82755. */
  82756. createRenderTargetTexture(size: number | {
  82757. width: number;
  82758. height: number;
  82759. layers?: number;
  82760. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82761. /**
  82762. * Creates a depth stencil texture.
  82763. * This is only available in WebGL 2 or with the depth texture extension available.
  82764. * @param size The size of face edge in the texture.
  82765. * @param options The options defining the texture.
  82766. * @returns The texture
  82767. */
  82768. createDepthStencilTexture(size: number | {
  82769. width: number;
  82770. height: number;
  82771. layers?: number;
  82772. }, options: DepthTextureCreationOptions): InternalTexture;
  82773. /** @hidden */
  82774. _createDepthStencilTexture(size: number | {
  82775. width: number;
  82776. height: number;
  82777. layers?: number;
  82778. }, options: DepthTextureCreationOptions): InternalTexture;
  82779. }
  82780. }
  82781. declare module BABYLON {
  82782. /** Defines supported spaces */
  82783. export enum Space {
  82784. /** Local (object) space */
  82785. LOCAL = 0,
  82786. /** World space */
  82787. WORLD = 1,
  82788. /** Bone space */
  82789. BONE = 2
  82790. }
  82791. /** Defines the 3 main axes */
  82792. export class Axis {
  82793. /** X axis */
  82794. static X: Vector3;
  82795. /** Y axis */
  82796. static Y: Vector3;
  82797. /** Z axis */
  82798. static Z: Vector3;
  82799. }
  82800. }
  82801. declare module BABYLON {
  82802. /**
  82803. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82804. * This is the base of the follow, arc rotate cameras and Free camera
  82805. * @see http://doc.babylonjs.com/features/cameras
  82806. */
  82807. export class TargetCamera extends Camera {
  82808. private static _RigCamTransformMatrix;
  82809. private static _TargetTransformMatrix;
  82810. private static _TargetFocalPoint;
  82811. /**
  82812. * Define the current direction the camera is moving to
  82813. */
  82814. cameraDirection: Vector3;
  82815. /**
  82816. * Define the current rotation the camera is rotating to
  82817. */
  82818. cameraRotation: Vector2;
  82819. /**
  82820. * When set, the up vector of the camera will be updated by the rotation of the camera
  82821. */
  82822. updateUpVectorFromRotation: boolean;
  82823. private _tmpQuaternion;
  82824. /**
  82825. * Define the current rotation of the camera
  82826. */
  82827. rotation: Vector3;
  82828. /**
  82829. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82830. */
  82831. rotationQuaternion: Quaternion;
  82832. /**
  82833. * Define the current speed of the camera
  82834. */
  82835. speed: number;
  82836. /**
  82837. * Add constraint to the camera to prevent it to move freely in all directions and
  82838. * around all axis.
  82839. */
  82840. noRotationConstraint: boolean;
  82841. /**
  82842. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82843. * panning
  82844. */
  82845. invertRotation: boolean;
  82846. /**
  82847. * Speed multiplier for inverse camera panning
  82848. */
  82849. inverseRotationSpeed: number;
  82850. /**
  82851. * Define the current target of the camera as an object or a position.
  82852. */
  82853. lockedTarget: any;
  82854. /** @hidden */
  82855. _currentTarget: Vector3;
  82856. /** @hidden */
  82857. _initialFocalDistance: number;
  82858. /** @hidden */
  82859. _viewMatrix: Matrix;
  82860. /** @hidden */
  82861. _camMatrix: Matrix;
  82862. /** @hidden */
  82863. _cameraTransformMatrix: Matrix;
  82864. /** @hidden */
  82865. _cameraRotationMatrix: Matrix;
  82866. /** @hidden */
  82867. _referencePoint: Vector3;
  82868. /** @hidden */
  82869. _transformedReferencePoint: Vector3;
  82870. protected _globalCurrentTarget: Vector3;
  82871. protected _globalCurrentUpVector: Vector3;
  82872. /** @hidden */
  82873. _reset: () => void;
  82874. private _defaultUp;
  82875. /**
  82876. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82877. * This is the base of the follow, arc rotate cameras and Free camera
  82878. * @see http://doc.babylonjs.com/features/cameras
  82879. * @param name Defines the name of the camera in the scene
  82880. * @param position Defines the start position of the camera in the scene
  82881. * @param scene Defines the scene the camera belongs to
  82882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82883. */
  82884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82885. /**
  82886. * Gets the position in front of the camera at a given distance.
  82887. * @param distance The distance from the camera we want the position to be
  82888. * @returns the position
  82889. */
  82890. getFrontPosition(distance: number): Vector3;
  82891. /** @hidden */
  82892. _getLockedTargetPosition(): Nullable<Vector3>;
  82893. private _storedPosition;
  82894. private _storedRotation;
  82895. private _storedRotationQuaternion;
  82896. /**
  82897. * Store current camera state of the camera (fov, position, rotation, etc..)
  82898. * @returns the camera
  82899. */
  82900. storeState(): Camera;
  82901. /**
  82902. * Restored camera state. You must call storeState() first
  82903. * @returns whether it was successful or not
  82904. * @hidden
  82905. */
  82906. _restoreStateValues(): boolean;
  82907. /** @hidden */
  82908. _initCache(): void;
  82909. /** @hidden */
  82910. _updateCache(ignoreParentClass?: boolean): void;
  82911. /** @hidden */
  82912. _isSynchronizedViewMatrix(): boolean;
  82913. /** @hidden */
  82914. _computeLocalCameraSpeed(): number;
  82915. /**
  82916. * Defines the target the camera should look at.
  82917. * @param target Defines the new target as a Vector or a mesh
  82918. */
  82919. setTarget(target: Vector3): void;
  82920. /**
  82921. * Return the current target position of the camera. This value is expressed in local space.
  82922. * @returns the target position
  82923. */
  82924. getTarget(): Vector3;
  82925. /** @hidden */
  82926. _decideIfNeedsToMove(): boolean;
  82927. /** @hidden */
  82928. _updatePosition(): void;
  82929. /** @hidden */
  82930. _checkInputs(): void;
  82931. protected _updateCameraRotationMatrix(): void;
  82932. /**
  82933. * 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)
  82934. * @returns the current camera
  82935. */
  82936. private _rotateUpVectorWithCameraRotationMatrix;
  82937. private _cachedRotationZ;
  82938. private _cachedQuaternionRotationZ;
  82939. /** @hidden */
  82940. _getViewMatrix(): Matrix;
  82941. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82942. /**
  82943. * @hidden
  82944. */
  82945. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82946. /**
  82947. * @hidden
  82948. */
  82949. _updateRigCameras(): void;
  82950. private _getRigCamPositionAndTarget;
  82951. /**
  82952. * Gets the current object class name.
  82953. * @return the class name
  82954. */
  82955. getClassName(): string;
  82956. }
  82957. }
  82958. declare module BABYLON {
  82959. /**
  82960. * Gather the list of keyboard event types as constants.
  82961. */
  82962. export class KeyboardEventTypes {
  82963. /**
  82964. * The keydown event is fired when a key becomes active (pressed).
  82965. */
  82966. static readonly KEYDOWN: number;
  82967. /**
  82968. * The keyup event is fired when a key has been released.
  82969. */
  82970. static readonly KEYUP: number;
  82971. }
  82972. /**
  82973. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82974. */
  82975. export class KeyboardInfo {
  82976. /**
  82977. * Defines the type of event (KeyboardEventTypes)
  82978. */
  82979. type: number;
  82980. /**
  82981. * Defines the related dom event
  82982. */
  82983. event: KeyboardEvent;
  82984. /**
  82985. * Instantiates a new keyboard info.
  82986. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82987. * @param type Defines the type of event (KeyboardEventTypes)
  82988. * @param event Defines the related dom event
  82989. */
  82990. constructor(
  82991. /**
  82992. * Defines the type of event (KeyboardEventTypes)
  82993. */
  82994. type: number,
  82995. /**
  82996. * Defines the related dom event
  82997. */
  82998. event: KeyboardEvent);
  82999. }
  83000. /**
  83001. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83002. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  83003. */
  83004. export class KeyboardInfoPre extends KeyboardInfo {
  83005. /**
  83006. * Defines the type of event (KeyboardEventTypes)
  83007. */
  83008. type: number;
  83009. /**
  83010. * Defines the related dom event
  83011. */
  83012. event: KeyboardEvent;
  83013. /**
  83014. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83015. */
  83016. skipOnPointerObservable: boolean;
  83017. /**
  83018. * Instantiates a new keyboard pre info.
  83019. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83020. * @param type Defines the type of event (KeyboardEventTypes)
  83021. * @param event Defines the related dom event
  83022. */
  83023. constructor(
  83024. /**
  83025. * Defines the type of event (KeyboardEventTypes)
  83026. */
  83027. type: number,
  83028. /**
  83029. * Defines the related dom event
  83030. */
  83031. event: KeyboardEvent);
  83032. }
  83033. }
  83034. declare module BABYLON {
  83035. /**
  83036. * Manage the keyboard inputs to control the movement of a free camera.
  83037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83038. */
  83039. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83040. /**
  83041. * Defines the camera the input is attached to.
  83042. */
  83043. camera: FreeCamera;
  83044. /**
  83045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83046. */
  83047. keysUp: number[];
  83048. /**
  83049. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83050. */
  83051. keysUpward: number[];
  83052. /**
  83053. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83054. */
  83055. keysDown: number[];
  83056. /**
  83057. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83058. */
  83059. keysDownward: number[];
  83060. /**
  83061. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83062. */
  83063. keysLeft: number[];
  83064. /**
  83065. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83066. */
  83067. keysRight: number[];
  83068. private _keys;
  83069. private _onCanvasBlurObserver;
  83070. private _onKeyboardObserver;
  83071. private _engine;
  83072. private _scene;
  83073. /**
  83074. * Attach the input controls to a specific dom element to get the input from.
  83075. * @param element Defines the element the controls should be listened from
  83076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83077. */
  83078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83079. /**
  83080. * Detach the current controls from the specified dom element.
  83081. * @param element Defines the element to stop listening the inputs from
  83082. */
  83083. detachControl(element: Nullable<HTMLElement>): void;
  83084. /**
  83085. * Update the current camera state depending on the inputs that have been used this frame.
  83086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83087. */
  83088. checkInputs(): void;
  83089. /**
  83090. * Gets the class name of the current intput.
  83091. * @returns the class name
  83092. */
  83093. getClassName(): string;
  83094. /** @hidden */
  83095. _onLostFocus(): void;
  83096. /**
  83097. * Get the friendly name associated with the input class.
  83098. * @returns the input friendly name
  83099. */
  83100. getSimpleName(): string;
  83101. }
  83102. }
  83103. declare module BABYLON {
  83104. /**
  83105. * Interface describing all the common properties and methods a shadow light needs to implement.
  83106. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83107. * as well as binding the different shadow properties to the effects.
  83108. */
  83109. export interface IShadowLight extends Light {
  83110. /**
  83111. * The light id in the scene (used in scene.findLighById for instance)
  83112. */
  83113. id: string;
  83114. /**
  83115. * The position the shdow will be casted from.
  83116. */
  83117. position: Vector3;
  83118. /**
  83119. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83120. */
  83121. direction: Vector3;
  83122. /**
  83123. * The transformed position. Position of the light in world space taking parenting in account.
  83124. */
  83125. transformedPosition: Vector3;
  83126. /**
  83127. * The transformed direction. Direction of the light in world space taking parenting in account.
  83128. */
  83129. transformedDirection: Vector3;
  83130. /**
  83131. * The friendly name of the light in the scene.
  83132. */
  83133. name: string;
  83134. /**
  83135. * Defines the shadow projection clipping minimum z value.
  83136. */
  83137. shadowMinZ: number;
  83138. /**
  83139. * Defines the shadow projection clipping maximum z value.
  83140. */
  83141. shadowMaxZ: number;
  83142. /**
  83143. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83144. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83145. */
  83146. computeTransformedInformation(): boolean;
  83147. /**
  83148. * Gets the scene the light belongs to.
  83149. * @returns The scene
  83150. */
  83151. getScene(): Scene;
  83152. /**
  83153. * Callback defining a custom Projection Matrix Builder.
  83154. * This can be used to override the default projection matrix computation.
  83155. */
  83156. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83157. /**
  83158. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83159. * @param matrix The materix to updated with the projection information
  83160. * @param viewMatrix The transform matrix of the light
  83161. * @param renderList The list of mesh to render in the map
  83162. * @returns The current light
  83163. */
  83164. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83165. /**
  83166. * Gets the current depth scale used in ESM.
  83167. * @returns The scale
  83168. */
  83169. getDepthScale(): number;
  83170. /**
  83171. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83172. * @returns true if a cube texture needs to be use
  83173. */
  83174. needCube(): boolean;
  83175. /**
  83176. * Detects if the projection matrix requires to be recomputed this frame.
  83177. * @returns true if it requires to be recomputed otherwise, false.
  83178. */
  83179. needProjectionMatrixCompute(): boolean;
  83180. /**
  83181. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83182. */
  83183. forceProjectionMatrixCompute(): void;
  83184. /**
  83185. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83188. */
  83189. getShadowDirection(faceIndex?: number): Vector3;
  83190. /**
  83191. * Gets the minZ used for shadow according to both the scene and the light.
  83192. * @param activeCamera The camera we are returning the min for
  83193. * @returns the depth min z
  83194. */
  83195. getDepthMinZ(activeCamera: Camera): number;
  83196. /**
  83197. * Gets the maxZ used for shadow according to both the scene and the light.
  83198. * @param activeCamera The camera we are returning the max for
  83199. * @returns the depth max z
  83200. */
  83201. getDepthMaxZ(activeCamera: Camera): number;
  83202. }
  83203. /**
  83204. * Base implementation IShadowLight
  83205. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83206. */
  83207. export abstract class ShadowLight extends Light implements IShadowLight {
  83208. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83209. protected _position: Vector3;
  83210. protected _setPosition(value: Vector3): void;
  83211. /**
  83212. * Sets the position the shadow will be casted from. Also use as the light position for both
  83213. * point and spot lights.
  83214. */
  83215. get position(): Vector3;
  83216. /**
  83217. * Sets the position the shadow will be casted from. Also use as the light position for both
  83218. * point and spot lights.
  83219. */
  83220. set position(value: Vector3);
  83221. protected _direction: Vector3;
  83222. protected _setDirection(value: Vector3): void;
  83223. /**
  83224. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83225. * Also use as the light direction on spot and directional lights.
  83226. */
  83227. get direction(): Vector3;
  83228. /**
  83229. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83230. * Also use as the light direction on spot and directional lights.
  83231. */
  83232. set direction(value: Vector3);
  83233. protected _shadowMinZ: number;
  83234. /**
  83235. * Gets the shadow projection clipping minimum z value.
  83236. */
  83237. get shadowMinZ(): number;
  83238. /**
  83239. * Sets the shadow projection clipping minimum z value.
  83240. */
  83241. set shadowMinZ(value: number);
  83242. protected _shadowMaxZ: number;
  83243. /**
  83244. * Sets the shadow projection clipping maximum z value.
  83245. */
  83246. get shadowMaxZ(): number;
  83247. /**
  83248. * Gets the shadow projection clipping maximum z value.
  83249. */
  83250. set shadowMaxZ(value: number);
  83251. /**
  83252. * Callback defining a custom Projection Matrix Builder.
  83253. * This can be used to override the default projection matrix computation.
  83254. */
  83255. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83256. /**
  83257. * The transformed position. Position of the light in world space taking parenting in account.
  83258. */
  83259. transformedPosition: Vector3;
  83260. /**
  83261. * The transformed direction. Direction of the light in world space taking parenting in account.
  83262. */
  83263. transformedDirection: Vector3;
  83264. private _needProjectionMatrixCompute;
  83265. /**
  83266. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83267. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83268. */
  83269. computeTransformedInformation(): boolean;
  83270. /**
  83271. * Return the depth scale used for the shadow map.
  83272. * @returns the depth scale.
  83273. */
  83274. getDepthScale(): number;
  83275. /**
  83276. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83277. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83278. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83279. */
  83280. getShadowDirection(faceIndex?: number): Vector3;
  83281. /**
  83282. * Returns the ShadowLight absolute position in the World.
  83283. * @returns the position vector in world space
  83284. */
  83285. getAbsolutePosition(): Vector3;
  83286. /**
  83287. * Sets the ShadowLight direction toward the passed target.
  83288. * @param target The point to target in local space
  83289. * @returns the updated ShadowLight direction
  83290. */
  83291. setDirectionToTarget(target: Vector3): Vector3;
  83292. /**
  83293. * Returns the light rotation in euler definition.
  83294. * @returns the x y z rotation in local space.
  83295. */
  83296. getRotation(): Vector3;
  83297. /**
  83298. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83299. * @returns true if a cube texture needs to be use
  83300. */
  83301. needCube(): boolean;
  83302. /**
  83303. * Detects if the projection matrix requires to be recomputed this frame.
  83304. * @returns true if it requires to be recomputed otherwise, false.
  83305. */
  83306. needProjectionMatrixCompute(): boolean;
  83307. /**
  83308. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83309. */
  83310. forceProjectionMatrixCompute(): void;
  83311. /** @hidden */
  83312. _initCache(): void;
  83313. /** @hidden */
  83314. _isSynchronized(): boolean;
  83315. /**
  83316. * Computes the world matrix of the node
  83317. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83318. * @returns the world matrix
  83319. */
  83320. computeWorldMatrix(force?: boolean): Matrix;
  83321. /**
  83322. * Gets the minZ used for shadow according to both the scene and the light.
  83323. * @param activeCamera The camera we are returning the min for
  83324. * @returns the depth min z
  83325. */
  83326. getDepthMinZ(activeCamera: Camera): number;
  83327. /**
  83328. * Gets the maxZ used for shadow according to both the scene and the light.
  83329. * @param activeCamera The camera we are returning the max for
  83330. * @returns the depth max z
  83331. */
  83332. getDepthMaxZ(activeCamera: Camera): number;
  83333. /**
  83334. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83335. * @param matrix The materix to updated with the projection information
  83336. * @param viewMatrix The transform matrix of the light
  83337. * @param renderList The list of mesh to render in the map
  83338. * @returns The current light
  83339. */
  83340. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83341. }
  83342. }
  83343. declare module BABYLON {
  83344. /**
  83345. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83346. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83347. */
  83348. export class EffectFallbacks implements IEffectFallbacks {
  83349. private _defines;
  83350. private _currentRank;
  83351. private _maxRank;
  83352. private _mesh;
  83353. /**
  83354. * Removes the fallback from the bound mesh.
  83355. */
  83356. unBindMesh(): void;
  83357. /**
  83358. * Adds a fallback on the specified property.
  83359. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83360. * @param define The name of the define in the shader
  83361. */
  83362. addFallback(rank: number, define: string): void;
  83363. /**
  83364. * Sets the mesh to use CPU skinning when needing to fallback.
  83365. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83366. * @param mesh The mesh to use the fallbacks.
  83367. */
  83368. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83369. /**
  83370. * Checks to see if more fallbacks are still availible.
  83371. */
  83372. get hasMoreFallbacks(): boolean;
  83373. /**
  83374. * Removes the defines that should be removed when falling back.
  83375. * @param currentDefines defines the current define statements for the shader.
  83376. * @param effect defines the current effect we try to compile
  83377. * @returns The resulting defines with defines of the current rank removed.
  83378. */
  83379. reduce(currentDefines: string, effect: Effect): string;
  83380. }
  83381. }
  83382. declare module BABYLON {
  83383. /**
  83384. * "Static Class" containing the most commonly used helper while dealing with material for
  83385. * rendering purpose.
  83386. *
  83387. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83388. *
  83389. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83390. */
  83391. export class MaterialHelper {
  83392. /**
  83393. * Bind the current view position to an effect.
  83394. * @param effect The effect to be bound
  83395. * @param scene The scene the eyes position is used from
  83396. */
  83397. static BindEyePosition(effect: Effect, scene: Scene): void;
  83398. /**
  83399. * Helps preparing the defines values about the UVs in used in the effect.
  83400. * UVs are shared as much as we can accross channels in the shaders.
  83401. * @param texture The texture we are preparing the UVs for
  83402. * @param defines The defines to update
  83403. * @param key The channel key "diffuse", "specular"... used in the shader
  83404. */
  83405. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83406. /**
  83407. * Binds a texture matrix value to its corrsponding uniform
  83408. * @param texture The texture to bind the matrix for
  83409. * @param uniformBuffer The uniform buffer receivin the data
  83410. * @param key The channel key "diffuse", "specular"... used in the shader
  83411. */
  83412. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83413. /**
  83414. * Gets the current status of the fog (should it be enabled?)
  83415. * @param mesh defines the mesh to evaluate for fog support
  83416. * @param scene defines the hosting scene
  83417. * @returns true if fog must be enabled
  83418. */
  83419. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83420. /**
  83421. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83422. * @param mesh defines the current mesh
  83423. * @param scene defines the current scene
  83424. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83425. * @param pointsCloud defines if point cloud rendering has to be turned on
  83426. * @param fogEnabled defines if fog has to be turned on
  83427. * @param alphaTest defines if alpha testing has to be turned on
  83428. * @param defines defines the current list of defines
  83429. */
  83430. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83431. /**
  83432. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83433. * @param scene defines the current scene
  83434. * @param engine defines the current engine
  83435. * @param defines specifies the list of active defines
  83436. * @param useInstances defines if instances have to be turned on
  83437. * @param useClipPlane defines if clip plane have to be turned on
  83438. */
  83439. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83440. /**
  83441. * Prepares the defines for bones
  83442. * @param mesh The mesh containing the geometry data we will draw
  83443. * @param defines The defines to update
  83444. */
  83445. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83446. /**
  83447. * Prepares the defines for morph targets
  83448. * @param mesh The mesh containing the geometry data we will draw
  83449. * @param defines The defines to update
  83450. */
  83451. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83452. /**
  83453. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83454. * @param mesh The mesh containing the geometry data we will draw
  83455. * @param defines The defines to update
  83456. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83457. * @param useBones Precise whether bones should be used or not (override mesh info)
  83458. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83459. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83460. * @returns false if defines are considered not dirty and have not been checked
  83461. */
  83462. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83463. /**
  83464. * Prepares the defines related to multiview
  83465. * @param scene The scene we are intending to draw
  83466. * @param defines The defines to update
  83467. */
  83468. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83469. /**
  83470. * Prepares the defines related to the light information passed in parameter
  83471. * @param scene The scene we are intending to draw
  83472. * @param mesh The mesh the effect is compiling for
  83473. * @param light The light the effect is compiling for
  83474. * @param lightIndex The index of the light
  83475. * @param defines The defines to update
  83476. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83477. * @param state Defines the current state regarding what is needed (normals, etc...)
  83478. */
  83479. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83480. needNormals: boolean;
  83481. needRebuild: boolean;
  83482. shadowEnabled: boolean;
  83483. specularEnabled: boolean;
  83484. lightmapMode: boolean;
  83485. }): void;
  83486. /**
  83487. * Prepares the defines related to the light information passed in parameter
  83488. * @param scene The scene we are intending to draw
  83489. * @param mesh The mesh the effect is compiling for
  83490. * @param defines The defines to update
  83491. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83492. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83493. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83494. * @returns true if normals will be required for the rest of the effect
  83495. */
  83496. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83497. /**
  83498. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83499. * @param lightIndex defines the light index
  83500. * @param uniformsList The uniform list
  83501. * @param samplersList The sampler list
  83502. * @param projectedLightTexture defines if projected texture must be used
  83503. * @param uniformBuffersList defines an optional list of uniform buffers
  83504. */
  83505. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83506. /**
  83507. * Prepares the uniforms and samplers list to be used in the effect
  83508. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83509. * @param samplersList The sampler list
  83510. * @param defines The defines helping in the list generation
  83511. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83512. */
  83513. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83514. /**
  83515. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83516. * @param defines The defines to update while falling back
  83517. * @param fallbacks The authorized effect fallbacks
  83518. * @param maxSimultaneousLights The maximum number of lights allowed
  83519. * @param rank the current rank of the Effect
  83520. * @returns The newly affected rank
  83521. */
  83522. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83523. private static _TmpMorphInfluencers;
  83524. /**
  83525. * Prepares the list of attributes required for morph targets according to the effect defines.
  83526. * @param attribs The current list of supported attribs
  83527. * @param mesh The mesh to prepare the morph targets attributes for
  83528. * @param influencers The number of influencers
  83529. */
  83530. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83531. /**
  83532. * Prepares the list of attributes required for morph targets according to the effect defines.
  83533. * @param attribs The current list of supported attribs
  83534. * @param mesh The mesh to prepare the morph targets attributes for
  83535. * @param defines The current Defines of the effect
  83536. */
  83537. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83538. /**
  83539. * Prepares the list of attributes required for bones according to the effect defines.
  83540. * @param attribs The current list of supported attribs
  83541. * @param mesh The mesh to prepare the bones attributes for
  83542. * @param defines The current Defines of the effect
  83543. * @param fallbacks The current efffect fallback strategy
  83544. */
  83545. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83546. /**
  83547. * Check and prepare the list of attributes required for instances according to the effect defines.
  83548. * @param attribs The current list of supported attribs
  83549. * @param defines The current MaterialDefines of the effect
  83550. */
  83551. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83552. /**
  83553. * Add the list of attributes required for instances to the attribs array.
  83554. * @param attribs The current list of supported attribs
  83555. */
  83556. static PushAttributesForInstances(attribs: string[]): void;
  83557. /**
  83558. * Binds the light information to the effect.
  83559. * @param light The light containing the generator
  83560. * @param effect The effect we are binding the data to
  83561. * @param lightIndex The light index in the effect used to render
  83562. */
  83563. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83564. /**
  83565. * Binds the lights information from the scene to the effect for the given mesh.
  83566. * @param light Light to bind
  83567. * @param lightIndex Light index
  83568. * @param scene The scene where the light belongs to
  83569. * @param effect The effect we are binding the data to
  83570. * @param useSpecular Defines if specular is supported
  83571. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83572. */
  83573. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83574. /**
  83575. * Binds the lights information from the scene to the effect for the given mesh.
  83576. * @param scene The scene the lights belongs to
  83577. * @param mesh The mesh we are binding the information to render
  83578. * @param effect The effect we are binding the data to
  83579. * @param defines The generated defines for the effect
  83580. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83581. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83582. */
  83583. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83584. private static _tempFogColor;
  83585. /**
  83586. * Binds the fog information from the scene to the effect for the given mesh.
  83587. * @param scene The scene the lights belongs to
  83588. * @param mesh The mesh we are binding the information to render
  83589. * @param effect The effect we are binding the data to
  83590. * @param linearSpace Defines if the fog effect is applied in linear space
  83591. */
  83592. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83593. /**
  83594. * Binds the bones information from the mesh to the effect.
  83595. * @param mesh The mesh we are binding the information to render
  83596. * @param effect The effect we are binding the data to
  83597. */
  83598. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83599. /**
  83600. * Binds the morph targets information from the mesh to the effect.
  83601. * @param abstractMesh The mesh we are binding the information to render
  83602. * @param effect The effect we are binding the data to
  83603. */
  83604. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83605. /**
  83606. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83607. * @param defines The generated defines used in the effect
  83608. * @param effect The effect we are binding the data to
  83609. * @param scene The scene we are willing to render with logarithmic scale for
  83610. */
  83611. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83612. /**
  83613. * Binds the clip plane information from the scene to the effect.
  83614. * @param scene The scene the clip plane information are extracted from
  83615. * @param effect The effect we are binding the data to
  83616. */
  83617. static BindClipPlane(effect: Effect, scene: Scene): void;
  83618. }
  83619. }
  83620. declare module BABYLON {
  83621. /** @hidden */
  83622. export var packingFunctions: {
  83623. name: string;
  83624. shader: string;
  83625. };
  83626. }
  83627. declare module BABYLON {
  83628. /** @hidden */
  83629. export var clipPlaneFragmentDeclaration: {
  83630. name: string;
  83631. shader: string;
  83632. };
  83633. }
  83634. declare module BABYLON {
  83635. /** @hidden */
  83636. export var clipPlaneFragment: {
  83637. name: string;
  83638. shader: string;
  83639. };
  83640. }
  83641. declare module BABYLON {
  83642. /** @hidden */
  83643. export var shadowMapPixelShader: {
  83644. name: string;
  83645. shader: string;
  83646. };
  83647. }
  83648. declare module BABYLON {
  83649. /** @hidden */
  83650. export var bonesDeclaration: {
  83651. name: string;
  83652. shader: string;
  83653. };
  83654. }
  83655. declare module BABYLON {
  83656. /** @hidden */
  83657. export var morphTargetsVertexGlobalDeclaration: {
  83658. name: string;
  83659. shader: string;
  83660. };
  83661. }
  83662. declare module BABYLON {
  83663. /** @hidden */
  83664. export var morphTargetsVertexDeclaration: {
  83665. name: string;
  83666. shader: string;
  83667. };
  83668. }
  83669. declare module BABYLON {
  83670. /** @hidden */
  83671. export var instancesDeclaration: {
  83672. name: string;
  83673. shader: string;
  83674. };
  83675. }
  83676. declare module BABYLON {
  83677. /** @hidden */
  83678. export var helperFunctions: {
  83679. name: string;
  83680. shader: string;
  83681. };
  83682. }
  83683. declare module BABYLON {
  83684. /** @hidden */
  83685. export var clipPlaneVertexDeclaration: {
  83686. name: string;
  83687. shader: string;
  83688. };
  83689. }
  83690. declare module BABYLON {
  83691. /** @hidden */
  83692. export var morphTargetsVertex: {
  83693. name: string;
  83694. shader: string;
  83695. };
  83696. }
  83697. declare module BABYLON {
  83698. /** @hidden */
  83699. export var instancesVertex: {
  83700. name: string;
  83701. shader: string;
  83702. };
  83703. }
  83704. declare module BABYLON {
  83705. /** @hidden */
  83706. export var bonesVertex: {
  83707. name: string;
  83708. shader: string;
  83709. };
  83710. }
  83711. declare module BABYLON {
  83712. /** @hidden */
  83713. export var clipPlaneVertex: {
  83714. name: string;
  83715. shader: string;
  83716. };
  83717. }
  83718. declare module BABYLON {
  83719. /** @hidden */
  83720. export var shadowMapVertexShader: {
  83721. name: string;
  83722. shader: string;
  83723. };
  83724. }
  83725. declare module BABYLON {
  83726. /** @hidden */
  83727. export var depthBoxBlurPixelShader: {
  83728. name: string;
  83729. shader: string;
  83730. };
  83731. }
  83732. declare module BABYLON {
  83733. /**
  83734. * Class representing a ray with position and direction
  83735. */
  83736. export class Ray {
  83737. /** origin point */
  83738. origin: Vector3;
  83739. /** direction */
  83740. direction: Vector3;
  83741. /** length of the ray */
  83742. length: number;
  83743. private static readonly TmpVector3;
  83744. private _tmpRay;
  83745. /**
  83746. * Creates a new ray
  83747. * @param origin origin point
  83748. * @param direction direction
  83749. * @param length length of the ray
  83750. */
  83751. constructor(
  83752. /** origin point */
  83753. origin: Vector3,
  83754. /** direction */
  83755. direction: Vector3,
  83756. /** length of the ray */
  83757. length?: number);
  83758. /**
  83759. * Checks if the ray intersects a box
  83760. * @param minimum bound of the box
  83761. * @param maximum bound of the box
  83762. * @param intersectionTreshold extra extend to be added to the box in all direction
  83763. * @returns if the box was hit
  83764. */
  83765. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83766. /**
  83767. * Checks if the ray intersects a box
  83768. * @param box the bounding box to check
  83769. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83770. * @returns if the box was hit
  83771. */
  83772. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83773. /**
  83774. * If the ray hits a sphere
  83775. * @param sphere the bounding sphere to check
  83776. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83777. * @returns true if it hits the sphere
  83778. */
  83779. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83780. /**
  83781. * If the ray hits a triange
  83782. * @param vertex0 triangle vertex
  83783. * @param vertex1 triangle vertex
  83784. * @param vertex2 triangle vertex
  83785. * @returns intersection information if hit
  83786. */
  83787. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83788. /**
  83789. * Checks if ray intersects a plane
  83790. * @param plane the plane to check
  83791. * @returns the distance away it was hit
  83792. */
  83793. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83794. /**
  83795. * Calculate the intercept of a ray on a given axis
  83796. * @param axis to check 'x' | 'y' | 'z'
  83797. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83798. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83799. */
  83800. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83801. /**
  83802. * Checks if ray intersects a mesh
  83803. * @param mesh the mesh to check
  83804. * @param fastCheck if only the bounding box should checked
  83805. * @returns picking info of the intersecton
  83806. */
  83807. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83808. /**
  83809. * Checks if ray intersects a mesh
  83810. * @param meshes the meshes to check
  83811. * @param fastCheck if only the bounding box should checked
  83812. * @param results array to store result in
  83813. * @returns Array of picking infos
  83814. */
  83815. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83816. private _comparePickingInfo;
  83817. private static smallnum;
  83818. private static rayl;
  83819. /**
  83820. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83821. * @param sega the first point of the segment to test the intersection against
  83822. * @param segb the second point of the segment to test the intersection against
  83823. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83824. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83825. */
  83826. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83827. /**
  83828. * Update the ray from viewport position
  83829. * @param x position
  83830. * @param y y position
  83831. * @param viewportWidth viewport width
  83832. * @param viewportHeight viewport height
  83833. * @param world world matrix
  83834. * @param view view matrix
  83835. * @param projection projection matrix
  83836. * @returns this ray updated
  83837. */
  83838. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83839. /**
  83840. * Creates a ray with origin and direction of 0,0,0
  83841. * @returns the new ray
  83842. */
  83843. static Zero(): Ray;
  83844. /**
  83845. * Creates a new ray from screen space and viewport
  83846. * @param x position
  83847. * @param y y position
  83848. * @param viewportWidth viewport width
  83849. * @param viewportHeight viewport height
  83850. * @param world world matrix
  83851. * @param view view matrix
  83852. * @param projection projection matrix
  83853. * @returns new ray
  83854. */
  83855. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83856. /**
  83857. * 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
  83858. * transformed to the given world matrix.
  83859. * @param origin The origin point
  83860. * @param end The end point
  83861. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83862. * @returns the new ray
  83863. */
  83864. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83865. /**
  83866. * Transforms a ray by a matrix
  83867. * @param ray ray to transform
  83868. * @param matrix matrix to apply
  83869. * @returns the resulting new ray
  83870. */
  83871. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83872. /**
  83873. * Transforms a ray by a matrix
  83874. * @param ray ray to transform
  83875. * @param matrix matrix to apply
  83876. * @param result ray to store result in
  83877. */
  83878. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83879. /**
  83880. * Unproject a ray from screen space to object space
  83881. * @param sourceX defines the screen space x coordinate to use
  83882. * @param sourceY defines the screen space y coordinate to use
  83883. * @param viewportWidth defines the current width of the viewport
  83884. * @param viewportHeight defines the current height of the viewport
  83885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83886. * @param view defines the view matrix to use
  83887. * @param projection defines the projection matrix to use
  83888. */
  83889. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83890. }
  83891. /**
  83892. * Type used to define predicate used to select faces when a mesh intersection is detected
  83893. */
  83894. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83895. interface Scene {
  83896. /** @hidden */
  83897. _tempPickingRay: Nullable<Ray>;
  83898. /** @hidden */
  83899. _cachedRayForTransform: Ray;
  83900. /** @hidden */
  83901. _pickWithRayInverseMatrix: Matrix;
  83902. /** @hidden */
  83903. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83904. /** @hidden */
  83905. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * Groups all the scene component constants in one place to ease maintenance.
  83911. * @hidden
  83912. */
  83913. export class SceneComponentConstants {
  83914. static readonly NAME_EFFECTLAYER: string;
  83915. static readonly NAME_LAYER: string;
  83916. static readonly NAME_LENSFLARESYSTEM: string;
  83917. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83918. static readonly NAME_PARTICLESYSTEM: string;
  83919. static readonly NAME_GAMEPAD: string;
  83920. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83921. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83922. static readonly NAME_DEPTHRENDERER: string;
  83923. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83924. static readonly NAME_SPRITE: string;
  83925. static readonly NAME_OUTLINERENDERER: string;
  83926. static readonly NAME_PROCEDURALTEXTURE: string;
  83927. static readonly NAME_SHADOWGENERATOR: string;
  83928. static readonly NAME_OCTREE: string;
  83929. static readonly NAME_PHYSICSENGINE: string;
  83930. static readonly NAME_AUDIO: string;
  83931. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83932. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83933. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83934. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83935. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83936. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83937. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83938. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83939. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83940. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83941. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83942. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83943. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83944. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83945. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83946. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83947. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83948. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83949. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83950. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83951. static readonly STEP_AFTERRENDER_AUDIO: number;
  83952. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83953. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83954. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83955. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83956. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83957. static readonly STEP_POINTERMOVE_SPRITE: number;
  83958. static readonly STEP_POINTERDOWN_SPRITE: number;
  83959. static readonly STEP_POINTERUP_SPRITE: number;
  83960. }
  83961. /**
  83962. * This represents a scene component.
  83963. *
  83964. * This is used to decouple the dependency the scene is having on the different workloads like
  83965. * layers, post processes...
  83966. */
  83967. export interface ISceneComponent {
  83968. /**
  83969. * The name of the component. Each component must have a unique name.
  83970. */
  83971. name: string;
  83972. /**
  83973. * The scene the component belongs to.
  83974. */
  83975. scene: Scene;
  83976. /**
  83977. * Register the component to one instance of a scene.
  83978. */
  83979. register(): void;
  83980. /**
  83981. * Rebuilds the elements related to this component in case of
  83982. * context lost for instance.
  83983. */
  83984. rebuild(): void;
  83985. /**
  83986. * Disposes the component and the associated ressources.
  83987. */
  83988. dispose(): void;
  83989. }
  83990. /**
  83991. * This represents a SERIALIZABLE scene component.
  83992. *
  83993. * This extends Scene Component to add Serialization methods on top.
  83994. */
  83995. export interface ISceneSerializableComponent extends ISceneComponent {
  83996. /**
  83997. * Adds all the elements from the container to the scene
  83998. * @param container the container holding the elements
  83999. */
  84000. addFromContainer(container: AbstractScene): void;
  84001. /**
  84002. * Removes all the elements in the container from the scene
  84003. * @param container contains the elements to remove
  84004. * @param dispose if the removed element should be disposed (default: false)
  84005. */
  84006. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84007. /**
  84008. * Serializes the component data to the specified json object
  84009. * @param serializationObject The object to serialize to
  84010. */
  84011. serialize(serializationObject: any): void;
  84012. }
  84013. /**
  84014. * Strong typing of a Mesh related stage step action
  84015. */
  84016. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84017. /**
  84018. * Strong typing of a Evaluate Sub Mesh related stage step action
  84019. */
  84020. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84021. /**
  84022. * Strong typing of a Active Mesh related stage step action
  84023. */
  84024. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84025. /**
  84026. * Strong typing of a Camera related stage step action
  84027. */
  84028. export type CameraStageAction = (camera: Camera) => void;
  84029. /**
  84030. * Strong typing of a Camera Frame buffer related stage step action
  84031. */
  84032. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84033. /**
  84034. * Strong typing of a Render Target related stage step action
  84035. */
  84036. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84037. /**
  84038. * Strong typing of a RenderingGroup related stage step action
  84039. */
  84040. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84041. /**
  84042. * Strong typing of a Mesh Render related stage step action
  84043. */
  84044. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84045. /**
  84046. * Strong typing of a simple stage step action
  84047. */
  84048. export type SimpleStageAction = () => void;
  84049. /**
  84050. * Strong typing of a render target action.
  84051. */
  84052. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84053. /**
  84054. * Strong typing of a pointer move action.
  84055. */
  84056. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84057. /**
  84058. * Strong typing of a pointer up/down action.
  84059. */
  84060. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84061. /**
  84062. * Representation of a stage in the scene (Basically a list of ordered steps)
  84063. * @hidden
  84064. */
  84065. export class Stage<T extends Function> extends Array<{
  84066. index: number;
  84067. component: ISceneComponent;
  84068. action: T;
  84069. }> {
  84070. /**
  84071. * Hide ctor from the rest of the world.
  84072. * @param items The items to add.
  84073. */
  84074. private constructor();
  84075. /**
  84076. * Creates a new Stage.
  84077. * @returns A new instance of a Stage
  84078. */
  84079. static Create<T extends Function>(): Stage<T>;
  84080. /**
  84081. * Registers a step in an ordered way in the targeted stage.
  84082. * @param index Defines the position to register the step in
  84083. * @param component Defines the component attached to the step
  84084. * @param action Defines the action to launch during the step
  84085. */
  84086. registerStep(index: number, component: ISceneComponent, action: T): void;
  84087. /**
  84088. * Clears all the steps from the stage.
  84089. */
  84090. clear(): void;
  84091. }
  84092. }
  84093. declare module BABYLON {
  84094. interface Scene {
  84095. /** @hidden */
  84096. _pointerOverSprite: Nullable<Sprite>;
  84097. /** @hidden */
  84098. _pickedDownSprite: Nullable<Sprite>;
  84099. /** @hidden */
  84100. _tempSpritePickingRay: Nullable<Ray>;
  84101. /**
  84102. * All of the sprite managers added to this scene
  84103. * @see http://doc.babylonjs.com/babylon101/sprites
  84104. */
  84105. spriteManagers: Array<ISpriteManager>;
  84106. /**
  84107. * An event triggered when sprites rendering is about to start
  84108. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84109. */
  84110. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84111. /**
  84112. * An event triggered when sprites rendering is done
  84113. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84114. */
  84115. onAfterSpritesRenderingObservable: Observable<Scene>;
  84116. /** @hidden */
  84117. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84118. /** Launch a ray to try to pick a sprite in the scene
  84119. * @param x position on screen
  84120. * @param y position on screen
  84121. * @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
  84122. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84123. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84124. * @returns a PickingInfo
  84125. */
  84126. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84127. /** Use the given ray to pick a sprite in the scene
  84128. * @param ray The ray (in world space) to use to pick meshes
  84129. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  84130. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84132. * @returns a PickingInfo
  84133. */
  84134. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84135. /** @hidden */
  84136. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84137. /** Launch a ray to try to pick sprites in the scene
  84138. * @param x position on screen
  84139. * @param y position on screen
  84140. * @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
  84141. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84142. * @returns a PickingInfo array
  84143. */
  84144. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84145. /** Use the given ray to pick sprites in the scene
  84146. * @param ray The ray (in world space) to use to pick meshes
  84147. * @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
  84148. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84149. * @returns a PickingInfo array
  84150. */
  84151. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84152. /**
  84153. * Force the sprite under the pointer
  84154. * @param sprite defines the sprite to use
  84155. */
  84156. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84157. /**
  84158. * Gets the sprite under the pointer
  84159. * @returns a Sprite or null if no sprite is under the pointer
  84160. */
  84161. getPointerOverSprite(): Nullable<Sprite>;
  84162. }
  84163. /**
  84164. * Defines the sprite scene component responsible to manage sprites
  84165. * in a given scene.
  84166. */
  84167. export class SpriteSceneComponent implements ISceneComponent {
  84168. /**
  84169. * The component name helpfull to identify the component in the list of scene components.
  84170. */
  84171. readonly name: string;
  84172. /**
  84173. * The scene the component belongs to.
  84174. */
  84175. scene: Scene;
  84176. /** @hidden */
  84177. private _spritePredicate;
  84178. /**
  84179. * Creates a new instance of the component for the given scene
  84180. * @param scene Defines the scene to register the component in
  84181. */
  84182. constructor(scene: Scene);
  84183. /**
  84184. * Registers the component in a given scene
  84185. */
  84186. register(): void;
  84187. /**
  84188. * Rebuilds the elements related to this component in case of
  84189. * context lost for instance.
  84190. */
  84191. rebuild(): void;
  84192. /**
  84193. * Disposes the component and the associated ressources.
  84194. */
  84195. dispose(): void;
  84196. private _pickSpriteButKeepRay;
  84197. private _pointerMove;
  84198. private _pointerDown;
  84199. private _pointerUp;
  84200. }
  84201. }
  84202. declare module BABYLON {
  84203. /** @hidden */
  84204. export var fogFragmentDeclaration: {
  84205. name: string;
  84206. shader: string;
  84207. };
  84208. }
  84209. declare module BABYLON {
  84210. /** @hidden */
  84211. export var fogFragment: {
  84212. name: string;
  84213. shader: string;
  84214. };
  84215. }
  84216. declare module BABYLON {
  84217. /** @hidden */
  84218. export var spritesPixelShader: {
  84219. name: string;
  84220. shader: string;
  84221. };
  84222. }
  84223. declare module BABYLON {
  84224. /** @hidden */
  84225. export var fogVertexDeclaration: {
  84226. name: string;
  84227. shader: string;
  84228. };
  84229. }
  84230. declare module BABYLON {
  84231. /** @hidden */
  84232. export var spritesVertexShader: {
  84233. name: string;
  84234. shader: string;
  84235. };
  84236. }
  84237. declare module BABYLON {
  84238. /**
  84239. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84240. */
  84241. export interface ISpriteManager extends IDisposable {
  84242. /**
  84243. * Restricts the camera to viewing objects with the same layerMask.
  84244. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84245. */
  84246. layerMask: number;
  84247. /**
  84248. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84249. */
  84250. isPickable: boolean;
  84251. /**
  84252. * Specifies the rendering group id for this mesh (0 by default)
  84253. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84254. */
  84255. renderingGroupId: number;
  84256. /**
  84257. * Defines the list of sprites managed by the manager.
  84258. */
  84259. sprites: Array<Sprite>;
  84260. /**
  84261. * Tests the intersection of a sprite with a specific ray.
  84262. * @param ray The ray we are sending to test the collision
  84263. * @param camera The camera space we are sending rays in
  84264. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84265. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84266. * @returns picking info or null.
  84267. */
  84268. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84269. /**
  84270. * Intersects the sprites with a ray
  84271. * @param ray defines the ray to intersect with
  84272. * @param camera defines the current active camera
  84273. * @param predicate defines a predicate used to select candidate sprites
  84274. * @returns null if no hit or a PickingInfo array
  84275. */
  84276. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84277. /**
  84278. * Renders the list of sprites on screen.
  84279. */
  84280. render(): void;
  84281. }
  84282. /**
  84283. * Class used to manage multiple sprites on the same spritesheet
  84284. * @see http://doc.babylonjs.com/babylon101/sprites
  84285. */
  84286. export class SpriteManager implements ISpriteManager {
  84287. /** defines the manager's name */
  84288. name: string;
  84289. /** Gets the list of sprites */
  84290. sprites: Sprite[];
  84291. /** Gets or sets the rendering group id (0 by default) */
  84292. renderingGroupId: number;
  84293. /** Gets or sets camera layer mask */
  84294. layerMask: number;
  84295. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84296. fogEnabled: boolean;
  84297. /** Gets or sets a boolean indicating if the sprites are pickable */
  84298. isPickable: boolean;
  84299. /** Defines the default width of a cell in the spritesheet */
  84300. cellWidth: number;
  84301. /** Defines the default height of a cell in the spritesheet */
  84302. cellHeight: number;
  84303. /** Associative array from JSON sprite data file */
  84304. private _cellData;
  84305. /** Array of sprite names from JSON sprite data file */
  84306. private _spriteMap;
  84307. /** True when packed cell data from JSON file is ready*/
  84308. private _packedAndReady;
  84309. /**
  84310. * An event triggered when the manager is disposed.
  84311. */
  84312. onDisposeObservable: Observable<SpriteManager>;
  84313. private _onDisposeObserver;
  84314. /**
  84315. * Callback called when the manager is disposed
  84316. */
  84317. set onDispose(callback: () => void);
  84318. private _capacity;
  84319. private _fromPacked;
  84320. private _spriteTexture;
  84321. private _epsilon;
  84322. private _scene;
  84323. private _vertexData;
  84324. private _buffer;
  84325. private _vertexBuffers;
  84326. private _indexBuffer;
  84327. private _effectBase;
  84328. private _effectFog;
  84329. /**
  84330. * Gets or sets the spritesheet texture
  84331. */
  84332. get texture(): Texture;
  84333. set texture(value: Texture);
  84334. private _blendMode;
  84335. /**
  84336. * Blend mode use to render the particle, it can be any of
  84337. * the static Constants.ALPHA_x properties provided in this class.
  84338. * Default value is Constants.ALPHA_COMBINE
  84339. */
  84340. get blendMode(): number;
  84341. set blendMode(blendMode: number);
  84342. /** Disables writing to the depth buffer when rendering the sprites.
  84343. * It can be handy to disable depth writing when using textures without alpha channel
  84344. * and setting some specific blend modes.
  84345. */
  84346. disableDepthWrite: boolean;
  84347. /**
  84348. * Creates a new sprite manager
  84349. * @param name defines the manager's name
  84350. * @param imgUrl defines the sprite sheet url
  84351. * @param capacity defines the maximum allowed number of sprites
  84352. * @param cellSize defines the size of a sprite cell
  84353. * @param scene defines the hosting scene
  84354. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84355. * @param samplingMode defines the smapling mode to use with spritesheet
  84356. * @param fromPacked set to false; do not alter
  84357. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84358. */
  84359. constructor(
  84360. /** defines the manager's name */
  84361. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84362. private _makePacked;
  84363. private _appendSpriteVertex;
  84364. /**
  84365. * Intersects the sprites with a ray
  84366. * @param ray defines the ray to intersect with
  84367. * @param camera defines the current active camera
  84368. * @param predicate defines a predicate used to select candidate sprites
  84369. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84370. * @returns null if no hit or a PickingInfo
  84371. */
  84372. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84373. /**
  84374. * Intersects the sprites with a ray
  84375. * @param ray defines the ray to intersect with
  84376. * @param camera defines the current active camera
  84377. * @param predicate defines a predicate used to select candidate sprites
  84378. * @returns null if no hit or a PickingInfo array
  84379. */
  84380. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84381. /**
  84382. * Render all child sprites
  84383. */
  84384. render(): void;
  84385. /**
  84386. * Release associated resources
  84387. */
  84388. dispose(): void;
  84389. }
  84390. }
  84391. declare module BABYLON {
  84392. /** Interface used by value gradients (color, factor, ...) */
  84393. export interface IValueGradient {
  84394. /**
  84395. * Gets or sets the gradient value (between 0 and 1)
  84396. */
  84397. gradient: number;
  84398. }
  84399. /** Class used to store color4 gradient */
  84400. export class ColorGradient implements IValueGradient {
  84401. /**
  84402. * Gets or sets the gradient value (between 0 and 1)
  84403. */
  84404. gradient: number;
  84405. /**
  84406. * Gets or sets first associated color
  84407. */
  84408. color1: Color4;
  84409. /**
  84410. * Gets or sets second associated color
  84411. */
  84412. color2?: Color4 | undefined;
  84413. /**
  84414. * Creates a new color4 gradient
  84415. * @param gradient gets or sets the gradient value (between 0 and 1)
  84416. * @param color1 gets or sets first associated color
  84417. * @param color2 gets or sets first second color
  84418. */
  84419. constructor(
  84420. /**
  84421. * Gets or sets the gradient value (between 0 and 1)
  84422. */
  84423. gradient: number,
  84424. /**
  84425. * Gets or sets first associated color
  84426. */
  84427. color1: Color4,
  84428. /**
  84429. * Gets or sets second associated color
  84430. */
  84431. color2?: Color4 | undefined);
  84432. /**
  84433. * Will get a color picked randomly between color1 and color2.
  84434. * If color2 is undefined then color1 will be used
  84435. * @param result defines the target Color4 to store the result in
  84436. */
  84437. getColorToRef(result: Color4): void;
  84438. }
  84439. /** Class used to store color 3 gradient */
  84440. export class Color3Gradient implements IValueGradient {
  84441. /**
  84442. * Gets or sets the gradient value (between 0 and 1)
  84443. */
  84444. gradient: number;
  84445. /**
  84446. * Gets or sets the associated color
  84447. */
  84448. color: Color3;
  84449. /**
  84450. * Creates a new color3 gradient
  84451. * @param gradient gets or sets the gradient value (between 0 and 1)
  84452. * @param color gets or sets associated color
  84453. */
  84454. constructor(
  84455. /**
  84456. * Gets or sets the gradient value (between 0 and 1)
  84457. */
  84458. gradient: number,
  84459. /**
  84460. * Gets or sets the associated color
  84461. */
  84462. color: Color3);
  84463. }
  84464. /** Class used to store factor gradient */
  84465. export class FactorGradient implements IValueGradient {
  84466. /**
  84467. * Gets or sets the gradient value (between 0 and 1)
  84468. */
  84469. gradient: number;
  84470. /**
  84471. * Gets or sets first associated factor
  84472. */
  84473. factor1: number;
  84474. /**
  84475. * Gets or sets second associated factor
  84476. */
  84477. factor2?: number | undefined;
  84478. /**
  84479. * Creates a new factor gradient
  84480. * @param gradient gets or sets the gradient value (between 0 and 1)
  84481. * @param factor1 gets or sets first associated factor
  84482. * @param factor2 gets or sets second associated factor
  84483. */
  84484. constructor(
  84485. /**
  84486. * Gets or sets the gradient value (between 0 and 1)
  84487. */
  84488. gradient: number,
  84489. /**
  84490. * Gets or sets first associated factor
  84491. */
  84492. factor1: number,
  84493. /**
  84494. * Gets or sets second associated factor
  84495. */
  84496. factor2?: number | undefined);
  84497. /**
  84498. * Will get a number picked randomly between factor1 and factor2.
  84499. * If factor2 is undefined then factor1 will be used
  84500. * @returns the picked number
  84501. */
  84502. getFactor(): number;
  84503. }
  84504. /**
  84505. * Helper used to simplify some generic gradient tasks
  84506. */
  84507. export class GradientHelper {
  84508. /**
  84509. * Gets the current gradient from an array of IValueGradient
  84510. * @param ratio defines the current ratio to get
  84511. * @param gradients defines the array of IValueGradient
  84512. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84513. */
  84514. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84515. }
  84516. }
  84517. declare module BABYLON {
  84518. /**
  84519. * Interface for the size containing width and height
  84520. */
  84521. export interface ISize {
  84522. /**
  84523. * Width
  84524. */
  84525. width: number;
  84526. /**
  84527. * Heighht
  84528. */
  84529. height: number;
  84530. }
  84531. /**
  84532. * Size containing widht and height
  84533. */
  84534. export class Size implements ISize {
  84535. /**
  84536. * Width
  84537. */
  84538. width: number;
  84539. /**
  84540. * Height
  84541. */
  84542. height: number;
  84543. /**
  84544. * Creates a Size object from the given width and height (floats).
  84545. * @param width width of the new size
  84546. * @param height height of the new size
  84547. */
  84548. constructor(width: number, height: number);
  84549. /**
  84550. * Returns a string with the Size width and height
  84551. * @returns a string with the Size width and height
  84552. */
  84553. toString(): string;
  84554. /**
  84555. * "Size"
  84556. * @returns the string "Size"
  84557. */
  84558. getClassName(): string;
  84559. /**
  84560. * Returns the Size hash code.
  84561. * @returns a hash code for a unique width and height
  84562. */
  84563. getHashCode(): number;
  84564. /**
  84565. * Updates the current size from the given one.
  84566. * @param src the given size
  84567. */
  84568. copyFrom(src: Size): void;
  84569. /**
  84570. * Updates in place the current Size from the given floats.
  84571. * @param width width of the new size
  84572. * @param height height of the new size
  84573. * @returns the updated Size.
  84574. */
  84575. copyFromFloats(width: number, height: number): Size;
  84576. /**
  84577. * Updates in place the current Size from the given floats.
  84578. * @param width width to set
  84579. * @param height height to set
  84580. * @returns the updated Size.
  84581. */
  84582. set(width: number, height: number): Size;
  84583. /**
  84584. * Multiplies the width and height by numbers
  84585. * @param w factor to multiple the width by
  84586. * @param h factor to multiple the height by
  84587. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84588. */
  84589. multiplyByFloats(w: number, h: number): Size;
  84590. /**
  84591. * Clones the size
  84592. * @returns a new Size copied from the given one.
  84593. */
  84594. clone(): Size;
  84595. /**
  84596. * True if the current Size and the given one width and height are strictly equal.
  84597. * @param other the other size to compare against
  84598. * @returns True if the current Size and the given one width and height are strictly equal.
  84599. */
  84600. equals(other: Size): boolean;
  84601. /**
  84602. * The surface of the Size : width * height (float).
  84603. */
  84604. get surface(): number;
  84605. /**
  84606. * Create a new size of zero
  84607. * @returns a new Size set to (0.0, 0.0)
  84608. */
  84609. static Zero(): Size;
  84610. /**
  84611. * Sums the width and height of two sizes
  84612. * @param otherSize size to add to this size
  84613. * @returns a new Size set as the addition result of the current Size and the given one.
  84614. */
  84615. add(otherSize: Size): Size;
  84616. /**
  84617. * Subtracts the width and height of two
  84618. * @param otherSize size to subtract to this size
  84619. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84620. */
  84621. subtract(otherSize: Size): Size;
  84622. /**
  84623. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84624. * @param start starting size to lerp between
  84625. * @param end end size to lerp between
  84626. * @param amount amount to lerp between the start and end values
  84627. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84628. */
  84629. static Lerp(start: Size, end: Size, amount: number): Size;
  84630. }
  84631. }
  84632. declare module BABYLON {
  84633. interface ThinEngine {
  84634. /**
  84635. * Creates a dynamic texture
  84636. * @param width defines the width of the texture
  84637. * @param height defines the height of the texture
  84638. * @param generateMipMaps defines if the engine should generate the mip levels
  84639. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84640. * @returns the dynamic texture inside an InternalTexture
  84641. */
  84642. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84643. /**
  84644. * Update the content of a dynamic texture
  84645. * @param texture defines the texture to update
  84646. * @param canvas defines the canvas containing the source
  84647. * @param invertY defines if data must be stored with Y axis inverted
  84648. * @param premulAlpha defines if alpha is stored as premultiplied
  84649. * @param format defines the format of the data
  84650. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84651. */
  84652. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84653. }
  84654. }
  84655. declare module BABYLON {
  84656. /**
  84657. * Helper class used to generate a canvas to manipulate images
  84658. */
  84659. export class CanvasGenerator {
  84660. /**
  84661. * Create a new canvas (or offscreen canvas depending on the context)
  84662. * @param width defines the expected width
  84663. * @param height defines the expected height
  84664. * @return a new canvas or offscreen canvas
  84665. */
  84666. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84667. }
  84668. }
  84669. declare module BABYLON {
  84670. /**
  84671. * A class extending Texture allowing drawing on a texture
  84672. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84673. */
  84674. export class DynamicTexture extends Texture {
  84675. private _generateMipMaps;
  84676. private _canvas;
  84677. private _context;
  84678. private _engine;
  84679. /**
  84680. * Creates a DynamicTexture
  84681. * @param name defines the name of the texture
  84682. * @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
  84683. * @param scene defines the scene where you want the texture
  84684. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84685. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84686. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84687. */
  84688. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84689. /**
  84690. * Get the current class name of the texture useful for serialization or dynamic coding.
  84691. * @returns "DynamicTexture"
  84692. */
  84693. getClassName(): string;
  84694. /**
  84695. * Gets the current state of canRescale
  84696. */
  84697. get canRescale(): boolean;
  84698. private _recreate;
  84699. /**
  84700. * Scales the texture
  84701. * @param ratio the scale factor to apply to both width and height
  84702. */
  84703. scale(ratio: number): void;
  84704. /**
  84705. * Resizes the texture
  84706. * @param width the new width
  84707. * @param height the new height
  84708. */
  84709. scaleTo(width: number, height: number): void;
  84710. /**
  84711. * Gets the context of the canvas used by the texture
  84712. * @returns the canvas context of the dynamic texture
  84713. */
  84714. getContext(): CanvasRenderingContext2D;
  84715. /**
  84716. * Clears the texture
  84717. */
  84718. clear(): void;
  84719. /**
  84720. * Updates the texture
  84721. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84722. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84723. */
  84724. update(invertY?: boolean, premulAlpha?: boolean): void;
  84725. /**
  84726. * Draws text onto the texture
  84727. * @param text defines the text to be drawn
  84728. * @param x defines the placement of the text from the left
  84729. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84730. * @param font defines the font to be used with font-style, font-size, font-name
  84731. * @param color defines the color used for the text
  84732. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84733. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84734. * @param update defines whether texture is immediately update (default is true)
  84735. */
  84736. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  84737. /**
  84738. * Clones the texture
  84739. * @returns the clone of the texture.
  84740. */
  84741. clone(): DynamicTexture;
  84742. /**
  84743. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84744. * @returns a serialized dynamic texture object
  84745. */
  84746. serialize(): any;
  84747. /** @hidden */
  84748. _rebuild(): void;
  84749. }
  84750. }
  84751. declare module BABYLON {
  84752. interface Engine {
  84753. /**
  84754. * Creates a raw texture
  84755. * @param data defines the data to store in the texture
  84756. * @param width defines the width of the texture
  84757. * @param height defines the height of the texture
  84758. * @param format defines the format of the data
  84759. * @param generateMipMaps defines if the engine should generate the mip levels
  84760. * @param invertY defines if data must be stored with Y axis inverted
  84761. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84762. * @param compression defines the compression used (null by default)
  84763. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84764. * @returns the raw texture inside an InternalTexture
  84765. */
  84766. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84767. /**
  84768. * Update a raw texture
  84769. * @param texture defines the texture to update
  84770. * @param data defines the data to store in the texture
  84771. * @param format defines the format of the data
  84772. * @param invertY defines if data must be stored with Y axis inverted
  84773. */
  84774. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84775. /**
  84776. * Update a raw texture
  84777. * @param texture defines the texture to update
  84778. * @param data defines the data to store in the texture
  84779. * @param format defines the format of the data
  84780. * @param invertY defines if data must be stored with Y axis inverted
  84781. * @param compression defines the compression used (null by default)
  84782. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84783. */
  84784. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84785. /**
  84786. * Creates a new raw cube texture
  84787. * @param data defines the array of data to use to create each face
  84788. * @param size defines the size of the textures
  84789. * @param format defines the format of the data
  84790. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84791. * @param generateMipMaps defines if the engine should generate the mip levels
  84792. * @param invertY defines if data must be stored with Y axis inverted
  84793. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84794. * @param compression defines the compression used (null by default)
  84795. * @returns the cube texture as an InternalTexture
  84796. */
  84797. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84798. /**
  84799. * Update a raw cube texture
  84800. * @param texture defines the texture to udpdate
  84801. * @param data defines the data to store
  84802. * @param format defines the data format
  84803. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84804. * @param invertY defines if data must be stored with Y axis inverted
  84805. */
  84806. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84807. /**
  84808. * Update a raw cube texture
  84809. * @param texture defines the texture to udpdate
  84810. * @param data defines the data to store
  84811. * @param format defines the data format
  84812. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84813. * @param invertY defines if data must be stored with Y axis inverted
  84814. * @param compression defines the compression used (null by default)
  84815. */
  84816. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84817. /**
  84818. * Update a raw cube texture
  84819. * @param texture defines the texture to udpdate
  84820. * @param data defines the data to store
  84821. * @param format defines the data format
  84822. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84823. * @param invertY defines if data must be stored with Y axis inverted
  84824. * @param compression defines the compression used (null by default)
  84825. * @param level defines which level of the texture to update
  84826. */
  84827. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84828. /**
  84829. * Creates a new raw cube texture from a specified url
  84830. * @param url defines the url where the data is located
  84831. * @param scene defines the current scene
  84832. * @param size defines the size of the textures
  84833. * @param format defines the format of the data
  84834. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84835. * @param noMipmap defines if the engine should avoid generating the mip levels
  84836. * @param callback defines a callback used to extract texture data from loaded data
  84837. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84838. * @param onLoad defines a callback called when texture is loaded
  84839. * @param onError defines a callback called if there is an error
  84840. * @returns the cube texture as an InternalTexture
  84841. */
  84842. 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;
  84843. /**
  84844. * Creates a new raw cube texture from a specified url
  84845. * @param url defines the url where the data is located
  84846. * @param scene defines the current scene
  84847. * @param size defines the size of the textures
  84848. * @param format defines the format of the data
  84849. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84850. * @param noMipmap defines if the engine should avoid generating the mip levels
  84851. * @param callback defines a callback used to extract texture data from loaded data
  84852. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84853. * @param onLoad defines a callback called when texture is loaded
  84854. * @param onError defines a callback called if there is an error
  84855. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84856. * @param invertY defines if data must be stored with Y axis inverted
  84857. * @returns the cube texture as an InternalTexture
  84858. */
  84859. 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;
  84860. /**
  84861. * Creates a new raw 3D texture
  84862. * @param data defines the data used to create the texture
  84863. * @param width defines the width of the texture
  84864. * @param height defines the height of the texture
  84865. * @param depth defines the depth of the texture
  84866. * @param format defines the format of the texture
  84867. * @param generateMipMaps defines if the engine must generate mip levels
  84868. * @param invertY defines if data must be stored with Y axis inverted
  84869. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84870. * @param compression defines the compressed used (can be null)
  84871. * @param textureType defines the compressed used (can be null)
  84872. * @returns a new raw 3D texture (stored in an InternalTexture)
  84873. */
  84874. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84875. /**
  84876. * Update a raw 3D texture
  84877. * @param texture defines the texture to update
  84878. * @param data defines the data to store
  84879. * @param format defines the data format
  84880. * @param invertY defines if data must be stored with Y axis inverted
  84881. */
  84882. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84883. /**
  84884. * Update a raw 3D texture
  84885. * @param texture defines the texture to update
  84886. * @param data defines the data to store
  84887. * @param format defines the data format
  84888. * @param invertY defines if data must be stored with Y axis inverted
  84889. * @param compression defines the used compression (can be null)
  84890. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84891. */
  84892. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84893. /**
  84894. * Creates a new raw 2D array texture
  84895. * @param data defines the data used to create the texture
  84896. * @param width defines the width of the texture
  84897. * @param height defines the height of the texture
  84898. * @param depth defines the number of layers of the texture
  84899. * @param format defines the format of the texture
  84900. * @param generateMipMaps defines if the engine must generate mip levels
  84901. * @param invertY defines if data must be stored with Y axis inverted
  84902. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84903. * @param compression defines the compressed used (can be null)
  84904. * @param textureType defines the compressed used (can be null)
  84905. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84906. */
  84907. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84908. /**
  84909. * Update a raw 2D array texture
  84910. * @param texture defines the texture to update
  84911. * @param data defines the data to store
  84912. * @param format defines the data format
  84913. * @param invertY defines if data must be stored with Y axis inverted
  84914. */
  84915. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84916. /**
  84917. * Update a raw 2D array texture
  84918. * @param texture defines the texture to update
  84919. * @param data defines the data to store
  84920. * @param format defines the data format
  84921. * @param invertY defines if data must be stored with Y axis inverted
  84922. * @param compression defines the used compression (can be null)
  84923. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84924. */
  84925. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84926. }
  84927. }
  84928. declare module BABYLON {
  84929. /**
  84930. * Raw texture can help creating a texture directly from an array of data.
  84931. * This can be super useful if you either get the data from an uncompressed source or
  84932. * if you wish to create your texture pixel by pixel.
  84933. */
  84934. export class RawTexture extends Texture {
  84935. /**
  84936. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84937. */
  84938. format: number;
  84939. private _engine;
  84940. /**
  84941. * Instantiates a new RawTexture.
  84942. * Raw texture can help creating a texture directly from an array of data.
  84943. * This can be super useful if you either get the data from an uncompressed source or
  84944. * if you wish to create your texture pixel by pixel.
  84945. * @param data define the array of data to use to create the texture
  84946. * @param width define the width of the texture
  84947. * @param height define the height of the texture
  84948. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84949. * @param scene define the scene the texture belongs to
  84950. * @param generateMipMaps define whether mip maps should be generated or not
  84951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84954. */
  84955. constructor(data: ArrayBufferView, width: number, height: number,
  84956. /**
  84957. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84958. */
  84959. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84960. /**
  84961. * Updates the texture underlying data.
  84962. * @param data Define the new data of the texture
  84963. */
  84964. update(data: ArrayBufferView): void;
  84965. /**
  84966. * Creates a luminance texture from some data.
  84967. * @param data Define the texture data
  84968. * @param width Define the width of the texture
  84969. * @param height Define the height of the texture
  84970. * @param scene Define the scene the texture belongs to
  84971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84974. * @returns the luminance texture
  84975. */
  84976. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84977. /**
  84978. * Creates a luminance alpha texture from some data.
  84979. * @param data Define the texture data
  84980. * @param width Define the width of the texture
  84981. * @param height Define the height of the texture
  84982. * @param scene Define the scene the texture belongs to
  84983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84986. * @returns the luminance alpha texture
  84987. */
  84988. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84989. /**
  84990. * Creates an alpha texture from some data.
  84991. * @param data Define the texture data
  84992. * @param width Define the width of the texture
  84993. * @param height Define the height of the texture
  84994. * @param scene Define the scene the texture belongs to
  84995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84998. * @returns the alpha texture
  84999. */
  85000. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85001. /**
  85002. * Creates a RGB 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 RGB alpha texture
  85012. */
  85013. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85014. /**
  85015. * Creates a RGBA 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 RGBA texture
  85025. */
  85026. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85027. /**
  85028. * Creates a R texture from some data.
  85029. * @param data Define the texture data
  85030. * @param width Define the width of the texture
  85031. * @param height Define the height of the texture
  85032. * @param scene Define the scene the texture belongs to
  85033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85036. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85037. * @returns the R texture
  85038. */
  85039. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85040. }
  85041. }
  85042. declare module BABYLON {
  85043. interface AbstractScene {
  85044. /**
  85045. * The list of procedural textures added to the scene
  85046. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85047. */
  85048. proceduralTextures: Array<ProceduralTexture>;
  85049. }
  85050. /**
  85051. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85052. * in a given scene.
  85053. */
  85054. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85055. /**
  85056. * The component name helpfull to identify the component in the list of scene components.
  85057. */
  85058. readonly name: string;
  85059. /**
  85060. * The scene the component belongs to.
  85061. */
  85062. scene: Scene;
  85063. /**
  85064. * Creates a new instance of the component for the given scene
  85065. * @param scene Defines the scene to register the component in
  85066. */
  85067. constructor(scene: Scene);
  85068. /**
  85069. * Registers the component in a given scene
  85070. */
  85071. register(): void;
  85072. /**
  85073. * Rebuilds the elements related to this component in case of
  85074. * context lost for instance.
  85075. */
  85076. rebuild(): void;
  85077. /**
  85078. * Disposes the component and the associated ressources.
  85079. */
  85080. dispose(): void;
  85081. private _beforeClear;
  85082. }
  85083. }
  85084. declare module BABYLON {
  85085. interface ThinEngine {
  85086. /**
  85087. * Creates a new render target cube texture
  85088. * @param size defines the size of the texture
  85089. * @param options defines the options used to create the texture
  85090. * @returns a new render target cube texture stored in an InternalTexture
  85091. */
  85092. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85093. }
  85094. }
  85095. declare module BABYLON {
  85096. /** @hidden */
  85097. export var proceduralVertexShader: {
  85098. name: string;
  85099. shader: string;
  85100. };
  85101. }
  85102. declare module BABYLON {
  85103. /**
  85104. * 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.
  85105. * This is the base class of any Procedural texture and contains most of the shareable code.
  85106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85107. */
  85108. export class ProceduralTexture extends Texture {
  85109. isCube: boolean;
  85110. /**
  85111. * Define if the texture is enabled or not (disabled texture will not render)
  85112. */
  85113. isEnabled: boolean;
  85114. /**
  85115. * Define if the texture must be cleared before rendering (default is true)
  85116. */
  85117. autoClear: boolean;
  85118. /**
  85119. * Callback called when the texture is generated
  85120. */
  85121. onGenerated: () => void;
  85122. /**
  85123. * Event raised when the texture is generated
  85124. */
  85125. onGeneratedObservable: Observable<ProceduralTexture>;
  85126. /** @hidden */
  85127. _generateMipMaps: boolean;
  85128. /** @hidden **/
  85129. _effect: Effect;
  85130. /** @hidden */
  85131. _textures: {
  85132. [key: string]: Texture;
  85133. };
  85134. /** @hidden */
  85135. protected _fallbackTexture: Nullable<Texture>;
  85136. private _size;
  85137. private _currentRefreshId;
  85138. private _frameId;
  85139. private _refreshRate;
  85140. private _vertexBuffers;
  85141. private _indexBuffer;
  85142. private _uniforms;
  85143. private _samplers;
  85144. private _fragment;
  85145. private _floats;
  85146. private _ints;
  85147. private _floatsArrays;
  85148. private _colors3;
  85149. private _colors4;
  85150. private _vectors2;
  85151. private _vectors3;
  85152. private _matrices;
  85153. private _fallbackTextureUsed;
  85154. private _engine;
  85155. private _cachedDefines;
  85156. private _contentUpdateId;
  85157. private _contentData;
  85158. /**
  85159. * Instantiates a new procedural texture.
  85160. * 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.
  85161. * This is the base class of any Procedural texture and contains most of the shareable code.
  85162. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85163. * @param name Define the name of the texture
  85164. * @param size Define the size of the texture to create
  85165. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85166. * @param scene Define the scene the texture belongs to
  85167. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85168. * @param generateMipMaps Define if the texture should creates mip maps or not
  85169. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85170. */
  85171. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85172. /**
  85173. * The effect that is created when initializing the post process.
  85174. * @returns The created effect corresponding the the postprocess.
  85175. */
  85176. getEffect(): Effect;
  85177. /**
  85178. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85179. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85180. */
  85181. getContent(): Nullable<ArrayBufferView>;
  85182. private _createIndexBuffer;
  85183. /** @hidden */
  85184. _rebuild(): void;
  85185. /**
  85186. * Resets the texture in order to recreate its associated resources.
  85187. * This can be called in case of context loss
  85188. */
  85189. reset(): void;
  85190. protected _getDefines(): string;
  85191. /**
  85192. * Is the texture ready to be used ? (rendered at least once)
  85193. * @returns true if ready, otherwise, false.
  85194. */
  85195. isReady(): boolean;
  85196. /**
  85197. * Resets the refresh counter of the texture and start bak from scratch.
  85198. * Could be useful to regenerate the texture if it is setup to render only once.
  85199. */
  85200. resetRefreshCounter(): void;
  85201. /**
  85202. * Set the fragment shader to use in order to render the texture.
  85203. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85204. */
  85205. setFragment(fragment: any): void;
  85206. /**
  85207. * Define the refresh rate of the texture or the rendering frequency.
  85208. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85209. */
  85210. get refreshRate(): number;
  85211. set refreshRate(value: number);
  85212. /** @hidden */
  85213. _shouldRender(): boolean;
  85214. /**
  85215. * Get the size the texture is rendering at.
  85216. * @returns the size (texture is always squared)
  85217. */
  85218. getRenderSize(): number;
  85219. /**
  85220. * Resize the texture to new value.
  85221. * @param size Define the new size the texture should have
  85222. * @param generateMipMaps Define whether the new texture should create mip maps
  85223. */
  85224. resize(size: number, generateMipMaps: boolean): void;
  85225. private _checkUniform;
  85226. /**
  85227. * Set a texture in the shader program used to render.
  85228. * @param name Define the name of the uniform samplers as defined in the shader
  85229. * @param texture Define the texture to bind to this sampler
  85230. * @return the texture itself allowing "fluent" like uniform updates
  85231. */
  85232. setTexture(name: string, texture: Texture): ProceduralTexture;
  85233. /**
  85234. * Set a float in the shader.
  85235. * @param name Define the name of the uniform as defined in the shader
  85236. * @param value Define the value to give to the uniform
  85237. * @return the texture itself allowing "fluent" like uniform updates
  85238. */
  85239. setFloat(name: string, value: number): ProceduralTexture;
  85240. /**
  85241. * Set a int in the shader.
  85242. * @param name Define the name of the uniform as defined in the shader
  85243. * @param value Define the value to give to the uniform
  85244. * @return the texture itself allowing "fluent" like uniform updates
  85245. */
  85246. setInt(name: string, value: number): ProceduralTexture;
  85247. /**
  85248. * Set an array of floats in the shader.
  85249. * @param name Define the name of the uniform as defined in the shader
  85250. * @param value Define the value to give to the uniform
  85251. * @return the texture itself allowing "fluent" like uniform updates
  85252. */
  85253. setFloats(name: string, value: number[]): ProceduralTexture;
  85254. /**
  85255. * Set a vec3 in the shader from a Color3.
  85256. * @param name Define the name of the uniform as defined in the shader
  85257. * @param value Define the value to give to the uniform
  85258. * @return the texture itself allowing "fluent" like uniform updates
  85259. */
  85260. setColor3(name: string, value: Color3): ProceduralTexture;
  85261. /**
  85262. * Set a vec4 in the shader from a Color4.
  85263. * @param name Define the name of the uniform as defined in the shader
  85264. * @param value Define the value to give to the uniform
  85265. * @return the texture itself allowing "fluent" like uniform updates
  85266. */
  85267. setColor4(name: string, value: Color4): ProceduralTexture;
  85268. /**
  85269. * Set a vec2 in the shader from a Vector2.
  85270. * @param name Define the name of the uniform as defined in the shader
  85271. * @param value Define the value to give to the uniform
  85272. * @return the texture itself allowing "fluent" like uniform updates
  85273. */
  85274. setVector2(name: string, value: Vector2): ProceduralTexture;
  85275. /**
  85276. * Set a vec3 in the shader from a Vector3.
  85277. * @param name Define the name of the uniform as defined in the shader
  85278. * @param value Define the value to give to the uniform
  85279. * @return the texture itself allowing "fluent" like uniform updates
  85280. */
  85281. setVector3(name: string, value: Vector3): ProceduralTexture;
  85282. /**
  85283. * Set a mat4 in the shader from a MAtrix.
  85284. * @param name Define the name of the uniform as defined in the shader
  85285. * @param value Define the value to give to the uniform
  85286. * @return the texture itself allowing "fluent" like uniform updates
  85287. */
  85288. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85289. /**
  85290. * Render the texture to its associated render target.
  85291. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85292. */
  85293. render(useCameraPostProcess?: boolean): void;
  85294. /**
  85295. * Clone the texture.
  85296. * @returns the cloned texture
  85297. */
  85298. clone(): ProceduralTexture;
  85299. /**
  85300. * Dispose the texture and release its asoociated resources.
  85301. */
  85302. dispose(): void;
  85303. }
  85304. }
  85305. declare module BABYLON {
  85306. /**
  85307. * This represents the base class for particle system in Babylon.
  85308. * 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.
  85309. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85310. * @example https://doc.babylonjs.com/babylon101/particles
  85311. */
  85312. export class BaseParticleSystem {
  85313. /**
  85314. * Source color is added to the destination color without alpha affecting the result
  85315. */
  85316. static BLENDMODE_ONEONE: number;
  85317. /**
  85318. * Blend current color and particle color using particle’s alpha
  85319. */
  85320. static BLENDMODE_STANDARD: number;
  85321. /**
  85322. * Add current color and particle color multiplied by particle’s alpha
  85323. */
  85324. static BLENDMODE_ADD: number;
  85325. /**
  85326. * Multiply current color with particle color
  85327. */
  85328. static BLENDMODE_MULTIPLY: number;
  85329. /**
  85330. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85331. */
  85332. static BLENDMODE_MULTIPLYADD: number;
  85333. /**
  85334. * List of animations used by the particle system.
  85335. */
  85336. animations: Animation[];
  85337. /**
  85338. * Gets or sets the unique id of the particle system
  85339. */
  85340. uniqueId: number;
  85341. /**
  85342. * The id of the Particle system.
  85343. */
  85344. id: string;
  85345. /**
  85346. * The friendly name of the Particle system.
  85347. */
  85348. name: string;
  85349. /**
  85350. * Snippet ID if the particle system was created from the snippet server
  85351. */
  85352. snippetId: string;
  85353. /**
  85354. * The rendering group used by the Particle system to chose when to render.
  85355. */
  85356. renderingGroupId: number;
  85357. /**
  85358. * The emitter represents the Mesh or position we are attaching the particle system to.
  85359. */
  85360. emitter: Nullable<AbstractMesh | Vector3>;
  85361. /**
  85362. * The maximum number of particles to emit per frame
  85363. */
  85364. emitRate: number;
  85365. /**
  85366. * If you want to launch only a few particles at once, that can be done, as well.
  85367. */
  85368. manualEmitCount: number;
  85369. /**
  85370. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85371. */
  85372. updateSpeed: number;
  85373. /**
  85374. * The amount of time the particle system is running (depends of the overall update speed).
  85375. */
  85376. targetStopDuration: number;
  85377. /**
  85378. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85379. */
  85380. disposeOnStop: boolean;
  85381. /**
  85382. * Minimum power of emitting particles.
  85383. */
  85384. minEmitPower: number;
  85385. /**
  85386. * Maximum power of emitting particles.
  85387. */
  85388. maxEmitPower: number;
  85389. /**
  85390. * Minimum life time of emitting particles.
  85391. */
  85392. minLifeTime: number;
  85393. /**
  85394. * Maximum life time of emitting particles.
  85395. */
  85396. maxLifeTime: number;
  85397. /**
  85398. * Minimum Size of emitting particles.
  85399. */
  85400. minSize: number;
  85401. /**
  85402. * Maximum Size of emitting particles.
  85403. */
  85404. maxSize: number;
  85405. /**
  85406. * Minimum scale of emitting particles on X axis.
  85407. */
  85408. minScaleX: number;
  85409. /**
  85410. * Maximum scale of emitting particles on X axis.
  85411. */
  85412. maxScaleX: number;
  85413. /**
  85414. * Minimum scale of emitting particles on Y axis.
  85415. */
  85416. minScaleY: number;
  85417. /**
  85418. * Maximum scale of emitting particles on Y axis.
  85419. */
  85420. maxScaleY: number;
  85421. /**
  85422. * Gets or sets the minimal initial rotation in radians.
  85423. */
  85424. minInitialRotation: number;
  85425. /**
  85426. * Gets or sets the maximal initial rotation in radians.
  85427. */
  85428. maxInitialRotation: number;
  85429. /**
  85430. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85431. */
  85432. minAngularSpeed: number;
  85433. /**
  85434. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85435. */
  85436. maxAngularSpeed: number;
  85437. /**
  85438. * The texture used to render each particle. (this can be a spritesheet)
  85439. */
  85440. particleTexture: Nullable<Texture>;
  85441. /**
  85442. * The layer mask we are rendering the particles through.
  85443. */
  85444. layerMask: number;
  85445. /**
  85446. * This can help using your own shader to render the particle system.
  85447. * The according effect will be created
  85448. */
  85449. customShader: any;
  85450. /**
  85451. * By default particle system starts as soon as they are created. This prevents the
  85452. * automatic start to happen and let you decide when to start emitting particles.
  85453. */
  85454. preventAutoStart: boolean;
  85455. private _noiseTexture;
  85456. /**
  85457. * Gets or sets a texture used to add random noise to particle positions
  85458. */
  85459. get noiseTexture(): Nullable<ProceduralTexture>;
  85460. set noiseTexture(value: Nullable<ProceduralTexture>);
  85461. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85462. noiseStrength: Vector3;
  85463. /**
  85464. * Callback triggered when the particle animation is ending.
  85465. */
  85466. onAnimationEnd: Nullable<() => void>;
  85467. /**
  85468. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85469. */
  85470. blendMode: number;
  85471. /**
  85472. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85473. * to override the particles.
  85474. */
  85475. forceDepthWrite: boolean;
  85476. /** 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 */
  85477. preWarmCycles: number;
  85478. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85479. preWarmStepOffset: number;
  85480. /**
  85481. * 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)
  85482. */
  85483. spriteCellChangeSpeed: number;
  85484. /**
  85485. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85486. */
  85487. startSpriteCellID: number;
  85488. /**
  85489. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85490. */
  85491. endSpriteCellID: number;
  85492. /**
  85493. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85494. */
  85495. spriteCellWidth: number;
  85496. /**
  85497. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85498. */
  85499. spriteCellHeight: number;
  85500. /**
  85501. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85502. */
  85503. spriteRandomStartCell: boolean;
  85504. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85505. translationPivot: Vector2;
  85506. /** @hidden */
  85507. protected _isAnimationSheetEnabled: boolean;
  85508. /**
  85509. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85510. */
  85511. beginAnimationOnStart: boolean;
  85512. /**
  85513. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85514. */
  85515. beginAnimationFrom: number;
  85516. /**
  85517. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85518. */
  85519. beginAnimationTo: number;
  85520. /**
  85521. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85522. */
  85523. beginAnimationLoop: boolean;
  85524. /**
  85525. * Gets or sets a world offset applied to all particles
  85526. */
  85527. worldOffset: Vector3;
  85528. /**
  85529. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85530. */
  85531. get isAnimationSheetEnabled(): boolean;
  85532. set isAnimationSheetEnabled(value: boolean);
  85533. /**
  85534. * Get hosting scene
  85535. * @returns the scene
  85536. */
  85537. getScene(): Scene;
  85538. /**
  85539. * You can use gravity if you want to give an orientation to your particles.
  85540. */
  85541. gravity: Vector3;
  85542. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85543. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85544. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85545. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85546. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85547. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85548. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85549. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85550. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85551. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85552. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85553. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85554. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85555. /**
  85556. * Defines the delay in milliseconds before starting the system (0 by default)
  85557. */
  85558. startDelay: number;
  85559. /**
  85560. * Gets the current list of drag gradients.
  85561. * You must use addDragGradient and removeDragGradient to udpate this list
  85562. * @returns the list of drag gradients
  85563. */
  85564. getDragGradients(): Nullable<Array<FactorGradient>>;
  85565. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85566. limitVelocityDamping: number;
  85567. /**
  85568. * Gets the current list of limit velocity gradients.
  85569. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85570. * @returns the list of limit velocity gradients
  85571. */
  85572. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85573. /**
  85574. * Gets the current list of color gradients.
  85575. * You must use addColorGradient and removeColorGradient to udpate this list
  85576. * @returns the list of color gradients
  85577. */
  85578. getColorGradients(): Nullable<Array<ColorGradient>>;
  85579. /**
  85580. * Gets the current list of size gradients.
  85581. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85582. * @returns the list of size gradients
  85583. */
  85584. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85585. /**
  85586. * Gets the current list of color remap gradients.
  85587. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85588. * @returns the list of color remap gradients
  85589. */
  85590. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85591. /**
  85592. * Gets the current list of alpha remap gradients.
  85593. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85594. * @returns the list of alpha remap gradients
  85595. */
  85596. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85597. /**
  85598. * Gets the current list of life time gradients.
  85599. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85600. * @returns the list of life time gradients
  85601. */
  85602. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85603. /**
  85604. * Gets the current list of angular speed gradients.
  85605. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85606. * @returns the list of angular speed gradients
  85607. */
  85608. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85609. /**
  85610. * Gets the current list of velocity gradients.
  85611. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85612. * @returns the list of velocity gradients
  85613. */
  85614. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85615. /**
  85616. * Gets the current list of start size gradients.
  85617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85618. * @returns the list of start size gradients
  85619. */
  85620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85621. /**
  85622. * Gets the current list of emit rate gradients.
  85623. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85624. * @returns the list of emit rate gradients
  85625. */
  85626. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85627. /**
  85628. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85629. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85630. */
  85631. get direction1(): Vector3;
  85632. set direction1(value: Vector3);
  85633. /**
  85634. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85635. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85636. */
  85637. get direction2(): Vector3;
  85638. set direction2(value: Vector3);
  85639. /**
  85640. * 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.
  85641. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85642. */
  85643. get minEmitBox(): Vector3;
  85644. set minEmitBox(value: Vector3);
  85645. /**
  85646. * 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.
  85647. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85648. */
  85649. get maxEmitBox(): Vector3;
  85650. set maxEmitBox(value: Vector3);
  85651. /**
  85652. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85653. */
  85654. color1: Color4;
  85655. /**
  85656. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85657. */
  85658. color2: Color4;
  85659. /**
  85660. * Color the particle will have at the end of its lifetime
  85661. */
  85662. colorDead: Color4;
  85663. /**
  85664. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85665. */
  85666. textureMask: Color4;
  85667. /**
  85668. * The particle emitter type defines the emitter used by the particle system.
  85669. * It can be for example box, sphere, or cone...
  85670. */
  85671. particleEmitterType: IParticleEmitterType;
  85672. /** @hidden */
  85673. _isSubEmitter: boolean;
  85674. /**
  85675. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85676. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85677. */
  85678. billboardMode: number;
  85679. protected _isBillboardBased: boolean;
  85680. /**
  85681. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85682. */
  85683. get isBillboardBased(): boolean;
  85684. set isBillboardBased(value: boolean);
  85685. /**
  85686. * The scene the particle system belongs to.
  85687. */
  85688. protected _scene: Scene;
  85689. /**
  85690. * Local cache of defines for image processing.
  85691. */
  85692. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85693. /**
  85694. * Default configuration related to image processing available in the standard Material.
  85695. */
  85696. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85697. /**
  85698. * Gets the image processing configuration used either in this material.
  85699. */
  85700. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85701. /**
  85702. * Sets the Default image processing configuration used either in the this material.
  85703. *
  85704. * If sets to null, the scene one is in use.
  85705. */
  85706. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85707. /**
  85708. * Attaches a new image processing configuration to the Standard Material.
  85709. * @param configuration
  85710. */
  85711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85712. /** @hidden */
  85713. protected _reset(): void;
  85714. /** @hidden */
  85715. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85716. /**
  85717. * Instantiates a particle system.
  85718. * 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.
  85719. * @param name The name of the particle system
  85720. */
  85721. constructor(name: string);
  85722. /**
  85723. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85726. * @returns the emitter
  85727. */
  85728. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85729. /**
  85730. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85731. * @param radius The radius of the hemisphere to emit from
  85732. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85733. * @returns the emitter
  85734. */
  85735. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85736. /**
  85737. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85738. * @param radius The radius of the sphere to emit from
  85739. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85740. * @returns the emitter
  85741. */
  85742. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85743. /**
  85744. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85745. * @param radius The radius of the sphere to emit from
  85746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85748. * @returns the emitter
  85749. */
  85750. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85751. /**
  85752. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85753. * @param radius The radius of the emission cylinder
  85754. * @param height The height of the emission cylinder
  85755. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85756. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85757. * @returns the emitter
  85758. */
  85759. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85760. /**
  85761. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85762. * @param radius The radius of the cylinder to emit from
  85763. * @param height The height of the emission cylinder
  85764. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85767. * @returns the emitter
  85768. */
  85769. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85770. /**
  85771. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85772. * @param radius The radius of the cone to emit from
  85773. * @param angle The base angle of the cone
  85774. * @returns the emitter
  85775. */
  85776. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85777. /**
  85778. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85779. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85780. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85781. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85782. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85783. * @returns the emitter
  85784. */
  85785. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85786. }
  85787. }
  85788. declare module BABYLON {
  85789. /**
  85790. * Type of sub emitter
  85791. */
  85792. export enum SubEmitterType {
  85793. /**
  85794. * Attached to the particle over it's lifetime
  85795. */
  85796. ATTACHED = 0,
  85797. /**
  85798. * Created when the particle dies
  85799. */
  85800. END = 1
  85801. }
  85802. /**
  85803. * Sub emitter class used to emit particles from an existing particle
  85804. */
  85805. export class SubEmitter {
  85806. /**
  85807. * the particle system to be used by the sub emitter
  85808. */
  85809. particleSystem: ParticleSystem;
  85810. /**
  85811. * Type of the submitter (Default: END)
  85812. */
  85813. type: SubEmitterType;
  85814. /**
  85815. * 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)
  85816. * Note: This only is supported when using an emitter of type Mesh
  85817. */
  85818. inheritDirection: boolean;
  85819. /**
  85820. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85821. */
  85822. inheritedVelocityAmount: number;
  85823. /**
  85824. * Creates a sub emitter
  85825. * @param particleSystem the particle system to be used by the sub emitter
  85826. */
  85827. constructor(
  85828. /**
  85829. * the particle system to be used by the sub emitter
  85830. */
  85831. particleSystem: ParticleSystem);
  85832. /**
  85833. * Clones the sub emitter
  85834. * @returns the cloned sub emitter
  85835. */
  85836. clone(): SubEmitter;
  85837. /**
  85838. * Serialize current object to a JSON object
  85839. * @returns the serialized object
  85840. */
  85841. serialize(): any;
  85842. /** @hidden */
  85843. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85844. /**
  85845. * Creates a new SubEmitter from a serialized JSON version
  85846. * @param serializationObject defines the JSON object to read from
  85847. * @param scene defines the hosting scene
  85848. * @param rootUrl defines the rootUrl for data loading
  85849. * @returns a new SubEmitter
  85850. */
  85851. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85852. /** Release associated resources */
  85853. dispose(): void;
  85854. }
  85855. }
  85856. declare module BABYLON {
  85857. /** @hidden */
  85858. export var imageProcessingDeclaration: {
  85859. name: string;
  85860. shader: string;
  85861. };
  85862. }
  85863. declare module BABYLON {
  85864. /** @hidden */
  85865. export var imageProcessingFunctions: {
  85866. name: string;
  85867. shader: string;
  85868. };
  85869. }
  85870. declare module BABYLON {
  85871. /** @hidden */
  85872. export var particlesPixelShader: {
  85873. name: string;
  85874. shader: string;
  85875. };
  85876. }
  85877. declare module BABYLON {
  85878. /** @hidden */
  85879. export var particlesVertexShader: {
  85880. name: string;
  85881. shader: string;
  85882. };
  85883. }
  85884. declare module BABYLON {
  85885. /**
  85886. * This represents a particle system in Babylon.
  85887. * 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.
  85888. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85889. * @example https://doc.babylonjs.com/babylon101/particles
  85890. */
  85891. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85892. /**
  85893. * Billboard mode will only apply to Y axis
  85894. */
  85895. static readonly BILLBOARDMODE_Y: number;
  85896. /**
  85897. * Billboard mode will apply to all axes
  85898. */
  85899. static readonly BILLBOARDMODE_ALL: number;
  85900. /**
  85901. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85902. */
  85903. static readonly BILLBOARDMODE_STRETCHED: number;
  85904. /**
  85905. * This function can be defined to provide custom update for active particles.
  85906. * This function will be called instead of regular update (age, position, color, etc.).
  85907. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85908. */
  85909. updateFunction: (particles: Particle[]) => void;
  85910. private _emitterWorldMatrix;
  85911. /**
  85912. * This function can be defined to specify initial direction for every new particle.
  85913. * It by default use the emitterType defined function
  85914. */
  85915. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85916. /**
  85917. * This function can be defined to specify initial position for every new particle.
  85918. * It by default use the emitterType defined function
  85919. */
  85920. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85921. /**
  85922. * @hidden
  85923. */
  85924. _inheritedVelocityOffset: Vector3;
  85925. /**
  85926. * An event triggered when the system is disposed
  85927. */
  85928. onDisposeObservable: Observable<ParticleSystem>;
  85929. private _onDisposeObserver;
  85930. /**
  85931. * Sets a callback that will be triggered when the system is disposed
  85932. */
  85933. set onDispose(callback: () => void);
  85934. private _particles;
  85935. private _epsilon;
  85936. private _capacity;
  85937. private _stockParticles;
  85938. private _newPartsExcess;
  85939. private _vertexData;
  85940. private _vertexBuffer;
  85941. private _vertexBuffers;
  85942. private _spriteBuffer;
  85943. private _indexBuffer;
  85944. private _effect;
  85945. private _customEffect;
  85946. private _cachedDefines;
  85947. private _scaledColorStep;
  85948. private _colorDiff;
  85949. private _scaledDirection;
  85950. private _scaledGravity;
  85951. private _currentRenderId;
  85952. private _alive;
  85953. private _useInstancing;
  85954. private _started;
  85955. private _stopped;
  85956. private _actualFrame;
  85957. private _scaledUpdateSpeed;
  85958. private _vertexBufferSize;
  85959. /** @hidden */
  85960. _currentEmitRateGradient: Nullable<FactorGradient>;
  85961. /** @hidden */
  85962. _currentEmitRate1: number;
  85963. /** @hidden */
  85964. _currentEmitRate2: number;
  85965. /** @hidden */
  85966. _currentStartSizeGradient: Nullable<FactorGradient>;
  85967. /** @hidden */
  85968. _currentStartSize1: number;
  85969. /** @hidden */
  85970. _currentStartSize2: number;
  85971. private readonly _rawTextureWidth;
  85972. private _rampGradientsTexture;
  85973. private _useRampGradients;
  85974. /** Gets or sets a boolean indicating that ramp gradients must be used
  85975. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85976. */
  85977. get useRampGradients(): boolean;
  85978. set useRampGradients(value: boolean);
  85979. /**
  85980. * 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.
  85981. * 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: [])
  85982. */
  85983. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85984. private _subEmitters;
  85985. /**
  85986. * @hidden
  85987. * If the particle systems emitter should be disposed when the particle system is disposed
  85988. */
  85989. _disposeEmitterOnDispose: boolean;
  85990. /**
  85991. * The current active Sub-systems, this property is used by the root particle system only.
  85992. */
  85993. activeSubSystems: Array<ParticleSystem>;
  85994. /**
  85995. * Specifies if the particles are updated in emitter local space or world space
  85996. */
  85997. isLocal: boolean;
  85998. private _rootParticleSystem;
  85999. /**
  86000. * Gets the current list of active particles
  86001. */
  86002. get particles(): Particle[];
  86003. /**
  86004. * Gets the number of particles active at the same time.
  86005. * @returns The number of active particles.
  86006. */
  86007. getActiveCount(): number;
  86008. /**
  86009. * Returns the string "ParticleSystem"
  86010. * @returns a string containing the class name
  86011. */
  86012. getClassName(): string;
  86013. /**
  86014. * Gets a boolean indicating that the system is stopping
  86015. * @returns true if the system is currently stopping
  86016. */
  86017. isStopping(): boolean;
  86018. /**
  86019. * Instantiates a particle system.
  86020. * 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.
  86021. * @param name The name of the particle system
  86022. * @param capacity The max number of particles alive at the same time
  86023. * @param scene The scene the particle system belongs to
  86024. * @param customEffect a custom effect used to change the way particles are rendered by default
  86025. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86026. * @param epsilon Offset used to render the particles
  86027. */
  86028. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86029. private _addFactorGradient;
  86030. private _removeFactorGradient;
  86031. /**
  86032. * Adds a new life time gradient
  86033. * @param gradient defines the gradient to use (between 0 and 1)
  86034. * @param factor defines the life time factor to affect to the specified gradient
  86035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86036. * @returns the current particle system
  86037. */
  86038. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86039. /**
  86040. * Remove a specific life time gradient
  86041. * @param gradient defines the gradient to remove
  86042. * @returns the current particle system
  86043. */
  86044. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86045. /**
  86046. * Adds a new size gradient
  86047. * @param gradient defines the gradient to use (between 0 and 1)
  86048. * @param factor defines the size factor to affect to the specified gradient
  86049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86050. * @returns the current particle system
  86051. */
  86052. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86053. /**
  86054. * Remove a specific size gradient
  86055. * @param gradient defines the gradient to remove
  86056. * @returns the current particle system
  86057. */
  86058. removeSizeGradient(gradient: number): IParticleSystem;
  86059. /**
  86060. * Adds a new color remap gradient
  86061. * @param gradient defines the gradient to use (between 0 and 1)
  86062. * @param min defines the color remap minimal range
  86063. * @param max defines the color remap maximal range
  86064. * @returns the current particle system
  86065. */
  86066. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86067. /**
  86068. * Remove a specific color remap gradient
  86069. * @param gradient defines the gradient to remove
  86070. * @returns the current particle system
  86071. */
  86072. removeColorRemapGradient(gradient: number): IParticleSystem;
  86073. /**
  86074. * Adds a new alpha remap gradient
  86075. * @param gradient defines the gradient to use (between 0 and 1)
  86076. * @param min defines the alpha remap minimal range
  86077. * @param max defines the alpha remap maximal range
  86078. * @returns the current particle system
  86079. */
  86080. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86081. /**
  86082. * Remove a specific alpha remap gradient
  86083. * @param gradient defines the gradient to remove
  86084. * @returns the current particle system
  86085. */
  86086. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86087. /**
  86088. * Adds a new angular speed gradient
  86089. * @param gradient defines the gradient to use (between 0 and 1)
  86090. * @param factor defines the angular speed to affect to the specified gradient
  86091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86092. * @returns the current particle system
  86093. */
  86094. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86095. /**
  86096. * Remove a specific angular speed gradient
  86097. * @param gradient defines the gradient to remove
  86098. * @returns the current particle system
  86099. */
  86100. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86101. /**
  86102. * Adds a new velocity gradient
  86103. * @param gradient defines the gradient to use (between 0 and 1)
  86104. * @param factor defines the velocity to affect to the specified gradient
  86105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86106. * @returns the current particle system
  86107. */
  86108. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86109. /**
  86110. * Remove a specific velocity gradient
  86111. * @param gradient defines the gradient to remove
  86112. * @returns the current particle system
  86113. */
  86114. removeVelocityGradient(gradient: number): IParticleSystem;
  86115. /**
  86116. * Adds a new limit velocity gradient
  86117. * @param gradient defines the gradient to use (between 0 and 1)
  86118. * @param factor defines the limit velocity value to affect to the specified gradient
  86119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86120. * @returns the current particle system
  86121. */
  86122. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86123. /**
  86124. * Remove a specific limit velocity gradient
  86125. * @param gradient defines the gradient to remove
  86126. * @returns the current particle system
  86127. */
  86128. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86129. /**
  86130. * Adds a new drag gradient
  86131. * @param gradient defines the gradient to use (between 0 and 1)
  86132. * @param factor defines the drag value to affect to the specified gradient
  86133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86134. * @returns the current particle system
  86135. */
  86136. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86137. /**
  86138. * Remove a specific drag gradient
  86139. * @param gradient defines the gradient to remove
  86140. * @returns the current particle system
  86141. */
  86142. removeDragGradient(gradient: number): IParticleSystem;
  86143. /**
  86144. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86145. * @param gradient defines the gradient to use (between 0 and 1)
  86146. * @param factor defines the emit rate value to affect to the specified gradient
  86147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86148. * @returns the current particle system
  86149. */
  86150. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86151. /**
  86152. * Remove a specific emit rate gradient
  86153. * @param gradient defines the gradient to remove
  86154. * @returns the current particle system
  86155. */
  86156. removeEmitRateGradient(gradient: number): IParticleSystem;
  86157. /**
  86158. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86159. * @param gradient defines the gradient to use (between 0 and 1)
  86160. * @param factor defines the start size value to affect to the specified gradient
  86161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86162. * @returns the current particle system
  86163. */
  86164. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86165. /**
  86166. * Remove a specific start size gradient
  86167. * @param gradient defines the gradient to remove
  86168. * @returns the current particle system
  86169. */
  86170. removeStartSizeGradient(gradient: number): IParticleSystem;
  86171. private _createRampGradientTexture;
  86172. /**
  86173. * Gets the current list of ramp gradients.
  86174. * You must use addRampGradient and removeRampGradient to udpate this list
  86175. * @returns the list of ramp gradients
  86176. */
  86177. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86178. /** Force the system to rebuild all gradients that need to be resync */
  86179. forceRefreshGradients(): void;
  86180. private _syncRampGradientTexture;
  86181. /**
  86182. * Adds a new ramp gradient used to remap particle colors
  86183. * @param gradient defines the gradient to use (between 0 and 1)
  86184. * @param color defines the color to affect to the specified gradient
  86185. * @returns the current particle system
  86186. */
  86187. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86188. /**
  86189. * Remove a specific ramp gradient
  86190. * @param gradient defines the gradient to remove
  86191. * @returns the current particle system
  86192. */
  86193. removeRampGradient(gradient: number): ParticleSystem;
  86194. /**
  86195. * Adds a new color gradient
  86196. * @param gradient defines the gradient to use (between 0 and 1)
  86197. * @param color1 defines the color to affect to the specified gradient
  86198. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86199. * @returns this particle system
  86200. */
  86201. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86202. /**
  86203. * Remove a specific color gradient
  86204. * @param gradient defines the gradient to remove
  86205. * @returns this particle system
  86206. */
  86207. removeColorGradient(gradient: number): IParticleSystem;
  86208. private _fetchR;
  86209. protected _reset(): void;
  86210. private _resetEffect;
  86211. private _createVertexBuffers;
  86212. private _createIndexBuffer;
  86213. /**
  86214. * Gets the maximum number of particles active at the same time.
  86215. * @returns The max number of active particles.
  86216. */
  86217. getCapacity(): number;
  86218. /**
  86219. * Gets whether there are still active particles in the system.
  86220. * @returns True if it is alive, otherwise false.
  86221. */
  86222. isAlive(): boolean;
  86223. /**
  86224. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86225. * @returns True if it has been started, otherwise false.
  86226. */
  86227. isStarted(): boolean;
  86228. private _prepareSubEmitterInternalArray;
  86229. /**
  86230. * Starts the particle system and begins to emit
  86231. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86232. */
  86233. start(delay?: number): void;
  86234. /**
  86235. * Stops the particle system.
  86236. * @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.
  86237. */
  86238. stop(stopSubEmitters?: boolean): void;
  86239. /**
  86240. * Remove all active particles
  86241. */
  86242. reset(): void;
  86243. /**
  86244. * @hidden (for internal use only)
  86245. */
  86246. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86247. /**
  86248. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86249. * Its lifetime will start back at 0.
  86250. */
  86251. recycleParticle: (particle: Particle) => void;
  86252. private _stopSubEmitters;
  86253. private _createParticle;
  86254. private _removeFromRoot;
  86255. private _emitFromParticle;
  86256. private _update;
  86257. /** @hidden */
  86258. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86259. /** @hidden */
  86260. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86261. /** @hidden */
  86262. private _getEffect;
  86263. /**
  86264. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86265. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86266. */
  86267. animate(preWarmOnly?: boolean): void;
  86268. private _appendParticleVertices;
  86269. /**
  86270. * Rebuilds the particle system.
  86271. */
  86272. rebuild(): void;
  86273. /**
  86274. * Is this system ready to be used/rendered
  86275. * @return true if the system is ready
  86276. */
  86277. isReady(): boolean;
  86278. private _render;
  86279. /**
  86280. * Renders the particle system in its current state.
  86281. * @returns the current number of particles
  86282. */
  86283. render(): number;
  86284. /**
  86285. * Disposes the particle system and free the associated resources
  86286. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86287. */
  86288. dispose(disposeTexture?: boolean): void;
  86289. /**
  86290. * Clones the particle system.
  86291. * @param name The name of the cloned object
  86292. * @param newEmitter The new emitter to use
  86293. * @returns the cloned particle system
  86294. */
  86295. clone(name: string, newEmitter: any): ParticleSystem;
  86296. /**
  86297. * Serializes the particle system to a JSON object
  86298. * @param serializeTexture defines if the texture must be serialized as well
  86299. * @returns the JSON object
  86300. */
  86301. serialize(serializeTexture?: boolean): any;
  86302. /** @hidden */
  86303. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86304. /** @hidden */
  86305. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86306. /**
  86307. * Parses a JSON object to create a particle system.
  86308. * @param parsedParticleSystem The JSON object to parse
  86309. * @param scene The scene to create the particle system in
  86310. * @param rootUrl The root url to use to load external dependencies like texture
  86311. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86312. * @returns the Parsed particle system
  86313. */
  86314. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86315. }
  86316. }
  86317. declare module BABYLON {
  86318. /**
  86319. * A particle represents one of the element emitted by a particle system.
  86320. * This is mainly define by its coordinates, direction, velocity and age.
  86321. */
  86322. export class Particle {
  86323. /**
  86324. * The particle system the particle belongs to.
  86325. */
  86326. particleSystem: ParticleSystem;
  86327. private static _Count;
  86328. /**
  86329. * Unique ID of the particle
  86330. */
  86331. id: number;
  86332. /**
  86333. * The world position of the particle in the scene.
  86334. */
  86335. position: Vector3;
  86336. /**
  86337. * The world direction of the particle in the scene.
  86338. */
  86339. direction: Vector3;
  86340. /**
  86341. * The color of the particle.
  86342. */
  86343. color: Color4;
  86344. /**
  86345. * The color change of the particle per step.
  86346. */
  86347. colorStep: Color4;
  86348. /**
  86349. * Defines how long will the life of the particle be.
  86350. */
  86351. lifeTime: number;
  86352. /**
  86353. * The current age of the particle.
  86354. */
  86355. age: number;
  86356. /**
  86357. * The current size of the particle.
  86358. */
  86359. size: number;
  86360. /**
  86361. * The current scale of the particle.
  86362. */
  86363. scale: Vector2;
  86364. /**
  86365. * The current angle of the particle.
  86366. */
  86367. angle: number;
  86368. /**
  86369. * Defines how fast is the angle changing.
  86370. */
  86371. angularSpeed: number;
  86372. /**
  86373. * Defines the cell index used by the particle to be rendered from a sprite.
  86374. */
  86375. cellIndex: number;
  86376. /**
  86377. * The information required to support color remapping
  86378. */
  86379. remapData: Vector4;
  86380. /** @hidden */
  86381. _randomCellOffset?: number;
  86382. /** @hidden */
  86383. _initialDirection: Nullable<Vector3>;
  86384. /** @hidden */
  86385. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86386. /** @hidden */
  86387. _initialStartSpriteCellID: number;
  86388. /** @hidden */
  86389. _initialEndSpriteCellID: number;
  86390. /** @hidden */
  86391. _currentColorGradient: Nullable<ColorGradient>;
  86392. /** @hidden */
  86393. _currentColor1: Color4;
  86394. /** @hidden */
  86395. _currentColor2: Color4;
  86396. /** @hidden */
  86397. _currentSizeGradient: Nullable<FactorGradient>;
  86398. /** @hidden */
  86399. _currentSize1: number;
  86400. /** @hidden */
  86401. _currentSize2: number;
  86402. /** @hidden */
  86403. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86404. /** @hidden */
  86405. _currentAngularSpeed1: number;
  86406. /** @hidden */
  86407. _currentAngularSpeed2: number;
  86408. /** @hidden */
  86409. _currentVelocityGradient: Nullable<FactorGradient>;
  86410. /** @hidden */
  86411. _currentVelocity1: number;
  86412. /** @hidden */
  86413. _currentVelocity2: number;
  86414. /** @hidden */
  86415. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86416. /** @hidden */
  86417. _currentLimitVelocity1: number;
  86418. /** @hidden */
  86419. _currentLimitVelocity2: number;
  86420. /** @hidden */
  86421. _currentDragGradient: Nullable<FactorGradient>;
  86422. /** @hidden */
  86423. _currentDrag1: number;
  86424. /** @hidden */
  86425. _currentDrag2: number;
  86426. /** @hidden */
  86427. _randomNoiseCoordinates1: Vector3;
  86428. /** @hidden */
  86429. _randomNoiseCoordinates2: Vector3;
  86430. /** @hidden */
  86431. _localPosition?: Vector3;
  86432. /**
  86433. * Creates a new instance Particle
  86434. * @param particleSystem the particle system the particle belongs to
  86435. */
  86436. constructor(
  86437. /**
  86438. * The particle system the particle belongs to.
  86439. */
  86440. particleSystem: ParticleSystem);
  86441. private updateCellInfoFromSystem;
  86442. /**
  86443. * Defines how the sprite cell index is updated for the particle
  86444. */
  86445. updateCellIndex(): void;
  86446. /** @hidden */
  86447. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86448. /** @hidden */
  86449. _inheritParticleInfoToSubEmitters(): void;
  86450. /** @hidden */
  86451. _reset(): void;
  86452. /**
  86453. * Copy the properties of particle to another one.
  86454. * @param other the particle to copy the information to.
  86455. */
  86456. copyTo(other: Particle): void;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /**
  86461. * Particle emitter represents a volume emitting particles.
  86462. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86463. */
  86464. export interface IParticleEmitterType {
  86465. /**
  86466. * Called by the particle System when the direction is computed for the created particle.
  86467. * @param worldMatrix is the world matrix of the particle system
  86468. * @param directionToUpdate is the direction vector to update with the result
  86469. * @param particle is the particle we are computed the direction for
  86470. * @param isLocal defines if the direction should be set in local space
  86471. */
  86472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86473. /**
  86474. * Called by the particle System when the position is computed for the created particle.
  86475. * @param worldMatrix is the world matrix of the particle system
  86476. * @param positionToUpdate is the position vector to update with the result
  86477. * @param particle is the particle we are computed the position for
  86478. * @param isLocal defines if the position should be set in local space
  86479. */
  86480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86481. /**
  86482. * Clones the current emitter and returns a copy of it
  86483. * @returns the new emitter
  86484. */
  86485. clone(): IParticleEmitterType;
  86486. /**
  86487. * Called by the GPUParticleSystem to setup the update shader
  86488. * @param effect defines the update shader
  86489. */
  86490. applyToShader(effect: Effect): void;
  86491. /**
  86492. * Returns a string to use to update the GPU particles update shader
  86493. * @returns the effect defines string
  86494. */
  86495. getEffectDefines(): string;
  86496. /**
  86497. * Returns a string representing the class name
  86498. * @returns a string containing the class name
  86499. */
  86500. getClassName(): string;
  86501. /**
  86502. * Serializes the particle system to a JSON object.
  86503. * @returns the JSON object
  86504. */
  86505. serialize(): any;
  86506. /**
  86507. * Parse properties from a JSON object
  86508. * @param serializationObject defines the JSON object
  86509. * @param scene defines the hosting scene
  86510. */
  86511. parse(serializationObject: any, scene: Scene): void;
  86512. }
  86513. }
  86514. declare module BABYLON {
  86515. /**
  86516. * Particle emitter emitting particles from the inside of a box.
  86517. * It emits the particles randomly between 2 given directions.
  86518. */
  86519. export class BoxParticleEmitter implements IParticleEmitterType {
  86520. /**
  86521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86522. */
  86523. direction1: Vector3;
  86524. /**
  86525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86526. */
  86527. direction2: Vector3;
  86528. /**
  86529. * 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.
  86530. */
  86531. minEmitBox: Vector3;
  86532. /**
  86533. * 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.
  86534. */
  86535. maxEmitBox: Vector3;
  86536. /**
  86537. * Creates a new instance BoxParticleEmitter
  86538. */
  86539. constructor();
  86540. /**
  86541. * Called by the particle System when the direction is computed for the created particle.
  86542. * @param worldMatrix is the world matrix of the particle system
  86543. * @param directionToUpdate is the direction vector to update with the result
  86544. * @param particle is the particle we are computed the direction for
  86545. * @param isLocal defines if the direction should be set in local space
  86546. */
  86547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86548. /**
  86549. * Called by the particle System when the position is computed for the created particle.
  86550. * @param worldMatrix is the world matrix of the particle system
  86551. * @param positionToUpdate is the position vector to update with the result
  86552. * @param particle is the particle we are computed the position for
  86553. * @param isLocal defines if the position should be set in local space
  86554. */
  86555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86556. /**
  86557. * Clones the current emitter and returns a copy of it
  86558. * @returns the new emitter
  86559. */
  86560. clone(): BoxParticleEmitter;
  86561. /**
  86562. * Called by the GPUParticleSystem to setup the update shader
  86563. * @param effect defines the update shader
  86564. */
  86565. applyToShader(effect: Effect): void;
  86566. /**
  86567. * Returns a string to use to update the GPU particles update shader
  86568. * @returns a string containng the defines string
  86569. */
  86570. getEffectDefines(): string;
  86571. /**
  86572. * Returns the string "BoxParticleEmitter"
  86573. * @returns a string containing the class name
  86574. */
  86575. getClassName(): string;
  86576. /**
  86577. * Serializes the particle system to a JSON object.
  86578. * @returns the JSON object
  86579. */
  86580. serialize(): any;
  86581. /**
  86582. * Parse properties from a JSON object
  86583. * @param serializationObject defines the JSON object
  86584. */
  86585. parse(serializationObject: any): void;
  86586. }
  86587. }
  86588. declare module BABYLON {
  86589. /**
  86590. * Particle emitter emitting particles from the inside of a cone.
  86591. * It emits the particles alongside the cone volume from the base to the particle.
  86592. * The emission direction might be randomized.
  86593. */
  86594. export class ConeParticleEmitter implements IParticleEmitterType {
  86595. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86596. directionRandomizer: number;
  86597. private _radius;
  86598. private _angle;
  86599. private _height;
  86600. /**
  86601. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86602. */
  86603. radiusRange: number;
  86604. /**
  86605. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86606. */
  86607. heightRange: number;
  86608. /**
  86609. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86610. */
  86611. emitFromSpawnPointOnly: boolean;
  86612. /**
  86613. * Gets or sets the radius of the emission cone
  86614. */
  86615. get radius(): number;
  86616. set radius(value: number);
  86617. /**
  86618. * Gets or sets the angle of the emission cone
  86619. */
  86620. get angle(): number;
  86621. set angle(value: number);
  86622. private _buildHeight;
  86623. /**
  86624. * Creates a new instance ConeParticleEmitter
  86625. * @param radius the radius of the emission cone (1 by default)
  86626. * @param angle the cone base angle (PI by default)
  86627. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86628. */
  86629. constructor(radius?: number, angle?: number,
  86630. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86631. directionRandomizer?: number);
  86632. /**
  86633. * Called by the particle System when the direction is computed for the created particle.
  86634. * @param worldMatrix is the world matrix of the particle system
  86635. * @param directionToUpdate is the direction vector to update with the result
  86636. * @param particle is the particle we are computed the direction for
  86637. * @param isLocal defines if the direction should be set in local space
  86638. */
  86639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86640. /**
  86641. * Called by the particle System when the position is computed for the created particle.
  86642. * @param worldMatrix is the world matrix of the particle system
  86643. * @param positionToUpdate is the position vector to update with the result
  86644. * @param particle is the particle we are computed the position for
  86645. * @param isLocal defines if the position should be set in local space
  86646. */
  86647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86648. /**
  86649. * Clones the current emitter and returns a copy of it
  86650. * @returns the new emitter
  86651. */
  86652. clone(): ConeParticleEmitter;
  86653. /**
  86654. * Called by the GPUParticleSystem to setup the update shader
  86655. * @param effect defines the update shader
  86656. */
  86657. applyToShader(effect: Effect): void;
  86658. /**
  86659. * Returns a string to use to update the GPU particles update shader
  86660. * @returns a string containng the defines string
  86661. */
  86662. getEffectDefines(): string;
  86663. /**
  86664. * Returns the string "ConeParticleEmitter"
  86665. * @returns a string containing the class name
  86666. */
  86667. getClassName(): string;
  86668. /**
  86669. * Serializes the particle system to a JSON object.
  86670. * @returns the JSON object
  86671. */
  86672. serialize(): any;
  86673. /**
  86674. * Parse properties from a JSON object
  86675. * @param serializationObject defines the JSON object
  86676. */
  86677. parse(serializationObject: any): void;
  86678. }
  86679. }
  86680. declare module BABYLON {
  86681. /**
  86682. * Particle emitter emitting particles from the inside of a cylinder.
  86683. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86684. */
  86685. export class CylinderParticleEmitter implements IParticleEmitterType {
  86686. /**
  86687. * The radius of the emission cylinder.
  86688. */
  86689. radius: number;
  86690. /**
  86691. * The height of the emission cylinder.
  86692. */
  86693. height: number;
  86694. /**
  86695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86696. */
  86697. radiusRange: number;
  86698. /**
  86699. * How much to randomize the particle direction [0-1].
  86700. */
  86701. directionRandomizer: number;
  86702. /**
  86703. * Creates a new instance CylinderParticleEmitter
  86704. * @param radius the radius of the emission cylinder (1 by default)
  86705. * @param height the height of the emission cylinder (1 by default)
  86706. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86707. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86708. */
  86709. constructor(
  86710. /**
  86711. * The radius of the emission cylinder.
  86712. */
  86713. radius?: number,
  86714. /**
  86715. * The height of the emission cylinder.
  86716. */
  86717. height?: number,
  86718. /**
  86719. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86720. */
  86721. radiusRange?: number,
  86722. /**
  86723. * How much to randomize the particle direction [0-1].
  86724. */
  86725. directionRandomizer?: number);
  86726. /**
  86727. * Called by the particle System when the direction is computed for the created particle.
  86728. * @param worldMatrix is the world matrix of the particle system
  86729. * @param directionToUpdate is the direction vector to update with the result
  86730. * @param particle is the particle we are computed the direction for
  86731. * @param isLocal defines if the direction should be set in local space
  86732. */
  86733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86734. /**
  86735. * Called by the particle System when the position is computed for the created particle.
  86736. * @param worldMatrix is the world matrix of the particle system
  86737. * @param positionToUpdate is the position vector to update with the result
  86738. * @param particle is the particle we are computed the position for
  86739. * @param isLocal defines if the position should be set in local space
  86740. */
  86741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86742. /**
  86743. * Clones the current emitter and returns a copy of it
  86744. * @returns the new emitter
  86745. */
  86746. clone(): CylinderParticleEmitter;
  86747. /**
  86748. * Called by the GPUParticleSystem to setup the update shader
  86749. * @param effect defines the update shader
  86750. */
  86751. applyToShader(effect: Effect): void;
  86752. /**
  86753. * Returns a string to use to update the GPU particles update shader
  86754. * @returns a string containng the defines string
  86755. */
  86756. getEffectDefines(): string;
  86757. /**
  86758. * Returns the string "CylinderParticleEmitter"
  86759. * @returns a string containing the class name
  86760. */
  86761. getClassName(): string;
  86762. /**
  86763. * Serializes the particle system to a JSON object.
  86764. * @returns the JSON object
  86765. */
  86766. serialize(): any;
  86767. /**
  86768. * Parse properties from a JSON object
  86769. * @param serializationObject defines the JSON object
  86770. */
  86771. parse(serializationObject: any): void;
  86772. }
  86773. /**
  86774. * Particle emitter emitting particles from the inside of a cylinder.
  86775. * It emits the particles randomly between two vectors.
  86776. */
  86777. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  86788. * @param radius the radius of the emission cylinder (1 by default)
  86789. * @param height the height of the emission cylinder (1 by default)
  86790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86791. * @param direction1 the min limit of the emission direction (up vector by default)
  86792. * @param direction2 the max limit of the emission direction (up vector by default)
  86793. */
  86794. constructor(radius?: number, height?: number, radiusRange?: number,
  86795. /**
  86796. * The min limit of the emission direction.
  86797. */
  86798. direction1?: Vector3,
  86799. /**
  86800. * The max limit of the emission direction.
  86801. */
  86802. direction2?: Vector3);
  86803. /**
  86804. * Called by the particle System when the direction is computed for the created particle.
  86805. * @param worldMatrix is the world matrix of the particle system
  86806. * @param directionToUpdate is the direction vector to update with the result
  86807. * @param particle is the particle we are computed the direction for
  86808. */
  86809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86810. /**
  86811. * Clones the current emitter and returns a copy of it
  86812. * @returns the new emitter
  86813. */
  86814. clone(): CylinderDirectedParticleEmitter;
  86815. /**
  86816. * Called by the GPUParticleSystem to setup the update shader
  86817. * @param effect defines the update shader
  86818. */
  86819. applyToShader(effect: Effect): void;
  86820. /**
  86821. * Returns a string to use to update the GPU particles update shader
  86822. * @returns a string containng the defines string
  86823. */
  86824. getEffectDefines(): string;
  86825. /**
  86826. * Returns the string "CylinderDirectedParticleEmitter"
  86827. * @returns a string containing the class name
  86828. */
  86829. getClassName(): string;
  86830. /**
  86831. * Serializes the particle system to a JSON object.
  86832. * @returns the JSON object
  86833. */
  86834. serialize(): any;
  86835. /**
  86836. * Parse properties from a JSON object
  86837. * @param serializationObject defines the JSON object
  86838. */
  86839. parse(serializationObject: any): void;
  86840. }
  86841. }
  86842. declare module BABYLON {
  86843. /**
  86844. * Particle emitter emitting particles from the inside of a hemisphere.
  86845. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86846. */
  86847. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86848. /**
  86849. * The radius of the emission hemisphere.
  86850. */
  86851. radius: number;
  86852. /**
  86853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86854. */
  86855. radiusRange: number;
  86856. /**
  86857. * How much to randomize the particle direction [0-1].
  86858. */
  86859. directionRandomizer: number;
  86860. /**
  86861. * Creates a new instance HemisphericParticleEmitter
  86862. * @param radius the radius of the emission hemisphere (1 by default)
  86863. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86864. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86865. */
  86866. constructor(
  86867. /**
  86868. * The radius of the emission hemisphere.
  86869. */
  86870. radius?: number,
  86871. /**
  86872. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86873. */
  86874. radiusRange?: number,
  86875. /**
  86876. * How much to randomize the particle direction [0-1].
  86877. */
  86878. directionRandomizer?: number);
  86879. /**
  86880. * Called by the particle System when the direction is computed for the created particle.
  86881. * @param worldMatrix is the world matrix of the particle system
  86882. * @param directionToUpdate is the direction vector to update with the result
  86883. * @param particle is the particle we are computed the direction for
  86884. * @param isLocal defines if the direction should be set in local space
  86885. */
  86886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86887. /**
  86888. * Called by the particle System when the position is computed for the created particle.
  86889. * @param worldMatrix is the world matrix of the particle system
  86890. * @param positionToUpdate is the position vector to update with the result
  86891. * @param particle is the particle we are computed the position for
  86892. * @param isLocal defines if the position should be set in local space
  86893. */
  86894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86895. /**
  86896. * Clones the current emitter and returns a copy of it
  86897. * @returns the new emitter
  86898. */
  86899. clone(): HemisphericParticleEmitter;
  86900. /**
  86901. * Called by the GPUParticleSystem to setup the update shader
  86902. * @param effect defines the update shader
  86903. */
  86904. applyToShader(effect: Effect): void;
  86905. /**
  86906. * Returns a string to use to update the GPU particles update shader
  86907. * @returns a string containng the defines string
  86908. */
  86909. getEffectDefines(): string;
  86910. /**
  86911. * Returns the string "HemisphericParticleEmitter"
  86912. * @returns a string containing the class name
  86913. */
  86914. getClassName(): string;
  86915. /**
  86916. * Serializes the particle system to a JSON object.
  86917. * @returns the JSON object
  86918. */
  86919. serialize(): any;
  86920. /**
  86921. * Parse properties from a JSON object
  86922. * @param serializationObject defines the JSON object
  86923. */
  86924. parse(serializationObject: any): void;
  86925. }
  86926. }
  86927. declare module BABYLON {
  86928. /**
  86929. * Particle emitter emitting particles from a point.
  86930. * It emits the particles randomly between 2 given directions.
  86931. */
  86932. export class PointParticleEmitter implements IParticleEmitterType {
  86933. /**
  86934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86935. */
  86936. direction1: Vector3;
  86937. /**
  86938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86939. */
  86940. direction2: Vector3;
  86941. /**
  86942. * Creates a new instance PointParticleEmitter
  86943. */
  86944. constructor();
  86945. /**
  86946. * Called by the particle System when the direction is computed for the created particle.
  86947. * @param worldMatrix is the world matrix of the particle system
  86948. * @param directionToUpdate is the direction vector to update with the result
  86949. * @param particle is the particle we are computed the direction for
  86950. * @param isLocal defines if the direction should be set in local space
  86951. */
  86952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86953. /**
  86954. * Called by the particle System when the position is computed for the created particle.
  86955. * @param worldMatrix is the world matrix of the particle system
  86956. * @param positionToUpdate is the position vector to update with the result
  86957. * @param particle is the particle we are computed the position for
  86958. * @param isLocal defines if the position should be set in local space
  86959. */
  86960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86961. /**
  86962. * Clones the current emitter and returns a copy of it
  86963. * @returns the new emitter
  86964. */
  86965. clone(): PointParticleEmitter;
  86966. /**
  86967. * Called by the GPUParticleSystem to setup the update shader
  86968. * @param effect defines the update shader
  86969. */
  86970. applyToShader(effect: Effect): void;
  86971. /**
  86972. * Returns a string to use to update the GPU particles update shader
  86973. * @returns a string containng the defines string
  86974. */
  86975. getEffectDefines(): string;
  86976. /**
  86977. * Returns the string "PointParticleEmitter"
  86978. * @returns a string containing the class name
  86979. */
  86980. getClassName(): string;
  86981. /**
  86982. * Serializes the particle system to a JSON object.
  86983. * @returns the JSON object
  86984. */
  86985. serialize(): any;
  86986. /**
  86987. * Parse properties from a JSON object
  86988. * @param serializationObject defines the JSON object
  86989. */
  86990. parse(serializationObject: any): void;
  86991. }
  86992. }
  86993. declare module BABYLON {
  86994. /**
  86995. * Particle emitter emitting particles from the inside of a sphere.
  86996. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86997. */
  86998. export class SphereParticleEmitter implements IParticleEmitterType {
  86999. /**
  87000. * The radius of the emission sphere.
  87001. */
  87002. radius: number;
  87003. /**
  87004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87005. */
  87006. radiusRange: number;
  87007. /**
  87008. * How much to randomize the particle direction [0-1].
  87009. */
  87010. directionRandomizer: number;
  87011. /**
  87012. * Creates a new instance SphereParticleEmitter
  87013. * @param radius the radius of the emission sphere (1 by default)
  87014. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87015. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87016. */
  87017. constructor(
  87018. /**
  87019. * The radius of the emission sphere.
  87020. */
  87021. radius?: number,
  87022. /**
  87023. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87024. */
  87025. radiusRange?: number,
  87026. /**
  87027. * How much to randomize the particle direction [0-1].
  87028. */
  87029. directionRandomizer?: number);
  87030. /**
  87031. * Called by the particle System when the direction is computed for the created particle.
  87032. * @param worldMatrix is the world matrix of the particle system
  87033. * @param directionToUpdate is the direction vector to update with the result
  87034. * @param particle is the particle we are computed the direction for
  87035. * @param isLocal defines if the direction should be set in local space
  87036. */
  87037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87038. /**
  87039. * Called by the particle System when the position is computed for the created particle.
  87040. * @param worldMatrix is the world matrix of the particle system
  87041. * @param positionToUpdate is the position vector to update with the result
  87042. * @param particle is the particle we are computed the position for
  87043. * @param isLocal defines if the position should be set in local space
  87044. */
  87045. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87046. /**
  87047. * Clones the current emitter and returns a copy of it
  87048. * @returns the new emitter
  87049. */
  87050. clone(): SphereParticleEmitter;
  87051. /**
  87052. * Called by the GPUParticleSystem to setup the update shader
  87053. * @param effect defines the update shader
  87054. */
  87055. applyToShader(effect: Effect): void;
  87056. /**
  87057. * Returns a string to use to update the GPU particles update shader
  87058. * @returns a string containng the defines string
  87059. */
  87060. getEffectDefines(): string;
  87061. /**
  87062. * Returns the string "SphereParticleEmitter"
  87063. * @returns a string containing the class name
  87064. */
  87065. getClassName(): string;
  87066. /**
  87067. * Serializes the particle system to a JSON object.
  87068. * @returns the JSON object
  87069. */
  87070. serialize(): any;
  87071. /**
  87072. * Parse properties from a JSON object
  87073. * @param serializationObject defines the JSON object
  87074. */
  87075. parse(serializationObject: any): void;
  87076. }
  87077. /**
  87078. * Particle emitter emitting particles from the inside of a sphere.
  87079. * It emits the particles randomly between two vectors.
  87080. */
  87081. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87082. /**
  87083. * The min limit of the emission direction.
  87084. */
  87085. direction1: Vector3;
  87086. /**
  87087. * The max limit of the emission direction.
  87088. */
  87089. direction2: Vector3;
  87090. /**
  87091. * Creates a new instance SphereDirectedParticleEmitter
  87092. * @param radius the radius of the emission sphere (1 by default)
  87093. * @param direction1 the min limit of the emission direction (up vector by default)
  87094. * @param direction2 the max limit of the emission direction (up vector by default)
  87095. */
  87096. constructor(radius?: number,
  87097. /**
  87098. * The min limit of the emission direction.
  87099. */
  87100. direction1?: Vector3,
  87101. /**
  87102. * The max limit of the emission direction.
  87103. */
  87104. direction2?: Vector3);
  87105. /**
  87106. * Called by the particle System when the direction is computed for the created particle.
  87107. * @param worldMatrix is the world matrix of the particle system
  87108. * @param directionToUpdate is the direction vector to update with the result
  87109. * @param particle is the particle we are computed the direction for
  87110. */
  87111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87112. /**
  87113. * Clones the current emitter and returns a copy of it
  87114. * @returns the new emitter
  87115. */
  87116. clone(): SphereDirectedParticleEmitter;
  87117. /**
  87118. * Called by the GPUParticleSystem to setup the update shader
  87119. * @param effect defines the update shader
  87120. */
  87121. applyToShader(effect: Effect): void;
  87122. /**
  87123. * Returns a string to use to update the GPU particles update shader
  87124. * @returns a string containng the defines string
  87125. */
  87126. getEffectDefines(): string;
  87127. /**
  87128. * Returns the string "SphereDirectedParticleEmitter"
  87129. * @returns a string containing the class name
  87130. */
  87131. getClassName(): string;
  87132. /**
  87133. * Serializes the particle system to a JSON object.
  87134. * @returns the JSON object
  87135. */
  87136. serialize(): any;
  87137. /**
  87138. * Parse properties from a JSON object
  87139. * @param serializationObject defines the JSON object
  87140. */
  87141. parse(serializationObject: any): void;
  87142. }
  87143. }
  87144. declare module BABYLON {
  87145. /**
  87146. * Particle emitter emitting particles from a custom list of positions.
  87147. */
  87148. export class CustomParticleEmitter implements IParticleEmitterType {
  87149. /**
  87150. * Gets or sets the position generator that will create the inital position of each particle.
  87151. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87152. */
  87153. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87154. /**
  87155. * Gets or sets the destination generator that will create the final destination of each particle.
  87156. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87157. */
  87158. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87159. /**
  87160. * Creates a new instance CustomParticleEmitter
  87161. */
  87162. constructor();
  87163. /**
  87164. * Called by the particle System when the direction is computed for the created particle.
  87165. * @param worldMatrix is the world matrix of the particle system
  87166. * @param directionToUpdate is the direction vector to update with the result
  87167. * @param particle is the particle we are computed the direction for
  87168. * @param isLocal defines if the direction should be set in local space
  87169. */
  87170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87171. /**
  87172. * Called by the particle System when the position is computed for the created particle.
  87173. * @param worldMatrix is the world matrix of the particle system
  87174. * @param positionToUpdate is the position vector to update with the result
  87175. * @param particle is the particle we are computed the position for
  87176. * @param isLocal defines if the position should be set in local space
  87177. */
  87178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87179. /**
  87180. * Clones the current emitter and returns a copy of it
  87181. * @returns the new emitter
  87182. */
  87183. clone(): CustomParticleEmitter;
  87184. /**
  87185. * Called by the GPUParticleSystem to setup the update shader
  87186. * @param effect defines the update shader
  87187. */
  87188. applyToShader(effect: Effect): void;
  87189. /**
  87190. * Returns a string to use to update the GPU particles update shader
  87191. * @returns a string containng the defines string
  87192. */
  87193. getEffectDefines(): string;
  87194. /**
  87195. * Returns the string "PointParticleEmitter"
  87196. * @returns a string containing the class name
  87197. */
  87198. getClassName(): string;
  87199. /**
  87200. * Serializes the particle system to a JSON object.
  87201. * @returns the JSON object
  87202. */
  87203. serialize(): any;
  87204. /**
  87205. * Parse properties from a JSON object
  87206. * @param serializationObject defines the JSON object
  87207. */
  87208. parse(serializationObject: any): void;
  87209. }
  87210. }
  87211. declare module BABYLON {
  87212. /**
  87213. * Particle emitter emitting particles from the inside of a box.
  87214. * It emits the particles randomly between 2 given directions.
  87215. */
  87216. export class MeshParticleEmitter implements IParticleEmitterType {
  87217. private _indices;
  87218. private _positions;
  87219. private _normals;
  87220. private _storedNormal;
  87221. private _mesh;
  87222. /**
  87223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87224. */
  87225. direction1: Vector3;
  87226. /**
  87227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87228. */
  87229. direction2: Vector3;
  87230. /**
  87231. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87232. */
  87233. useMeshNormalsForDirection: boolean;
  87234. /** Defines the mesh to use as source */
  87235. get mesh(): Nullable<AbstractMesh>;
  87236. set mesh(value: Nullable<AbstractMesh>);
  87237. /**
  87238. * Creates a new instance MeshParticleEmitter
  87239. * @param mesh defines the mesh to use as source
  87240. */
  87241. constructor(mesh?: Nullable<AbstractMesh>);
  87242. /**
  87243. * Called by the particle System when the direction is computed for the created particle.
  87244. * @param worldMatrix is the world matrix of the particle system
  87245. * @param directionToUpdate is the direction vector to update with the result
  87246. * @param particle is the particle we are computed the direction for
  87247. * @param isLocal defines if the direction should be set in local space
  87248. */
  87249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87250. /**
  87251. * Called by the particle System when the position is computed for the created particle.
  87252. * @param worldMatrix is the world matrix of the particle system
  87253. * @param positionToUpdate is the position vector to update with the result
  87254. * @param particle is the particle we are computed the position for
  87255. * @param isLocal defines if the position should be set in local space
  87256. */
  87257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87258. /**
  87259. * Clones the current emitter and returns a copy of it
  87260. * @returns the new emitter
  87261. */
  87262. clone(): MeshParticleEmitter;
  87263. /**
  87264. * Called by the GPUParticleSystem to setup the update shader
  87265. * @param effect defines the update shader
  87266. */
  87267. applyToShader(effect: Effect): void;
  87268. /**
  87269. * Returns a string to use to update the GPU particles update shader
  87270. * @returns a string containng the defines string
  87271. */
  87272. getEffectDefines(): string;
  87273. /**
  87274. * Returns the string "BoxParticleEmitter"
  87275. * @returns a string containing the class name
  87276. */
  87277. getClassName(): string;
  87278. /**
  87279. * Serializes the particle system to a JSON object.
  87280. * @returns the JSON object
  87281. */
  87282. serialize(): any;
  87283. /**
  87284. * Parse properties from a JSON object
  87285. * @param serializationObject defines the JSON object
  87286. * @param scene defines the hosting scene
  87287. */
  87288. parse(serializationObject: any, scene: Scene): void;
  87289. }
  87290. }
  87291. declare module BABYLON {
  87292. /**
  87293. * Interface representing a particle system in Babylon.js.
  87294. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87295. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87296. */
  87297. export interface IParticleSystem {
  87298. /**
  87299. * List of animations used by the particle system.
  87300. */
  87301. animations: Animation[];
  87302. /**
  87303. * The id of the Particle system.
  87304. */
  87305. id: string;
  87306. /**
  87307. * The name of the Particle system.
  87308. */
  87309. name: string;
  87310. /**
  87311. * The emitter represents the Mesh or position we are attaching the particle system to.
  87312. */
  87313. emitter: Nullable<AbstractMesh | Vector3>;
  87314. /**
  87315. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87316. */
  87317. isBillboardBased: boolean;
  87318. /**
  87319. * The rendering group used by the Particle system to chose when to render.
  87320. */
  87321. renderingGroupId: number;
  87322. /**
  87323. * The layer mask we are rendering the particles through.
  87324. */
  87325. layerMask: number;
  87326. /**
  87327. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87328. */
  87329. updateSpeed: number;
  87330. /**
  87331. * The amount of time the particle system is running (depends of the overall update speed).
  87332. */
  87333. targetStopDuration: number;
  87334. /**
  87335. * The texture used to render each particle. (this can be a spritesheet)
  87336. */
  87337. particleTexture: Nullable<Texture>;
  87338. /**
  87339. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87340. */
  87341. blendMode: number;
  87342. /**
  87343. * Minimum life time of emitting particles.
  87344. */
  87345. minLifeTime: number;
  87346. /**
  87347. * Maximum life time of emitting particles.
  87348. */
  87349. maxLifeTime: number;
  87350. /**
  87351. * Minimum Size of emitting particles.
  87352. */
  87353. minSize: number;
  87354. /**
  87355. * Maximum Size of emitting particles.
  87356. */
  87357. maxSize: number;
  87358. /**
  87359. * Minimum scale of emitting particles on X axis.
  87360. */
  87361. minScaleX: number;
  87362. /**
  87363. * Maximum scale of emitting particles on X axis.
  87364. */
  87365. maxScaleX: number;
  87366. /**
  87367. * Minimum scale of emitting particles on Y axis.
  87368. */
  87369. minScaleY: number;
  87370. /**
  87371. * Maximum scale of emitting particles on Y axis.
  87372. */
  87373. maxScaleY: number;
  87374. /**
  87375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87376. */
  87377. color1: Color4;
  87378. /**
  87379. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87380. */
  87381. color2: Color4;
  87382. /**
  87383. * Color the particle will have at the end of its lifetime.
  87384. */
  87385. colorDead: Color4;
  87386. /**
  87387. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87388. */
  87389. emitRate: number;
  87390. /**
  87391. * You can use gravity if you want to give an orientation to your particles.
  87392. */
  87393. gravity: Vector3;
  87394. /**
  87395. * Minimum power of emitting particles.
  87396. */
  87397. minEmitPower: number;
  87398. /**
  87399. * Maximum power of emitting particles.
  87400. */
  87401. maxEmitPower: number;
  87402. /**
  87403. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87404. */
  87405. minAngularSpeed: number;
  87406. /**
  87407. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87408. */
  87409. maxAngularSpeed: number;
  87410. /**
  87411. * Gets or sets the minimal initial rotation in radians.
  87412. */
  87413. minInitialRotation: number;
  87414. /**
  87415. * Gets or sets the maximal initial rotation in radians.
  87416. */
  87417. maxInitialRotation: number;
  87418. /**
  87419. * The particle emitter type defines the emitter used by the particle system.
  87420. * It can be for example box, sphere, or cone...
  87421. */
  87422. particleEmitterType: Nullable<IParticleEmitterType>;
  87423. /**
  87424. * Defines the delay in milliseconds before starting the system (0 by default)
  87425. */
  87426. startDelay: number;
  87427. /**
  87428. * 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
  87429. */
  87430. preWarmCycles: number;
  87431. /**
  87432. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87433. */
  87434. preWarmStepOffset: number;
  87435. /**
  87436. * 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)
  87437. */
  87438. spriteCellChangeSpeed: number;
  87439. /**
  87440. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87441. */
  87442. startSpriteCellID: number;
  87443. /**
  87444. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87445. */
  87446. endSpriteCellID: number;
  87447. /**
  87448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87449. */
  87450. spriteCellWidth: number;
  87451. /**
  87452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87453. */
  87454. spriteCellHeight: number;
  87455. /**
  87456. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87457. */
  87458. spriteRandomStartCell: boolean;
  87459. /**
  87460. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87461. */
  87462. isAnimationSheetEnabled: boolean;
  87463. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87464. translationPivot: Vector2;
  87465. /**
  87466. * Gets or sets a texture used to add random noise to particle positions
  87467. */
  87468. noiseTexture: Nullable<BaseTexture>;
  87469. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87470. noiseStrength: Vector3;
  87471. /**
  87472. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87473. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87474. */
  87475. billboardMode: number;
  87476. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87477. limitVelocityDamping: number;
  87478. /**
  87479. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87480. */
  87481. beginAnimationOnStart: boolean;
  87482. /**
  87483. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87484. */
  87485. beginAnimationFrom: number;
  87486. /**
  87487. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87488. */
  87489. beginAnimationTo: number;
  87490. /**
  87491. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87492. */
  87493. beginAnimationLoop: boolean;
  87494. /**
  87495. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87496. */
  87497. disposeOnStop: boolean;
  87498. /**
  87499. * Specifies if the particles are updated in emitter local space or world space
  87500. */
  87501. isLocal: boolean;
  87502. /** Snippet ID if the particle system was created from the snippet server */
  87503. snippetId: string;
  87504. /**
  87505. * Gets the maximum number of particles active at the same time.
  87506. * @returns The max number of active particles.
  87507. */
  87508. getCapacity(): number;
  87509. /**
  87510. * Gets the number of particles active at the same time.
  87511. * @returns The number of active particles.
  87512. */
  87513. getActiveCount(): number;
  87514. /**
  87515. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87516. * @returns True if it has been started, otherwise false.
  87517. */
  87518. isStarted(): boolean;
  87519. /**
  87520. * Animates the particle system for this frame.
  87521. */
  87522. animate(): void;
  87523. /**
  87524. * Renders the particle system in its current state.
  87525. * @returns the current number of particles
  87526. */
  87527. render(): number;
  87528. /**
  87529. * Dispose the particle system and frees its associated resources.
  87530. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87531. */
  87532. dispose(disposeTexture?: boolean): void;
  87533. /**
  87534. * Clones the particle system.
  87535. * @param name The name of the cloned object
  87536. * @param newEmitter The new emitter to use
  87537. * @returns the cloned particle system
  87538. */
  87539. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87540. /**
  87541. * Serializes the particle system to a JSON object
  87542. * @param serializeTexture defines if the texture must be serialized as well
  87543. * @returns the JSON object
  87544. */
  87545. serialize(serializeTexture: boolean): any;
  87546. /**
  87547. * Rebuild the particle system
  87548. */
  87549. rebuild(): void;
  87550. /** Force the system to rebuild all gradients that need to be resync */
  87551. forceRefreshGradients(): void;
  87552. /**
  87553. * Starts the particle system and begins to emit
  87554. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87555. */
  87556. start(delay?: number): void;
  87557. /**
  87558. * Stops the particle system.
  87559. */
  87560. stop(): void;
  87561. /**
  87562. * Remove all active particles
  87563. */
  87564. reset(): void;
  87565. /**
  87566. * Gets a boolean indicating that the system is stopping
  87567. * @returns true if the system is currently stopping
  87568. */
  87569. isStopping(): boolean;
  87570. /**
  87571. * Is this system ready to be used/rendered
  87572. * @return true if the system is ready
  87573. */
  87574. isReady(): boolean;
  87575. /**
  87576. * Returns the string "ParticleSystem"
  87577. * @returns a string containing the class name
  87578. */
  87579. getClassName(): string;
  87580. /**
  87581. * Adds a new color gradient
  87582. * @param gradient defines the gradient to use (between 0 and 1)
  87583. * @param color1 defines the color to affect to the specified gradient
  87584. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87585. * @returns the current particle system
  87586. */
  87587. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87588. /**
  87589. * Remove a specific color gradient
  87590. * @param gradient defines the gradient to remove
  87591. * @returns the current particle system
  87592. */
  87593. removeColorGradient(gradient: number): IParticleSystem;
  87594. /**
  87595. * Adds a new size gradient
  87596. * @param gradient defines the gradient to use (between 0 and 1)
  87597. * @param factor defines the size factor to affect to the specified gradient
  87598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87599. * @returns the current particle system
  87600. */
  87601. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87602. /**
  87603. * Remove a specific size gradient
  87604. * @param gradient defines the gradient to remove
  87605. * @returns the current particle system
  87606. */
  87607. removeSizeGradient(gradient: number): IParticleSystem;
  87608. /**
  87609. * Gets the current list of color gradients.
  87610. * You must use addColorGradient and removeColorGradient to udpate this list
  87611. * @returns the list of color gradients
  87612. */
  87613. getColorGradients(): Nullable<Array<ColorGradient>>;
  87614. /**
  87615. * Gets the current list of size gradients.
  87616. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87617. * @returns the list of size gradients
  87618. */
  87619. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87620. /**
  87621. * Gets the current list of angular speed gradients.
  87622. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87623. * @returns the list of angular speed gradients
  87624. */
  87625. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87626. /**
  87627. * Adds a new angular speed gradient
  87628. * @param gradient defines the gradient to use (between 0 and 1)
  87629. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87634. /**
  87635. * Remove a specific angular speed gradient
  87636. * @param gradient defines the gradient to remove
  87637. * @returns the current particle system
  87638. */
  87639. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87640. /**
  87641. * Gets the current list of velocity gradients.
  87642. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87643. * @returns the list of velocity gradients
  87644. */
  87645. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87646. /**
  87647. * Adds a new velocity gradient
  87648. * @param gradient defines the gradient to use (between 0 and 1)
  87649. * @param factor defines the 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87654. /**
  87655. * Remove a specific velocity gradient
  87656. * @param gradient defines the gradient to remove
  87657. * @returns the current particle system
  87658. */
  87659. removeVelocityGradient(gradient: number): IParticleSystem;
  87660. /**
  87661. * Gets the current list of limit velocity gradients.
  87662. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87663. * @returns the list of limit velocity gradients
  87664. */
  87665. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87666. /**
  87667. * Adds a new limit velocity gradient
  87668. * @param gradient defines the gradient to use (between 0 and 1)
  87669. * @param factor defines the limit velocity to affect to the specified gradient
  87670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87671. * @returns the current particle system
  87672. */
  87673. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87674. /**
  87675. * Remove a specific limit velocity gradient
  87676. * @param gradient defines the gradient to remove
  87677. * @returns the current particle system
  87678. */
  87679. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87680. /**
  87681. * Adds a new drag gradient
  87682. * @param gradient defines the gradient to use (between 0 and 1)
  87683. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87688. /**
  87689. * Remove a specific drag gradient
  87690. * @param gradient defines the gradient to remove
  87691. * @returns the current particle system
  87692. */
  87693. removeDragGradient(gradient: number): IParticleSystem;
  87694. /**
  87695. * Gets the current list of drag gradients.
  87696. * You must use addDragGradient and removeDragGradient to udpate this list
  87697. * @returns the list of drag gradients
  87698. */
  87699. getDragGradients(): Nullable<Array<FactorGradient>>;
  87700. /**
  87701. * Adds a new emit rate 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 emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87708. /**
  87709. * Remove a specific emit rate gradient
  87710. * @param gradient defines the gradient to remove
  87711. * @returns the current particle system
  87712. */
  87713. removeEmitRateGradient(gradient: number): IParticleSystem;
  87714. /**
  87715. * Gets the current list of emit rate gradients.
  87716. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87717. * @returns the list of emit rate gradients
  87718. */
  87719. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87720. /**
  87721. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87722. * @param gradient defines the gradient to use (between 0 and 1)
  87723. * @param factor defines the start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87728. /**
  87729. * Remove a specific start size gradient
  87730. * @param gradient defines the gradient to remove
  87731. * @returns the current particle system
  87732. */
  87733. removeStartSizeGradient(gradient: number): IParticleSystem;
  87734. /**
  87735. * Gets the current list of start size gradients.
  87736. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87737. * @returns the list of start size gradients
  87738. */
  87739. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87740. /**
  87741. * Adds a new life time gradient
  87742. * @param gradient defines the gradient to use (between 0 and 1)
  87743. * @param factor defines the life time factor to affect to the specified gradient
  87744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87745. * @returns the current particle system
  87746. */
  87747. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87748. /**
  87749. * Remove a specific life time gradient
  87750. * @param gradient defines the gradient to remove
  87751. * @returns the current particle system
  87752. */
  87753. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87754. /**
  87755. * Gets the current list of life time gradients.
  87756. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87757. * @returns the list of life time gradients
  87758. */
  87759. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87760. /**
  87761. * Gets the current list of color gradients.
  87762. * You must use addColorGradient and removeColorGradient to udpate this list
  87763. * @returns the list of color gradients
  87764. */
  87765. getColorGradients(): Nullable<Array<ColorGradient>>;
  87766. /**
  87767. * Adds a new ramp gradient used to remap particle colors
  87768. * @param gradient defines the gradient to use (between 0 and 1)
  87769. * @param color defines the color to affect to the specified gradient
  87770. * @returns the current particle system
  87771. */
  87772. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87773. /**
  87774. * Gets the current list of ramp gradients.
  87775. * You must use addRampGradient and removeRampGradient to udpate this list
  87776. * @returns the list of ramp gradients
  87777. */
  87778. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87779. /** Gets or sets a boolean indicating that ramp gradients must be used
  87780. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87781. */
  87782. useRampGradients: boolean;
  87783. /**
  87784. * Adds a new color remap gradient
  87785. * @param gradient defines the gradient to use (between 0 and 1)
  87786. * @param min defines the color remap minimal range
  87787. * @param max defines the color remap maximal range
  87788. * @returns the current particle system
  87789. */
  87790. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87791. /**
  87792. * Gets the current list of color remap gradients.
  87793. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87794. * @returns the list of color remap gradients
  87795. */
  87796. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87797. /**
  87798. * Adds a new alpha remap gradient
  87799. * @param gradient defines the gradient to use (between 0 and 1)
  87800. * @param min defines the alpha remap minimal range
  87801. * @param max defines the alpha remap maximal range
  87802. * @returns the current particle system
  87803. */
  87804. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87805. /**
  87806. * Gets the current list of alpha remap gradients.
  87807. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87808. * @returns the list of alpha remap gradients
  87809. */
  87810. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87811. /**
  87812. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87815. * @returns the emitter
  87816. */
  87817. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87818. /**
  87819. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87820. * @param radius The radius of the hemisphere to emit from
  87821. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87822. * @returns the emitter
  87823. */
  87824. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87825. /**
  87826. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87827. * @param radius The radius of the sphere to emit from
  87828. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87829. * @returns the emitter
  87830. */
  87831. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87832. /**
  87833. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87834. * @param radius The radius of the sphere to emit from
  87835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87837. * @returns the emitter
  87838. */
  87839. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87840. /**
  87841. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87842. * @param radius The radius of the emission cylinder
  87843. * @param height The height of the emission cylinder
  87844. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87845. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87846. * @returns the emitter
  87847. */
  87848. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87849. /**
  87850. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87851. * @param radius The radius of the cylinder to emit from
  87852. * @param height The height of the emission cylinder
  87853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87856. * @returns the emitter
  87857. */
  87858. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87859. /**
  87860. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87861. * @param radius The radius of the cone to emit from
  87862. * @param angle The base angle of the cone
  87863. * @returns the emitter
  87864. */
  87865. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87866. /**
  87867. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87870. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87871. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87872. * @returns the emitter
  87873. */
  87874. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87875. /**
  87876. * Get hosting scene
  87877. * @returns the scene
  87878. */
  87879. getScene(): Scene;
  87880. }
  87881. }
  87882. declare module BABYLON {
  87883. /**
  87884. * 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.
  87885. * @see https://doc.babylonjs.com/how_to/transformnode
  87886. */
  87887. export class TransformNode extends Node {
  87888. /**
  87889. * Object will not rotate to face the camera
  87890. */
  87891. static BILLBOARDMODE_NONE: number;
  87892. /**
  87893. * Object will rotate to face the camera but only on the x axis
  87894. */
  87895. static BILLBOARDMODE_X: number;
  87896. /**
  87897. * Object will rotate to face the camera but only on the y axis
  87898. */
  87899. static BILLBOARDMODE_Y: number;
  87900. /**
  87901. * Object will rotate to face the camera but only on the z axis
  87902. */
  87903. static BILLBOARDMODE_Z: number;
  87904. /**
  87905. * Object will rotate to face the camera
  87906. */
  87907. static BILLBOARDMODE_ALL: number;
  87908. /**
  87909. * Object will rotate to face the camera's position instead of orientation
  87910. */
  87911. static BILLBOARDMODE_USE_POSITION: number;
  87912. private _forward;
  87913. private _forwardInverted;
  87914. private _up;
  87915. private _right;
  87916. private _rightInverted;
  87917. private _position;
  87918. private _rotation;
  87919. private _rotationQuaternion;
  87920. protected _scaling: Vector3;
  87921. protected _isDirty: boolean;
  87922. private _transformToBoneReferal;
  87923. private _isAbsoluteSynced;
  87924. private _billboardMode;
  87925. /**
  87926. * Gets or sets the billboard mode. Default is 0.
  87927. *
  87928. * | Value | Type | Description |
  87929. * | --- | --- | --- |
  87930. * | 0 | BILLBOARDMODE_NONE | |
  87931. * | 1 | BILLBOARDMODE_X | |
  87932. * | 2 | BILLBOARDMODE_Y | |
  87933. * | 4 | BILLBOARDMODE_Z | |
  87934. * | 7 | BILLBOARDMODE_ALL | |
  87935. *
  87936. */
  87937. get billboardMode(): number;
  87938. set billboardMode(value: number);
  87939. private _preserveParentRotationForBillboard;
  87940. /**
  87941. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87942. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87943. */
  87944. get preserveParentRotationForBillboard(): boolean;
  87945. set preserveParentRotationForBillboard(value: boolean);
  87946. /**
  87947. * 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
  87948. */
  87949. scalingDeterminant: number;
  87950. private _infiniteDistance;
  87951. /**
  87952. * Gets or sets the distance of the object to max, often used by skybox
  87953. */
  87954. get infiniteDistance(): boolean;
  87955. set infiniteDistance(value: boolean);
  87956. /**
  87957. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87958. * By default the system will update normals to compensate
  87959. */
  87960. ignoreNonUniformScaling: boolean;
  87961. /**
  87962. * 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
  87963. */
  87964. reIntegrateRotationIntoRotationQuaternion: boolean;
  87965. /** @hidden */
  87966. _poseMatrix: Nullable<Matrix>;
  87967. /** @hidden */
  87968. _localMatrix: Matrix;
  87969. private _usePivotMatrix;
  87970. private _absolutePosition;
  87971. private _absoluteScaling;
  87972. private _absoluteRotationQuaternion;
  87973. private _pivotMatrix;
  87974. private _pivotMatrixInverse;
  87975. protected _postMultiplyPivotMatrix: boolean;
  87976. protected _isWorldMatrixFrozen: boolean;
  87977. /** @hidden */
  87978. _indexInSceneTransformNodesArray: number;
  87979. /**
  87980. * An event triggered after the world matrix is updated
  87981. */
  87982. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87983. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87984. /**
  87985. * Gets a string identifying the name of the class
  87986. * @returns "TransformNode" string
  87987. */
  87988. getClassName(): string;
  87989. /**
  87990. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87991. */
  87992. get position(): Vector3;
  87993. set position(newPosition: Vector3);
  87994. /**
  87995. * 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)).
  87996. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87997. */
  87998. get rotation(): Vector3;
  87999. set rotation(newRotation: Vector3);
  88000. /**
  88001. * 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)).
  88002. */
  88003. get scaling(): Vector3;
  88004. set scaling(newScaling: Vector3);
  88005. /**
  88006. * 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).
  88007. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88008. */
  88009. get rotationQuaternion(): Nullable<Quaternion>;
  88010. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  88011. /**
  88012. * The forward direction of that transform in world space.
  88013. */
  88014. get forward(): Vector3;
  88015. /**
  88016. * The up direction of that transform in world space.
  88017. */
  88018. get up(): Vector3;
  88019. /**
  88020. * The right direction of that transform in world space.
  88021. */
  88022. get right(): Vector3;
  88023. /**
  88024. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88025. * @param matrix the matrix to copy the pose from
  88026. * @returns this TransformNode.
  88027. */
  88028. updatePoseMatrix(matrix: Matrix): TransformNode;
  88029. /**
  88030. * Returns the mesh Pose matrix.
  88031. * @returns the pose matrix
  88032. */
  88033. getPoseMatrix(): Matrix;
  88034. /** @hidden */
  88035. _isSynchronized(): boolean;
  88036. /** @hidden */
  88037. _initCache(): void;
  88038. /**
  88039. * Flag the transform node as dirty (Forcing it to update everything)
  88040. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88041. * @returns this transform node
  88042. */
  88043. markAsDirty(property: string): TransformNode;
  88044. /**
  88045. * Returns the current mesh absolute position.
  88046. * Returns a Vector3.
  88047. */
  88048. get absolutePosition(): Vector3;
  88049. /**
  88050. * Returns the current mesh absolute scaling.
  88051. * Returns a Vector3.
  88052. */
  88053. get absoluteScaling(): Vector3;
  88054. /**
  88055. * Returns the current mesh absolute rotation.
  88056. * Returns a Quaternion.
  88057. */
  88058. get absoluteRotationQuaternion(): Quaternion;
  88059. /**
  88060. * Sets a new matrix to apply before all other transformation
  88061. * @param matrix defines the transform matrix
  88062. * @returns the current TransformNode
  88063. */
  88064. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88065. /**
  88066. * Sets a new pivot matrix to the current node
  88067. * @param matrix defines the new pivot matrix to use
  88068. * @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
  88069. * @returns the current TransformNode
  88070. */
  88071. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88072. /**
  88073. * Returns the mesh pivot matrix.
  88074. * Default : Identity.
  88075. * @returns the matrix
  88076. */
  88077. getPivotMatrix(): Matrix;
  88078. /**
  88079. * Instantiate (when possible) or clone that node with its hierarchy
  88080. * @param newParent defines the new parent to use for the instance (or clone)
  88081. * @param options defines options to configure how copy is done
  88082. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88083. * @returns an instance (or a clone) of the current node with its hiearchy
  88084. */
  88085. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88086. doNotInstantiate: boolean;
  88087. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88088. /**
  88089. * Prevents the World matrix to be computed any longer
  88090. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88091. * @returns the TransformNode.
  88092. */
  88093. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88094. /**
  88095. * Allows back the World matrix computation.
  88096. * @returns the TransformNode.
  88097. */
  88098. unfreezeWorldMatrix(): this;
  88099. /**
  88100. * True if the World matrix has been frozen.
  88101. */
  88102. get isWorldMatrixFrozen(): boolean;
  88103. /**
  88104. * Retuns the mesh absolute position in the World.
  88105. * @returns a Vector3.
  88106. */
  88107. getAbsolutePosition(): Vector3;
  88108. /**
  88109. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88110. * @param absolutePosition the absolute position to set
  88111. * @returns the TransformNode.
  88112. */
  88113. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88114. /**
  88115. * Sets the mesh position in its local space.
  88116. * @param vector3 the position to set in localspace
  88117. * @returns the TransformNode.
  88118. */
  88119. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88120. /**
  88121. * Returns the mesh position in the local space from the current World matrix values.
  88122. * @returns a new Vector3.
  88123. */
  88124. getPositionExpressedInLocalSpace(): Vector3;
  88125. /**
  88126. * Translates the mesh along the passed Vector3 in its local space.
  88127. * @param vector3 the distance to translate in localspace
  88128. * @returns the TransformNode.
  88129. */
  88130. locallyTranslate(vector3: Vector3): TransformNode;
  88131. private static _lookAtVectorCache;
  88132. /**
  88133. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88134. * @param targetPoint the position (must be in same space as current mesh) to look at
  88135. * @param yawCor optional yaw (y-axis) correction in radians
  88136. * @param pitchCor optional pitch (x-axis) correction in radians
  88137. * @param rollCor optional roll (z-axis) correction in radians
  88138. * @param space the choosen space of the target
  88139. * @returns the TransformNode.
  88140. */
  88141. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88142. /**
  88143. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88144. * This Vector3 is expressed in the World space.
  88145. * @param localAxis axis to rotate
  88146. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88147. */
  88148. getDirection(localAxis: Vector3): Vector3;
  88149. /**
  88150. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88151. * localAxis is expressed in the mesh local space.
  88152. * result is computed in the Wordl space from the mesh World matrix.
  88153. * @param localAxis axis to rotate
  88154. * @param result the resulting transformnode
  88155. * @returns this TransformNode.
  88156. */
  88157. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88158. /**
  88159. * Sets this transform node rotation to the given local axis.
  88160. * @param localAxis the axis in local space
  88161. * @param yawCor optional yaw (y-axis) correction in radians
  88162. * @param pitchCor optional pitch (x-axis) correction in radians
  88163. * @param rollCor optional roll (z-axis) correction in radians
  88164. * @returns this TransformNode
  88165. */
  88166. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88167. /**
  88168. * Sets a new pivot point to the current node
  88169. * @param point defines the new pivot point to use
  88170. * @param space defines if the point is in world or local space (local by default)
  88171. * @returns the current TransformNode
  88172. */
  88173. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88174. /**
  88175. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88176. * @returns the pivot point
  88177. */
  88178. getPivotPoint(): Vector3;
  88179. /**
  88180. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88181. * @param result the vector3 to store the result
  88182. * @returns this TransformNode.
  88183. */
  88184. getPivotPointToRef(result: Vector3): TransformNode;
  88185. /**
  88186. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88187. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88188. */
  88189. getAbsolutePivotPoint(): Vector3;
  88190. /**
  88191. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88192. * @param result vector3 to store the result
  88193. * @returns this TransformNode.
  88194. */
  88195. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88196. /**
  88197. * Defines the passed node as the parent of the current node.
  88198. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88199. * @see https://doc.babylonjs.com/how_to/parenting
  88200. * @param node the node ot set as the parent
  88201. * @returns this TransformNode.
  88202. */
  88203. setParent(node: Nullable<Node>): TransformNode;
  88204. private _nonUniformScaling;
  88205. /**
  88206. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88207. */
  88208. get nonUniformScaling(): boolean;
  88209. /** @hidden */
  88210. _updateNonUniformScalingState(value: boolean): boolean;
  88211. /**
  88212. * Attach the current TransformNode to another TransformNode associated with a bone
  88213. * @param bone Bone affecting the TransformNode
  88214. * @param affectedTransformNode TransformNode associated with the bone
  88215. * @returns this object
  88216. */
  88217. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88218. /**
  88219. * Detach the transform node if its associated with a bone
  88220. * @returns this object
  88221. */
  88222. detachFromBone(): TransformNode;
  88223. private static _rotationAxisCache;
  88224. /**
  88225. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88226. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88227. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88228. * The passed axis is also normalized.
  88229. * @param axis the axis to rotate around
  88230. * @param amount the amount to rotate in radians
  88231. * @param space Space to rotate in (Default: local)
  88232. * @returns the TransformNode.
  88233. */
  88234. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88235. /**
  88236. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88237. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88238. * The passed axis is also normalized. .
  88239. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88240. * @param point the point to rotate around
  88241. * @param axis the axis to rotate around
  88242. * @param amount the amount to rotate in radians
  88243. * @returns the TransformNode
  88244. */
  88245. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88246. /**
  88247. * Translates the mesh along the axis vector for the passed distance in the given space.
  88248. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88249. * @param axis the axis to translate in
  88250. * @param distance the distance to translate
  88251. * @param space Space to rotate in (Default: local)
  88252. * @returns the TransformNode.
  88253. */
  88254. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88255. /**
  88256. * Adds a rotation step to the mesh current rotation.
  88257. * x, y, z are Euler angles expressed in radians.
  88258. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88259. * This means this rotation is made in the mesh local space only.
  88260. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88261. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88262. * ```javascript
  88263. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88264. * ```
  88265. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88266. * 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.
  88267. * @param x Rotation to add
  88268. * @param y Rotation to add
  88269. * @param z Rotation to add
  88270. * @returns the TransformNode.
  88271. */
  88272. addRotation(x: number, y: number, z: number): TransformNode;
  88273. /**
  88274. * @hidden
  88275. */
  88276. protected _getEffectiveParent(): Nullable<Node>;
  88277. /**
  88278. * Computes the world matrix of the node
  88279. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88280. * @returns the world matrix
  88281. */
  88282. computeWorldMatrix(force?: boolean): Matrix;
  88283. /**
  88284. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88285. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88286. */
  88287. resetLocalMatrix(independentOfChildren?: boolean): void;
  88288. protected _afterComputeWorldMatrix(): void;
  88289. /**
  88290. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88291. * @param func callback function to add
  88292. *
  88293. * @returns the TransformNode.
  88294. */
  88295. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88296. /**
  88297. * Removes a registered callback function.
  88298. * @param func callback function to remove
  88299. * @returns the TransformNode.
  88300. */
  88301. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88302. /**
  88303. * Gets the position of the current mesh in camera space
  88304. * @param camera defines the camera to use
  88305. * @returns a position
  88306. */
  88307. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88308. /**
  88309. * Returns the distance from the mesh to the active camera
  88310. * @param camera defines the camera to use
  88311. * @returns the distance
  88312. */
  88313. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88314. /**
  88315. * Clone the current transform node
  88316. * @param name Name of the new clone
  88317. * @param newParent New parent for the clone
  88318. * @param doNotCloneChildren Do not clone children hierarchy
  88319. * @returns the new transform node
  88320. */
  88321. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88322. /**
  88323. * Serializes the objects information.
  88324. * @param currentSerializationObject defines the object to serialize in
  88325. * @returns the serialized object
  88326. */
  88327. serialize(currentSerializationObject?: any): any;
  88328. /**
  88329. * Returns a new TransformNode object parsed from the source provided.
  88330. * @param parsedTransformNode is the source.
  88331. * @param scene the scne the object belongs to
  88332. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88333. * @returns a new TransformNode object parsed from the source provided.
  88334. */
  88335. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88336. /**
  88337. * Get all child-transformNodes of this node
  88338. * @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
  88339. * @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
  88340. * @returns an array of TransformNode
  88341. */
  88342. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88343. /**
  88344. * Releases resources associated with this transform node.
  88345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88347. */
  88348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88349. /**
  88350. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88351. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88352. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88353. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88354. * @returns the current mesh
  88355. */
  88356. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88357. private _syncAbsoluteScalingAndRotation;
  88358. }
  88359. }
  88360. declare module BABYLON {
  88361. /**
  88362. * Class used to override all child animations of a given target
  88363. */
  88364. export class AnimationPropertiesOverride {
  88365. /**
  88366. * Gets or sets a value indicating if animation blending must be used
  88367. */
  88368. enableBlending: boolean;
  88369. /**
  88370. * Gets or sets the blending speed to use when enableBlending is true
  88371. */
  88372. blendingSpeed: number;
  88373. /**
  88374. * Gets or sets the default loop mode to use
  88375. */
  88376. loopMode: number;
  88377. }
  88378. }
  88379. declare module BABYLON {
  88380. /**
  88381. * Class used to store bone information
  88382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88383. */
  88384. export class Bone extends Node {
  88385. /**
  88386. * defines the bone name
  88387. */
  88388. name: string;
  88389. private static _tmpVecs;
  88390. private static _tmpQuat;
  88391. private static _tmpMats;
  88392. /**
  88393. * Gets the list of child bones
  88394. */
  88395. children: Bone[];
  88396. /** Gets the animations associated with this bone */
  88397. animations: Animation[];
  88398. /**
  88399. * Gets or sets bone length
  88400. */
  88401. length: number;
  88402. /**
  88403. * @hidden Internal only
  88404. * Set this value to map this bone to a different index in the transform matrices
  88405. * Set this value to -1 to exclude the bone from the transform matrices
  88406. */
  88407. _index: Nullable<number>;
  88408. private _skeleton;
  88409. private _localMatrix;
  88410. private _restPose;
  88411. private _baseMatrix;
  88412. private _absoluteTransform;
  88413. private _invertedAbsoluteTransform;
  88414. private _parent;
  88415. private _scalingDeterminant;
  88416. private _worldTransform;
  88417. private _localScaling;
  88418. private _localRotation;
  88419. private _localPosition;
  88420. private _needToDecompose;
  88421. private _needToCompose;
  88422. /** @hidden */
  88423. _linkedTransformNode: Nullable<TransformNode>;
  88424. /** @hidden */
  88425. _waitingTransformNodeId: Nullable<string>;
  88426. /** @hidden */
  88427. get _matrix(): Matrix;
  88428. /** @hidden */
  88429. set _matrix(value: Matrix);
  88430. /**
  88431. * Create a new bone
  88432. * @param name defines the bone name
  88433. * @param skeleton defines the parent skeleton
  88434. * @param parentBone defines the parent (can be null if the bone is the root)
  88435. * @param localMatrix defines the local matrix
  88436. * @param restPose defines the rest pose matrix
  88437. * @param baseMatrix defines the base matrix
  88438. * @param index defines index of the bone in the hiearchy
  88439. */
  88440. constructor(
  88441. /**
  88442. * defines the bone name
  88443. */
  88444. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88445. /**
  88446. * Gets the current object class name.
  88447. * @return the class name
  88448. */
  88449. getClassName(): string;
  88450. /**
  88451. * Gets the parent skeleton
  88452. * @returns a skeleton
  88453. */
  88454. getSkeleton(): Skeleton;
  88455. /**
  88456. * Gets parent bone
  88457. * @returns a bone or null if the bone is the root of the bone hierarchy
  88458. */
  88459. getParent(): Nullable<Bone>;
  88460. /**
  88461. * Returns an array containing the root bones
  88462. * @returns an array containing the root bones
  88463. */
  88464. getChildren(): Array<Bone>;
  88465. /**
  88466. * Gets the node index in matrix array generated for rendering
  88467. * @returns the node index
  88468. */
  88469. getIndex(): number;
  88470. /**
  88471. * Sets the parent bone
  88472. * @param parent defines the parent (can be null if the bone is the root)
  88473. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88474. */
  88475. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88476. /**
  88477. * Gets the local matrix
  88478. * @returns a matrix
  88479. */
  88480. getLocalMatrix(): Matrix;
  88481. /**
  88482. * Gets the base matrix (initial matrix which remains unchanged)
  88483. * @returns a matrix
  88484. */
  88485. getBaseMatrix(): Matrix;
  88486. /**
  88487. * Gets the rest pose matrix
  88488. * @returns a matrix
  88489. */
  88490. getRestPose(): Matrix;
  88491. /**
  88492. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88493. */
  88494. getWorldMatrix(): Matrix;
  88495. /**
  88496. * Sets the local matrix to rest pose matrix
  88497. */
  88498. returnToRest(): void;
  88499. /**
  88500. * Gets the inverse of the absolute transform matrix.
  88501. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88502. * @returns a matrix
  88503. */
  88504. getInvertedAbsoluteTransform(): Matrix;
  88505. /**
  88506. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88507. * @returns a matrix
  88508. */
  88509. getAbsoluteTransform(): Matrix;
  88510. /**
  88511. * Links with the given transform node.
  88512. * The local matrix of this bone is copied from the transform node every frame.
  88513. * @param transformNode defines the transform node to link to
  88514. */
  88515. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88516. /**
  88517. * Gets the node used to drive the bone's transformation
  88518. * @returns a transform node or null
  88519. */
  88520. getTransformNode(): Nullable<TransformNode>;
  88521. /** Gets or sets current position (in local space) */
  88522. get position(): Vector3;
  88523. set position(newPosition: Vector3);
  88524. /** Gets or sets current rotation (in local space) */
  88525. get rotation(): Vector3;
  88526. set rotation(newRotation: Vector3);
  88527. /** Gets or sets current rotation quaternion (in local space) */
  88528. get rotationQuaternion(): Quaternion;
  88529. set rotationQuaternion(newRotation: Quaternion);
  88530. /** Gets or sets current scaling (in local space) */
  88531. get scaling(): Vector3;
  88532. set scaling(newScaling: Vector3);
  88533. /**
  88534. * Gets the animation properties override
  88535. */
  88536. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88537. private _decompose;
  88538. private _compose;
  88539. /**
  88540. * Update the base and local matrices
  88541. * @param matrix defines the new base or local matrix
  88542. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88543. * @param updateLocalMatrix defines if the local matrix should be updated
  88544. */
  88545. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88546. /** @hidden */
  88547. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88548. /**
  88549. * Flag the bone as dirty (Forcing it to update everything)
  88550. */
  88551. markAsDirty(): void;
  88552. /** @hidden */
  88553. _markAsDirtyAndCompose(): void;
  88554. private _markAsDirtyAndDecompose;
  88555. /**
  88556. * Translate the bone in local or world space
  88557. * @param vec The amount to translate the bone
  88558. * @param space The space that the translation is in
  88559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88560. */
  88561. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88562. /**
  88563. * Set the postion of the bone in local or world space
  88564. * @param position The position to set the bone
  88565. * @param space The space that the position is in
  88566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88567. */
  88568. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88569. /**
  88570. * Set the absolute position of the bone (world space)
  88571. * @param position The position to set the bone
  88572. * @param mesh The mesh that this bone is attached to
  88573. */
  88574. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88575. /**
  88576. * Scale the bone on the x, y and z axes (in local space)
  88577. * @param x The amount to scale the bone on the x axis
  88578. * @param y The amount to scale the bone on the y axis
  88579. * @param z The amount to scale the bone on the z axis
  88580. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88581. */
  88582. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88583. /**
  88584. * Set the bone scaling in local space
  88585. * @param scale defines the scaling vector
  88586. */
  88587. setScale(scale: Vector3): void;
  88588. /**
  88589. * Gets the current scaling in local space
  88590. * @returns the current scaling vector
  88591. */
  88592. getScale(): Vector3;
  88593. /**
  88594. * Gets the current scaling in local space and stores it in a target vector
  88595. * @param result defines the target vector
  88596. */
  88597. getScaleToRef(result: Vector3): void;
  88598. /**
  88599. * Set the yaw, pitch, and roll of the bone in local or world space
  88600. * @param yaw The rotation of the bone on the y axis
  88601. * @param pitch The rotation of the bone on the x axis
  88602. * @param roll The rotation of the bone on the z axis
  88603. * @param space The space that the axes of rotation are in
  88604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88605. */
  88606. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88607. /**
  88608. * Add a rotation to the bone on an axis in local or world space
  88609. * @param axis The axis to rotate the bone on
  88610. * @param amount The amount to rotate the bone
  88611. * @param space The space that the axis is in
  88612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88613. */
  88614. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88615. /**
  88616. * Set the rotation of the bone to a particular axis angle in local or world space
  88617. * @param axis The axis to rotate the bone on
  88618. * @param angle The angle that the bone should be rotated to
  88619. * @param space The space that the axis is in
  88620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88621. */
  88622. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88623. /**
  88624. * Set the euler rotation of the bone in local of world space
  88625. * @param rotation The euler rotation that the bone should be set to
  88626. * @param space The space that the rotation is in
  88627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88628. */
  88629. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88630. /**
  88631. * Set the quaternion rotation of the bone in local of world space
  88632. * @param quat The quaternion rotation that the bone should be set to
  88633. * @param space The space that the rotation is in
  88634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88635. */
  88636. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88637. /**
  88638. * Set the rotation matrix of the bone in local of world space
  88639. * @param rotMat The rotation matrix that the bone should be set to
  88640. * @param space The space that the rotation is in
  88641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88642. */
  88643. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88644. private _rotateWithMatrix;
  88645. private _getNegativeRotationToRef;
  88646. /**
  88647. * Get the position of the bone in local or world space
  88648. * @param space The space that the returned position is in
  88649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88650. * @returns The position of the bone
  88651. */
  88652. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88653. /**
  88654. * Copy the position of the bone to a vector3 in local or world space
  88655. * @param space The space that the returned position is in
  88656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88657. * @param result The vector3 to copy the position to
  88658. */
  88659. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88660. /**
  88661. * Get the absolute position of the bone (world space)
  88662. * @param mesh The mesh that this bone is attached to
  88663. * @returns The absolute position of the bone
  88664. */
  88665. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88666. /**
  88667. * Copy the absolute position of the bone (world space) to the result param
  88668. * @param mesh The mesh that this bone is attached to
  88669. * @param result The vector3 to copy the absolute position to
  88670. */
  88671. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88672. /**
  88673. * Compute the absolute transforms of this bone and its children
  88674. */
  88675. computeAbsoluteTransforms(): void;
  88676. /**
  88677. * Get the world direction from an axis that is in the local space of the bone
  88678. * @param localAxis The local direction that is used to compute the world direction
  88679. * @param mesh The mesh that this bone is attached to
  88680. * @returns The world direction
  88681. */
  88682. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88683. /**
  88684. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88685. * @param localAxis The local direction that is used to compute the world direction
  88686. * @param mesh The mesh that this bone is attached to
  88687. * @param result The vector3 that the world direction will be copied to
  88688. */
  88689. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88690. /**
  88691. * Get the euler rotation of the bone in local or world space
  88692. * @param space The space that the rotation should be in
  88693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88694. * @returns The euler rotation
  88695. */
  88696. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88697. /**
  88698. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88699. * @param space The space that the rotation should be in
  88700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88701. * @param result The vector3 that the rotation should be copied to
  88702. */
  88703. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88704. /**
  88705. * Get the quaternion rotation of the bone in either local or world space
  88706. * @param space The space that the rotation should be in
  88707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88708. * @returns The quaternion rotation
  88709. */
  88710. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88711. /**
  88712. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88713. * @param space The space that the rotation should be in
  88714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88715. * @param result The quaternion that the rotation should be copied to
  88716. */
  88717. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88718. /**
  88719. * Get the rotation matrix of the bone in local or world space
  88720. * @param space The space that the rotation should be in
  88721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88722. * @returns The rotation matrix
  88723. */
  88724. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88725. /**
  88726. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88727. * @param space The space that the rotation should be in
  88728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88729. * @param result The quaternion that the rotation should be copied to
  88730. */
  88731. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88732. /**
  88733. * Get the world position of a point that is in the local space of the bone
  88734. * @param position The local position
  88735. * @param mesh The mesh that this bone is attached to
  88736. * @returns The world position
  88737. */
  88738. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88739. /**
  88740. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88741. * @param position The local position
  88742. * @param mesh The mesh that this bone is attached to
  88743. * @param result The vector3 that the world position should be copied to
  88744. */
  88745. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88746. /**
  88747. * Get the local position of a point that is in world space
  88748. * @param position The world position
  88749. * @param mesh The mesh that this bone is attached to
  88750. * @returns The local position
  88751. */
  88752. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88753. /**
  88754. * Get the local position of a point that is in world space and copy it to the result param
  88755. * @param position The world position
  88756. * @param mesh The mesh that this bone is attached to
  88757. * @param result The vector3 that the local position should be copied to
  88758. */
  88759. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88760. }
  88761. }
  88762. declare module BABYLON {
  88763. /**
  88764. * Defines a runtime animation
  88765. */
  88766. export class RuntimeAnimation {
  88767. private _events;
  88768. /**
  88769. * The current frame of the runtime animation
  88770. */
  88771. private _currentFrame;
  88772. /**
  88773. * The animation used by the runtime animation
  88774. */
  88775. private _animation;
  88776. /**
  88777. * The target of the runtime animation
  88778. */
  88779. private _target;
  88780. /**
  88781. * The initiating animatable
  88782. */
  88783. private _host;
  88784. /**
  88785. * The original value of the runtime animation
  88786. */
  88787. private _originalValue;
  88788. /**
  88789. * The original blend value of the runtime animation
  88790. */
  88791. private _originalBlendValue;
  88792. /**
  88793. * The offsets cache of the runtime animation
  88794. */
  88795. private _offsetsCache;
  88796. /**
  88797. * The high limits cache of the runtime animation
  88798. */
  88799. private _highLimitsCache;
  88800. /**
  88801. * Specifies if the runtime animation has been stopped
  88802. */
  88803. private _stopped;
  88804. /**
  88805. * The blending factor of the runtime animation
  88806. */
  88807. private _blendingFactor;
  88808. /**
  88809. * The BabylonJS scene
  88810. */
  88811. private _scene;
  88812. /**
  88813. * The current value of the runtime animation
  88814. */
  88815. private _currentValue;
  88816. /** @hidden */
  88817. _animationState: _IAnimationState;
  88818. /**
  88819. * The active target of the runtime animation
  88820. */
  88821. private _activeTargets;
  88822. private _currentActiveTarget;
  88823. private _directTarget;
  88824. /**
  88825. * The target path of the runtime animation
  88826. */
  88827. private _targetPath;
  88828. /**
  88829. * The weight of the runtime animation
  88830. */
  88831. private _weight;
  88832. /**
  88833. * The ratio offset of the runtime animation
  88834. */
  88835. private _ratioOffset;
  88836. /**
  88837. * The previous delay of the runtime animation
  88838. */
  88839. private _previousDelay;
  88840. /**
  88841. * The previous ratio of the runtime animation
  88842. */
  88843. private _previousRatio;
  88844. private _enableBlending;
  88845. private _keys;
  88846. private _minFrame;
  88847. private _maxFrame;
  88848. private _minValue;
  88849. private _maxValue;
  88850. private _targetIsArray;
  88851. /**
  88852. * Gets the current frame of the runtime animation
  88853. */
  88854. get currentFrame(): number;
  88855. /**
  88856. * Gets the weight of the runtime animation
  88857. */
  88858. get weight(): number;
  88859. /**
  88860. * Gets the current value of the runtime animation
  88861. */
  88862. get currentValue(): any;
  88863. /**
  88864. * Gets the target path of the runtime animation
  88865. */
  88866. get targetPath(): string;
  88867. /**
  88868. * Gets the actual target of the runtime animation
  88869. */
  88870. get target(): any;
  88871. /**
  88872. * Gets the additive state of the runtime animation
  88873. */
  88874. get isAdditive(): boolean;
  88875. /** @hidden */
  88876. _onLoop: () => void;
  88877. /**
  88878. * Create a new RuntimeAnimation object
  88879. * @param target defines the target of the animation
  88880. * @param animation defines the source animation object
  88881. * @param scene defines the hosting scene
  88882. * @param host defines the initiating Animatable
  88883. */
  88884. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88885. private _preparePath;
  88886. /**
  88887. * Gets the animation from the runtime animation
  88888. */
  88889. get animation(): Animation;
  88890. /**
  88891. * Resets the runtime animation to the beginning
  88892. * @param restoreOriginal defines whether to restore the target property to the original value
  88893. */
  88894. reset(restoreOriginal?: boolean): void;
  88895. /**
  88896. * Specifies if the runtime animation is stopped
  88897. * @returns Boolean specifying if the runtime animation is stopped
  88898. */
  88899. isStopped(): boolean;
  88900. /**
  88901. * Disposes of the runtime animation
  88902. */
  88903. dispose(): void;
  88904. /**
  88905. * Apply the interpolated value to the target
  88906. * @param currentValue defines the value computed by the animation
  88907. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88908. */
  88909. setValue(currentValue: any, weight: number): void;
  88910. private _getOriginalValues;
  88911. private _setValue;
  88912. /**
  88913. * Gets the loop pmode of the runtime animation
  88914. * @returns Loop Mode
  88915. */
  88916. private _getCorrectLoopMode;
  88917. /**
  88918. * Move the current animation to a given frame
  88919. * @param frame defines the frame to move to
  88920. */
  88921. goToFrame(frame: number): void;
  88922. /**
  88923. * @hidden Internal use only
  88924. */
  88925. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88926. /**
  88927. * Execute the current animation
  88928. * @param delay defines the delay to add to the current frame
  88929. * @param from defines the lower bound of the animation range
  88930. * @param to defines the upper bound of the animation range
  88931. * @param loop defines if the current animation must loop
  88932. * @param speedRatio defines the current speed ratio
  88933. * @param weight defines the weight of the animation (default is -1 so no weight)
  88934. * @param onLoop optional callback called when animation loops
  88935. * @returns a boolean indicating if the animation is running
  88936. */
  88937. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88938. }
  88939. }
  88940. declare module BABYLON {
  88941. /**
  88942. * Class used to store an actual running animation
  88943. */
  88944. export class Animatable {
  88945. /** defines the target object */
  88946. target: any;
  88947. /** defines the starting frame number (default is 0) */
  88948. fromFrame: number;
  88949. /** defines the ending frame number (default is 100) */
  88950. toFrame: number;
  88951. /** defines if the animation must loop (default is false) */
  88952. loopAnimation: boolean;
  88953. /** defines a callback to call when animation ends if it is not looping */
  88954. onAnimationEnd?: (() => void) | null | undefined;
  88955. /** defines a callback to call when animation loops */
  88956. onAnimationLoop?: (() => void) | null | undefined;
  88957. /** defines whether the animation should be evaluated additively */
  88958. isAdditive: boolean;
  88959. private _localDelayOffset;
  88960. private _pausedDelay;
  88961. private _runtimeAnimations;
  88962. private _paused;
  88963. private _scene;
  88964. private _speedRatio;
  88965. private _weight;
  88966. private _syncRoot;
  88967. /**
  88968. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88969. * This will only apply for non looping animation (default is true)
  88970. */
  88971. disposeOnEnd: boolean;
  88972. /**
  88973. * Gets a boolean indicating if the animation has started
  88974. */
  88975. animationStarted: boolean;
  88976. /**
  88977. * Observer raised when the animation ends
  88978. */
  88979. onAnimationEndObservable: Observable<Animatable>;
  88980. /**
  88981. * Observer raised when the animation loops
  88982. */
  88983. onAnimationLoopObservable: Observable<Animatable>;
  88984. /**
  88985. * Gets the root Animatable used to synchronize and normalize animations
  88986. */
  88987. get syncRoot(): Nullable<Animatable>;
  88988. /**
  88989. * Gets the current frame of the first RuntimeAnimation
  88990. * Used to synchronize Animatables
  88991. */
  88992. get masterFrame(): number;
  88993. /**
  88994. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88995. */
  88996. get weight(): number;
  88997. set weight(value: number);
  88998. /**
  88999. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  89000. */
  89001. get speedRatio(): number;
  89002. set speedRatio(value: number);
  89003. /**
  89004. * Creates a new Animatable
  89005. * @param scene defines the hosting scene
  89006. * @param target defines the target object
  89007. * @param fromFrame defines the starting frame number (default is 0)
  89008. * @param toFrame defines the ending frame number (default is 100)
  89009. * @param loopAnimation defines if the animation must loop (default is false)
  89010. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  89011. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  89012. * @param animations defines a group of animation to add to the new Animatable
  89013. * @param onAnimationLoop defines a callback to call when animation loops
  89014. * @param isAdditive defines whether the animation should be evaluated additively
  89015. */
  89016. constructor(scene: Scene,
  89017. /** defines the target object */
  89018. target: any,
  89019. /** defines the starting frame number (default is 0) */
  89020. fromFrame?: number,
  89021. /** defines the ending frame number (default is 100) */
  89022. toFrame?: number,
  89023. /** defines if the animation must loop (default is false) */
  89024. loopAnimation?: boolean, speedRatio?: number,
  89025. /** defines a callback to call when animation ends if it is not looping */
  89026. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89027. /** defines a callback to call when animation loops */
  89028. onAnimationLoop?: (() => void) | null | undefined,
  89029. /** defines whether the animation should be evaluated additively */
  89030. isAdditive?: boolean);
  89031. /**
  89032. * Synchronize and normalize current Animatable with a source Animatable
  89033. * This is useful when using animation weights and when animations are not of the same length
  89034. * @param root defines the root Animatable to synchronize with
  89035. * @returns the current Animatable
  89036. */
  89037. syncWith(root: Animatable): Animatable;
  89038. /**
  89039. * Gets the list of runtime animations
  89040. * @returns an array of RuntimeAnimation
  89041. */
  89042. getAnimations(): RuntimeAnimation[];
  89043. /**
  89044. * Adds more animations to the current animatable
  89045. * @param target defines the target of the animations
  89046. * @param animations defines the new animations to add
  89047. */
  89048. appendAnimations(target: any, animations: Animation[]): void;
  89049. /**
  89050. * Gets the source animation for a specific property
  89051. * @param property defines the propertyu to look for
  89052. * @returns null or the source animation for the given property
  89053. */
  89054. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89055. /**
  89056. * Gets the runtime animation for a specific property
  89057. * @param property defines the propertyu to look for
  89058. * @returns null or the runtime animation for the given property
  89059. */
  89060. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89061. /**
  89062. * Resets the animatable to its original state
  89063. */
  89064. reset(): void;
  89065. /**
  89066. * Allows the animatable to blend with current running animations
  89067. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89068. * @param blendingSpeed defines the blending speed to use
  89069. */
  89070. enableBlending(blendingSpeed: number): void;
  89071. /**
  89072. * Disable animation blending
  89073. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89074. */
  89075. disableBlending(): void;
  89076. /**
  89077. * Jump directly to a given frame
  89078. * @param frame defines the frame to jump to
  89079. */
  89080. goToFrame(frame: number): void;
  89081. /**
  89082. * Pause the animation
  89083. */
  89084. pause(): void;
  89085. /**
  89086. * Restart the animation
  89087. */
  89088. restart(): void;
  89089. private _raiseOnAnimationEnd;
  89090. /**
  89091. * Stop and delete the current animation
  89092. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89093. * @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)
  89094. */
  89095. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89096. /**
  89097. * Wait asynchronously for the animation to end
  89098. * @returns a promise which will be fullfilled when the animation ends
  89099. */
  89100. waitAsync(): Promise<Animatable>;
  89101. /** @hidden */
  89102. _animate(delay: number): boolean;
  89103. }
  89104. interface Scene {
  89105. /** @hidden */
  89106. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89107. /** @hidden */
  89108. _processLateAnimationBindingsForMatrices(holder: {
  89109. totalWeight: number;
  89110. totalAdditiveWeight: number;
  89111. animations: RuntimeAnimation[];
  89112. additiveAnimations: RuntimeAnimation[];
  89113. originalValue: Matrix;
  89114. }): any;
  89115. /** @hidden */
  89116. _processLateAnimationBindingsForQuaternions(holder: {
  89117. totalWeight: number;
  89118. totalAdditiveWeight: number;
  89119. animations: RuntimeAnimation[];
  89120. additiveAnimations: RuntimeAnimation[];
  89121. originalValue: Quaternion;
  89122. }, refQuaternion: Quaternion): Quaternion;
  89123. /** @hidden */
  89124. _processLateAnimationBindings(): void;
  89125. /**
  89126. * Will start the animation sequence of a given target
  89127. * @param target defines the target
  89128. * @param from defines from which frame should animation start
  89129. * @param to defines until which frame should animation run.
  89130. * @param weight defines the weight to apply to the animation (1.0 by default)
  89131. * @param loop defines if the animation loops
  89132. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89133. * @param onAnimationEnd defines the function to be executed when the animation ends
  89134. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89135. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89136. * @param onAnimationLoop defines the callback to call when an animation loops
  89137. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89138. * @returns the animatable object created for this animation
  89139. */
  89140. 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;
  89141. /**
  89142. * Will start the animation sequence of a given target
  89143. * @param target defines the target
  89144. * @param from defines from which frame should animation start
  89145. * @param to defines until which frame should animation run.
  89146. * @param loop defines if the animation loops
  89147. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89148. * @param onAnimationEnd defines the function to be executed when the animation ends
  89149. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89150. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89151. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89152. * @param onAnimationLoop defines the callback to call when an animation loops
  89153. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89154. * @returns the animatable object created for this animation
  89155. */
  89156. 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;
  89157. /**
  89158. * Will start the animation sequence of a given target and its hierarchy
  89159. * @param target defines the target
  89160. * @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.
  89161. * @param from defines from which frame should animation start
  89162. * @param to defines until which frame should animation run.
  89163. * @param loop defines if the animation loops
  89164. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89165. * @param onAnimationEnd defines the function to be executed when the animation ends
  89166. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89167. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89168. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89169. * @param onAnimationLoop defines the callback to call when an animation loops
  89170. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89171. * @returns the list of created animatables
  89172. */
  89173. 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[];
  89174. /**
  89175. * Begin a new animation on a given node
  89176. * @param target defines the target where the animation will take place
  89177. * @param animations defines the list of animations to start
  89178. * @param from defines the initial value
  89179. * @param to defines the final value
  89180. * @param loop defines if you want animation to loop (off by default)
  89181. * @param speedRatio defines the speed ratio to apply to all animations
  89182. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89183. * @param onAnimationLoop defines the callback to call when an animation loops
  89184. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89185. * @returns the list of created animatables
  89186. */
  89187. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89188. /**
  89189. * Begin a new animation on a given node and its hierarchy
  89190. * @param target defines the root node where the animation will take place
  89191. * @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.
  89192. * @param animations defines the list of animations to start
  89193. * @param from defines the initial value
  89194. * @param to defines the final value
  89195. * @param loop defines if you want animation to loop (off by default)
  89196. * @param speedRatio defines the speed ratio to apply to all animations
  89197. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89198. * @param onAnimationLoop defines the callback to call when an animation loops
  89199. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89200. * @returns the list of animatables created for all nodes
  89201. */
  89202. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89203. /**
  89204. * Gets the animatable associated with a specific target
  89205. * @param target defines the target of the animatable
  89206. * @returns the required animatable if found
  89207. */
  89208. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89209. /**
  89210. * Gets all animatables associated with a given target
  89211. * @param target defines the target to look animatables for
  89212. * @returns an array of Animatables
  89213. */
  89214. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89215. /**
  89216. * Stops and removes all animations that have been applied to the scene
  89217. */
  89218. stopAllAnimations(): void;
  89219. /**
  89220. * Gets the current delta time used by animation engine
  89221. */
  89222. deltaTime: number;
  89223. }
  89224. interface Bone {
  89225. /**
  89226. * Copy an animation range from another bone
  89227. * @param source defines the source bone
  89228. * @param rangeName defines the range name to copy
  89229. * @param frameOffset defines the frame offset
  89230. * @param rescaleAsRequired defines if rescaling must be applied if required
  89231. * @param skelDimensionsRatio defines the scaling ratio
  89232. * @returns true if operation was successful
  89233. */
  89234. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89235. }
  89236. }
  89237. declare module BABYLON {
  89238. /**
  89239. * Class used to handle skinning animations
  89240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89241. */
  89242. export class Skeleton implements IAnimatable {
  89243. /** defines the skeleton name */
  89244. name: string;
  89245. /** defines the skeleton Id */
  89246. id: string;
  89247. /**
  89248. * Defines the list of child bones
  89249. */
  89250. bones: Bone[];
  89251. /**
  89252. * Defines an estimate of the dimension of the skeleton at rest
  89253. */
  89254. dimensionsAtRest: Vector3;
  89255. /**
  89256. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89257. */
  89258. needInitialSkinMatrix: boolean;
  89259. /**
  89260. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89261. */
  89262. overrideMesh: Nullable<AbstractMesh>;
  89263. /**
  89264. * Gets the list of animations attached to this skeleton
  89265. */
  89266. animations: Array<Animation>;
  89267. private _scene;
  89268. private _isDirty;
  89269. private _transformMatrices;
  89270. private _transformMatrixTexture;
  89271. private _meshesWithPoseMatrix;
  89272. private _animatables;
  89273. private _identity;
  89274. private _synchronizedWithMesh;
  89275. private _ranges;
  89276. private _lastAbsoluteTransformsUpdateId;
  89277. private _canUseTextureForBones;
  89278. private _uniqueId;
  89279. /** @hidden */
  89280. _numBonesWithLinkedTransformNode: number;
  89281. /** @hidden */
  89282. _hasWaitingData: Nullable<boolean>;
  89283. /**
  89284. * Specifies if the skeleton should be serialized
  89285. */
  89286. doNotSerialize: boolean;
  89287. private _useTextureToStoreBoneMatrices;
  89288. /**
  89289. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89290. * Please note that this option is not available if the hardware does not support it
  89291. */
  89292. get useTextureToStoreBoneMatrices(): boolean;
  89293. set useTextureToStoreBoneMatrices(value: boolean);
  89294. private _animationPropertiesOverride;
  89295. /**
  89296. * Gets or sets the animation properties override
  89297. */
  89298. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89299. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89300. /**
  89301. * List of inspectable custom properties (used by the Inspector)
  89302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89303. */
  89304. inspectableCustomProperties: IInspectable[];
  89305. /**
  89306. * An observable triggered before computing the skeleton's matrices
  89307. */
  89308. onBeforeComputeObservable: Observable<Skeleton>;
  89309. /**
  89310. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89311. */
  89312. get isUsingTextureForMatrices(): boolean;
  89313. /**
  89314. * Gets the unique ID of this skeleton
  89315. */
  89316. get uniqueId(): number;
  89317. /**
  89318. * Creates a new skeleton
  89319. * @param name defines the skeleton name
  89320. * @param id defines the skeleton Id
  89321. * @param scene defines the hosting scene
  89322. */
  89323. constructor(
  89324. /** defines the skeleton name */
  89325. name: string,
  89326. /** defines the skeleton Id */
  89327. id: string, scene: Scene);
  89328. /**
  89329. * Gets the current object class name.
  89330. * @return the class name
  89331. */
  89332. getClassName(): string;
  89333. /**
  89334. * Returns an array containing the root bones
  89335. * @returns an array containing the root bones
  89336. */
  89337. getChildren(): Array<Bone>;
  89338. /**
  89339. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89340. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89341. * @returns a Float32Array containing matrices data
  89342. */
  89343. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89344. /**
  89345. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89346. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89347. * @returns a raw texture containing the data
  89348. */
  89349. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89350. /**
  89351. * Gets the current hosting scene
  89352. * @returns a scene object
  89353. */
  89354. getScene(): Scene;
  89355. /**
  89356. * Gets a string representing the current skeleton data
  89357. * @param fullDetails defines a boolean indicating if we want a verbose version
  89358. * @returns a string representing the current skeleton data
  89359. */
  89360. toString(fullDetails?: boolean): string;
  89361. /**
  89362. * Get bone's index searching by name
  89363. * @param name defines bone's name to search for
  89364. * @return the indice of the bone. Returns -1 if not found
  89365. */
  89366. getBoneIndexByName(name: string): number;
  89367. /**
  89368. * Creater a new animation range
  89369. * @param name defines the name of the range
  89370. * @param from defines the start key
  89371. * @param to defines the end key
  89372. */
  89373. createAnimationRange(name: string, from: number, to: number): void;
  89374. /**
  89375. * Delete a specific animation range
  89376. * @param name defines the name of the range
  89377. * @param deleteFrames defines if frames must be removed as well
  89378. */
  89379. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89380. /**
  89381. * Gets a specific animation range
  89382. * @param name defines the name of the range to look for
  89383. * @returns the requested animation range or null if not found
  89384. */
  89385. getAnimationRange(name: string): Nullable<AnimationRange>;
  89386. /**
  89387. * Gets the list of all animation ranges defined on this skeleton
  89388. * @returns an array
  89389. */
  89390. getAnimationRanges(): Nullable<AnimationRange>[];
  89391. /**
  89392. * Copy animation range from a source skeleton.
  89393. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89394. * @param source defines the source skeleton
  89395. * @param name defines the name of the range to copy
  89396. * @param rescaleAsRequired defines if rescaling must be applied if required
  89397. * @returns true if operation was successful
  89398. */
  89399. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89400. /**
  89401. * Forces the skeleton to go to rest pose
  89402. */
  89403. returnToRest(): void;
  89404. private _getHighestAnimationFrame;
  89405. /**
  89406. * Begin a specific animation range
  89407. * @param name defines the name of the range to start
  89408. * @param loop defines if looping must be turned on (false by default)
  89409. * @param speedRatio defines the speed ratio to apply (1 by default)
  89410. * @param onAnimationEnd defines a callback which will be called when animation will end
  89411. * @returns a new animatable
  89412. */
  89413. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89414. /**
  89415. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89416. * @param skeleton defines the Skeleton containing the animation range to convert
  89417. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89418. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89419. * @returns the original skeleton
  89420. */
  89421. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89422. /** @hidden */
  89423. _markAsDirty(): void;
  89424. /** @hidden */
  89425. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89426. /** @hidden */
  89427. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89428. private _computeTransformMatrices;
  89429. /**
  89430. * Build all resources required to render a skeleton
  89431. */
  89432. prepare(): void;
  89433. /**
  89434. * Gets the list of animatables currently running for this skeleton
  89435. * @returns an array of animatables
  89436. */
  89437. getAnimatables(): IAnimatable[];
  89438. /**
  89439. * Clone the current skeleton
  89440. * @param name defines the name of the new skeleton
  89441. * @param id defines the id of the new skeleton
  89442. * @returns the new skeleton
  89443. */
  89444. clone(name: string, id?: string): Skeleton;
  89445. /**
  89446. * Enable animation blending for this skeleton
  89447. * @param blendingSpeed defines the blending speed to apply
  89448. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89449. */
  89450. enableBlending(blendingSpeed?: number): void;
  89451. /**
  89452. * Releases all resources associated with the current skeleton
  89453. */
  89454. dispose(): void;
  89455. /**
  89456. * Serialize the skeleton in a JSON object
  89457. * @returns a JSON object
  89458. */
  89459. serialize(): any;
  89460. /**
  89461. * Creates a new skeleton from serialized data
  89462. * @param parsedSkeleton defines the serialized data
  89463. * @param scene defines the hosting scene
  89464. * @returns a new skeleton
  89465. */
  89466. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89467. /**
  89468. * Compute all node absolute transforms
  89469. * @param forceUpdate defines if computation must be done even if cache is up to date
  89470. */
  89471. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89472. /**
  89473. * Gets the root pose matrix
  89474. * @returns a matrix
  89475. */
  89476. getPoseMatrix(): Nullable<Matrix>;
  89477. /**
  89478. * Sorts bones per internal index
  89479. */
  89480. sortBones(): void;
  89481. private _sortBones;
  89482. }
  89483. }
  89484. declare module BABYLON {
  89485. /**
  89486. * Creates an instance based on a source mesh.
  89487. */
  89488. export class InstancedMesh extends AbstractMesh {
  89489. private _sourceMesh;
  89490. private _currentLOD;
  89491. /** @hidden */
  89492. _indexInSourceMeshInstanceArray: number;
  89493. constructor(name: string, source: Mesh);
  89494. /**
  89495. * Returns the string "InstancedMesh".
  89496. */
  89497. getClassName(): string;
  89498. /** Gets the list of lights affecting that mesh */
  89499. get lightSources(): Light[];
  89500. _resyncLightSources(): void;
  89501. _resyncLightSource(light: Light): void;
  89502. _removeLightSource(light: Light, dispose: boolean): void;
  89503. /**
  89504. * If the source mesh receives shadows
  89505. */
  89506. get receiveShadows(): boolean;
  89507. /**
  89508. * The material of the source mesh
  89509. */
  89510. get material(): Nullable<Material>;
  89511. /**
  89512. * Visibility of the source mesh
  89513. */
  89514. get visibility(): number;
  89515. /**
  89516. * Skeleton of the source mesh
  89517. */
  89518. get skeleton(): Nullable<Skeleton>;
  89519. /**
  89520. * Rendering ground id of the source mesh
  89521. */
  89522. get renderingGroupId(): number;
  89523. set renderingGroupId(value: number);
  89524. /**
  89525. * Returns the total number of vertices (integer).
  89526. */
  89527. getTotalVertices(): number;
  89528. /**
  89529. * Returns a positive integer : the total number of indices in this mesh geometry.
  89530. * @returns the numner of indices or zero if the mesh has no geometry.
  89531. */
  89532. getTotalIndices(): number;
  89533. /**
  89534. * The source mesh of the instance
  89535. */
  89536. get sourceMesh(): Mesh;
  89537. /**
  89538. * Is this node ready to be used/rendered
  89539. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89540. * @return {boolean} is it ready
  89541. */
  89542. isReady(completeCheck?: boolean): boolean;
  89543. /**
  89544. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89545. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89546. * @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.
  89547. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89548. */
  89549. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89550. /**
  89551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89553. * The `data` are either a numeric array either a Float32Array.
  89554. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89555. * 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).
  89556. * Note that a new underlying VertexBuffer object is created each call.
  89557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89558. *
  89559. * Possible `kind` values :
  89560. * - VertexBuffer.PositionKind
  89561. * - VertexBuffer.UVKind
  89562. * - VertexBuffer.UV2Kind
  89563. * - VertexBuffer.UV3Kind
  89564. * - VertexBuffer.UV4Kind
  89565. * - VertexBuffer.UV5Kind
  89566. * - VertexBuffer.UV6Kind
  89567. * - VertexBuffer.ColorKind
  89568. * - VertexBuffer.MatricesIndicesKind
  89569. * - VertexBuffer.MatricesIndicesExtraKind
  89570. * - VertexBuffer.MatricesWeightsKind
  89571. * - VertexBuffer.MatricesWeightsExtraKind
  89572. *
  89573. * Returns the Mesh.
  89574. */
  89575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89576. /**
  89577. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89578. * If the mesh has no geometry, it is simply returned as it is.
  89579. * The `data` are either a numeric array either a Float32Array.
  89580. * No new underlying VertexBuffer object is created.
  89581. * 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.
  89582. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89583. *
  89584. * Possible `kind` values :
  89585. * - VertexBuffer.PositionKind
  89586. * - VertexBuffer.UVKind
  89587. * - VertexBuffer.UV2Kind
  89588. * - VertexBuffer.UV3Kind
  89589. * - VertexBuffer.UV4Kind
  89590. * - VertexBuffer.UV5Kind
  89591. * - VertexBuffer.UV6Kind
  89592. * - VertexBuffer.ColorKind
  89593. * - VertexBuffer.MatricesIndicesKind
  89594. * - VertexBuffer.MatricesIndicesExtraKind
  89595. * - VertexBuffer.MatricesWeightsKind
  89596. * - VertexBuffer.MatricesWeightsExtraKind
  89597. *
  89598. * Returns the Mesh.
  89599. */
  89600. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89601. /**
  89602. * Sets the mesh indices.
  89603. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89604. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89605. * This method creates a new index buffer each call.
  89606. * Returns the Mesh.
  89607. */
  89608. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89609. /**
  89610. * Boolean : True if the mesh owns the requested kind of data.
  89611. */
  89612. isVerticesDataPresent(kind: string): boolean;
  89613. /**
  89614. * Returns an array of indices (IndicesArray).
  89615. */
  89616. getIndices(): Nullable<IndicesArray>;
  89617. get _positions(): Nullable<Vector3[]>;
  89618. /**
  89619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89620. * This means the mesh underlying bounding box and sphere are recomputed.
  89621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89622. * @returns the current mesh
  89623. */
  89624. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89625. /** @hidden */
  89626. _preActivate(): InstancedMesh;
  89627. /** @hidden */
  89628. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89629. /** @hidden */
  89630. _postActivate(): void;
  89631. getWorldMatrix(): Matrix;
  89632. get isAnInstance(): boolean;
  89633. /**
  89634. * Returns the current associated LOD AbstractMesh.
  89635. */
  89636. getLOD(camera: Camera): AbstractMesh;
  89637. /** @hidden */
  89638. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89639. /** @hidden */
  89640. _syncSubMeshes(): InstancedMesh;
  89641. /** @hidden */
  89642. _generatePointsArray(): boolean;
  89643. /**
  89644. * Creates a new InstancedMesh from the current mesh.
  89645. * - name (string) : the cloned mesh name
  89646. * - newParent (optional Node) : the optional Node to parent the clone to.
  89647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89648. *
  89649. * Returns the clone.
  89650. */
  89651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89652. /**
  89653. * Disposes the InstancedMesh.
  89654. * Returns nothing.
  89655. */
  89656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89657. }
  89658. interface Mesh {
  89659. /**
  89660. * Register a custom buffer that will be instanced
  89661. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89662. * @param kind defines the buffer kind
  89663. * @param stride defines the stride in floats
  89664. */
  89665. registerInstancedBuffer(kind: string, stride: number): void;
  89666. /** @hidden */
  89667. _userInstancedBuffersStorage: {
  89668. data: {
  89669. [key: string]: Float32Array;
  89670. };
  89671. sizes: {
  89672. [key: string]: number;
  89673. };
  89674. vertexBuffers: {
  89675. [key: string]: Nullable<VertexBuffer>;
  89676. };
  89677. strides: {
  89678. [key: string]: number;
  89679. };
  89680. };
  89681. }
  89682. interface AbstractMesh {
  89683. /**
  89684. * Object used to store instanced buffers defined by user
  89685. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89686. */
  89687. instancedBuffers: {
  89688. [key: string]: any;
  89689. };
  89690. }
  89691. }
  89692. declare module BABYLON {
  89693. /**
  89694. * Defines the options associated with the creation of a shader material.
  89695. */
  89696. export interface IShaderMaterialOptions {
  89697. /**
  89698. * Does the material work in alpha blend mode
  89699. */
  89700. needAlphaBlending: boolean;
  89701. /**
  89702. * Does the material work in alpha test mode
  89703. */
  89704. needAlphaTesting: boolean;
  89705. /**
  89706. * The list of attribute names used in the shader
  89707. */
  89708. attributes: string[];
  89709. /**
  89710. * The list of unifrom names used in the shader
  89711. */
  89712. uniforms: string[];
  89713. /**
  89714. * The list of UBO names used in the shader
  89715. */
  89716. uniformBuffers: string[];
  89717. /**
  89718. * The list of sampler names used in the shader
  89719. */
  89720. samplers: string[];
  89721. /**
  89722. * The list of defines used in the shader
  89723. */
  89724. defines: string[];
  89725. }
  89726. /**
  89727. * 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.
  89728. *
  89729. * This returned material effects how the mesh will look based on the code in the shaders.
  89730. *
  89731. * @see http://doc.babylonjs.com/how_to/shader_material
  89732. */
  89733. export class ShaderMaterial extends Material {
  89734. private _shaderPath;
  89735. private _options;
  89736. private _textures;
  89737. private _textureArrays;
  89738. private _floats;
  89739. private _ints;
  89740. private _floatsArrays;
  89741. private _colors3;
  89742. private _colors3Arrays;
  89743. private _colors4;
  89744. private _colors4Arrays;
  89745. private _vectors2;
  89746. private _vectors3;
  89747. private _vectors4;
  89748. private _matrices;
  89749. private _matrixArrays;
  89750. private _matrices3x3;
  89751. private _matrices2x2;
  89752. private _vectors2Arrays;
  89753. private _vectors3Arrays;
  89754. private _vectors4Arrays;
  89755. private _cachedWorldViewMatrix;
  89756. private _cachedWorldViewProjectionMatrix;
  89757. private _renderId;
  89758. private _multiview;
  89759. /**
  89760. * Instantiate a new shader material.
  89761. * 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.
  89762. * This returned material effects how the mesh will look based on the code in the shaders.
  89763. * @see http://doc.babylonjs.com/how_to/shader_material
  89764. * @param name Define the name of the material in the scene
  89765. * @param scene Define the scene the material belongs to
  89766. * @param shaderPath Defines the route to the shader code in one of three ways:
  89767. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89768. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89769. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89770. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89771. * @param options Define the options used to create the shader
  89772. */
  89773. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89774. /**
  89775. * Gets the shader path used to define the shader code
  89776. * It can be modified to trigger a new compilation
  89777. */
  89778. get shaderPath(): any;
  89779. /**
  89780. * Sets the shader path used to define the shader code
  89781. * It can be modified to trigger a new compilation
  89782. */
  89783. set shaderPath(shaderPath: any);
  89784. /**
  89785. * Gets the options used to compile the shader.
  89786. * They can be modified to trigger a new compilation
  89787. */
  89788. get options(): IShaderMaterialOptions;
  89789. /**
  89790. * Gets the current class name of the material e.g. "ShaderMaterial"
  89791. * Mainly use in serialization.
  89792. * @returns the class name
  89793. */
  89794. getClassName(): string;
  89795. /**
  89796. * Specifies if the material will require alpha blending
  89797. * @returns a boolean specifying if alpha blending is needed
  89798. */
  89799. needAlphaBlending(): boolean;
  89800. /**
  89801. * Specifies if this material should be rendered in alpha test mode
  89802. * @returns a boolean specifying if an alpha test is needed.
  89803. */
  89804. needAlphaTesting(): boolean;
  89805. private _checkUniform;
  89806. /**
  89807. * Set a texture in the shader.
  89808. * @param name Define the name of the uniform samplers as defined in the shader
  89809. * @param texture Define the texture to bind to this sampler
  89810. * @return the material itself allowing "fluent" like uniform updates
  89811. */
  89812. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89813. /**
  89814. * Set a texture array in the shader.
  89815. * @param name Define the name of the uniform sampler array as defined in the shader
  89816. * @param textures Define the list of textures to bind to this sampler
  89817. * @return the material itself allowing "fluent" like uniform updates
  89818. */
  89819. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89820. /**
  89821. * Set a float in the shader.
  89822. * @param name Define the name of the uniform as defined in the shader
  89823. * @param value Define the value to give to the uniform
  89824. * @return the material itself allowing "fluent" like uniform updates
  89825. */
  89826. setFloat(name: string, value: number): ShaderMaterial;
  89827. /**
  89828. * Set a int in the shader.
  89829. * @param name Define the name of the uniform as defined in the shader
  89830. * @param value Define the value to give to the uniform
  89831. * @return the material itself allowing "fluent" like uniform updates
  89832. */
  89833. setInt(name: string, value: number): ShaderMaterial;
  89834. /**
  89835. * Set an array of floats in the shader.
  89836. * @param name Define the name of the uniform as defined in the shader
  89837. * @param value Define the value to give to the uniform
  89838. * @return the material itself allowing "fluent" like uniform updates
  89839. */
  89840. setFloats(name: string, value: number[]): ShaderMaterial;
  89841. /**
  89842. * Set a vec3 in the shader from a Color3.
  89843. * @param name Define the name of the uniform as defined in the shader
  89844. * @param value Define the value to give to the uniform
  89845. * @return the material itself allowing "fluent" like uniform updates
  89846. */
  89847. setColor3(name: string, value: Color3): ShaderMaterial;
  89848. /**
  89849. * Set a vec3 array in the shader from a Color3 array.
  89850. * @param name Define the name of the uniform as defined in the shader
  89851. * @param value Define the value to give to the uniform
  89852. * @return the material itself allowing "fluent" like uniform updates
  89853. */
  89854. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89855. /**
  89856. * Set a vec4 in the shader from a Color4.
  89857. * @param name Define the name of the uniform as defined in the shader
  89858. * @param value Define the value to give to the uniform
  89859. * @return the material itself allowing "fluent" like uniform updates
  89860. */
  89861. setColor4(name: string, value: Color4): ShaderMaterial;
  89862. /**
  89863. * Set a vec4 array in the shader from a Color4 array.
  89864. * @param name Define the name of the uniform as defined in the shader
  89865. * @param value Define the value to give to the uniform
  89866. * @return the material itself allowing "fluent" like uniform updates
  89867. */
  89868. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89869. /**
  89870. * Set a vec2 in the shader from a Vector2.
  89871. * @param name Define the name of the uniform as defined in the shader
  89872. * @param value Define the value to give to the uniform
  89873. * @return the material itself allowing "fluent" like uniform updates
  89874. */
  89875. setVector2(name: string, value: Vector2): ShaderMaterial;
  89876. /**
  89877. * Set a vec3 in the shader from a Vector3.
  89878. * @param name Define the name of the uniform as defined in the shader
  89879. * @param value Define the value to give to the uniform
  89880. * @return the material itself allowing "fluent" like uniform updates
  89881. */
  89882. setVector3(name: string, value: Vector3): ShaderMaterial;
  89883. /**
  89884. * Set a vec4 in the shader from a Vector4.
  89885. * @param name Define the name of the uniform as defined in the shader
  89886. * @param value Define the value to give to the uniform
  89887. * @return the material itself allowing "fluent" like uniform updates
  89888. */
  89889. setVector4(name: string, value: Vector4): ShaderMaterial;
  89890. /**
  89891. * Set a mat4 in the shader from a Matrix.
  89892. * @param name Define the name of the uniform as defined in the shader
  89893. * @param value Define the value to give to the uniform
  89894. * @return the material itself allowing "fluent" like uniform updates
  89895. */
  89896. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89897. /**
  89898. * Set a float32Array in the shader from a matrix array.
  89899. * @param name Define the name of the uniform as defined in the shader
  89900. * @param value Define the value to give to the uniform
  89901. * @return the material itself allowing "fluent" like uniform updates
  89902. */
  89903. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89904. /**
  89905. * Set a mat3 in the shader from a Float32Array.
  89906. * @param name Define the name of the uniform as defined in the shader
  89907. * @param value Define the value to give to the uniform
  89908. * @return the material itself allowing "fluent" like uniform updates
  89909. */
  89910. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89911. /**
  89912. * Set a mat2 in the shader from a Float32Array.
  89913. * @param name Define the name of the uniform as defined in the shader
  89914. * @param value Define the value to give to the uniform
  89915. * @return the material itself allowing "fluent" like uniform updates
  89916. */
  89917. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89918. /**
  89919. * Set a vec2 array in the shader from a number array.
  89920. * @param name Define the name of the uniform as defined in the shader
  89921. * @param value Define the value to give to the uniform
  89922. * @return the material itself allowing "fluent" like uniform updates
  89923. */
  89924. setArray2(name: string, value: number[]): ShaderMaterial;
  89925. /**
  89926. * Set a vec3 array in the shader from a number array.
  89927. * @param name Define the name of the uniform as defined in the shader
  89928. * @param value Define the value to give to the uniform
  89929. * @return the material itself allowing "fluent" like uniform updates
  89930. */
  89931. setArray3(name: string, value: number[]): ShaderMaterial;
  89932. /**
  89933. * Set a vec4 array in the shader from a number array.
  89934. * @param name Define the name of the uniform as defined in the shader
  89935. * @param value Define the value to give to the uniform
  89936. * @return the material itself allowing "fluent" like uniform updates
  89937. */
  89938. setArray4(name: string, value: number[]): ShaderMaterial;
  89939. private _checkCache;
  89940. /**
  89941. * Specifies that the submesh is ready to be used
  89942. * @param mesh defines the mesh to check
  89943. * @param subMesh defines which submesh to check
  89944. * @param useInstances specifies that instances should be used
  89945. * @returns a boolean indicating that the submesh is ready or not
  89946. */
  89947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89948. /**
  89949. * Checks if the material is ready to render the requested mesh
  89950. * @param mesh Define the mesh to render
  89951. * @param useInstances Define whether or not the material is used with instances
  89952. * @returns true if ready, otherwise false
  89953. */
  89954. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89955. /**
  89956. * Binds the world matrix to the material
  89957. * @param world defines the world transformation matrix
  89958. */
  89959. bindOnlyWorldMatrix(world: Matrix): void;
  89960. /**
  89961. * Binds the material to the mesh
  89962. * @param world defines the world transformation matrix
  89963. * @param mesh defines the mesh to bind the material to
  89964. */
  89965. bind(world: Matrix, mesh?: Mesh): void;
  89966. /**
  89967. * Gets the active textures from the material
  89968. * @returns an array of textures
  89969. */
  89970. getActiveTextures(): BaseTexture[];
  89971. /**
  89972. * Specifies if the material uses a texture
  89973. * @param texture defines the texture to check against the material
  89974. * @returns a boolean specifying if the material uses the texture
  89975. */
  89976. hasTexture(texture: BaseTexture): boolean;
  89977. /**
  89978. * Makes a duplicate of the material, and gives it a new name
  89979. * @param name defines the new name for the duplicated material
  89980. * @returns the cloned material
  89981. */
  89982. clone(name: string): ShaderMaterial;
  89983. /**
  89984. * Disposes the material
  89985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89987. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89988. */
  89989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89990. /**
  89991. * Serializes this material in a JSON representation
  89992. * @returns the serialized material object
  89993. */
  89994. serialize(): any;
  89995. /**
  89996. * Creates a shader material from parsed shader material data
  89997. * @param source defines the JSON represnetation of the material
  89998. * @param scene defines the hosting scene
  89999. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90000. * @returns a new material
  90001. */
  90002. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90003. }
  90004. }
  90005. declare module BABYLON {
  90006. /** @hidden */
  90007. export var colorPixelShader: {
  90008. name: string;
  90009. shader: string;
  90010. };
  90011. }
  90012. declare module BABYLON {
  90013. /** @hidden */
  90014. export var colorVertexShader: {
  90015. name: string;
  90016. shader: string;
  90017. };
  90018. }
  90019. declare module BABYLON {
  90020. /**
  90021. * Line mesh
  90022. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90023. */
  90024. export class LinesMesh extends Mesh {
  90025. /**
  90026. * If vertex color should be applied to the mesh
  90027. */
  90028. readonly useVertexColor?: boolean | undefined;
  90029. /**
  90030. * If vertex alpha should be applied to the mesh
  90031. */
  90032. readonly useVertexAlpha?: boolean | undefined;
  90033. /**
  90034. * Color of the line (Default: White)
  90035. */
  90036. color: Color3;
  90037. /**
  90038. * Alpha of the line (Default: 1)
  90039. */
  90040. alpha: number;
  90041. /**
  90042. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90043. * This margin is expressed in world space coordinates, so its value may vary.
  90044. * Default value is 0.1
  90045. */
  90046. intersectionThreshold: number;
  90047. private _colorShader;
  90048. private color4;
  90049. /**
  90050. * Creates a new LinesMesh
  90051. * @param name defines the name
  90052. * @param scene defines the hosting scene
  90053. * @param parent defines the parent mesh if any
  90054. * @param source defines the optional source LinesMesh used to clone data from
  90055. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90056. * When false, achieved by calling a clone(), also passing False.
  90057. * This will make creation of children, recursive.
  90058. * @param useVertexColor defines if this LinesMesh supports vertex color
  90059. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90060. */
  90061. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90062. /**
  90063. * If vertex color should be applied to the mesh
  90064. */
  90065. useVertexColor?: boolean | undefined,
  90066. /**
  90067. * If vertex alpha should be applied to the mesh
  90068. */
  90069. useVertexAlpha?: boolean | undefined);
  90070. private _addClipPlaneDefine;
  90071. private _removeClipPlaneDefine;
  90072. isReady(): boolean;
  90073. /**
  90074. * Returns the string "LineMesh"
  90075. */
  90076. getClassName(): string;
  90077. /**
  90078. * @hidden
  90079. */
  90080. get material(): Material;
  90081. /**
  90082. * @hidden
  90083. */
  90084. set material(value: Material);
  90085. /**
  90086. * @hidden
  90087. */
  90088. get checkCollisions(): boolean;
  90089. /** @hidden */
  90090. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90091. /** @hidden */
  90092. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90093. /**
  90094. * Disposes of the line mesh
  90095. * @param doNotRecurse If children should be disposed
  90096. */
  90097. dispose(doNotRecurse?: boolean): void;
  90098. /**
  90099. * Returns a new LineMesh object cloned from the current one.
  90100. */
  90101. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90102. /**
  90103. * Creates a new InstancedLinesMesh object from the mesh model.
  90104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90105. * @param name defines the name of the new instance
  90106. * @returns a new InstancedLinesMesh
  90107. */
  90108. createInstance(name: string): InstancedLinesMesh;
  90109. }
  90110. /**
  90111. * Creates an instance based on a source LinesMesh
  90112. */
  90113. export class InstancedLinesMesh extends InstancedMesh {
  90114. /**
  90115. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90116. * This margin is expressed in world space coordinates, so its value may vary.
  90117. * Initilized with the intersectionThreshold value of the source LinesMesh
  90118. */
  90119. intersectionThreshold: number;
  90120. constructor(name: string, source: LinesMesh);
  90121. /**
  90122. * Returns the string "InstancedLinesMesh".
  90123. */
  90124. getClassName(): string;
  90125. }
  90126. }
  90127. declare module BABYLON {
  90128. /** @hidden */
  90129. export var linePixelShader: {
  90130. name: string;
  90131. shader: string;
  90132. };
  90133. }
  90134. declare module BABYLON {
  90135. /** @hidden */
  90136. export var lineVertexShader: {
  90137. name: string;
  90138. shader: string;
  90139. };
  90140. }
  90141. declare module BABYLON {
  90142. interface AbstractMesh {
  90143. /**
  90144. * Gets the edgesRenderer associated with the mesh
  90145. */
  90146. edgesRenderer: Nullable<EdgesRenderer>;
  90147. }
  90148. interface LinesMesh {
  90149. /**
  90150. * Enables the edge rendering mode on the mesh.
  90151. * This mode makes the mesh edges visible
  90152. * @param epsilon defines the maximal distance between two angles to detect a face
  90153. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90154. * @returns the currentAbstractMesh
  90155. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90156. */
  90157. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90158. }
  90159. interface InstancedLinesMesh {
  90160. /**
  90161. * Enables the edge rendering mode on the mesh.
  90162. * This mode makes the mesh edges visible
  90163. * @param epsilon defines the maximal distance between two angles to detect a face
  90164. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90165. * @returns the current InstancedLinesMesh
  90166. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90167. */
  90168. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90169. }
  90170. /**
  90171. * Defines the minimum contract an Edges renderer should follow.
  90172. */
  90173. export interface IEdgesRenderer extends IDisposable {
  90174. /**
  90175. * Gets or sets a boolean indicating if the edgesRenderer is active
  90176. */
  90177. isEnabled: boolean;
  90178. /**
  90179. * Renders the edges of the attached mesh,
  90180. */
  90181. render(): void;
  90182. /**
  90183. * Checks wether or not the edges renderer is ready to render.
  90184. * @return true if ready, otherwise false.
  90185. */
  90186. isReady(): boolean;
  90187. }
  90188. /**
  90189. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90190. */
  90191. export class EdgesRenderer implements IEdgesRenderer {
  90192. /**
  90193. * Define the size of the edges with an orthographic camera
  90194. */
  90195. edgesWidthScalerForOrthographic: number;
  90196. /**
  90197. * Define the size of the edges with a perspective camera
  90198. */
  90199. edgesWidthScalerForPerspective: number;
  90200. protected _source: AbstractMesh;
  90201. protected _linesPositions: number[];
  90202. protected _linesNormals: number[];
  90203. protected _linesIndices: number[];
  90204. protected _epsilon: number;
  90205. protected _indicesCount: number;
  90206. protected _lineShader: ShaderMaterial;
  90207. protected _ib: DataBuffer;
  90208. protected _buffers: {
  90209. [key: string]: Nullable<VertexBuffer>;
  90210. };
  90211. protected _checkVerticesInsteadOfIndices: boolean;
  90212. private _meshRebuildObserver;
  90213. private _meshDisposeObserver;
  90214. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90215. isEnabled: boolean;
  90216. /**
  90217. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90218. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90219. * @param source Mesh used to create edges
  90220. * @param epsilon sum of angles in adjacency to check for edge
  90221. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90222. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90223. */
  90224. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90225. protected _prepareRessources(): void;
  90226. /** @hidden */
  90227. _rebuild(): void;
  90228. /**
  90229. * Releases the required resources for the edges renderer
  90230. */
  90231. dispose(): void;
  90232. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90233. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90234. /**
  90235. * Checks if the pair of p0 and p1 is en edge
  90236. * @param faceIndex
  90237. * @param edge
  90238. * @param faceNormals
  90239. * @param p0
  90240. * @param p1
  90241. * @private
  90242. */
  90243. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90244. /**
  90245. * push line into the position, normal and index buffer
  90246. * @protected
  90247. */
  90248. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90249. /**
  90250. * Generates lines edges from adjacencjes
  90251. * @private
  90252. */
  90253. _generateEdgesLines(): void;
  90254. /**
  90255. * Checks wether or not the edges renderer is ready to render.
  90256. * @return true if ready, otherwise false.
  90257. */
  90258. isReady(): boolean;
  90259. /**
  90260. * Renders the edges of the attached mesh,
  90261. */
  90262. render(): void;
  90263. }
  90264. /**
  90265. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90266. */
  90267. export class LineEdgesRenderer extends EdgesRenderer {
  90268. /**
  90269. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90270. * @param source LineMesh used to generate edges
  90271. * @param epsilon not important (specified angle for edge detection)
  90272. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90273. */
  90274. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90275. /**
  90276. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90277. */
  90278. _generateEdgesLines(): void;
  90279. }
  90280. }
  90281. declare module BABYLON {
  90282. /**
  90283. * This represents the object necessary to create a rendering group.
  90284. * This is exclusively used and created by the rendering manager.
  90285. * To modify the behavior, you use the available helpers in your scene or meshes.
  90286. * @hidden
  90287. */
  90288. export class RenderingGroup {
  90289. index: number;
  90290. private static _zeroVector;
  90291. private _scene;
  90292. private _opaqueSubMeshes;
  90293. private _transparentSubMeshes;
  90294. private _alphaTestSubMeshes;
  90295. private _depthOnlySubMeshes;
  90296. private _particleSystems;
  90297. private _spriteManagers;
  90298. private _opaqueSortCompareFn;
  90299. private _alphaTestSortCompareFn;
  90300. private _transparentSortCompareFn;
  90301. private _renderOpaque;
  90302. private _renderAlphaTest;
  90303. private _renderTransparent;
  90304. /** @hidden */
  90305. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90306. onBeforeTransparentRendering: () => void;
  90307. /**
  90308. * Set the opaque sort comparison function.
  90309. * If null the sub meshes will be render in the order they were created
  90310. */
  90311. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90312. /**
  90313. * Set the alpha test sort comparison function.
  90314. * If null the sub meshes will be render in the order they were created
  90315. */
  90316. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90317. /**
  90318. * Set the transparent sort comparison function.
  90319. * If null the sub meshes will be render in the order they were created
  90320. */
  90321. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90322. /**
  90323. * Creates a new rendering group.
  90324. * @param index The rendering group index
  90325. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90326. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90327. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90328. */
  90329. 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>);
  90330. /**
  90331. * Render all the sub meshes contained in the group.
  90332. * @param customRenderFunction Used to override the default render behaviour of the group.
  90333. * @returns true if rendered some submeshes.
  90334. */
  90335. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90336. /**
  90337. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90338. * @param subMeshes The submeshes to render
  90339. */
  90340. private renderOpaqueSorted;
  90341. /**
  90342. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90343. * @param subMeshes The submeshes to render
  90344. */
  90345. private renderAlphaTestSorted;
  90346. /**
  90347. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90348. * @param subMeshes The submeshes to render
  90349. */
  90350. private renderTransparentSorted;
  90351. /**
  90352. * Renders the submeshes in a specified order.
  90353. * @param subMeshes The submeshes to sort before render
  90354. * @param sortCompareFn The comparison function use to sort
  90355. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90356. * @param transparent Specifies to activate blending if true
  90357. */
  90358. private static renderSorted;
  90359. /**
  90360. * Renders the submeshes in the order they were dispatched (no sort applied).
  90361. * @param subMeshes The submeshes to render
  90362. */
  90363. private static renderUnsorted;
  90364. /**
  90365. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90366. * are rendered back to front if in the same alpha index.
  90367. *
  90368. * @param a The first submesh
  90369. * @param b The second submesh
  90370. * @returns The result of the comparison
  90371. */
  90372. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90373. /**
  90374. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90375. * are rendered back to front.
  90376. *
  90377. * @param a The first submesh
  90378. * @param b The second submesh
  90379. * @returns The result of the comparison
  90380. */
  90381. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90382. /**
  90383. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90384. * are rendered front to back (prevent overdraw).
  90385. *
  90386. * @param a The first submesh
  90387. * @param b The second submesh
  90388. * @returns The result of the comparison
  90389. */
  90390. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90391. /**
  90392. * Resets the different lists of submeshes to prepare a new frame.
  90393. */
  90394. prepare(): void;
  90395. dispose(): void;
  90396. /**
  90397. * Inserts the submesh in its correct queue depending on its material.
  90398. * @param subMesh The submesh to dispatch
  90399. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90400. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90401. */
  90402. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90403. dispatchSprites(spriteManager: ISpriteManager): void;
  90404. dispatchParticles(particleSystem: IParticleSystem): void;
  90405. private _renderParticles;
  90406. private _renderSprites;
  90407. }
  90408. }
  90409. declare module BABYLON {
  90410. /**
  90411. * Interface describing the different options available in the rendering manager
  90412. * regarding Auto Clear between groups.
  90413. */
  90414. export interface IRenderingManagerAutoClearSetup {
  90415. /**
  90416. * Defines whether or not autoclear is enable.
  90417. */
  90418. autoClear: boolean;
  90419. /**
  90420. * Defines whether or not to autoclear the depth buffer.
  90421. */
  90422. depth: boolean;
  90423. /**
  90424. * Defines whether or not to autoclear the stencil buffer.
  90425. */
  90426. stencil: boolean;
  90427. }
  90428. /**
  90429. * This class is used by the onRenderingGroupObservable
  90430. */
  90431. export class RenderingGroupInfo {
  90432. /**
  90433. * The Scene that being rendered
  90434. */
  90435. scene: Scene;
  90436. /**
  90437. * The camera currently used for the rendering pass
  90438. */
  90439. camera: Nullable<Camera>;
  90440. /**
  90441. * The ID of the renderingGroup being processed
  90442. */
  90443. renderingGroupId: number;
  90444. }
  90445. /**
  90446. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90447. * It is enable to manage the different groups as well as the different necessary sort functions.
  90448. * This should not be used directly aside of the few static configurations
  90449. */
  90450. export class RenderingManager {
  90451. /**
  90452. * The max id used for rendering groups (not included)
  90453. */
  90454. static MAX_RENDERINGGROUPS: number;
  90455. /**
  90456. * The min id used for rendering groups (included)
  90457. */
  90458. static MIN_RENDERINGGROUPS: number;
  90459. /**
  90460. * Used to globally prevent autoclearing scenes.
  90461. */
  90462. static AUTOCLEAR: boolean;
  90463. /**
  90464. * @hidden
  90465. */
  90466. _useSceneAutoClearSetup: boolean;
  90467. private _scene;
  90468. private _renderingGroups;
  90469. private _depthStencilBufferAlreadyCleaned;
  90470. private _autoClearDepthStencil;
  90471. private _customOpaqueSortCompareFn;
  90472. private _customAlphaTestSortCompareFn;
  90473. private _customTransparentSortCompareFn;
  90474. private _renderingGroupInfo;
  90475. /**
  90476. * Instantiates a new rendering group for a particular scene
  90477. * @param scene Defines the scene the groups belongs to
  90478. */
  90479. constructor(scene: Scene);
  90480. private _clearDepthStencilBuffer;
  90481. /**
  90482. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90483. * @hidden
  90484. */
  90485. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90486. /**
  90487. * Resets the different information of the group to prepare a new frame
  90488. * @hidden
  90489. */
  90490. reset(): void;
  90491. /**
  90492. * Dispose and release the group and its associated resources.
  90493. * @hidden
  90494. */
  90495. dispose(): void;
  90496. /**
  90497. * Clear the info related to rendering groups preventing retention points during dispose.
  90498. */
  90499. freeRenderingGroups(): void;
  90500. private _prepareRenderingGroup;
  90501. /**
  90502. * Add a sprite manager to the rendering manager in order to render it this frame.
  90503. * @param spriteManager Define the sprite manager to render
  90504. */
  90505. dispatchSprites(spriteManager: ISpriteManager): void;
  90506. /**
  90507. * Add a particle system to the rendering manager in order to render it this frame.
  90508. * @param particleSystem Define the particle system to render
  90509. */
  90510. dispatchParticles(particleSystem: IParticleSystem): void;
  90511. /**
  90512. * Add a submesh to the manager in order to render it this frame
  90513. * @param subMesh The submesh to dispatch
  90514. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90515. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90516. */
  90517. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90518. /**
  90519. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90520. * This allowed control for front to back rendering or reversly depending of the special needs.
  90521. *
  90522. * @param renderingGroupId The rendering group id corresponding to its index
  90523. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90524. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90525. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90526. */
  90527. 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;
  90528. /**
  90529. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90530. *
  90531. * @param renderingGroupId The rendering group id corresponding to its index
  90532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90533. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90534. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90535. */
  90536. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90537. /**
  90538. * Gets the current auto clear configuration for one rendering group of the rendering
  90539. * manager.
  90540. * @param index the rendering group index to get the information for
  90541. * @returns The auto clear setup for the requested rendering group
  90542. */
  90543. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90544. }
  90545. }
  90546. declare module BABYLON {
  90547. /**
  90548. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90549. */
  90550. export interface ICustomShaderOptions {
  90551. /**
  90552. * Gets or sets the custom shader name to use
  90553. */
  90554. shaderName: string;
  90555. /**
  90556. * The list of attribute names used in the shader
  90557. */
  90558. attributes?: string[];
  90559. /**
  90560. * The list of unifrom names used in the shader
  90561. */
  90562. uniforms?: string[];
  90563. /**
  90564. * The list of sampler names used in the shader
  90565. */
  90566. samplers?: string[];
  90567. /**
  90568. * The list of defines used in the shader
  90569. */
  90570. defines?: string[];
  90571. }
  90572. /**
  90573. * Interface to implement to create a shadow generator compatible with BJS.
  90574. */
  90575. export interface IShadowGenerator {
  90576. /**
  90577. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90578. * @returns The render target texture if present otherwise, null
  90579. */
  90580. getShadowMap(): Nullable<RenderTargetTexture>;
  90581. /**
  90582. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90583. * @param subMesh The submesh we want to render in the shadow map
  90584. * @param useInstances Defines wether will draw in the map using instances
  90585. * @returns true if ready otherwise, false
  90586. */
  90587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90588. /**
  90589. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90590. * @param defines Defines of the material we want to update
  90591. * @param lightIndex Index of the light in the enabled light list of the material
  90592. */
  90593. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90594. /**
  90595. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90596. * defined in the generator but impacting the effect).
  90597. * It implies the unifroms available on the materials are the standard BJS ones.
  90598. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90599. * @param effect The effect we are binfing the information for
  90600. */
  90601. bindShadowLight(lightIndex: string, effect: Effect): void;
  90602. /**
  90603. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90604. * (eq to shadow prjection matrix * light transform matrix)
  90605. * @returns The transform matrix used to create the shadow map
  90606. */
  90607. getTransformMatrix(): Matrix;
  90608. /**
  90609. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90610. * Cube and 2D textures for instance.
  90611. */
  90612. recreateShadowMap(): void;
  90613. /**
  90614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90615. * @param onCompiled Callback triggered at the and of the effects compilation
  90616. * @param options Sets of optional options forcing the compilation with different modes
  90617. */
  90618. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90619. useInstances: boolean;
  90620. }>): void;
  90621. /**
  90622. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90623. * @param options Sets of optional options forcing the compilation with different modes
  90624. * @returns A promise that resolves when the compilation completes
  90625. */
  90626. forceCompilationAsync(options?: Partial<{
  90627. useInstances: boolean;
  90628. }>): Promise<void>;
  90629. /**
  90630. * Serializes the shadow generator setup to a json object.
  90631. * @returns The serialized JSON object
  90632. */
  90633. serialize(): any;
  90634. /**
  90635. * Disposes the Shadow map and related Textures and effects.
  90636. */
  90637. dispose(): void;
  90638. }
  90639. /**
  90640. * Default implementation IShadowGenerator.
  90641. * This is the main object responsible of generating shadows in the framework.
  90642. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90643. */
  90644. export class ShadowGenerator implements IShadowGenerator {
  90645. /**
  90646. * Name of the shadow generator class
  90647. */
  90648. static CLASSNAME: string;
  90649. /**
  90650. * Shadow generator mode None: no filtering applied.
  90651. */
  90652. static readonly FILTER_NONE: number;
  90653. /**
  90654. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90655. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90656. */
  90657. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90658. /**
  90659. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90660. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90661. */
  90662. static readonly FILTER_POISSONSAMPLING: number;
  90663. /**
  90664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90665. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90666. */
  90667. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90668. /**
  90669. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90670. * edge artifacts on steep falloff.
  90671. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90672. */
  90673. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90674. /**
  90675. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90676. * edge artifacts on steep falloff.
  90677. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90678. */
  90679. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90680. /**
  90681. * Shadow generator mode PCF: Percentage Closer Filtering
  90682. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90683. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90684. */
  90685. static readonly FILTER_PCF: number;
  90686. /**
  90687. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90688. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90689. * Contact Hardening
  90690. */
  90691. static readonly FILTER_PCSS: number;
  90692. /**
  90693. * Reserved for PCF and PCSS
  90694. * Highest Quality.
  90695. *
  90696. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90697. *
  90698. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90699. */
  90700. static readonly QUALITY_HIGH: number;
  90701. /**
  90702. * Reserved for PCF and PCSS
  90703. * Good tradeoff for quality/perf cross devices
  90704. *
  90705. * Execute PCF on a 3*3 kernel.
  90706. *
  90707. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90708. */
  90709. static readonly QUALITY_MEDIUM: number;
  90710. /**
  90711. * Reserved for PCF and PCSS
  90712. * The lowest quality but the fastest.
  90713. *
  90714. * Execute PCF on a 1*1 kernel.
  90715. *
  90716. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90717. */
  90718. static readonly QUALITY_LOW: number;
  90719. /** Gets or sets the custom shader name to use */
  90720. customShaderOptions: ICustomShaderOptions;
  90721. /**
  90722. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90723. */
  90724. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90725. /**
  90726. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90727. */
  90728. onAfterShadowMapRenderObservable: Observable<Effect>;
  90729. /**
  90730. * Observable triggered before a mesh is rendered in the shadow map.
  90731. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90732. */
  90733. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90734. /**
  90735. * Observable triggered after a mesh is rendered in the shadow map.
  90736. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90737. */
  90738. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90739. protected _bias: number;
  90740. /**
  90741. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90742. */
  90743. get bias(): number;
  90744. /**
  90745. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90746. */
  90747. set bias(bias: number);
  90748. protected _normalBias: number;
  90749. /**
  90750. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90751. */
  90752. get normalBias(): number;
  90753. /**
  90754. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90755. */
  90756. set normalBias(normalBias: number);
  90757. protected _blurBoxOffset: number;
  90758. /**
  90759. * Gets the blur box offset: offset applied during the blur pass.
  90760. * Only useful if useKernelBlur = false
  90761. */
  90762. get blurBoxOffset(): number;
  90763. /**
  90764. * Sets the blur box offset: offset applied during the blur pass.
  90765. * Only useful if useKernelBlur = false
  90766. */
  90767. set blurBoxOffset(value: number);
  90768. protected _blurScale: number;
  90769. /**
  90770. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90771. * 2 means half of the size.
  90772. */
  90773. get blurScale(): number;
  90774. /**
  90775. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90776. * 2 means half of the size.
  90777. */
  90778. set blurScale(value: number);
  90779. protected _blurKernel: number;
  90780. /**
  90781. * Gets the blur kernel: kernel size of the blur pass.
  90782. * Only useful if useKernelBlur = true
  90783. */
  90784. get blurKernel(): number;
  90785. /**
  90786. * Sets the blur kernel: kernel size of the blur pass.
  90787. * Only useful if useKernelBlur = true
  90788. */
  90789. set blurKernel(value: number);
  90790. protected _useKernelBlur: boolean;
  90791. /**
  90792. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90793. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90794. */
  90795. get useKernelBlur(): boolean;
  90796. /**
  90797. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90798. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90799. */
  90800. set useKernelBlur(value: boolean);
  90801. protected _depthScale: number;
  90802. /**
  90803. * Gets the depth scale used in ESM mode.
  90804. */
  90805. get depthScale(): number;
  90806. /**
  90807. * Sets the depth scale used in ESM mode.
  90808. * This can override the scale stored on the light.
  90809. */
  90810. set depthScale(value: number);
  90811. protected _validateFilter(filter: number): number;
  90812. protected _filter: number;
  90813. /**
  90814. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90815. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90816. */
  90817. get filter(): number;
  90818. /**
  90819. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90820. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90821. */
  90822. set filter(value: number);
  90823. /**
  90824. * Gets if the current filter is set to Poisson Sampling.
  90825. */
  90826. get usePoissonSampling(): boolean;
  90827. /**
  90828. * Sets the current filter to Poisson Sampling.
  90829. */
  90830. set usePoissonSampling(value: boolean);
  90831. /**
  90832. * Gets if the current filter is set to ESM.
  90833. */
  90834. get useExponentialShadowMap(): boolean;
  90835. /**
  90836. * Sets the current filter is to ESM.
  90837. */
  90838. set useExponentialShadowMap(value: boolean);
  90839. /**
  90840. * Gets if the current filter is set to filtered ESM.
  90841. */
  90842. get useBlurExponentialShadowMap(): boolean;
  90843. /**
  90844. * Gets if the current filter is set to filtered ESM.
  90845. */
  90846. set useBlurExponentialShadowMap(value: boolean);
  90847. /**
  90848. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90849. * exponential to prevent steep falloff artifacts).
  90850. */
  90851. get useCloseExponentialShadowMap(): boolean;
  90852. /**
  90853. * Sets the current filter to "close ESM" (using the inverse of the
  90854. * exponential to prevent steep falloff artifacts).
  90855. */
  90856. set useCloseExponentialShadowMap(value: boolean);
  90857. /**
  90858. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90859. * exponential to prevent steep falloff artifacts).
  90860. */
  90861. get useBlurCloseExponentialShadowMap(): boolean;
  90862. /**
  90863. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90864. * exponential to prevent steep falloff artifacts).
  90865. */
  90866. set useBlurCloseExponentialShadowMap(value: boolean);
  90867. /**
  90868. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90869. */
  90870. get usePercentageCloserFiltering(): boolean;
  90871. /**
  90872. * Sets the current filter to "PCF" (percentage closer filtering).
  90873. */
  90874. set usePercentageCloserFiltering(value: boolean);
  90875. protected _filteringQuality: number;
  90876. /**
  90877. * Gets the PCF or PCSS Quality.
  90878. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90879. */
  90880. get filteringQuality(): number;
  90881. /**
  90882. * Sets the PCF or PCSS Quality.
  90883. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90884. */
  90885. set filteringQuality(filteringQuality: number);
  90886. /**
  90887. * Gets if the current filter is set to "PCSS" (contact hardening).
  90888. */
  90889. get useContactHardeningShadow(): boolean;
  90890. /**
  90891. * Sets the current filter to "PCSS" (contact hardening).
  90892. */
  90893. set useContactHardeningShadow(value: boolean);
  90894. protected _contactHardeningLightSizeUVRatio: number;
  90895. /**
  90896. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90897. * Using a ratio helps keeping shape stability independently of the map size.
  90898. *
  90899. * It does not account for the light projection as it was having too much
  90900. * instability during the light setup or during light position changes.
  90901. *
  90902. * Only valid if useContactHardeningShadow is true.
  90903. */
  90904. get contactHardeningLightSizeUVRatio(): number;
  90905. /**
  90906. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90907. * Using a ratio helps keeping shape stability independently of the map size.
  90908. *
  90909. * It does not account for the light projection as it was having too much
  90910. * instability during the light setup or during light position changes.
  90911. *
  90912. * Only valid if useContactHardeningShadow is true.
  90913. */
  90914. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90915. protected _darkness: number;
  90916. /** Gets or sets the actual darkness of a shadow */
  90917. get darkness(): number;
  90918. set darkness(value: number);
  90919. /**
  90920. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90921. * 0 means strongest and 1 would means no shadow.
  90922. * @returns the darkness.
  90923. */
  90924. getDarkness(): number;
  90925. /**
  90926. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90927. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90928. * @returns the shadow generator allowing fluent coding.
  90929. */
  90930. setDarkness(darkness: number): ShadowGenerator;
  90931. protected _transparencyShadow: boolean;
  90932. /** Gets or sets the ability to have transparent shadow */
  90933. get transparencyShadow(): boolean;
  90934. set transparencyShadow(value: boolean);
  90935. /**
  90936. * Sets the ability to have transparent shadow (boolean).
  90937. * @param transparent True if transparent else False
  90938. * @returns the shadow generator allowing fluent coding
  90939. */
  90940. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90941. protected _shadowMap: Nullable<RenderTargetTexture>;
  90942. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90943. /**
  90944. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90945. * @returns The render target texture if present otherwise, null
  90946. */
  90947. getShadowMap(): Nullable<RenderTargetTexture>;
  90948. /**
  90949. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90950. * @returns The render target texture if the shadow map is present otherwise, null
  90951. */
  90952. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90953. /**
  90954. * Gets the class name of that object
  90955. * @returns "ShadowGenerator"
  90956. */
  90957. getClassName(): string;
  90958. /**
  90959. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90960. * @param mesh Mesh to add
  90961. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90962. * @returns the Shadow Generator itself
  90963. */
  90964. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90965. /**
  90966. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90967. * @param mesh Mesh to remove
  90968. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90969. * @returns the Shadow Generator itself
  90970. */
  90971. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90972. /**
  90973. * Controls the extent to which the shadows fade out at the edge of the frustum
  90974. */
  90975. frustumEdgeFalloff: number;
  90976. protected _light: IShadowLight;
  90977. /**
  90978. * Returns the associated light object.
  90979. * @returns the light generating the shadow
  90980. */
  90981. getLight(): IShadowLight;
  90982. /**
  90983. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90984. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90985. * It might on the other hand introduce peter panning.
  90986. */
  90987. forceBackFacesOnly: boolean;
  90988. protected _scene: Scene;
  90989. protected _lightDirection: Vector3;
  90990. protected _effect: Effect;
  90991. protected _viewMatrix: Matrix;
  90992. protected _projectionMatrix: Matrix;
  90993. protected _transformMatrix: Matrix;
  90994. protected _cachedPosition: Vector3;
  90995. protected _cachedDirection: Vector3;
  90996. protected _cachedDefines: string;
  90997. protected _currentRenderID: number;
  90998. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90999. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  91000. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  91001. protected _blurPostProcesses: PostProcess[];
  91002. protected _mapSize: number;
  91003. protected _currentFaceIndex: number;
  91004. protected _currentFaceIndexCache: number;
  91005. protected _textureType: number;
  91006. protected _defaultTextureMatrix: Matrix;
  91007. protected _storedUniqueId: Nullable<number>;
  91008. /** @hidden */
  91009. static _SceneComponentInitialization: (scene: Scene) => void;
  91010. /**
  91011. * Creates a ShadowGenerator object.
  91012. * A ShadowGenerator is the required tool to use the shadows.
  91013. * Each light casting shadows needs to use its own ShadowGenerator.
  91014. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91015. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91016. * @param light The light object generating the shadows.
  91017. * @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.
  91018. */
  91019. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91020. protected _initializeGenerator(): void;
  91021. protected _createTargetRenderTexture(): void;
  91022. protected _initializeShadowMap(): void;
  91023. protected _initializeBlurRTTAndPostProcesses(): void;
  91024. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91025. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91026. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91027. protected _applyFilterValues(): void;
  91028. /**
  91029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91030. * @param onCompiled Callback triggered at the and of the effects compilation
  91031. * @param options Sets of optional options forcing the compilation with different modes
  91032. */
  91033. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91034. useInstances: boolean;
  91035. }>): void;
  91036. /**
  91037. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91038. * @param options Sets of optional options forcing the compilation with different modes
  91039. * @returns A promise that resolves when the compilation completes
  91040. */
  91041. forceCompilationAsync(options?: Partial<{
  91042. useInstances: boolean;
  91043. }>): Promise<void>;
  91044. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91045. /**
  91046. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91047. * @param subMesh The submesh we want to render in the shadow map
  91048. * @param useInstances Defines wether will draw in the map using instances
  91049. * @returns true if ready otherwise, false
  91050. */
  91051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91052. /**
  91053. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91054. * @param defines Defines of the material we want to update
  91055. * @param lightIndex Index of the light in the enabled light list of the material
  91056. */
  91057. prepareDefines(defines: any, lightIndex: number): void;
  91058. /**
  91059. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91060. * defined in the generator but impacting the effect).
  91061. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91062. * @param effect The effect we are binfing the information for
  91063. */
  91064. bindShadowLight(lightIndex: string, effect: Effect): void;
  91065. /**
  91066. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91067. * (eq to shadow prjection matrix * light transform matrix)
  91068. * @returns The transform matrix used to create the shadow map
  91069. */
  91070. getTransformMatrix(): Matrix;
  91071. /**
  91072. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91073. * Cube and 2D textures for instance.
  91074. */
  91075. recreateShadowMap(): void;
  91076. protected _disposeBlurPostProcesses(): void;
  91077. protected _disposeRTTandPostProcesses(): void;
  91078. /**
  91079. * Disposes the ShadowGenerator.
  91080. * Returns nothing.
  91081. */
  91082. dispose(): void;
  91083. /**
  91084. * Serializes the shadow generator setup to a json object.
  91085. * @returns The serialized JSON object
  91086. */
  91087. serialize(): any;
  91088. /**
  91089. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91090. * @param parsedShadowGenerator The JSON object to parse
  91091. * @param scene The scene to create the shadow map for
  91092. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91093. * @returns The parsed shadow generator
  91094. */
  91095. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91096. }
  91097. }
  91098. declare module BABYLON {
  91099. /**
  91100. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91101. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91102. * 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.
  91103. */
  91104. export abstract class Light extends Node {
  91105. /**
  91106. * Falloff Default: light is falling off following the material specification:
  91107. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91108. */
  91109. static readonly FALLOFF_DEFAULT: number;
  91110. /**
  91111. * Falloff Physical: light is falling off following the inverse squared distance law.
  91112. */
  91113. static readonly FALLOFF_PHYSICAL: number;
  91114. /**
  91115. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91116. * to enhance interoperability with other engines.
  91117. */
  91118. static readonly FALLOFF_GLTF: number;
  91119. /**
  91120. * Falloff Standard: light is falling off like in the standard material
  91121. * to enhance interoperability with other materials.
  91122. */
  91123. static readonly FALLOFF_STANDARD: number;
  91124. /**
  91125. * If every light affecting the material is in this lightmapMode,
  91126. * material.lightmapTexture adds or multiplies
  91127. * (depends on material.useLightmapAsShadowmap)
  91128. * after every other light calculations.
  91129. */
  91130. static readonly LIGHTMAP_DEFAULT: number;
  91131. /**
  91132. * material.lightmapTexture as only diffuse lighting from this light
  91133. * adds only specular lighting from this light
  91134. * adds dynamic shadows
  91135. */
  91136. static readonly LIGHTMAP_SPECULAR: number;
  91137. /**
  91138. * material.lightmapTexture as only lighting
  91139. * no light calculation from this light
  91140. * only adds dynamic shadows from this light
  91141. */
  91142. static readonly LIGHTMAP_SHADOWSONLY: number;
  91143. /**
  91144. * Each light type uses the default quantity according to its type:
  91145. * point/spot lights use luminous intensity
  91146. * directional lights use illuminance
  91147. */
  91148. static readonly INTENSITYMODE_AUTOMATIC: number;
  91149. /**
  91150. * lumen (lm)
  91151. */
  91152. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91153. /**
  91154. * candela (lm/sr)
  91155. */
  91156. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91157. /**
  91158. * lux (lm/m^2)
  91159. */
  91160. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91161. /**
  91162. * nit (cd/m^2)
  91163. */
  91164. static readonly INTENSITYMODE_LUMINANCE: number;
  91165. /**
  91166. * Light type const id of the point light.
  91167. */
  91168. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91169. /**
  91170. * Light type const id of the directional light.
  91171. */
  91172. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91173. /**
  91174. * Light type const id of the spot light.
  91175. */
  91176. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91177. /**
  91178. * Light type const id of the hemispheric light.
  91179. */
  91180. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91181. /**
  91182. * Diffuse gives the basic color to an object.
  91183. */
  91184. diffuse: Color3;
  91185. /**
  91186. * Specular produces a highlight color on an object.
  91187. * Note: This is note affecting PBR materials.
  91188. */
  91189. specular: Color3;
  91190. /**
  91191. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91192. * falling off base on range or angle.
  91193. * This can be set to any values in Light.FALLOFF_x.
  91194. *
  91195. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91196. * other types of materials.
  91197. */
  91198. falloffType: number;
  91199. /**
  91200. * Strength of the light.
  91201. * Note: By default it is define in the framework own unit.
  91202. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91203. */
  91204. intensity: number;
  91205. private _range;
  91206. protected _inverseSquaredRange: number;
  91207. /**
  91208. * Defines how far from the source the light is impacting in scene units.
  91209. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91210. */
  91211. get range(): number;
  91212. /**
  91213. * Defines how far from the source the light is impacting in scene units.
  91214. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91215. */
  91216. set range(value: number);
  91217. /**
  91218. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91219. * of light.
  91220. */
  91221. private _photometricScale;
  91222. private _intensityMode;
  91223. /**
  91224. * Gets the photometric scale used to interpret the intensity.
  91225. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91226. */
  91227. get intensityMode(): number;
  91228. /**
  91229. * Sets the photometric scale used to interpret the intensity.
  91230. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91231. */
  91232. set intensityMode(value: number);
  91233. private _radius;
  91234. /**
  91235. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91236. */
  91237. get radius(): number;
  91238. /**
  91239. * sets the light radius used by PBR Materials to simulate soft area lights.
  91240. */
  91241. set radius(value: number);
  91242. private _renderPriority;
  91243. /**
  91244. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91245. * exceeding the number allowed of the materials.
  91246. */
  91247. renderPriority: number;
  91248. private _shadowEnabled;
  91249. /**
  91250. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91251. * the current shadow generator.
  91252. */
  91253. get shadowEnabled(): boolean;
  91254. /**
  91255. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91256. * the current shadow generator.
  91257. */
  91258. set shadowEnabled(value: boolean);
  91259. private _includedOnlyMeshes;
  91260. /**
  91261. * Gets the only meshes impacted by this light.
  91262. */
  91263. get includedOnlyMeshes(): AbstractMesh[];
  91264. /**
  91265. * Sets the only meshes impacted by this light.
  91266. */
  91267. set includedOnlyMeshes(value: AbstractMesh[]);
  91268. private _excludedMeshes;
  91269. /**
  91270. * Gets the meshes not impacted by this light.
  91271. */
  91272. get excludedMeshes(): AbstractMesh[];
  91273. /**
  91274. * Sets the meshes not impacted by this light.
  91275. */
  91276. set excludedMeshes(value: AbstractMesh[]);
  91277. private _excludeWithLayerMask;
  91278. /**
  91279. * Gets the layer id use to find what meshes are not impacted by the light.
  91280. * Inactive if 0
  91281. */
  91282. get excludeWithLayerMask(): number;
  91283. /**
  91284. * Sets the layer id use to find what meshes are not impacted by the light.
  91285. * Inactive if 0
  91286. */
  91287. set excludeWithLayerMask(value: number);
  91288. private _includeOnlyWithLayerMask;
  91289. /**
  91290. * Gets the layer id use to find what meshes are impacted by the light.
  91291. * Inactive if 0
  91292. */
  91293. get includeOnlyWithLayerMask(): number;
  91294. /**
  91295. * Sets the layer id use to find what meshes are impacted by the light.
  91296. * Inactive if 0
  91297. */
  91298. set includeOnlyWithLayerMask(value: number);
  91299. private _lightmapMode;
  91300. /**
  91301. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91302. */
  91303. get lightmapMode(): number;
  91304. /**
  91305. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91306. */
  91307. set lightmapMode(value: number);
  91308. /**
  91309. * Shadow generator associted to the light.
  91310. * @hidden Internal use only.
  91311. */
  91312. _shadowGenerator: Nullable<IShadowGenerator>;
  91313. /**
  91314. * @hidden Internal use only.
  91315. */
  91316. _excludedMeshesIds: string[];
  91317. /**
  91318. * @hidden Internal use only.
  91319. */
  91320. _includedOnlyMeshesIds: string[];
  91321. /**
  91322. * The current light unifom buffer.
  91323. * @hidden Internal use only.
  91324. */
  91325. _uniformBuffer: UniformBuffer;
  91326. /** @hidden */
  91327. _renderId: number;
  91328. /**
  91329. * Creates a Light object in the scene.
  91330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91331. * @param name The firendly name of the light
  91332. * @param scene The scene the light belongs too
  91333. */
  91334. constructor(name: string, scene: Scene);
  91335. protected abstract _buildUniformLayout(): void;
  91336. /**
  91337. * Sets the passed Effect "effect" with the Light information.
  91338. * @param effect The effect to update
  91339. * @param lightIndex The index of the light in the effect to update
  91340. * @returns The light
  91341. */
  91342. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91343. /**
  91344. * Sets the passed Effect "effect" with the Light textures.
  91345. * @param effect The effect to update
  91346. * @param lightIndex The index of the light in the effect to update
  91347. * @returns The light
  91348. */
  91349. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91350. /**
  91351. * Binds the lights information from the scene to the effect for the given mesh.
  91352. * @param lightIndex Light index
  91353. * @param scene The scene where the light belongs to
  91354. * @param effect The effect we are binding the data to
  91355. * @param useSpecular Defines if specular is supported
  91356. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91357. */
  91358. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91359. /**
  91360. * Sets the passed Effect "effect" with the Light information.
  91361. * @param effect The effect to update
  91362. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91363. * @returns The light
  91364. */
  91365. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91366. /**
  91367. * Returns the string "Light".
  91368. * @returns the class name
  91369. */
  91370. getClassName(): string;
  91371. /** @hidden */
  91372. readonly _isLight: boolean;
  91373. /**
  91374. * Converts the light information to a readable string for debug purpose.
  91375. * @param fullDetails Supports for multiple levels of logging within scene loading
  91376. * @returns the human readable light info
  91377. */
  91378. toString(fullDetails?: boolean): string;
  91379. /** @hidden */
  91380. protected _syncParentEnabledState(): void;
  91381. /**
  91382. * Set the enabled state of this node.
  91383. * @param value - the new enabled state
  91384. */
  91385. setEnabled(value: boolean): void;
  91386. /**
  91387. * Returns the Light associated shadow generator if any.
  91388. * @return the associated shadow generator.
  91389. */
  91390. getShadowGenerator(): Nullable<IShadowGenerator>;
  91391. /**
  91392. * Returns a Vector3, the absolute light position in the World.
  91393. * @returns the world space position of the light
  91394. */
  91395. getAbsolutePosition(): Vector3;
  91396. /**
  91397. * Specifies if the light will affect the passed mesh.
  91398. * @param mesh The mesh to test against the light
  91399. * @return true the mesh is affected otherwise, false.
  91400. */
  91401. canAffectMesh(mesh: AbstractMesh): boolean;
  91402. /**
  91403. * Sort function to order lights for rendering.
  91404. * @param a First Light object to compare to second.
  91405. * @param b Second Light object to compare first.
  91406. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91407. */
  91408. static CompareLightsPriority(a: Light, b: Light): number;
  91409. /**
  91410. * Releases resources associated with this node.
  91411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91413. */
  91414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91415. /**
  91416. * Returns the light type ID (integer).
  91417. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91418. */
  91419. getTypeID(): number;
  91420. /**
  91421. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91422. * @returns the scaled intensity in intensity mode unit
  91423. */
  91424. getScaledIntensity(): number;
  91425. /**
  91426. * Returns a new Light object, named "name", from the current one.
  91427. * @param name The name of the cloned light
  91428. * @returns the new created light
  91429. */
  91430. clone(name: string): Nullable<Light>;
  91431. /**
  91432. * Serializes the current light into a Serialization object.
  91433. * @returns the serialized object.
  91434. */
  91435. serialize(): any;
  91436. /**
  91437. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91438. * This new light is named "name" and added to the passed scene.
  91439. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91440. * @param name The friendly name of the light
  91441. * @param scene The scene the new light will belong to
  91442. * @returns the constructor function
  91443. */
  91444. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91445. /**
  91446. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91447. * @param parsedLight The JSON representation of the light
  91448. * @param scene The scene to create the parsed light in
  91449. * @returns the created light after parsing
  91450. */
  91451. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91452. private _hookArrayForExcluded;
  91453. private _hookArrayForIncludedOnly;
  91454. private _resyncMeshes;
  91455. /**
  91456. * Forces the meshes to update their light related information in their rendering used effects
  91457. * @hidden Internal Use Only
  91458. */
  91459. _markMeshesAsLightDirty(): void;
  91460. /**
  91461. * Recomputes the cached photometric scale if needed.
  91462. */
  91463. private _computePhotometricScale;
  91464. /**
  91465. * Returns the Photometric Scale according to the light type and intensity mode.
  91466. */
  91467. private _getPhotometricScale;
  91468. /**
  91469. * Reorder the light in the scene according to their defined priority.
  91470. * @hidden Internal Use Only
  91471. */
  91472. _reorderLightsInScene(): void;
  91473. /**
  91474. * Prepares the list of defines specific to the light type.
  91475. * @param defines the list of defines
  91476. * @param lightIndex defines the index of the light for the effect
  91477. */
  91478. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91479. }
  91480. }
  91481. declare module BABYLON {
  91482. /**
  91483. * Interface used to define Action
  91484. */
  91485. export interface IAction {
  91486. /**
  91487. * Trigger for the action
  91488. */
  91489. trigger: number;
  91490. /** Options of the trigger */
  91491. triggerOptions: any;
  91492. /**
  91493. * Gets the trigger parameters
  91494. * @returns the trigger parameters
  91495. */
  91496. getTriggerParameter(): any;
  91497. /**
  91498. * Internal only - executes current action event
  91499. * @hidden
  91500. */
  91501. _executeCurrent(evt?: ActionEvent): void;
  91502. /**
  91503. * Serialize placeholder for child classes
  91504. * @param parent of child
  91505. * @returns the serialized object
  91506. */
  91507. serialize(parent: any): any;
  91508. /**
  91509. * Internal only
  91510. * @hidden
  91511. */
  91512. _prepare(): void;
  91513. /**
  91514. * Internal only - manager for action
  91515. * @hidden
  91516. */
  91517. _actionManager: AbstractActionManager;
  91518. /**
  91519. * Adds action to chain of actions, may be a DoNothingAction
  91520. * @param action defines the next action to execute
  91521. * @returns The action passed in
  91522. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91523. */
  91524. then(action: IAction): IAction;
  91525. }
  91526. /**
  91527. * The action to be carried out following a trigger
  91528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91529. */
  91530. export class Action implements IAction {
  91531. /** the trigger, with or without parameters, for the action */
  91532. triggerOptions: any;
  91533. /**
  91534. * Trigger for the action
  91535. */
  91536. trigger: number;
  91537. /**
  91538. * Internal only - manager for action
  91539. * @hidden
  91540. */
  91541. _actionManager: ActionManager;
  91542. private _nextActiveAction;
  91543. private _child;
  91544. private _condition?;
  91545. private _triggerParameter;
  91546. /**
  91547. * An event triggered prior to action being executed.
  91548. */
  91549. onBeforeExecuteObservable: Observable<Action>;
  91550. /**
  91551. * Creates a new Action
  91552. * @param triggerOptions the trigger, with or without parameters, for the action
  91553. * @param condition an optional determinant of action
  91554. */
  91555. constructor(
  91556. /** the trigger, with or without parameters, for the action */
  91557. triggerOptions: any, condition?: Condition);
  91558. /**
  91559. * Internal only
  91560. * @hidden
  91561. */
  91562. _prepare(): void;
  91563. /**
  91564. * Gets the trigger parameters
  91565. * @returns the trigger parameters
  91566. */
  91567. getTriggerParameter(): any;
  91568. /**
  91569. * Internal only - executes current action event
  91570. * @hidden
  91571. */
  91572. _executeCurrent(evt?: ActionEvent): void;
  91573. /**
  91574. * Execute placeholder for child classes
  91575. * @param evt optional action event
  91576. */
  91577. execute(evt?: ActionEvent): void;
  91578. /**
  91579. * Skips to next active action
  91580. */
  91581. skipToNextActiveAction(): void;
  91582. /**
  91583. * Adds action to chain of actions, may be a DoNothingAction
  91584. * @param action defines the next action to execute
  91585. * @returns The action passed in
  91586. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91587. */
  91588. then(action: Action): Action;
  91589. /**
  91590. * Internal only
  91591. * @hidden
  91592. */
  91593. _getProperty(propertyPath: string): string;
  91594. /**
  91595. * Internal only
  91596. * @hidden
  91597. */
  91598. _getEffectiveTarget(target: any, propertyPath: string): any;
  91599. /**
  91600. * Serialize placeholder for child classes
  91601. * @param parent of child
  91602. * @returns the serialized object
  91603. */
  91604. serialize(parent: any): any;
  91605. /**
  91606. * Internal only called by serialize
  91607. * @hidden
  91608. */
  91609. protected _serialize(serializedAction: any, parent?: any): any;
  91610. /**
  91611. * Internal only
  91612. * @hidden
  91613. */
  91614. static _SerializeValueAsString: (value: any) => string;
  91615. /**
  91616. * Internal only
  91617. * @hidden
  91618. */
  91619. static _GetTargetProperty: (target: Node | Scene) => {
  91620. name: string;
  91621. targetType: string;
  91622. value: string;
  91623. };
  91624. }
  91625. }
  91626. declare module BABYLON {
  91627. /**
  91628. * A Condition applied to an Action
  91629. */
  91630. export class Condition {
  91631. /**
  91632. * Internal only - manager for action
  91633. * @hidden
  91634. */
  91635. _actionManager: ActionManager;
  91636. /**
  91637. * Internal only
  91638. * @hidden
  91639. */
  91640. _evaluationId: number;
  91641. /**
  91642. * Internal only
  91643. * @hidden
  91644. */
  91645. _currentResult: boolean;
  91646. /**
  91647. * Creates a new Condition
  91648. * @param actionManager the manager of the action the condition is applied to
  91649. */
  91650. constructor(actionManager: ActionManager);
  91651. /**
  91652. * Check if the current condition is valid
  91653. * @returns a boolean
  91654. */
  91655. isValid(): boolean;
  91656. /**
  91657. * Internal only
  91658. * @hidden
  91659. */
  91660. _getProperty(propertyPath: string): string;
  91661. /**
  91662. * Internal only
  91663. * @hidden
  91664. */
  91665. _getEffectiveTarget(target: any, propertyPath: string): any;
  91666. /**
  91667. * Serialize placeholder for child classes
  91668. * @returns the serialized object
  91669. */
  91670. serialize(): any;
  91671. /**
  91672. * Internal only
  91673. * @hidden
  91674. */
  91675. protected _serialize(serializedCondition: any): any;
  91676. }
  91677. /**
  91678. * Defines specific conditional operators as extensions of Condition
  91679. */
  91680. export class ValueCondition extends Condition {
  91681. /** path to specify the property of the target the conditional operator uses */
  91682. propertyPath: string;
  91683. /** the value compared by the conditional operator against the current value of the property */
  91684. value: any;
  91685. /** the conditional operator, default ValueCondition.IsEqual */
  91686. operator: number;
  91687. /**
  91688. * Internal only
  91689. * @hidden
  91690. */
  91691. private static _IsEqual;
  91692. /**
  91693. * Internal only
  91694. * @hidden
  91695. */
  91696. private static _IsDifferent;
  91697. /**
  91698. * Internal only
  91699. * @hidden
  91700. */
  91701. private static _IsGreater;
  91702. /**
  91703. * Internal only
  91704. * @hidden
  91705. */
  91706. private static _IsLesser;
  91707. /**
  91708. * returns the number for IsEqual
  91709. */
  91710. static get IsEqual(): number;
  91711. /**
  91712. * Returns the number for IsDifferent
  91713. */
  91714. static get IsDifferent(): number;
  91715. /**
  91716. * Returns the number for IsGreater
  91717. */
  91718. static get IsGreater(): number;
  91719. /**
  91720. * Returns the number for IsLesser
  91721. */
  91722. static get IsLesser(): number;
  91723. /**
  91724. * Internal only The action manager for the condition
  91725. * @hidden
  91726. */
  91727. _actionManager: ActionManager;
  91728. /**
  91729. * Internal only
  91730. * @hidden
  91731. */
  91732. private _target;
  91733. /**
  91734. * Internal only
  91735. * @hidden
  91736. */
  91737. private _effectiveTarget;
  91738. /**
  91739. * Internal only
  91740. * @hidden
  91741. */
  91742. private _property;
  91743. /**
  91744. * Creates a new ValueCondition
  91745. * @param actionManager manager for the action the condition applies to
  91746. * @param target for the action
  91747. * @param propertyPath path to specify the property of the target the conditional operator uses
  91748. * @param value the value compared by the conditional operator against the current value of the property
  91749. * @param operator the conditional operator, default ValueCondition.IsEqual
  91750. */
  91751. constructor(actionManager: ActionManager, target: any,
  91752. /** path to specify the property of the target the conditional operator uses */
  91753. propertyPath: string,
  91754. /** the value compared by the conditional operator against the current value of the property */
  91755. value: any,
  91756. /** the conditional operator, default ValueCondition.IsEqual */
  91757. operator?: number);
  91758. /**
  91759. * Compares the given value with the property value for the specified conditional operator
  91760. * @returns the result of the comparison
  91761. */
  91762. isValid(): boolean;
  91763. /**
  91764. * Serialize the ValueCondition into a JSON compatible object
  91765. * @returns serialization object
  91766. */
  91767. serialize(): any;
  91768. /**
  91769. * Gets the name of the conditional operator for the ValueCondition
  91770. * @param operator the conditional operator
  91771. * @returns the name
  91772. */
  91773. static GetOperatorName(operator: number): string;
  91774. }
  91775. /**
  91776. * Defines a predicate condition as an extension of Condition
  91777. */
  91778. export class PredicateCondition extends Condition {
  91779. /** defines the predicate function used to validate the condition */
  91780. predicate: () => boolean;
  91781. /**
  91782. * Internal only - manager for action
  91783. * @hidden
  91784. */
  91785. _actionManager: ActionManager;
  91786. /**
  91787. * Creates a new PredicateCondition
  91788. * @param actionManager manager for the action the condition applies to
  91789. * @param predicate defines the predicate function used to validate the condition
  91790. */
  91791. constructor(actionManager: ActionManager,
  91792. /** defines the predicate function used to validate the condition */
  91793. predicate: () => boolean);
  91794. /**
  91795. * @returns the validity of the predicate condition
  91796. */
  91797. isValid(): boolean;
  91798. }
  91799. /**
  91800. * Defines a state condition as an extension of Condition
  91801. */
  91802. export class StateCondition extends Condition {
  91803. /** Value to compare with target state */
  91804. value: string;
  91805. /**
  91806. * Internal only - manager for action
  91807. * @hidden
  91808. */
  91809. _actionManager: ActionManager;
  91810. /**
  91811. * Internal only
  91812. * @hidden
  91813. */
  91814. private _target;
  91815. /**
  91816. * Creates a new StateCondition
  91817. * @param actionManager manager for the action the condition applies to
  91818. * @param target of the condition
  91819. * @param value to compare with target state
  91820. */
  91821. constructor(actionManager: ActionManager, target: any,
  91822. /** Value to compare with target state */
  91823. value: string);
  91824. /**
  91825. * Gets a boolean indicating if the current condition is met
  91826. * @returns the validity of the state
  91827. */
  91828. isValid(): boolean;
  91829. /**
  91830. * Serialize the StateCondition into a JSON compatible object
  91831. * @returns serialization object
  91832. */
  91833. serialize(): any;
  91834. }
  91835. }
  91836. declare module BABYLON {
  91837. /**
  91838. * This defines an action responsible to toggle a boolean once triggered.
  91839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91840. */
  91841. export class SwitchBooleanAction extends Action {
  91842. /**
  91843. * The path to the boolean property in the target object
  91844. */
  91845. propertyPath: string;
  91846. private _target;
  91847. private _effectiveTarget;
  91848. private _property;
  91849. /**
  91850. * Instantiate the action
  91851. * @param triggerOptions defines the trigger options
  91852. * @param target defines the object containing the boolean
  91853. * @param propertyPath defines the path to the boolean property in the target object
  91854. * @param condition defines the trigger related conditions
  91855. */
  91856. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91857. /** @hidden */
  91858. _prepare(): void;
  91859. /**
  91860. * Execute the action toggle the boolean value.
  91861. */
  91862. execute(): void;
  91863. /**
  91864. * Serializes the actions and its related information.
  91865. * @param parent defines the object to serialize in
  91866. * @returns the serialized object
  91867. */
  91868. serialize(parent: any): any;
  91869. }
  91870. /**
  91871. * This defines an action responsible to set a the state field of the target
  91872. * to a desired value once triggered.
  91873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91874. */
  91875. export class SetStateAction extends Action {
  91876. /**
  91877. * The value to store in the state field.
  91878. */
  91879. value: string;
  91880. private _target;
  91881. /**
  91882. * Instantiate the action
  91883. * @param triggerOptions defines the trigger options
  91884. * @param target defines the object containing the state property
  91885. * @param value defines the value to store in the state field
  91886. * @param condition defines the trigger related conditions
  91887. */
  91888. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91889. /**
  91890. * Execute the action and store the value on the target state property.
  91891. */
  91892. execute(): void;
  91893. /**
  91894. * Serializes the actions and its related information.
  91895. * @param parent defines the object to serialize in
  91896. * @returns the serialized object
  91897. */
  91898. serialize(parent: any): any;
  91899. }
  91900. /**
  91901. * This defines an action responsible to set a property of the target
  91902. * to a desired value once triggered.
  91903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91904. */
  91905. export class SetValueAction extends Action {
  91906. /**
  91907. * The path of the property to set in the target.
  91908. */
  91909. propertyPath: string;
  91910. /**
  91911. * The value to set in the property
  91912. */
  91913. value: any;
  91914. private _target;
  91915. private _effectiveTarget;
  91916. private _property;
  91917. /**
  91918. * Instantiate the action
  91919. * @param triggerOptions defines the trigger options
  91920. * @param target defines the object containing the property
  91921. * @param propertyPath defines the path of the property to set in the target
  91922. * @param value defines the value to set in the property
  91923. * @param condition defines the trigger related conditions
  91924. */
  91925. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91926. /** @hidden */
  91927. _prepare(): void;
  91928. /**
  91929. * Execute the action and set the targetted property to the desired value.
  91930. */
  91931. execute(): void;
  91932. /**
  91933. * Serializes the actions and its related information.
  91934. * @param parent defines the object to serialize in
  91935. * @returns the serialized object
  91936. */
  91937. serialize(parent: any): any;
  91938. }
  91939. /**
  91940. * This defines an action responsible to increment the target value
  91941. * to a desired value once triggered.
  91942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91943. */
  91944. export class IncrementValueAction extends Action {
  91945. /**
  91946. * The path of the property to increment in the target.
  91947. */
  91948. propertyPath: string;
  91949. /**
  91950. * The value we should increment the property by.
  91951. */
  91952. value: any;
  91953. private _target;
  91954. private _effectiveTarget;
  91955. private _property;
  91956. /**
  91957. * Instantiate the action
  91958. * @param triggerOptions defines the trigger options
  91959. * @param target defines the object containing the property
  91960. * @param propertyPath defines the path of the property to increment in the target
  91961. * @param value defines the value value we should increment the property by
  91962. * @param condition defines the trigger related conditions
  91963. */
  91964. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91965. /** @hidden */
  91966. _prepare(): void;
  91967. /**
  91968. * Execute the action and increment the target of the value amount.
  91969. */
  91970. execute(): void;
  91971. /**
  91972. * Serializes the actions and its related information.
  91973. * @param parent defines the object to serialize in
  91974. * @returns the serialized object
  91975. */
  91976. serialize(parent: any): any;
  91977. }
  91978. /**
  91979. * This defines an action responsible to start an animation once triggered.
  91980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91981. */
  91982. export class PlayAnimationAction extends Action {
  91983. /**
  91984. * Where the animation should start (animation frame)
  91985. */
  91986. from: number;
  91987. /**
  91988. * Where the animation should stop (animation frame)
  91989. */
  91990. to: number;
  91991. /**
  91992. * Define if the animation should loop or stop after the first play.
  91993. */
  91994. loop?: boolean;
  91995. private _target;
  91996. /**
  91997. * Instantiate the action
  91998. * @param triggerOptions defines the trigger options
  91999. * @param target defines the target animation or animation name
  92000. * @param from defines from where the animation should start (animation frame)
  92001. * @param end defines where the animation should stop (animation frame)
  92002. * @param loop defines if the animation should loop or stop after the first play
  92003. * @param condition defines the trigger related conditions
  92004. */
  92005. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  92006. /** @hidden */
  92007. _prepare(): void;
  92008. /**
  92009. * Execute the action and play the animation.
  92010. */
  92011. execute(): void;
  92012. /**
  92013. * Serializes the actions and its related information.
  92014. * @param parent defines the object to serialize in
  92015. * @returns the serialized object
  92016. */
  92017. serialize(parent: any): any;
  92018. }
  92019. /**
  92020. * This defines an action responsible to stop an animation once triggered.
  92021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92022. */
  92023. export class StopAnimationAction extends Action {
  92024. private _target;
  92025. /**
  92026. * Instantiate the action
  92027. * @param triggerOptions defines the trigger options
  92028. * @param target defines the target animation or animation name
  92029. * @param condition defines the trigger related conditions
  92030. */
  92031. constructor(triggerOptions: any, target: any, condition?: Condition);
  92032. /** @hidden */
  92033. _prepare(): void;
  92034. /**
  92035. * Execute the action and stop the animation.
  92036. */
  92037. execute(): void;
  92038. /**
  92039. * Serializes the actions and its related information.
  92040. * @param parent defines the object to serialize in
  92041. * @returns the serialized object
  92042. */
  92043. serialize(parent: any): any;
  92044. }
  92045. /**
  92046. * This defines an action responsible that does nothing once triggered.
  92047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92048. */
  92049. export class DoNothingAction extends Action {
  92050. /**
  92051. * Instantiate the action
  92052. * @param triggerOptions defines the trigger options
  92053. * @param condition defines the trigger related conditions
  92054. */
  92055. constructor(triggerOptions?: any, condition?: Condition);
  92056. /**
  92057. * Execute the action and do nothing.
  92058. */
  92059. execute(): void;
  92060. /**
  92061. * Serializes the actions and its related information.
  92062. * @param parent defines the object to serialize in
  92063. * @returns the serialized object
  92064. */
  92065. serialize(parent: any): any;
  92066. }
  92067. /**
  92068. * This defines an action responsible to trigger several actions once triggered.
  92069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92070. */
  92071. export class CombineAction extends Action {
  92072. /**
  92073. * The list of aggregated animations to run.
  92074. */
  92075. children: Action[];
  92076. /**
  92077. * Instantiate the action
  92078. * @param triggerOptions defines the trigger options
  92079. * @param children defines the list of aggregated animations to run
  92080. * @param condition defines the trigger related conditions
  92081. */
  92082. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92083. /** @hidden */
  92084. _prepare(): void;
  92085. /**
  92086. * Execute the action and executes all the aggregated actions.
  92087. */
  92088. execute(evt: ActionEvent): void;
  92089. /**
  92090. * Serializes the actions and its related information.
  92091. * @param parent defines the object to serialize in
  92092. * @returns the serialized object
  92093. */
  92094. serialize(parent: any): any;
  92095. }
  92096. /**
  92097. * This defines an action responsible to run code (external event) once triggered.
  92098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92099. */
  92100. export class ExecuteCodeAction extends Action {
  92101. /**
  92102. * The callback function to run.
  92103. */
  92104. func: (evt: ActionEvent) => void;
  92105. /**
  92106. * Instantiate the action
  92107. * @param triggerOptions defines the trigger options
  92108. * @param func defines the callback function to run
  92109. * @param condition defines the trigger related conditions
  92110. */
  92111. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92112. /**
  92113. * Execute the action and run the attached code.
  92114. */
  92115. execute(evt: ActionEvent): void;
  92116. }
  92117. /**
  92118. * This defines an action responsible to set the parent property of the target once triggered.
  92119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92120. */
  92121. export class SetParentAction extends Action {
  92122. private _parent;
  92123. private _target;
  92124. /**
  92125. * Instantiate the action
  92126. * @param triggerOptions defines the trigger options
  92127. * @param target defines the target containing the parent property
  92128. * @param parent defines from where the animation should start (animation frame)
  92129. * @param condition defines the trigger related conditions
  92130. */
  92131. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92132. /** @hidden */
  92133. _prepare(): void;
  92134. /**
  92135. * Execute the action and set the parent property.
  92136. */
  92137. execute(): void;
  92138. /**
  92139. * Serializes the actions and its related information.
  92140. * @param parent defines the object to serialize in
  92141. * @returns the serialized object
  92142. */
  92143. serialize(parent: any): any;
  92144. }
  92145. }
  92146. declare module BABYLON {
  92147. /**
  92148. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92149. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92151. */
  92152. export class ActionManager extends AbstractActionManager {
  92153. /**
  92154. * Nothing
  92155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92156. */
  92157. static readonly NothingTrigger: number;
  92158. /**
  92159. * On pick
  92160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92161. */
  92162. static readonly OnPickTrigger: number;
  92163. /**
  92164. * On left pick
  92165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92166. */
  92167. static readonly OnLeftPickTrigger: number;
  92168. /**
  92169. * On right pick
  92170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92171. */
  92172. static readonly OnRightPickTrigger: number;
  92173. /**
  92174. * On center pick
  92175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92176. */
  92177. static readonly OnCenterPickTrigger: number;
  92178. /**
  92179. * On pick down
  92180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92181. */
  92182. static readonly OnPickDownTrigger: number;
  92183. /**
  92184. * On double pick
  92185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92186. */
  92187. static readonly OnDoublePickTrigger: number;
  92188. /**
  92189. * On pick up
  92190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92191. */
  92192. static readonly OnPickUpTrigger: number;
  92193. /**
  92194. * On pick out.
  92195. * This trigger will only be raised if you also declared a OnPickDown
  92196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92197. */
  92198. static readonly OnPickOutTrigger: number;
  92199. /**
  92200. * On long press
  92201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92202. */
  92203. static readonly OnLongPressTrigger: number;
  92204. /**
  92205. * On pointer over
  92206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92207. */
  92208. static readonly OnPointerOverTrigger: number;
  92209. /**
  92210. * On pointer out
  92211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92212. */
  92213. static readonly OnPointerOutTrigger: number;
  92214. /**
  92215. * On every frame
  92216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92217. */
  92218. static readonly OnEveryFrameTrigger: number;
  92219. /**
  92220. * On intersection enter
  92221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92222. */
  92223. static readonly OnIntersectionEnterTrigger: number;
  92224. /**
  92225. * On intersection exit
  92226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92227. */
  92228. static readonly OnIntersectionExitTrigger: number;
  92229. /**
  92230. * On key down
  92231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92232. */
  92233. static readonly OnKeyDownTrigger: number;
  92234. /**
  92235. * On key up
  92236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92237. */
  92238. static readonly OnKeyUpTrigger: number;
  92239. private _scene;
  92240. /**
  92241. * Creates a new action manager
  92242. * @param scene defines the hosting scene
  92243. */
  92244. constructor(scene: Scene);
  92245. /**
  92246. * Releases all associated resources
  92247. */
  92248. dispose(): void;
  92249. /**
  92250. * Gets hosting scene
  92251. * @returns the hosting scene
  92252. */
  92253. getScene(): Scene;
  92254. /**
  92255. * Does this action manager handles actions of any of the given triggers
  92256. * @param triggers defines the triggers to be tested
  92257. * @return a boolean indicating whether one (or more) of the triggers is handled
  92258. */
  92259. hasSpecificTriggers(triggers: number[]): boolean;
  92260. /**
  92261. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92262. * speed.
  92263. * @param triggerA defines the trigger to be tested
  92264. * @param triggerB defines the trigger to be tested
  92265. * @return a boolean indicating whether one (or more) of the triggers is handled
  92266. */
  92267. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92268. /**
  92269. * Does this action manager handles actions of a given trigger
  92270. * @param trigger defines the trigger to be tested
  92271. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92272. * @return whether the trigger is handled
  92273. */
  92274. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92275. /**
  92276. * Does this action manager has pointer triggers
  92277. */
  92278. get hasPointerTriggers(): boolean;
  92279. /**
  92280. * Does this action manager has pick triggers
  92281. */
  92282. get hasPickTriggers(): boolean;
  92283. /**
  92284. * Registers an action to this action manager
  92285. * @param action defines the action to be registered
  92286. * @return the action amended (prepared) after registration
  92287. */
  92288. registerAction(action: IAction): Nullable<IAction>;
  92289. /**
  92290. * Unregisters an action to this action manager
  92291. * @param action defines the action to be unregistered
  92292. * @return a boolean indicating whether the action has been unregistered
  92293. */
  92294. unregisterAction(action: IAction): Boolean;
  92295. /**
  92296. * Process a specific trigger
  92297. * @param trigger defines the trigger to process
  92298. * @param evt defines the event details to be processed
  92299. */
  92300. processTrigger(trigger: number, evt?: IActionEvent): void;
  92301. /** @hidden */
  92302. _getEffectiveTarget(target: any, propertyPath: string): any;
  92303. /** @hidden */
  92304. _getProperty(propertyPath: string): string;
  92305. /**
  92306. * Serialize this manager to a JSON object
  92307. * @param name defines the property name to store this manager
  92308. * @returns a JSON representation of this manager
  92309. */
  92310. serialize(name: string): any;
  92311. /**
  92312. * Creates a new ActionManager from a JSON data
  92313. * @param parsedActions defines the JSON data to read from
  92314. * @param object defines the hosting mesh
  92315. * @param scene defines the hosting scene
  92316. */
  92317. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92318. /**
  92319. * Get a trigger name by index
  92320. * @param trigger defines the trigger index
  92321. * @returns a trigger name
  92322. */
  92323. static GetTriggerName(trigger: number): string;
  92324. }
  92325. }
  92326. declare module BABYLON {
  92327. /**
  92328. * Class used to represent a sprite
  92329. * @see http://doc.babylonjs.com/babylon101/sprites
  92330. */
  92331. export class Sprite {
  92332. /** defines the name */
  92333. name: string;
  92334. /** Gets or sets the current world position */
  92335. position: Vector3;
  92336. /** Gets or sets the main color */
  92337. color: Color4;
  92338. /** Gets or sets the width */
  92339. width: number;
  92340. /** Gets or sets the height */
  92341. height: number;
  92342. /** Gets or sets rotation angle */
  92343. angle: number;
  92344. /** Gets or sets the cell index in the sprite sheet */
  92345. cellIndex: number;
  92346. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92347. cellRef: string;
  92348. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92349. invertU: number;
  92350. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92351. invertV: number;
  92352. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92353. disposeWhenFinishedAnimating: boolean;
  92354. /** Gets the list of attached animations */
  92355. animations: Animation[];
  92356. /** Gets or sets a boolean indicating if the sprite can be picked */
  92357. isPickable: boolean;
  92358. /**
  92359. * Gets or sets the associated action manager
  92360. */
  92361. actionManager: Nullable<ActionManager>;
  92362. private _animationStarted;
  92363. private _loopAnimation;
  92364. private _fromIndex;
  92365. private _toIndex;
  92366. private _delay;
  92367. private _direction;
  92368. private _manager;
  92369. private _time;
  92370. private _onAnimationEnd;
  92371. /**
  92372. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92373. */
  92374. isVisible: boolean;
  92375. /**
  92376. * Gets or sets the sprite size
  92377. */
  92378. get size(): number;
  92379. set size(value: number);
  92380. /**
  92381. * Creates a new Sprite
  92382. * @param name defines the name
  92383. * @param manager defines the manager
  92384. */
  92385. constructor(
  92386. /** defines the name */
  92387. name: string, manager: ISpriteManager);
  92388. /**
  92389. * Starts an animation
  92390. * @param from defines the initial key
  92391. * @param to defines the end key
  92392. * @param loop defines if the animation must loop
  92393. * @param delay defines the start delay (in ms)
  92394. * @param onAnimationEnd defines a callback to call when animation ends
  92395. */
  92396. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92397. /** Stops current animation (if any) */
  92398. stopAnimation(): void;
  92399. /** @hidden */
  92400. _animate(deltaTime: number): void;
  92401. /** Release associated resources */
  92402. dispose(): void;
  92403. }
  92404. }
  92405. declare module BABYLON {
  92406. /**
  92407. * Information about the result of picking within a scene
  92408. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92409. */
  92410. export class PickingInfo {
  92411. /** @hidden */
  92412. _pickingUnavailable: boolean;
  92413. /**
  92414. * If the pick collided with an object
  92415. */
  92416. hit: boolean;
  92417. /**
  92418. * Distance away where the pick collided
  92419. */
  92420. distance: number;
  92421. /**
  92422. * The location of pick collision
  92423. */
  92424. pickedPoint: Nullable<Vector3>;
  92425. /**
  92426. * The mesh corresponding the the pick collision
  92427. */
  92428. pickedMesh: Nullable<AbstractMesh>;
  92429. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92430. bu: number;
  92431. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92432. bv: number;
  92433. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92434. faceId: number;
  92435. /** Id of the the submesh that was picked */
  92436. subMeshId: number;
  92437. /** If a sprite was picked, this will be the sprite the pick collided with */
  92438. pickedSprite: Nullable<Sprite>;
  92439. /**
  92440. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92441. */
  92442. originMesh: Nullable<AbstractMesh>;
  92443. /**
  92444. * The ray that was used to perform the picking.
  92445. */
  92446. ray: Nullable<Ray>;
  92447. /**
  92448. * Gets the normal correspodning to the face the pick collided with
  92449. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92450. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92451. * @returns The normal correspodning to the face the pick collided with
  92452. */
  92453. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92454. /**
  92455. * Gets the texture coordinates of where the pick occured
  92456. * @returns the vector containing the coordnates of the texture
  92457. */
  92458. getTextureCoordinates(): Nullable<Vector2>;
  92459. }
  92460. }
  92461. declare module BABYLON {
  92462. /**
  92463. * Gather the list of pointer event types as constants.
  92464. */
  92465. export class PointerEventTypes {
  92466. /**
  92467. * 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.
  92468. */
  92469. static readonly POINTERDOWN: number;
  92470. /**
  92471. * The pointerup event is fired when a pointer is no longer active.
  92472. */
  92473. static readonly POINTERUP: number;
  92474. /**
  92475. * The pointermove event is fired when a pointer changes coordinates.
  92476. */
  92477. static readonly POINTERMOVE: number;
  92478. /**
  92479. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92480. */
  92481. static readonly POINTERWHEEL: number;
  92482. /**
  92483. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92484. */
  92485. static readonly POINTERPICK: number;
  92486. /**
  92487. * The pointertap event is fired when a the object has been touched and released without drag.
  92488. */
  92489. static readonly POINTERTAP: number;
  92490. /**
  92491. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92492. */
  92493. static readonly POINTERDOUBLETAP: number;
  92494. }
  92495. /**
  92496. * Base class of pointer info types.
  92497. */
  92498. export class PointerInfoBase {
  92499. /**
  92500. * Defines the type of event (PointerEventTypes)
  92501. */
  92502. type: number;
  92503. /**
  92504. * Defines the related dom event
  92505. */
  92506. event: PointerEvent | MouseWheelEvent;
  92507. /**
  92508. * Instantiates the base class of pointers info.
  92509. * @param type Defines the type of event (PointerEventTypes)
  92510. * @param event Defines the related dom event
  92511. */
  92512. constructor(
  92513. /**
  92514. * Defines the type of event (PointerEventTypes)
  92515. */
  92516. type: number,
  92517. /**
  92518. * Defines the related dom event
  92519. */
  92520. event: PointerEvent | MouseWheelEvent);
  92521. }
  92522. /**
  92523. * This class is used to store pointer related info for the onPrePointerObservable event.
  92524. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92525. */
  92526. export class PointerInfoPre extends PointerInfoBase {
  92527. /**
  92528. * Ray from a pointer if availible (eg. 6dof controller)
  92529. */
  92530. ray: Nullable<Ray>;
  92531. /**
  92532. * Defines the local position of the pointer on the canvas.
  92533. */
  92534. localPosition: Vector2;
  92535. /**
  92536. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92537. */
  92538. skipOnPointerObservable: boolean;
  92539. /**
  92540. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92541. * @param type Defines the type of event (PointerEventTypes)
  92542. * @param event Defines the related dom event
  92543. * @param localX Defines the local x coordinates of the pointer when the event occured
  92544. * @param localY Defines the local y coordinates of the pointer when the event occured
  92545. */
  92546. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92547. }
  92548. /**
  92549. * This type contains all the data related to a pointer event in Babylon.js.
  92550. * 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.
  92551. */
  92552. export class PointerInfo extends PointerInfoBase {
  92553. /**
  92554. * Defines the picking info associated to the info (if any)\
  92555. */
  92556. pickInfo: Nullable<PickingInfo>;
  92557. /**
  92558. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92559. * @param type Defines the type of event (PointerEventTypes)
  92560. * @param event Defines the related dom event
  92561. * @param pickInfo Defines the picking info associated to the info (if any)\
  92562. */
  92563. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92564. /**
  92565. * Defines the picking info associated to the info (if any)\
  92566. */
  92567. pickInfo: Nullable<PickingInfo>);
  92568. }
  92569. /**
  92570. * Data relating to a touch event on the screen.
  92571. */
  92572. export interface PointerTouch {
  92573. /**
  92574. * X coordinate of touch.
  92575. */
  92576. x: number;
  92577. /**
  92578. * Y coordinate of touch.
  92579. */
  92580. y: number;
  92581. /**
  92582. * Id of touch. Unique for each finger.
  92583. */
  92584. pointerId: number;
  92585. /**
  92586. * Event type passed from DOM.
  92587. */
  92588. type: any;
  92589. }
  92590. }
  92591. declare module BABYLON {
  92592. /**
  92593. * Manage the mouse inputs to control the movement of a free camera.
  92594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92595. */
  92596. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92597. /**
  92598. * Define if touch is enabled in the mouse input
  92599. */
  92600. touchEnabled: boolean;
  92601. /**
  92602. * Defines the camera the input is attached to.
  92603. */
  92604. camera: FreeCamera;
  92605. /**
  92606. * Defines the buttons associated with the input to handle camera move.
  92607. */
  92608. buttons: number[];
  92609. /**
  92610. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92611. */
  92612. angularSensibility: number;
  92613. private _pointerInput;
  92614. private _onMouseMove;
  92615. private _observer;
  92616. private previousPosition;
  92617. /**
  92618. * Observable for when a pointer move event occurs containing the move offset
  92619. */
  92620. onPointerMovedObservable: Observable<{
  92621. offsetX: number;
  92622. offsetY: number;
  92623. }>;
  92624. /**
  92625. * @hidden
  92626. * If the camera should be rotated automatically based on pointer movement
  92627. */
  92628. _allowCameraRotation: boolean;
  92629. /**
  92630. * Manage the mouse inputs to control the movement of a free camera.
  92631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92632. * @param touchEnabled Defines if touch is enabled or not
  92633. */
  92634. constructor(
  92635. /**
  92636. * Define if touch is enabled in the mouse input
  92637. */
  92638. touchEnabled?: boolean);
  92639. /**
  92640. * Attach the input controls to a specific dom element to get the input from.
  92641. * @param element Defines the element the controls should be listened from
  92642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92643. */
  92644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92645. /**
  92646. * Called on JS contextmenu event.
  92647. * Override this method to provide functionality.
  92648. */
  92649. protected onContextMenu(evt: PointerEvent): void;
  92650. /**
  92651. * Detach the current controls from the specified dom element.
  92652. * @param element Defines the element to stop listening the inputs from
  92653. */
  92654. detachControl(element: Nullable<HTMLElement>): void;
  92655. /**
  92656. * Gets the class name of the current intput.
  92657. * @returns the class name
  92658. */
  92659. getClassName(): string;
  92660. /**
  92661. * Get the friendly name associated with the input class.
  92662. * @returns the input friendly name
  92663. */
  92664. getSimpleName(): string;
  92665. }
  92666. }
  92667. declare module BABYLON {
  92668. /**
  92669. * Manage the touch inputs to control the movement of a free camera.
  92670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92671. */
  92672. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92673. /**
  92674. * Defines the camera the input is attached to.
  92675. */
  92676. camera: FreeCamera;
  92677. /**
  92678. * Defines the touch sensibility for rotation.
  92679. * The higher the faster.
  92680. */
  92681. touchAngularSensibility: number;
  92682. /**
  92683. * Defines the touch sensibility for move.
  92684. * The higher the faster.
  92685. */
  92686. touchMoveSensibility: number;
  92687. private _offsetX;
  92688. private _offsetY;
  92689. private _pointerPressed;
  92690. private _pointerInput;
  92691. private _observer;
  92692. private _onLostFocus;
  92693. /**
  92694. * Attach the input controls to a specific dom element to get the input from.
  92695. * @param element Defines the element the controls should be listened from
  92696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92697. */
  92698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92699. /**
  92700. * Detach the current controls from the specified dom element.
  92701. * @param element Defines the element to stop listening the inputs from
  92702. */
  92703. detachControl(element: Nullable<HTMLElement>): void;
  92704. /**
  92705. * Update the current camera state depending on the inputs that have been used this frame.
  92706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92707. */
  92708. checkInputs(): void;
  92709. /**
  92710. * Gets the class name of the current intput.
  92711. * @returns the class name
  92712. */
  92713. getClassName(): string;
  92714. /**
  92715. * Get the friendly name associated with the input class.
  92716. * @returns the input friendly name
  92717. */
  92718. getSimpleName(): string;
  92719. }
  92720. }
  92721. declare module BABYLON {
  92722. /**
  92723. * Default Inputs manager for the FreeCamera.
  92724. * It groups all the default supported inputs for ease of use.
  92725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92726. */
  92727. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92728. /**
  92729. * @hidden
  92730. */
  92731. _mouseInput: Nullable<FreeCameraMouseInput>;
  92732. /**
  92733. * Instantiates a new FreeCameraInputsManager.
  92734. * @param camera Defines the camera the inputs belong to
  92735. */
  92736. constructor(camera: FreeCamera);
  92737. /**
  92738. * Add keyboard input support to the input manager.
  92739. * @returns the current input manager
  92740. */
  92741. addKeyboard(): FreeCameraInputsManager;
  92742. /**
  92743. * Add mouse input support to the input manager.
  92744. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92745. * @returns the current input manager
  92746. */
  92747. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92748. /**
  92749. * Removes the mouse input support from the manager
  92750. * @returns the current input manager
  92751. */
  92752. removeMouse(): FreeCameraInputsManager;
  92753. /**
  92754. * Add touch input support to the input manager.
  92755. * @returns the current input manager
  92756. */
  92757. addTouch(): FreeCameraInputsManager;
  92758. /**
  92759. * Remove all attached input methods from a camera
  92760. */
  92761. clear(): void;
  92762. }
  92763. }
  92764. declare module BABYLON {
  92765. /**
  92766. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92767. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92768. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92769. */
  92770. export class FreeCamera extends TargetCamera {
  92771. /**
  92772. * Define the collision ellipsoid of the camera.
  92773. * This is helpful to simulate a camera body like the player body around the camera
  92774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92775. */
  92776. ellipsoid: Vector3;
  92777. /**
  92778. * Define an offset for the position of the ellipsoid around the camera.
  92779. * This can be helpful to determine the center of the body near the gravity center of the body
  92780. * instead of its head.
  92781. */
  92782. ellipsoidOffset: Vector3;
  92783. /**
  92784. * Enable or disable collisions of the camera with the rest of the scene objects.
  92785. */
  92786. checkCollisions: boolean;
  92787. /**
  92788. * Enable or disable gravity on the camera.
  92789. */
  92790. applyGravity: boolean;
  92791. /**
  92792. * Define the input manager associated to the camera.
  92793. */
  92794. inputs: FreeCameraInputsManager;
  92795. /**
  92796. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92797. * Higher values reduce sensitivity.
  92798. */
  92799. get angularSensibility(): number;
  92800. /**
  92801. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92802. * Higher values reduce sensitivity.
  92803. */
  92804. set angularSensibility(value: number);
  92805. /**
  92806. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92807. */
  92808. get keysUp(): number[];
  92809. set keysUp(value: number[]);
  92810. /**
  92811. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92812. */
  92813. get keysUpward(): number[];
  92814. set keysUpward(value: number[]);
  92815. /**
  92816. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92817. */
  92818. get keysDown(): number[];
  92819. set keysDown(value: number[]);
  92820. /**
  92821. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92822. */
  92823. get keysDownward(): number[];
  92824. set keysDownward(value: number[]);
  92825. /**
  92826. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92827. */
  92828. get keysLeft(): number[];
  92829. set keysLeft(value: number[]);
  92830. /**
  92831. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92832. */
  92833. get keysRight(): number[];
  92834. set keysRight(value: number[]);
  92835. /**
  92836. * Event raised when the camera collide with a mesh in the scene.
  92837. */
  92838. onCollide: (collidedMesh: AbstractMesh) => void;
  92839. private _collider;
  92840. private _needMoveForGravity;
  92841. private _oldPosition;
  92842. private _diffPosition;
  92843. private _newPosition;
  92844. /** @hidden */
  92845. _localDirection: Vector3;
  92846. /** @hidden */
  92847. _transformedDirection: Vector3;
  92848. /**
  92849. * Instantiates a Free Camera.
  92850. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92851. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92853. * @param name Define the name of the camera in the scene
  92854. * @param position Define the start position of the camera in the scene
  92855. * @param scene Define the scene the camera belongs to
  92856. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92857. */
  92858. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92859. /**
  92860. * Attached controls to the current camera.
  92861. * @param element Defines the element the controls should be listened from
  92862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92863. */
  92864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92865. /**
  92866. * Detach the current controls from the camera.
  92867. * The camera will stop reacting to inputs.
  92868. * @param element Defines the element to stop listening the inputs from
  92869. */
  92870. detachControl(element: HTMLElement): void;
  92871. private _collisionMask;
  92872. /**
  92873. * Define a collision mask to limit the list of object the camera can collide with
  92874. */
  92875. get collisionMask(): number;
  92876. set collisionMask(mask: number);
  92877. /** @hidden */
  92878. _collideWithWorld(displacement: Vector3): void;
  92879. private _onCollisionPositionChange;
  92880. /** @hidden */
  92881. _checkInputs(): void;
  92882. /** @hidden */
  92883. _decideIfNeedsToMove(): boolean;
  92884. /** @hidden */
  92885. _updatePosition(): void;
  92886. /**
  92887. * Destroy the camera and release the current resources hold by it.
  92888. */
  92889. dispose(): void;
  92890. /**
  92891. * Gets the current object class name.
  92892. * @return the class name
  92893. */
  92894. getClassName(): string;
  92895. }
  92896. }
  92897. declare module BABYLON {
  92898. /**
  92899. * Represents a gamepad control stick position
  92900. */
  92901. export class StickValues {
  92902. /**
  92903. * The x component of the control stick
  92904. */
  92905. x: number;
  92906. /**
  92907. * The y component of the control stick
  92908. */
  92909. y: number;
  92910. /**
  92911. * Initializes the gamepad x and y control stick values
  92912. * @param x The x component of the gamepad control stick value
  92913. * @param y The y component of the gamepad control stick value
  92914. */
  92915. constructor(
  92916. /**
  92917. * The x component of the control stick
  92918. */
  92919. x: number,
  92920. /**
  92921. * The y component of the control stick
  92922. */
  92923. y: number);
  92924. }
  92925. /**
  92926. * An interface which manages callbacks for gamepad button changes
  92927. */
  92928. export interface GamepadButtonChanges {
  92929. /**
  92930. * Called when a gamepad has been changed
  92931. */
  92932. changed: boolean;
  92933. /**
  92934. * Called when a gamepad press event has been triggered
  92935. */
  92936. pressChanged: boolean;
  92937. /**
  92938. * Called when a touch event has been triggered
  92939. */
  92940. touchChanged: boolean;
  92941. /**
  92942. * Called when a value has changed
  92943. */
  92944. valueChanged: boolean;
  92945. }
  92946. /**
  92947. * Represents a gamepad
  92948. */
  92949. export class Gamepad {
  92950. /**
  92951. * The id of the gamepad
  92952. */
  92953. id: string;
  92954. /**
  92955. * The index of the gamepad
  92956. */
  92957. index: number;
  92958. /**
  92959. * The browser gamepad
  92960. */
  92961. browserGamepad: any;
  92962. /**
  92963. * Specifies what type of gamepad this represents
  92964. */
  92965. type: number;
  92966. private _leftStick;
  92967. private _rightStick;
  92968. /** @hidden */
  92969. _isConnected: boolean;
  92970. private _leftStickAxisX;
  92971. private _leftStickAxisY;
  92972. private _rightStickAxisX;
  92973. private _rightStickAxisY;
  92974. /**
  92975. * Triggered when the left control stick has been changed
  92976. */
  92977. private _onleftstickchanged;
  92978. /**
  92979. * Triggered when the right control stick has been changed
  92980. */
  92981. private _onrightstickchanged;
  92982. /**
  92983. * Represents a gamepad controller
  92984. */
  92985. static GAMEPAD: number;
  92986. /**
  92987. * Represents a generic controller
  92988. */
  92989. static GENERIC: number;
  92990. /**
  92991. * Represents an XBox controller
  92992. */
  92993. static XBOX: number;
  92994. /**
  92995. * Represents a pose-enabled controller
  92996. */
  92997. static POSE_ENABLED: number;
  92998. /**
  92999. * Represents an Dual Shock controller
  93000. */
  93001. static DUALSHOCK: number;
  93002. /**
  93003. * Specifies whether the left control stick should be Y-inverted
  93004. */
  93005. protected _invertLeftStickY: boolean;
  93006. /**
  93007. * Specifies if the gamepad has been connected
  93008. */
  93009. get isConnected(): boolean;
  93010. /**
  93011. * Initializes the gamepad
  93012. * @param id The id of the gamepad
  93013. * @param index The index of the gamepad
  93014. * @param browserGamepad The browser gamepad
  93015. * @param leftStickX The x component of the left joystick
  93016. * @param leftStickY The y component of the left joystick
  93017. * @param rightStickX The x component of the right joystick
  93018. * @param rightStickY The y component of the right joystick
  93019. */
  93020. constructor(
  93021. /**
  93022. * The id of the gamepad
  93023. */
  93024. id: string,
  93025. /**
  93026. * The index of the gamepad
  93027. */
  93028. index: number,
  93029. /**
  93030. * The browser gamepad
  93031. */
  93032. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93033. /**
  93034. * Callback triggered when the left joystick has changed
  93035. * @param callback
  93036. */
  93037. onleftstickchanged(callback: (values: StickValues) => void): void;
  93038. /**
  93039. * Callback triggered when the right joystick has changed
  93040. * @param callback
  93041. */
  93042. onrightstickchanged(callback: (values: StickValues) => void): void;
  93043. /**
  93044. * Gets the left joystick
  93045. */
  93046. get leftStick(): StickValues;
  93047. /**
  93048. * Sets the left joystick values
  93049. */
  93050. set leftStick(newValues: StickValues);
  93051. /**
  93052. * Gets the right joystick
  93053. */
  93054. get rightStick(): StickValues;
  93055. /**
  93056. * Sets the right joystick value
  93057. */
  93058. set rightStick(newValues: StickValues);
  93059. /**
  93060. * Updates the gamepad joystick positions
  93061. */
  93062. update(): void;
  93063. /**
  93064. * Disposes the gamepad
  93065. */
  93066. dispose(): void;
  93067. }
  93068. /**
  93069. * Represents a generic gamepad
  93070. */
  93071. export class GenericPad extends Gamepad {
  93072. private _buttons;
  93073. private _onbuttondown;
  93074. private _onbuttonup;
  93075. /**
  93076. * Observable triggered when a button has been pressed
  93077. */
  93078. onButtonDownObservable: Observable<number>;
  93079. /**
  93080. * Observable triggered when a button has been released
  93081. */
  93082. onButtonUpObservable: Observable<number>;
  93083. /**
  93084. * Callback triggered when a button has been pressed
  93085. * @param callback Called when a button has been pressed
  93086. */
  93087. onbuttondown(callback: (buttonPressed: number) => void): void;
  93088. /**
  93089. * Callback triggered when a button has been released
  93090. * @param callback Called when a button has been released
  93091. */
  93092. onbuttonup(callback: (buttonReleased: number) => void): void;
  93093. /**
  93094. * Initializes the generic gamepad
  93095. * @param id The id of the generic gamepad
  93096. * @param index The index of the generic gamepad
  93097. * @param browserGamepad The browser gamepad
  93098. */
  93099. constructor(id: string, index: number, browserGamepad: any);
  93100. private _setButtonValue;
  93101. /**
  93102. * Updates the generic gamepad
  93103. */
  93104. update(): void;
  93105. /**
  93106. * Disposes the generic gamepad
  93107. */
  93108. dispose(): void;
  93109. }
  93110. }
  93111. declare module BABYLON {
  93112. /**
  93113. * Defines the types of pose enabled controllers that are supported
  93114. */
  93115. export enum PoseEnabledControllerType {
  93116. /**
  93117. * HTC Vive
  93118. */
  93119. VIVE = 0,
  93120. /**
  93121. * Oculus Rift
  93122. */
  93123. OCULUS = 1,
  93124. /**
  93125. * Windows mixed reality
  93126. */
  93127. WINDOWS = 2,
  93128. /**
  93129. * Samsung gear VR
  93130. */
  93131. GEAR_VR = 3,
  93132. /**
  93133. * Google Daydream
  93134. */
  93135. DAYDREAM = 4,
  93136. /**
  93137. * Generic
  93138. */
  93139. GENERIC = 5
  93140. }
  93141. /**
  93142. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93143. */
  93144. export interface MutableGamepadButton {
  93145. /**
  93146. * Value of the button/trigger
  93147. */
  93148. value: number;
  93149. /**
  93150. * If the button/trigger is currently touched
  93151. */
  93152. touched: boolean;
  93153. /**
  93154. * If the button/trigger is currently pressed
  93155. */
  93156. pressed: boolean;
  93157. }
  93158. /**
  93159. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93160. * @hidden
  93161. */
  93162. export interface ExtendedGamepadButton extends GamepadButton {
  93163. /**
  93164. * If the button/trigger is currently pressed
  93165. */
  93166. readonly pressed: boolean;
  93167. /**
  93168. * If the button/trigger is currently touched
  93169. */
  93170. readonly touched: boolean;
  93171. /**
  93172. * Value of the button/trigger
  93173. */
  93174. readonly value: number;
  93175. }
  93176. /** @hidden */
  93177. export interface _GamePadFactory {
  93178. /**
  93179. * Returns whether or not the current gamepad can be created for this type of controller.
  93180. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93181. * @returns true if it can be created, otherwise false
  93182. */
  93183. canCreate(gamepadInfo: any): boolean;
  93184. /**
  93185. * Creates a new instance of the Gamepad.
  93186. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93187. * @returns the new gamepad instance
  93188. */
  93189. create(gamepadInfo: any): Gamepad;
  93190. }
  93191. /**
  93192. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93193. */
  93194. export class PoseEnabledControllerHelper {
  93195. /** @hidden */
  93196. static _ControllerFactories: _GamePadFactory[];
  93197. /** @hidden */
  93198. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93199. /**
  93200. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93201. * @param vrGamepad the gamepad to initialized
  93202. * @returns a vr controller of the type the gamepad identified as
  93203. */
  93204. static InitiateController(vrGamepad: any): Gamepad;
  93205. }
  93206. /**
  93207. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93208. */
  93209. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93210. /**
  93211. * If the controller is used in a webXR session
  93212. */
  93213. isXR: boolean;
  93214. private _deviceRoomPosition;
  93215. private _deviceRoomRotationQuaternion;
  93216. /**
  93217. * The device position in babylon space
  93218. */
  93219. devicePosition: Vector3;
  93220. /**
  93221. * The device rotation in babylon space
  93222. */
  93223. deviceRotationQuaternion: Quaternion;
  93224. /**
  93225. * The scale factor of the device in babylon space
  93226. */
  93227. deviceScaleFactor: number;
  93228. /**
  93229. * (Likely devicePosition should be used instead) The device position in its room space
  93230. */
  93231. position: Vector3;
  93232. /**
  93233. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93234. */
  93235. rotationQuaternion: Quaternion;
  93236. /**
  93237. * The type of controller (Eg. Windows mixed reality)
  93238. */
  93239. controllerType: PoseEnabledControllerType;
  93240. protected _calculatedPosition: Vector3;
  93241. private _calculatedRotation;
  93242. /**
  93243. * The raw pose from the device
  93244. */
  93245. rawPose: DevicePose;
  93246. private _trackPosition;
  93247. private _maxRotationDistFromHeadset;
  93248. private _draggedRoomRotation;
  93249. /**
  93250. * @hidden
  93251. */
  93252. _disableTrackPosition(fixedPosition: Vector3): void;
  93253. /**
  93254. * Internal, the mesh attached to the controller
  93255. * @hidden
  93256. */
  93257. _mesh: Nullable<AbstractMesh>;
  93258. private _poseControlledCamera;
  93259. private _leftHandSystemQuaternion;
  93260. /**
  93261. * Internal, matrix used to convert room space to babylon space
  93262. * @hidden
  93263. */
  93264. _deviceToWorld: Matrix;
  93265. /**
  93266. * Node to be used when casting a ray from the controller
  93267. * @hidden
  93268. */
  93269. _pointingPoseNode: Nullable<TransformNode>;
  93270. /**
  93271. * Name of the child mesh that can be used to cast a ray from the controller
  93272. */
  93273. static readonly POINTING_POSE: string;
  93274. /**
  93275. * Creates a new PoseEnabledController from a gamepad
  93276. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93277. */
  93278. constructor(browserGamepad: any);
  93279. private _workingMatrix;
  93280. /**
  93281. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93282. */
  93283. update(): void;
  93284. /**
  93285. * Updates only the pose device and mesh without doing any button event checking
  93286. */
  93287. protected _updatePoseAndMesh(): void;
  93288. /**
  93289. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93290. * @param poseData raw pose fromthe device
  93291. */
  93292. updateFromDevice(poseData: DevicePose): void;
  93293. /**
  93294. * @hidden
  93295. */
  93296. _meshAttachedObservable: Observable<AbstractMesh>;
  93297. /**
  93298. * Attaches a mesh to the controller
  93299. * @param mesh the mesh to be attached
  93300. */
  93301. attachToMesh(mesh: AbstractMesh): void;
  93302. /**
  93303. * Attaches the controllers mesh to a camera
  93304. * @param camera the camera the mesh should be attached to
  93305. */
  93306. attachToPoseControlledCamera(camera: TargetCamera): void;
  93307. /**
  93308. * Disposes of the controller
  93309. */
  93310. dispose(): void;
  93311. /**
  93312. * The mesh that is attached to the controller
  93313. */
  93314. get mesh(): Nullable<AbstractMesh>;
  93315. /**
  93316. * Gets the ray of the controller in the direction the controller is pointing
  93317. * @param length the length the resulting ray should be
  93318. * @returns a ray in the direction the controller is pointing
  93319. */
  93320. getForwardRay(length?: number): Ray;
  93321. }
  93322. }
  93323. declare module BABYLON {
  93324. /**
  93325. * Defines the WebVRController object that represents controllers tracked in 3D space
  93326. */
  93327. export abstract class WebVRController extends PoseEnabledController {
  93328. /**
  93329. * Internal, the default controller model for the controller
  93330. */
  93331. protected _defaultModel: Nullable<AbstractMesh>;
  93332. /**
  93333. * Fired when the trigger state has changed
  93334. */
  93335. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93336. /**
  93337. * Fired when the main button state has changed
  93338. */
  93339. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93340. /**
  93341. * Fired when the secondary button state has changed
  93342. */
  93343. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93344. /**
  93345. * Fired when the pad state has changed
  93346. */
  93347. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93348. /**
  93349. * Fired when controllers stick values have changed
  93350. */
  93351. onPadValuesChangedObservable: Observable<StickValues>;
  93352. /**
  93353. * Array of button availible on the controller
  93354. */
  93355. protected _buttons: Array<MutableGamepadButton>;
  93356. private _onButtonStateChange;
  93357. /**
  93358. * Fired when a controller button's state has changed
  93359. * @param callback the callback containing the button that was modified
  93360. */
  93361. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93362. /**
  93363. * X and Y axis corresponding to the controllers joystick
  93364. */
  93365. pad: StickValues;
  93366. /**
  93367. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93368. */
  93369. hand: string;
  93370. /**
  93371. * The default controller model for the controller
  93372. */
  93373. get defaultModel(): Nullable<AbstractMesh>;
  93374. /**
  93375. * Creates a new WebVRController from a gamepad
  93376. * @param vrGamepad the gamepad that the WebVRController should be created from
  93377. */
  93378. constructor(vrGamepad: any);
  93379. /**
  93380. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93381. */
  93382. update(): void;
  93383. /**
  93384. * Function to be called when a button is modified
  93385. */
  93386. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93387. /**
  93388. * Loads a mesh and attaches it to the controller
  93389. * @param scene the scene the mesh should be added to
  93390. * @param meshLoaded callback for when the mesh has been loaded
  93391. */
  93392. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93393. private _setButtonValue;
  93394. private _changes;
  93395. private _checkChanges;
  93396. /**
  93397. * Disposes of th webVRCOntroller
  93398. */
  93399. dispose(): void;
  93400. }
  93401. }
  93402. declare module BABYLON {
  93403. /**
  93404. * The HemisphericLight simulates the ambient environment light,
  93405. * so the passed direction is the light reflection direction, not the incoming direction.
  93406. */
  93407. export class HemisphericLight extends Light {
  93408. /**
  93409. * The groundColor is the light in the opposite direction to the one specified during creation.
  93410. * 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.
  93411. */
  93412. groundColor: Color3;
  93413. /**
  93414. * The light reflection direction, not the incoming direction.
  93415. */
  93416. direction: Vector3;
  93417. /**
  93418. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93419. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93420. * The HemisphericLight can't cast shadows.
  93421. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93422. * @param name The friendly name of the light
  93423. * @param direction The direction of the light reflection
  93424. * @param scene The scene the light belongs to
  93425. */
  93426. constructor(name: string, direction: Vector3, scene: Scene);
  93427. protected _buildUniformLayout(): void;
  93428. /**
  93429. * Returns the string "HemisphericLight".
  93430. * @return The class name
  93431. */
  93432. getClassName(): string;
  93433. /**
  93434. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93435. * Returns the updated direction.
  93436. * @param target The target the direction should point to
  93437. * @return The computed direction
  93438. */
  93439. setDirectionToTarget(target: Vector3): Vector3;
  93440. /**
  93441. * Returns the shadow generator associated to the light.
  93442. * @returns Always null for hemispheric lights because it does not support shadows.
  93443. */
  93444. getShadowGenerator(): Nullable<IShadowGenerator>;
  93445. /**
  93446. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93447. * @param effect The effect to update
  93448. * @param lightIndex The index of the light in the effect to update
  93449. * @returns The hemispheric light
  93450. */
  93451. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93452. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93453. /**
  93454. * Computes the world matrix of the node
  93455. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93456. * @param useWasUpdatedFlag defines a reserved property
  93457. * @returns the world matrix
  93458. */
  93459. computeWorldMatrix(): Matrix;
  93460. /**
  93461. * Returns the integer 3.
  93462. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93463. */
  93464. getTypeID(): number;
  93465. /**
  93466. * Prepares the list of defines specific to the light type.
  93467. * @param defines the list of defines
  93468. * @param lightIndex defines the index of the light for the effect
  93469. */
  93470. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93471. }
  93472. }
  93473. declare module BABYLON {
  93474. /** @hidden */
  93475. export var vrMultiviewToSingleviewPixelShader: {
  93476. name: string;
  93477. shader: string;
  93478. };
  93479. }
  93480. declare module BABYLON {
  93481. /**
  93482. * Renders to multiple views with a single draw call
  93483. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93484. */
  93485. export class MultiviewRenderTarget extends RenderTargetTexture {
  93486. /**
  93487. * Creates a multiview render target
  93488. * @param scene scene used with the render target
  93489. * @param size the size of the render target (used for each view)
  93490. */
  93491. constructor(scene: Scene, size?: number | {
  93492. width: number;
  93493. height: number;
  93494. } | {
  93495. ratio: number;
  93496. });
  93497. /**
  93498. * @hidden
  93499. * @param faceIndex the face index, if its a cube texture
  93500. */
  93501. _bindFrameBuffer(faceIndex?: number): void;
  93502. /**
  93503. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93504. * @returns the view count
  93505. */
  93506. getViewCount(): number;
  93507. }
  93508. }
  93509. declare module BABYLON {
  93510. /**
  93511. * Represents a camera frustum
  93512. */
  93513. export class Frustum {
  93514. /**
  93515. * Gets the planes representing the frustum
  93516. * @param transform matrix to be applied to the returned planes
  93517. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93518. */
  93519. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93520. /**
  93521. * Gets the near frustum plane transformed by the transform matrix
  93522. * @param transform transformation matrix to be applied to the resulting frustum plane
  93523. * @param frustumPlane the resuling frustum plane
  93524. */
  93525. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93526. /**
  93527. * Gets the far frustum plane transformed by the transform matrix
  93528. * @param transform transformation matrix to be applied to the resulting frustum plane
  93529. * @param frustumPlane the resuling frustum plane
  93530. */
  93531. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93532. /**
  93533. * Gets the left frustum plane transformed by the transform matrix
  93534. * @param transform transformation matrix to be applied to the resulting frustum plane
  93535. * @param frustumPlane the resuling frustum plane
  93536. */
  93537. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93538. /**
  93539. * Gets the right frustum plane transformed by the transform matrix
  93540. * @param transform transformation matrix to be applied to the resulting frustum plane
  93541. * @param frustumPlane the resuling frustum plane
  93542. */
  93543. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93544. /**
  93545. * Gets the top frustum plane transformed by the transform matrix
  93546. * @param transform transformation matrix to be applied to the resulting frustum plane
  93547. * @param frustumPlane the resuling frustum plane
  93548. */
  93549. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93550. /**
  93551. * Gets the bottom frustum plane transformed by the transform matrix
  93552. * @param transform transformation matrix to be applied to the resulting frustum plane
  93553. * @param frustumPlane the resuling frustum plane
  93554. */
  93555. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93556. /**
  93557. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93558. * @param transform transformation matrix to be applied to the resulting frustum planes
  93559. * @param frustumPlanes the resuling frustum planes
  93560. */
  93561. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93562. }
  93563. }
  93564. declare module BABYLON {
  93565. interface Engine {
  93566. /**
  93567. * Creates a new multiview render target
  93568. * @param width defines the width of the texture
  93569. * @param height defines the height of the texture
  93570. * @returns the created multiview texture
  93571. */
  93572. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93573. /**
  93574. * Binds a multiview framebuffer to be drawn to
  93575. * @param multiviewTexture texture to bind
  93576. */
  93577. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93578. }
  93579. interface Camera {
  93580. /**
  93581. * @hidden
  93582. * 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)
  93583. */
  93584. _useMultiviewToSingleView: boolean;
  93585. /**
  93586. * @hidden
  93587. * 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)
  93588. */
  93589. _multiviewTexture: Nullable<RenderTargetTexture>;
  93590. /**
  93591. * @hidden
  93592. * ensures the multiview texture of the camera exists and has the specified width/height
  93593. * @param width height to set on the multiview texture
  93594. * @param height width to set on the multiview texture
  93595. */
  93596. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93597. }
  93598. interface Scene {
  93599. /** @hidden */
  93600. _transformMatrixR: Matrix;
  93601. /** @hidden */
  93602. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93603. /** @hidden */
  93604. _createMultiviewUbo(): void;
  93605. /** @hidden */
  93606. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93607. /** @hidden */
  93608. _renderMultiviewToSingleView(camera: Camera): void;
  93609. }
  93610. }
  93611. declare module BABYLON {
  93612. /**
  93613. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93614. * This will not be used for webXR as it supports displaying texture arrays directly
  93615. */
  93616. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93617. /**
  93618. * Initializes a VRMultiviewToSingleview
  93619. * @param name name of the post process
  93620. * @param camera camera to be applied to
  93621. * @param scaleFactor scaling factor to the size of the output texture
  93622. */
  93623. constructor(name: string, camera: Camera, scaleFactor: number);
  93624. }
  93625. }
  93626. declare module BABYLON {
  93627. /**
  93628. * Interface used to define additional presentation attributes
  93629. */
  93630. export interface IVRPresentationAttributes {
  93631. /**
  93632. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93633. */
  93634. highRefreshRate: boolean;
  93635. /**
  93636. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93637. */
  93638. foveationLevel: number;
  93639. }
  93640. interface Engine {
  93641. /** @hidden */
  93642. _vrDisplay: any;
  93643. /** @hidden */
  93644. _vrSupported: boolean;
  93645. /** @hidden */
  93646. _oldSize: Size;
  93647. /** @hidden */
  93648. _oldHardwareScaleFactor: number;
  93649. /** @hidden */
  93650. _vrExclusivePointerMode: boolean;
  93651. /** @hidden */
  93652. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93653. /** @hidden */
  93654. _onVRDisplayPointerRestricted: () => void;
  93655. /** @hidden */
  93656. _onVRDisplayPointerUnrestricted: () => void;
  93657. /** @hidden */
  93658. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93659. /** @hidden */
  93660. _onVrDisplayDisconnect: Nullable<() => void>;
  93661. /** @hidden */
  93662. _onVrDisplayPresentChange: Nullable<() => void>;
  93663. /**
  93664. * Observable signaled when VR display mode changes
  93665. */
  93666. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93667. /**
  93668. * Observable signaled when VR request present is complete
  93669. */
  93670. onVRRequestPresentComplete: Observable<boolean>;
  93671. /**
  93672. * Observable signaled when VR request present starts
  93673. */
  93674. onVRRequestPresentStart: Observable<Engine>;
  93675. /**
  93676. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93677. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93678. */
  93679. isInVRExclusivePointerMode: boolean;
  93680. /**
  93681. * Gets a boolean indicating if a webVR device was detected
  93682. * @returns true if a webVR device was detected
  93683. */
  93684. isVRDevicePresent(): boolean;
  93685. /**
  93686. * Gets the current webVR device
  93687. * @returns the current webVR device (or null)
  93688. */
  93689. getVRDevice(): any;
  93690. /**
  93691. * Initializes a webVR display and starts listening to display change events
  93692. * The onVRDisplayChangedObservable will be notified upon these changes
  93693. * @returns A promise containing a VRDisplay and if vr is supported
  93694. */
  93695. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93696. /** @hidden */
  93697. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93698. /**
  93699. * Gets or sets the presentation attributes used to configure VR rendering
  93700. */
  93701. vrPresentationAttributes?: IVRPresentationAttributes;
  93702. /**
  93703. * Call this function to switch to webVR mode
  93704. * Will do nothing if webVR is not supported or if there is no webVR device
  93705. * @param options the webvr options provided to the camera. mainly used for multiview
  93706. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93707. */
  93708. enableVR(options: WebVROptions): void;
  93709. /** @hidden */
  93710. _onVRFullScreenTriggered(): void;
  93711. }
  93712. }
  93713. declare module BABYLON {
  93714. /**
  93715. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93716. * IMPORTANT!! The data is right-hand data.
  93717. * @export
  93718. * @interface DevicePose
  93719. */
  93720. export interface DevicePose {
  93721. /**
  93722. * The position of the device, values in array are [x,y,z].
  93723. */
  93724. readonly position: Nullable<Float32Array>;
  93725. /**
  93726. * The linearVelocity of the device, values in array are [x,y,z].
  93727. */
  93728. readonly linearVelocity: Nullable<Float32Array>;
  93729. /**
  93730. * The linearAcceleration of the device, values in array are [x,y,z].
  93731. */
  93732. readonly linearAcceleration: Nullable<Float32Array>;
  93733. /**
  93734. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93735. */
  93736. readonly orientation: Nullable<Float32Array>;
  93737. /**
  93738. * The angularVelocity of the device, values in array are [x,y,z].
  93739. */
  93740. readonly angularVelocity: Nullable<Float32Array>;
  93741. /**
  93742. * The angularAcceleration of the device, values in array are [x,y,z].
  93743. */
  93744. readonly angularAcceleration: Nullable<Float32Array>;
  93745. }
  93746. /**
  93747. * Interface representing a pose controlled object in Babylon.
  93748. * A pose controlled object has both regular pose values as well as pose values
  93749. * from an external device such as a VR head mounted display
  93750. */
  93751. export interface PoseControlled {
  93752. /**
  93753. * The position of the object in babylon space.
  93754. */
  93755. position: Vector3;
  93756. /**
  93757. * The rotation quaternion of the object in babylon space.
  93758. */
  93759. rotationQuaternion: Quaternion;
  93760. /**
  93761. * The position of the device in babylon space.
  93762. */
  93763. devicePosition?: Vector3;
  93764. /**
  93765. * The rotation quaternion of the device in babylon space.
  93766. */
  93767. deviceRotationQuaternion: Quaternion;
  93768. /**
  93769. * The raw pose coming from the device.
  93770. */
  93771. rawPose: Nullable<DevicePose>;
  93772. /**
  93773. * The scale of the device to be used when translating from device space to babylon space.
  93774. */
  93775. deviceScaleFactor: number;
  93776. /**
  93777. * Updates the poseControlled values based on the input device pose.
  93778. * @param poseData the pose data to update the object with
  93779. */
  93780. updateFromDevice(poseData: DevicePose): void;
  93781. }
  93782. /**
  93783. * Set of options to customize the webVRCamera
  93784. */
  93785. export interface WebVROptions {
  93786. /**
  93787. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93788. */
  93789. trackPosition?: boolean;
  93790. /**
  93791. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93792. */
  93793. positionScale?: number;
  93794. /**
  93795. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93796. */
  93797. displayName?: string;
  93798. /**
  93799. * Should the native controller meshes be initialized. (default: true)
  93800. */
  93801. controllerMeshes?: boolean;
  93802. /**
  93803. * Creating a default HemiLight only on controllers. (default: true)
  93804. */
  93805. defaultLightingOnControllers?: boolean;
  93806. /**
  93807. * If you don't want to use the default VR button of the helper. (default: false)
  93808. */
  93809. useCustomVRButton?: boolean;
  93810. /**
  93811. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93812. */
  93813. customVRButton?: HTMLButtonElement;
  93814. /**
  93815. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93816. */
  93817. rayLength?: number;
  93818. /**
  93819. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93820. */
  93821. defaultHeight?: number;
  93822. /**
  93823. * If multiview should be used if availible (default: false)
  93824. */
  93825. useMultiview?: boolean;
  93826. }
  93827. /**
  93828. * This represents a WebVR camera.
  93829. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93830. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93831. */
  93832. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93833. private webVROptions;
  93834. /**
  93835. * @hidden
  93836. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93837. */
  93838. _vrDevice: any;
  93839. /**
  93840. * The rawPose of the vrDevice.
  93841. */
  93842. rawPose: Nullable<DevicePose>;
  93843. private _onVREnabled;
  93844. private _specsVersion;
  93845. private _attached;
  93846. private _frameData;
  93847. protected _descendants: Array<Node>;
  93848. private _deviceRoomPosition;
  93849. /** @hidden */
  93850. _deviceRoomRotationQuaternion: Quaternion;
  93851. private _standingMatrix;
  93852. /**
  93853. * Represents device position in babylon space.
  93854. */
  93855. devicePosition: Vector3;
  93856. /**
  93857. * Represents device rotation in babylon space.
  93858. */
  93859. deviceRotationQuaternion: Quaternion;
  93860. /**
  93861. * The scale of the device to be used when translating from device space to babylon space.
  93862. */
  93863. deviceScaleFactor: number;
  93864. private _deviceToWorld;
  93865. private _worldToDevice;
  93866. /**
  93867. * References to the webVR controllers for the vrDevice.
  93868. */
  93869. controllers: Array<WebVRController>;
  93870. /**
  93871. * Emits an event when a controller is attached.
  93872. */
  93873. onControllersAttachedObservable: Observable<WebVRController[]>;
  93874. /**
  93875. * Emits an event when a controller's mesh has been loaded;
  93876. */
  93877. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93878. /**
  93879. * Emits an event when the HMD's pose has been updated.
  93880. */
  93881. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93882. private _poseSet;
  93883. /**
  93884. * If the rig cameras be used as parent instead of this camera.
  93885. */
  93886. rigParenting: boolean;
  93887. private _lightOnControllers;
  93888. private _defaultHeight?;
  93889. /**
  93890. * Instantiates a WebVRFreeCamera.
  93891. * @param name The name of the WebVRFreeCamera
  93892. * @param position The starting anchor position for the camera
  93893. * @param scene The scene the camera belongs to
  93894. * @param webVROptions a set of customizable options for the webVRCamera
  93895. */
  93896. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93897. /**
  93898. * Gets the device distance from the ground in meters.
  93899. * @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.
  93900. */
  93901. deviceDistanceToRoomGround(): number;
  93902. /**
  93903. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93904. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93905. */
  93906. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93907. /**
  93908. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93909. * @returns A promise with a boolean set to if the standing matrix is supported.
  93910. */
  93911. useStandingMatrixAsync(): Promise<boolean>;
  93912. /**
  93913. * Disposes the camera
  93914. */
  93915. dispose(): void;
  93916. /**
  93917. * Gets a vrController by name.
  93918. * @param name The name of the controller to retreive
  93919. * @returns the controller matching the name specified or null if not found
  93920. */
  93921. getControllerByName(name: string): Nullable<WebVRController>;
  93922. private _leftController;
  93923. /**
  93924. * The controller corresponding to the users left hand.
  93925. */
  93926. get leftController(): Nullable<WebVRController>;
  93927. private _rightController;
  93928. /**
  93929. * The controller corresponding to the users right hand.
  93930. */
  93931. get rightController(): Nullable<WebVRController>;
  93932. /**
  93933. * Casts a ray forward from the vrCamera's gaze.
  93934. * @param length Length of the ray (default: 100)
  93935. * @returns the ray corresponding to the gaze
  93936. */
  93937. getForwardRay(length?: number): Ray;
  93938. /**
  93939. * @hidden
  93940. * Updates the camera based on device's frame data
  93941. */
  93942. _checkInputs(): void;
  93943. /**
  93944. * Updates the poseControlled values based on the input device pose.
  93945. * @param poseData Pose coming from the device
  93946. */
  93947. updateFromDevice(poseData: DevicePose): void;
  93948. private _htmlElementAttached;
  93949. private _detachIfAttached;
  93950. /**
  93951. * WebVR's attach control will start broadcasting frames to the device.
  93952. * Note that in certain browsers (chrome for example) this function must be called
  93953. * within a user-interaction callback. Example:
  93954. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93955. *
  93956. * @param element html element to attach the vrDevice to
  93957. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93958. */
  93959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93960. /**
  93961. * Detaches the camera from the html element and disables VR
  93962. *
  93963. * @param element html element to detach from
  93964. */
  93965. detachControl(element: HTMLElement): void;
  93966. /**
  93967. * @returns the name of this class
  93968. */
  93969. getClassName(): string;
  93970. /**
  93971. * Calls resetPose on the vrDisplay
  93972. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93973. */
  93974. resetToCurrentRotation(): void;
  93975. /**
  93976. * @hidden
  93977. * Updates the rig cameras (left and right eye)
  93978. */
  93979. _updateRigCameras(): void;
  93980. private _workingVector;
  93981. private _oneVector;
  93982. private _workingMatrix;
  93983. private updateCacheCalled;
  93984. private _correctPositionIfNotTrackPosition;
  93985. /**
  93986. * @hidden
  93987. * Updates the cached values of the camera
  93988. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93989. */
  93990. _updateCache(ignoreParentClass?: boolean): void;
  93991. /**
  93992. * @hidden
  93993. * Get current device position in babylon world
  93994. */
  93995. _computeDevicePosition(): void;
  93996. /**
  93997. * Updates the current device position and rotation in the babylon world
  93998. */
  93999. update(): void;
  94000. /**
  94001. * @hidden
  94002. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  94003. * @returns an identity matrix
  94004. */
  94005. _getViewMatrix(): Matrix;
  94006. private _tmpMatrix;
  94007. /**
  94008. * This function is called by the two RIG cameras.
  94009. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  94010. * @hidden
  94011. */
  94012. _getWebVRViewMatrix(): Matrix;
  94013. /** @hidden */
  94014. _getWebVRProjectionMatrix(): Matrix;
  94015. private _onGamepadConnectedObserver;
  94016. private _onGamepadDisconnectedObserver;
  94017. private _updateCacheWhenTrackingDisabledObserver;
  94018. /**
  94019. * Initializes the controllers and their meshes
  94020. */
  94021. initControllers(): void;
  94022. }
  94023. }
  94024. declare module BABYLON {
  94025. /**
  94026. * Size options for a post process
  94027. */
  94028. export type PostProcessOptions = {
  94029. width: number;
  94030. height: number;
  94031. };
  94032. /**
  94033. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94034. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94035. */
  94036. export class PostProcess {
  94037. /** Name of the PostProcess. */
  94038. name: string;
  94039. /**
  94040. * Gets or sets the unique id of the post process
  94041. */
  94042. uniqueId: number;
  94043. /**
  94044. * Width of the texture to apply the post process on
  94045. */
  94046. width: number;
  94047. /**
  94048. * Height of the texture to apply the post process on
  94049. */
  94050. height: number;
  94051. /**
  94052. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94053. * @hidden
  94054. */
  94055. _outputTexture: Nullable<InternalTexture>;
  94056. /**
  94057. * Sampling mode used by the shader
  94058. * See https://doc.babylonjs.com/classes/3.1/texture
  94059. */
  94060. renderTargetSamplingMode: number;
  94061. /**
  94062. * Clear color to use when screen clearing
  94063. */
  94064. clearColor: Color4;
  94065. /**
  94066. * If the buffer needs to be cleared before applying the post process. (default: true)
  94067. * Should be set to false if shader will overwrite all previous pixels.
  94068. */
  94069. autoClear: boolean;
  94070. /**
  94071. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94072. */
  94073. alphaMode: number;
  94074. /**
  94075. * Sets the setAlphaBlendConstants of the babylon engine
  94076. */
  94077. alphaConstants: Color4;
  94078. /**
  94079. * Animations to be used for the post processing
  94080. */
  94081. animations: Animation[];
  94082. /**
  94083. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94084. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94085. */
  94086. enablePixelPerfectMode: boolean;
  94087. /**
  94088. * Force the postprocess to be applied without taking in account viewport
  94089. */
  94090. forceFullscreenViewport: boolean;
  94091. /**
  94092. * List of inspectable custom properties (used by the Inspector)
  94093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94094. */
  94095. inspectableCustomProperties: IInspectable[];
  94096. /**
  94097. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94098. *
  94099. * | Value | Type | Description |
  94100. * | ----- | ----------------------------------- | ----------- |
  94101. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94102. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94103. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94104. *
  94105. */
  94106. scaleMode: number;
  94107. /**
  94108. * Force textures to be a power of two (default: false)
  94109. */
  94110. alwaysForcePOT: boolean;
  94111. private _samples;
  94112. /**
  94113. * Number of sample textures (default: 1)
  94114. */
  94115. get samples(): number;
  94116. set samples(n: number);
  94117. /**
  94118. * Modify the scale of the post process to be the same as the viewport (default: false)
  94119. */
  94120. adaptScaleToCurrentViewport: boolean;
  94121. private _camera;
  94122. private _scene;
  94123. private _engine;
  94124. private _options;
  94125. private _reusable;
  94126. private _textureType;
  94127. private _textureFormat;
  94128. /**
  94129. * Smart array of input and output textures for the post process.
  94130. * @hidden
  94131. */
  94132. _textures: SmartArray<InternalTexture>;
  94133. /**
  94134. * The index in _textures that corresponds to the output texture.
  94135. * @hidden
  94136. */
  94137. _currentRenderTextureInd: number;
  94138. private _effect;
  94139. private _samplers;
  94140. private _fragmentUrl;
  94141. private _vertexUrl;
  94142. private _parameters;
  94143. private _scaleRatio;
  94144. protected _indexParameters: any;
  94145. private _shareOutputWithPostProcess;
  94146. private _texelSize;
  94147. private _forcedOutputTexture;
  94148. /**
  94149. * Returns the fragment url or shader name used in the post process.
  94150. * @returns the fragment url or name in the shader store.
  94151. */
  94152. getEffectName(): string;
  94153. /**
  94154. * An event triggered when the postprocess is activated.
  94155. */
  94156. onActivateObservable: Observable<Camera>;
  94157. private _onActivateObserver;
  94158. /**
  94159. * A function that is added to the onActivateObservable
  94160. */
  94161. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94162. /**
  94163. * An event triggered when the postprocess changes its size.
  94164. */
  94165. onSizeChangedObservable: Observable<PostProcess>;
  94166. private _onSizeChangedObserver;
  94167. /**
  94168. * A function that is added to the onSizeChangedObservable
  94169. */
  94170. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94171. /**
  94172. * An event triggered when the postprocess applies its effect.
  94173. */
  94174. onApplyObservable: Observable<Effect>;
  94175. private _onApplyObserver;
  94176. /**
  94177. * A function that is added to the onApplyObservable
  94178. */
  94179. set onApply(callback: (effect: Effect) => void);
  94180. /**
  94181. * An event triggered before rendering the postprocess
  94182. */
  94183. onBeforeRenderObservable: Observable<Effect>;
  94184. private _onBeforeRenderObserver;
  94185. /**
  94186. * A function that is added to the onBeforeRenderObservable
  94187. */
  94188. set onBeforeRender(callback: (effect: Effect) => void);
  94189. /**
  94190. * An event triggered after rendering the postprocess
  94191. */
  94192. onAfterRenderObservable: Observable<Effect>;
  94193. private _onAfterRenderObserver;
  94194. /**
  94195. * A function that is added to the onAfterRenderObservable
  94196. */
  94197. set onAfterRender(callback: (efect: Effect) => void);
  94198. /**
  94199. * 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
  94200. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94201. */
  94202. get inputTexture(): InternalTexture;
  94203. set inputTexture(value: InternalTexture);
  94204. /**
  94205. * Gets the camera which post process is applied to.
  94206. * @returns The camera the post process is applied to.
  94207. */
  94208. getCamera(): Camera;
  94209. /**
  94210. * Gets the texel size of the postprocess.
  94211. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94212. */
  94213. get texelSize(): Vector2;
  94214. /**
  94215. * Creates a new instance PostProcess
  94216. * @param name The name of the PostProcess.
  94217. * @param fragmentUrl The url of the fragment shader to be used.
  94218. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94219. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94220. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94221. * @param camera The camera to apply the render pass to.
  94222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94223. * @param engine The engine which the post process will be applied. (default: current engine)
  94224. * @param reusable If the post process can be reused on the same frame. (default: false)
  94225. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94226. * @param textureType Type of textures used when performing the post process. (default: 0)
  94227. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94228. * @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
  94229. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94230. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94231. */
  94232. constructor(
  94233. /** Name of the PostProcess. */
  94234. 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);
  94235. /**
  94236. * Gets a string idenfifying the name of the class
  94237. * @returns "PostProcess" string
  94238. */
  94239. getClassName(): string;
  94240. /**
  94241. * Gets the engine which this post process belongs to.
  94242. * @returns The engine the post process was enabled with.
  94243. */
  94244. getEngine(): Engine;
  94245. /**
  94246. * The effect that is created when initializing the post process.
  94247. * @returns The created effect corresponding the the postprocess.
  94248. */
  94249. getEffect(): Effect;
  94250. /**
  94251. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94252. * @param postProcess The post process to share the output with.
  94253. * @returns This post process.
  94254. */
  94255. shareOutputWith(postProcess: PostProcess): PostProcess;
  94256. /**
  94257. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94258. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94259. */
  94260. useOwnOutput(): void;
  94261. /**
  94262. * Updates the effect with the current post process compile time values and recompiles the shader.
  94263. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94264. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94265. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94266. * @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
  94267. * @param onCompiled Called when the shader has been compiled.
  94268. * @param onError Called if there is an error when compiling a shader.
  94269. */
  94270. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94271. /**
  94272. * The post process is reusable if it can be used multiple times within one frame.
  94273. * @returns If the post process is reusable
  94274. */
  94275. isReusable(): boolean;
  94276. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94277. markTextureDirty(): void;
  94278. /**
  94279. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94280. * 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.
  94281. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94282. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94283. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94284. * @returns The target texture that was bound to be written to.
  94285. */
  94286. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94287. /**
  94288. * If the post process is supported.
  94289. */
  94290. get isSupported(): boolean;
  94291. /**
  94292. * The aspect ratio of the output texture.
  94293. */
  94294. get aspectRatio(): number;
  94295. /**
  94296. * Get a value indicating if the post-process is ready to be used
  94297. * @returns true if the post-process is ready (shader is compiled)
  94298. */
  94299. isReady(): boolean;
  94300. /**
  94301. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94302. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94303. */
  94304. apply(): Nullable<Effect>;
  94305. private _disposeTextures;
  94306. /**
  94307. * Disposes the post process.
  94308. * @param camera The camera to dispose the post process on.
  94309. */
  94310. dispose(camera?: Camera): void;
  94311. }
  94312. }
  94313. declare module BABYLON {
  94314. /** @hidden */
  94315. export var kernelBlurVaryingDeclaration: {
  94316. name: string;
  94317. shader: string;
  94318. };
  94319. }
  94320. declare module BABYLON {
  94321. /** @hidden */
  94322. export var kernelBlurFragment: {
  94323. name: string;
  94324. shader: string;
  94325. };
  94326. }
  94327. declare module BABYLON {
  94328. /** @hidden */
  94329. export var kernelBlurFragment2: {
  94330. name: string;
  94331. shader: string;
  94332. };
  94333. }
  94334. declare module BABYLON {
  94335. /** @hidden */
  94336. export var kernelBlurPixelShader: {
  94337. name: string;
  94338. shader: string;
  94339. };
  94340. }
  94341. declare module BABYLON {
  94342. /** @hidden */
  94343. export var kernelBlurVertex: {
  94344. name: string;
  94345. shader: string;
  94346. };
  94347. }
  94348. declare module BABYLON {
  94349. /** @hidden */
  94350. export var kernelBlurVertexShader: {
  94351. name: string;
  94352. shader: string;
  94353. };
  94354. }
  94355. declare module BABYLON {
  94356. /**
  94357. * The Blur Post Process which blurs an image based on a kernel and direction.
  94358. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94359. */
  94360. export class BlurPostProcess extends PostProcess {
  94361. /** The direction in which to blur the image. */
  94362. direction: Vector2;
  94363. private blockCompilation;
  94364. protected _kernel: number;
  94365. protected _idealKernel: number;
  94366. protected _packedFloat: boolean;
  94367. private _staticDefines;
  94368. /**
  94369. * Sets the length in pixels of the blur sample region
  94370. */
  94371. set kernel(v: number);
  94372. /**
  94373. * Gets the length in pixels of the blur sample region
  94374. */
  94375. get kernel(): number;
  94376. /**
  94377. * Sets wether or not the blur needs to unpack/repack floats
  94378. */
  94379. set packedFloat(v: boolean);
  94380. /**
  94381. * Gets wether or not the blur is unpacking/repacking floats
  94382. */
  94383. get packedFloat(): boolean;
  94384. /**
  94385. * Creates a new instance BlurPostProcess
  94386. * @param name The name of the effect.
  94387. * @param direction The direction in which to blur the image.
  94388. * @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.
  94389. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94390. * @param camera The camera to apply the render pass to.
  94391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94392. * @param engine The engine which the post process will be applied. (default: current engine)
  94393. * @param reusable If the post process can be reused on the same frame. (default: false)
  94394. * @param textureType Type of textures used when performing the post process. (default: 0)
  94395. * @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)
  94396. */
  94397. constructor(name: string,
  94398. /** The direction in which to blur the image. */
  94399. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94400. /**
  94401. * Updates the effect with the current post process compile time values and recompiles the shader.
  94402. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94403. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94404. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94405. * @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
  94406. * @param onCompiled Called when the shader has been compiled.
  94407. * @param onError Called if there is an error when compiling a shader.
  94408. */
  94409. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94410. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94411. /**
  94412. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94413. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94414. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94415. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94416. * The gaps between physical kernels are compensated for in the weighting of the samples
  94417. * @param idealKernel Ideal blur kernel.
  94418. * @return Nearest best kernel.
  94419. */
  94420. protected _nearestBestKernel(idealKernel: number): number;
  94421. /**
  94422. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94423. * @param x The point on the Gaussian distribution to sample.
  94424. * @return the value of the Gaussian function at x.
  94425. */
  94426. protected _gaussianWeight(x: number): number;
  94427. /**
  94428. * Generates a string that can be used as a floating point number in GLSL.
  94429. * @param x Value to print.
  94430. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94431. * @return GLSL float string.
  94432. */
  94433. protected _glslFloat(x: number, decimalFigures?: number): string;
  94434. }
  94435. }
  94436. declare module BABYLON {
  94437. /**
  94438. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94439. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94440. * You can then easily use it as a reflectionTexture on a flat surface.
  94441. * In case the surface is not a plane, please consider relying on reflection probes.
  94442. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94443. */
  94444. export class MirrorTexture extends RenderTargetTexture {
  94445. private scene;
  94446. /**
  94447. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94448. * 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.
  94449. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94450. */
  94451. mirrorPlane: Plane;
  94452. /**
  94453. * Define the blur ratio used to blur the reflection if needed.
  94454. */
  94455. set blurRatio(value: number);
  94456. get blurRatio(): number;
  94457. /**
  94458. * Define the adaptive blur kernel used to blur the reflection if needed.
  94459. * This will autocompute the closest best match for the `blurKernel`
  94460. */
  94461. set adaptiveBlurKernel(value: number);
  94462. /**
  94463. * Define the blur kernel used to blur the reflection if needed.
  94464. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94465. */
  94466. set blurKernel(value: number);
  94467. /**
  94468. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94469. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94470. */
  94471. set blurKernelX(value: number);
  94472. get blurKernelX(): number;
  94473. /**
  94474. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94475. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94476. */
  94477. set blurKernelY(value: number);
  94478. get blurKernelY(): number;
  94479. private _autoComputeBlurKernel;
  94480. protected _onRatioRescale(): void;
  94481. private _updateGammaSpace;
  94482. private _imageProcessingConfigChangeObserver;
  94483. private _transformMatrix;
  94484. private _mirrorMatrix;
  94485. private _savedViewMatrix;
  94486. private _blurX;
  94487. private _blurY;
  94488. private _adaptiveBlurKernel;
  94489. private _blurKernelX;
  94490. private _blurKernelY;
  94491. private _blurRatio;
  94492. /**
  94493. * Instantiates a Mirror Texture.
  94494. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94495. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94496. * You can then easily use it as a reflectionTexture on a flat surface.
  94497. * In case the surface is not a plane, please consider relying on reflection probes.
  94498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94499. * @param name
  94500. * @param size
  94501. * @param scene
  94502. * @param generateMipMaps
  94503. * @param type
  94504. * @param samplingMode
  94505. * @param generateDepthBuffer
  94506. */
  94507. constructor(name: string, size: number | {
  94508. width: number;
  94509. height: number;
  94510. } | {
  94511. ratio: number;
  94512. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94513. private _preparePostProcesses;
  94514. /**
  94515. * Clone the mirror texture.
  94516. * @returns the cloned texture
  94517. */
  94518. clone(): MirrorTexture;
  94519. /**
  94520. * Serialize the texture to a JSON representation you could use in Parse later on
  94521. * @returns the serialized JSON representation
  94522. */
  94523. serialize(): any;
  94524. /**
  94525. * Dispose the texture and release its associated resources.
  94526. */
  94527. dispose(): void;
  94528. }
  94529. }
  94530. declare module BABYLON {
  94531. /**
  94532. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94533. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94534. */
  94535. export class Texture extends BaseTexture {
  94536. /**
  94537. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94538. */
  94539. static SerializeBuffers: boolean;
  94540. /** @hidden */
  94541. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94542. /** @hidden */
  94543. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94544. /** @hidden */
  94545. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94546. /** nearest is mag = nearest and min = nearest and mip = linear */
  94547. static readonly NEAREST_SAMPLINGMODE: number;
  94548. /** nearest is mag = nearest and min = nearest and mip = linear */
  94549. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94551. static readonly BILINEAR_SAMPLINGMODE: number;
  94552. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94553. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94554. /** Trilinear is mag = linear and min = linear and mip = linear */
  94555. static readonly TRILINEAR_SAMPLINGMODE: number;
  94556. /** Trilinear is mag = linear and min = linear and mip = linear */
  94557. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94558. /** mag = nearest and min = nearest and mip = nearest */
  94559. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94560. /** mag = nearest and min = linear and mip = nearest */
  94561. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94562. /** mag = nearest and min = linear and mip = linear */
  94563. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94564. /** mag = nearest and min = linear and mip = none */
  94565. static readonly NEAREST_LINEAR: number;
  94566. /** mag = nearest and min = nearest and mip = none */
  94567. static readonly NEAREST_NEAREST: number;
  94568. /** mag = linear and min = nearest and mip = nearest */
  94569. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94570. /** mag = linear and min = nearest and mip = linear */
  94571. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94572. /** mag = linear and min = linear and mip = none */
  94573. static readonly LINEAR_LINEAR: number;
  94574. /** mag = linear and min = nearest and mip = none */
  94575. static readonly LINEAR_NEAREST: number;
  94576. /** Explicit coordinates mode */
  94577. static readonly EXPLICIT_MODE: number;
  94578. /** Spherical coordinates mode */
  94579. static readonly SPHERICAL_MODE: number;
  94580. /** Planar coordinates mode */
  94581. static readonly PLANAR_MODE: number;
  94582. /** Cubic coordinates mode */
  94583. static readonly CUBIC_MODE: number;
  94584. /** Projection coordinates mode */
  94585. static readonly PROJECTION_MODE: number;
  94586. /** Inverse Cubic coordinates mode */
  94587. static readonly SKYBOX_MODE: number;
  94588. /** Inverse Cubic coordinates mode */
  94589. static readonly INVCUBIC_MODE: number;
  94590. /** Equirectangular coordinates mode */
  94591. static readonly EQUIRECTANGULAR_MODE: number;
  94592. /** Equirectangular Fixed coordinates mode */
  94593. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94594. /** Equirectangular Fixed Mirrored coordinates mode */
  94595. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94596. /** Texture is not repeating outside of 0..1 UVs */
  94597. static readonly CLAMP_ADDRESSMODE: number;
  94598. /** Texture is repeating outside of 0..1 UVs */
  94599. static readonly WRAP_ADDRESSMODE: number;
  94600. /** Texture is repeating and mirrored */
  94601. static readonly MIRROR_ADDRESSMODE: number;
  94602. /**
  94603. * 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
  94604. */
  94605. static UseSerializedUrlIfAny: boolean;
  94606. /**
  94607. * Define the url of the texture.
  94608. */
  94609. url: Nullable<string>;
  94610. /**
  94611. * Define an offset on the texture to offset the u coordinates of the UVs
  94612. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94613. */
  94614. uOffset: number;
  94615. /**
  94616. * Define an offset on the texture to offset the v coordinates of the UVs
  94617. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94618. */
  94619. vOffset: number;
  94620. /**
  94621. * Define an offset on the texture to scale the u coordinates of the UVs
  94622. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94623. */
  94624. uScale: number;
  94625. /**
  94626. * Define an offset on the texture to scale the v coordinates of the UVs
  94627. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94628. */
  94629. vScale: number;
  94630. /**
  94631. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94632. * @see http://doc.babylonjs.com/how_to/more_materials
  94633. */
  94634. uAng: number;
  94635. /**
  94636. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94637. * @see http://doc.babylonjs.com/how_to/more_materials
  94638. */
  94639. vAng: number;
  94640. /**
  94641. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94642. * @see http://doc.babylonjs.com/how_to/more_materials
  94643. */
  94644. wAng: number;
  94645. /**
  94646. * Defines the center of rotation (U)
  94647. */
  94648. uRotationCenter: number;
  94649. /**
  94650. * Defines the center of rotation (V)
  94651. */
  94652. vRotationCenter: number;
  94653. /**
  94654. * Defines the center of rotation (W)
  94655. */
  94656. wRotationCenter: number;
  94657. /**
  94658. * Are mip maps generated for this texture or not.
  94659. */
  94660. get noMipmap(): boolean;
  94661. /**
  94662. * List of inspectable custom properties (used by the Inspector)
  94663. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94664. */
  94665. inspectableCustomProperties: Nullable<IInspectable[]>;
  94666. private _noMipmap;
  94667. /** @hidden */
  94668. _invertY: boolean;
  94669. private _rowGenerationMatrix;
  94670. private _cachedTextureMatrix;
  94671. private _projectionModeMatrix;
  94672. private _t0;
  94673. private _t1;
  94674. private _t2;
  94675. private _cachedUOffset;
  94676. private _cachedVOffset;
  94677. private _cachedUScale;
  94678. private _cachedVScale;
  94679. private _cachedUAng;
  94680. private _cachedVAng;
  94681. private _cachedWAng;
  94682. private _cachedProjectionMatrixId;
  94683. private _cachedCoordinatesMode;
  94684. /** @hidden */
  94685. protected _initialSamplingMode: number;
  94686. /** @hidden */
  94687. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94688. private _deleteBuffer;
  94689. protected _format: Nullable<number>;
  94690. private _delayedOnLoad;
  94691. private _delayedOnError;
  94692. private _mimeType?;
  94693. /**
  94694. * Observable triggered once the texture has been loaded.
  94695. */
  94696. onLoadObservable: Observable<Texture>;
  94697. protected _isBlocking: boolean;
  94698. /**
  94699. * Is the texture preventing material to render while loading.
  94700. * If false, a default texture will be used instead of the loading one during the preparation step.
  94701. */
  94702. set isBlocking(value: boolean);
  94703. get isBlocking(): boolean;
  94704. /**
  94705. * Get the current sampling mode associated with the texture.
  94706. */
  94707. get samplingMode(): number;
  94708. /**
  94709. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94710. */
  94711. get invertY(): boolean;
  94712. /**
  94713. * Instantiates a new texture.
  94714. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94715. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94716. * @param url defines the url of the picture to load as a texture
  94717. * @param scene defines the scene or engine the texture will belong to
  94718. * @param noMipmap defines if the texture will require mip maps or not
  94719. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94720. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94721. * @param onLoad defines a callback triggered when the texture has been loaded
  94722. * @param onError defines a callback triggered when an error occurred during the loading session
  94723. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94724. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94725. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94726. * @param mimeType defines an optional mime type information
  94727. */
  94728. 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);
  94729. /**
  94730. * Update the url (and optional buffer) of this texture if url was null during construction.
  94731. * @param url the url of the texture
  94732. * @param buffer the buffer of the texture (defaults to null)
  94733. * @param onLoad callback called when the texture is loaded (defaults to null)
  94734. */
  94735. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94736. /**
  94737. * Finish the loading sequence of a texture flagged as delayed load.
  94738. * @hidden
  94739. */
  94740. delayLoad(): void;
  94741. private _prepareRowForTextureGeneration;
  94742. /**
  94743. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94744. * @returns the transform matrix of the texture.
  94745. */
  94746. getTextureMatrix(uBase?: number): Matrix;
  94747. /**
  94748. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94749. * @returns The reflection texture transform
  94750. */
  94751. getReflectionTextureMatrix(): Matrix;
  94752. /**
  94753. * Clones the texture.
  94754. * @returns the cloned texture
  94755. */
  94756. clone(): Texture;
  94757. /**
  94758. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94759. * @returns The JSON representation of the texture
  94760. */
  94761. serialize(): any;
  94762. /**
  94763. * Get the current class name of the texture useful for serialization or dynamic coding.
  94764. * @returns "Texture"
  94765. */
  94766. getClassName(): string;
  94767. /**
  94768. * Dispose the texture and release its associated resources.
  94769. */
  94770. dispose(): void;
  94771. /**
  94772. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94773. * @param parsedTexture Define the JSON representation of the texture
  94774. * @param scene Define the scene the parsed texture should be instantiated in
  94775. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94776. * @returns The parsed texture if successful
  94777. */
  94778. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94779. /**
  94780. * Creates a texture from its base 64 representation.
  94781. * @param data Define the base64 payload without the data: prefix
  94782. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94783. * @param scene Define the scene the texture should belong to
  94784. * @param noMipmap Forces the texture to not create mip map information if true
  94785. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94786. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94787. * @param onLoad define a callback triggered when the texture has been loaded
  94788. * @param onError define a callback triggered when an error occurred during the loading session
  94789. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94790. * @returns the created texture
  94791. */
  94792. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94793. /**
  94794. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94795. * @param data Define the base64 payload without the data: prefix
  94796. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94797. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94798. * @param scene Define the scene the texture should belong to
  94799. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94800. * @param noMipmap Forces the texture to not create mip map information if true
  94801. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94802. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94803. * @param onLoad define a callback triggered when the texture has been loaded
  94804. * @param onError define a callback triggered when an error occurred during the loading session
  94805. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94806. * @returns the created texture
  94807. */
  94808. 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;
  94809. }
  94810. }
  94811. declare module BABYLON {
  94812. /**
  94813. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94814. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94815. */
  94816. export class PostProcessManager {
  94817. private _scene;
  94818. private _indexBuffer;
  94819. private _vertexBuffers;
  94820. /**
  94821. * Creates a new instance PostProcess
  94822. * @param scene The scene that the post process is associated with.
  94823. */
  94824. constructor(scene: Scene);
  94825. private _prepareBuffers;
  94826. private _buildIndexBuffer;
  94827. /**
  94828. * Rebuilds the vertex buffers of the manager.
  94829. * @hidden
  94830. */
  94831. _rebuild(): void;
  94832. /**
  94833. * Prepares a frame to be run through a post process.
  94834. * @param sourceTexture The input texture to the post procesess. (default: null)
  94835. * @param postProcesses An array of post processes to be run. (default: null)
  94836. * @returns True if the post processes were able to be run.
  94837. * @hidden
  94838. */
  94839. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94840. /**
  94841. * Manually render a set of post processes to a texture.
  94842. * @param postProcesses An array of post processes to be run.
  94843. * @param targetTexture The target texture to render to.
  94844. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94845. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94846. * @param lodLevel defines which lod of the texture to render to
  94847. */
  94848. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94849. /**
  94850. * Finalize the result of the output of the postprocesses.
  94851. * @param doNotPresent If true the result will not be displayed to the screen.
  94852. * @param targetTexture The target texture to render to.
  94853. * @param faceIndex The index of the face to bind the target texture to.
  94854. * @param postProcesses The array of post processes to render.
  94855. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94856. * @hidden
  94857. */
  94858. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94859. /**
  94860. * Disposes of the post process manager.
  94861. */
  94862. dispose(): void;
  94863. }
  94864. }
  94865. declare module BABYLON {
  94866. /**
  94867. * This Helps creating a texture that will be created from a camera in your scene.
  94868. * It is basically a dynamic texture that could be used to create special effects for instance.
  94869. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94870. */
  94871. export class RenderTargetTexture extends Texture {
  94872. isCube: boolean;
  94873. /**
  94874. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94875. */
  94876. static readonly REFRESHRATE_RENDER_ONCE: number;
  94877. /**
  94878. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94879. */
  94880. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94881. /**
  94882. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94883. * the central point of your effect and can save a lot of performances.
  94884. */
  94885. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94886. /**
  94887. * Use this predicate to dynamically define the list of mesh you want to render.
  94888. * If set, the renderList property will be overwritten.
  94889. */
  94890. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94891. private _renderList;
  94892. /**
  94893. * Use this list to define the list of mesh you want to render.
  94894. */
  94895. get renderList(): Nullable<Array<AbstractMesh>>;
  94896. set renderList(value: Nullable<Array<AbstractMesh>>);
  94897. /**
  94898. * Use this function to overload the renderList array at rendering time.
  94899. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94900. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94901. * the cube (if the RTT is a cube, else layerOrFace=0).
  94902. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94903. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94904. * hold dummy elements!
  94905. */
  94906. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94907. private _hookArray;
  94908. /**
  94909. * Define if particles should be rendered in your texture.
  94910. */
  94911. renderParticles: boolean;
  94912. /**
  94913. * Define if sprites should be rendered in your texture.
  94914. */
  94915. renderSprites: boolean;
  94916. /**
  94917. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94918. */
  94919. coordinatesMode: number;
  94920. /**
  94921. * Define the camera used to render the texture.
  94922. */
  94923. activeCamera: Nullable<Camera>;
  94924. /**
  94925. * Override the mesh isReady function with your own one.
  94926. */
  94927. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94928. /**
  94929. * Override the render function of the texture with your own one.
  94930. */
  94931. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94932. /**
  94933. * Define if camera post processes should be use while rendering the texture.
  94934. */
  94935. useCameraPostProcesses: boolean;
  94936. /**
  94937. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94938. */
  94939. ignoreCameraViewport: boolean;
  94940. private _postProcessManager;
  94941. private _postProcesses;
  94942. private _resizeObserver;
  94943. /**
  94944. * An event triggered when the texture is unbind.
  94945. */
  94946. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94947. /**
  94948. * An event triggered when the texture is unbind.
  94949. */
  94950. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94951. private _onAfterUnbindObserver;
  94952. /**
  94953. * Set a after unbind callback in the texture.
  94954. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94955. */
  94956. set onAfterUnbind(callback: () => void);
  94957. /**
  94958. * An event triggered before rendering the texture
  94959. */
  94960. onBeforeRenderObservable: Observable<number>;
  94961. private _onBeforeRenderObserver;
  94962. /**
  94963. * Set a before render callback in the texture.
  94964. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94965. */
  94966. set onBeforeRender(callback: (faceIndex: number) => void);
  94967. /**
  94968. * An event triggered after rendering the texture
  94969. */
  94970. onAfterRenderObservable: Observable<number>;
  94971. private _onAfterRenderObserver;
  94972. /**
  94973. * Set a after render callback in the texture.
  94974. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94975. */
  94976. set onAfterRender(callback: (faceIndex: number) => void);
  94977. /**
  94978. * An event triggered after the texture clear
  94979. */
  94980. onClearObservable: Observable<Engine>;
  94981. private _onClearObserver;
  94982. /**
  94983. * Set a clear callback in the texture.
  94984. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94985. */
  94986. set onClear(callback: (Engine: Engine) => void);
  94987. /**
  94988. * An event triggered when the texture is resized.
  94989. */
  94990. onResizeObservable: Observable<RenderTargetTexture>;
  94991. /**
  94992. * Define the clear color of the Render Target if it should be different from the scene.
  94993. */
  94994. clearColor: Color4;
  94995. protected _size: number | {
  94996. width: number;
  94997. height: number;
  94998. layers?: number;
  94999. };
  95000. protected _initialSizeParameter: number | {
  95001. width: number;
  95002. height: number;
  95003. } | {
  95004. ratio: number;
  95005. };
  95006. protected _sizeRatio: Nullable<number>;
  95007. /** @hidden */
  95008. _generateMipMaps: boolean;
  95009. protected _renderingManager: RenderingManager;
  95010. /** @hidden */
  95011. _waitingRenderList: string[];
  95012. protected _doNotChangeAspectRatio: boolean;
  95013. protected _currentRefreshId: number;
  95014. protected _refreshRate: number;
  95015. protected _textureMatrix: Matrix;
  95016. protected _samples: number;
  95017. protected _renderTargetOptions: RenderTargetCreationOptions;
  95018. /**
  95019. * Gets render target creation options that were used.
  95020. */
  95021. get renderTargetOptions(): RenderTargetCreationOptions;
  95022. protected _engine: Engine;
  95023. protected _onRatioRescale(): void;
  95024. /**
  95025. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95026. * It must define where the camera used to render the texture is set
  95027. */
  95028. boundingBoxPosition: Vector3;
  95029. private _boundingBoxSize;
  95030. /**
  95031. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95032. * When defined, the cubemap will switch to local mode
  95033. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95034. * @example https://www.babylonjs-playground.com/#RNASML
  95035. */
  95036. set boundingBoxSize(value: Vector3);
  95037. get boundingBoxSize(): Vector3;
  95038. /**
  95039. * In case the RTT has been created with a depth texture, get the associated
  95040. * depth texture.
  95041. * Otherwise, return null.
  95042. */
  95043. get depthStencilTexture(): Nullable<InternalTexture>;
  95044. /**
  95045. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95046. * or used a shadow, depth texture...
  95047. * @param name The friendly name of the texture
  95048. * @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)
  95049. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95050. * @param generateMipMaps True if mip maps need to be generated after render.
  95051. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95052. * @param type The type of the buffer in the RTT (int, half float, float...)
  95053. * @param isCube True if a cube texture needs to be created
  95054. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95055. * @param generateDepthBuffer True to generate a depth buffer
  95056. * @param generateStencilBuffer True to generate a stencil buffer
  95057. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95058. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95059. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95060. */
  95061. constructor(name: string, size: number | {
  95062. width: number;
  95063. height: number;
  95064. layers?: number;
  95065. } | {
  95066. ratio: number;
  95067. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95068. /**
  95069. * Creates a depth stencil texture.
  95070. * This is only available in WebGL 2 or with the depth texture extension available.
  95071. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95072. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95073. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95074. */
  95075. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95076. private _processSizeParameter;
  95077. /**
  95078. * Define the number of samples to use in case of MSAA.
  95079. * It defaults to one meaning no MSAA has been enabled.
  95080. */
  95081. get samples(): number;
  95082. set samples(value: number);
  95083. /**
  95084. * Resets the refresh counter of the texture and start bak from scratch.
  95085. * Could be useful to regenerate the texture if it is setup to render only once.
  95086. */
  95087. resetRefreshCounter(): void;
  95088. /**
  95089. * Define the refresh rate of the texture or the rendering frequency.
  95090. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95091. */
  95092. get refreshRate(): number;
  95093. set refreshRate(value: number);
  95094. /**
  95095. * Adds a post process to the render target rendering passes.
  95096. * @param postProcess define the post process to add
  95097. */
  95098. addPostProcess(postProcess: PostProcess): void;
  95099. /**
  95100. * Clear all the post processes attached to the render target
  95101. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95102. */
  95103. clearPostProcesses(dispose?: boolean): void;
  95104. /**
  95105. * Remove one of the post process from the list of attached post processes to the texture
  95106. * @param postProcess define the post process to remove from the list
  95107. */
  95108. removePostProcess(postProcess: PostProcess): void;
  95109. /** @hidden */
  95110. _shouldRender(): boolean;
  95111. /**
  95112. * Gets the actual render size of the texture.
  95113. * @returns the width of the render size
  95114. */
  95115. getRenderSize(): number;
  95116. /**
  95117. * Gets the actual render width of the texture.
  95118. * @returns the width of the render size
  95119. */
  95120. getRenderWidth(): number;
  95121. /**
  95122. * Gets the actual render height of the texture.
  95123. * @returns the height of the render size
  95124. */
  95125. getRenderHeight(): number;
  95126. /**
  95127. * Gets the actual number of layers of the texture.
  95128. * @returns the number of layers
  95129. */
  95130. getRenderLayers(): number;
  95131. /**
  95132. * Get if the texture can be rescaled or not.
  95133. */
  95134. get canRescale(): boolean;
  95135. /**
  95136. * Resize the texture using a ratio.
  95137. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95138. */
  95139. scale(ratio: number): void;
  95140. /**
  95141. * Get the texture reflection matrix used to rotate/transform the reflection.
  95142. * @returns the reflection matrix
  95143. */
  95144. getReflectionTextureMatrix(): Matrix;
  95145. /**
  95146. * Resize the texture to a new desired size.
  95147. * Be carrefull as it will recreate all the data in the new texture.
  95148. * @param size Define the new size. It can be:
  95149. * - a number for squared texture,
  95150. * - an object containing { width: number, height: number }
  95151. * - or an object containing a ratio { ratio: number }
  95152. */
  95153. resize(size: number | {
  95154. width: number;
  95155. height: number;
  95156. } | {
  95157. ratio: number;
  95158. }): void;
  95159. private _defaultRenderListPrepared;
  95160. /**
  95161. * Renders all the objects from the render list into the texture.
  95162. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95163. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95164. */
  95165. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95166. private _bestReflectionRenderTargetDimension;
  95167. private _prepareRenderingManager;
  95168. /**
  95169. * @hidden
  95170. * @param faceIndex face index to bind to if this is a cubetexture
  95171. * @param layer defines the index of the texture to bind in the array
  95172. */
  95173. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95174. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95175. private renderToTarget;
  95176. /**
  95177. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95178. * This allowed control for front to back rendering or reversly depending of the special needs.
  95179. *
  95180. * @param renderingGroupId The rendering group id corresponding to its index
  95181. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95182. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95183. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95184. */
  95185. 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;
  95186. /**
  95187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95188. *
  95189. * @param renderingGroupId The rendering group id corresponding to its index
  95190. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95191. */
  95192. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95193. /**
  95194. * Clones the texture.
  95195. * @returns the cloned texture
  95196. */
  95197. clone(): RenderTargetTexture;
  95198. /**
  95199. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95200. * @returns The JSON representation of the texture
  95201. */
  95202. serialize(): any;
  95203. /**
  95204. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95205. */
  95206. disposeFramebufferObjects(): void;
  95207. /**
  95208. * Dispose the texture and release its associated resources.
  95209. */
  95210. dispose(): void;
  95211. /** @hidden */
  95212. _rebuild(): void;
  95213. /**
  95214. * Clear the info related to rendering groups preventing retention point in material dispose.
  95215. */
  95216. freeRenderingGroups(): void;
  95217. /**
  95218. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95219. * @returns the view count
  95220. */
  95221. getViewCount(): number;
  95222. }
  95223. }
  95224. declare module BABYLON {
  95225. /**
  95226. * Options for compiling materials.
  95227. */
  95228. export interface IMaterialCompilationOptions {
  95229. /**
  95230. * Defines whether clip planes are enabled.
  95231. */
  95232. clipPlane: boolean;
  95233. /**
  95234. * Defines whether instances are enabled.
  95235. */
  95236. useInstances: boolean;
  95237. }
  95238. /**
  95239. * Base class for the main features of a material in Babylon.js
  95240. */
  95241. export class Material implements IAnimatable {
  95242. /**
  95243. * Returns the triangle fill mode
  95244. */
  95245. static readonly TriangleFillMode: number;
  95246. /**
  95247. * Returns the wireframe mode
  95248. */
  95249. static readonly WireFrameFillMode: number;
  95250. /**
  95251. * Returns the point fill mode
  95252. */
  95253. static readonly PointFillMode: number;
  95254. /**
  95255. * Returns the point list draw mode
  95256. */
  95257. static readonly PointListDrawMode: number;
  95258. /**
  95259. * Returns the line list draw mode
  95260. */
  95261. static readonly LineListDrawMode: number;
  95262. /**
  95263. * Returns the line loop draw mode
  95264. */
  95265. static readonly LineLoopDrawMode: number;
  95266. /**
  95267. * Returns the line strip draw mode
  95268. */
  95269. static readonly LineStripDrawMode: number;
  95270. /**
  95271. * Returns the triangle strip draw mode
  95272. */
  95273. static readonly TriangleStripDrawMode: number;
  95274. /**
  95275. * Returns the triangle fan draw mode
  95276. */
  95277. static readonly TriangleFanDrawMode: number;
  95278. /**
  95279. * Stores the clock-wise side orientation
  95280. */
  95281. static readonly ClockWiseSideOrientation: number;
  95282. /**
  95283. * Stores the counter clock-wise side orientation
  95284. */
  95285. static readonly CounterClockWiseSideOrientation: number;
  95286. /**
  95287. * The dirty texture flag value
  95288. */
  95289. static readonly TextureDirtyFlag: number;
  95290. /**
  95291. * The dirty light flag value
  95292. */
  95293. static readonly LightDirtyFlag: number;
  95294. /**
  95295. * The dirty fresnel flag value
  95296. */
  95297. static readonly FresnelDirtyFlag: number;
  95298. /**
  95299. * The dirty attribute flag value
  95300. */
  95301. static readonly AttributesDirtyFlag: number;
  95302. /**
  95303. * The dirty misc flag value
  95304. */
  95305. static readonly MiscDirtyFlag: number;
  95306. /**
  95307. * The all dirty flag value
  95308. */
  95309. static readonly AllDirtyFlag: number;
  95310. /**
  95311. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95312. */
  95313. static readonly MATERIAL_OPAQUE: number;
  95314. /**
  95315. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95316. */
  95317. static readonly MATERIAL_ALPHATEST: number;
  95318. /**
  95319. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95320. */
  95321. static readonly MATERIAL_ALPHABLEND: number;
  95322. /**
  95323. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95324. * They are also discarded below the alpha cutoff threshold to improve performances.
  95325. */
  95326. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95327. /**
  95328. * The ID of the material
  95329. */
  95330. id: string;
  95331. /**
  95332. * Gets or sets the unique id of the material
  95333. */
  95334. uniqueId: number;
  95335. /**
  95336. * The name of the material
  95337. */
  95338. name: string;
  95339. /**
  95340. * Gets or sets user defined metadata
  95341. */
  95342. metadata: any;
  95343. /**
  95344. * For internal use only. Please do not use.
  95345. */
  95346. reservedDataStore: any;
  95347. /**
  95348. * Specifies if the ready state should be checked on each call
  95349. */
  95350. checkReadyOnEveryCall: boolean;
  95351. /**
  95352. * Specifies if the ready state should be checked once
  95353. */
  95354. checkReadyOnlyOnce: boolean;
  95355. /**
  95356. * The state of the material
  95357. */
  95358. state: string;
  95359. /**
  95360. * The alpha value of the material
  95361. */
  95362. protected _alpha: number;
  95363. /**
  95364. * List of inspectable custom properties (used by the Inspector)
  95365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95366. */
  95367. inspectableCustomProperties: IInspectable[];
  95368. /**
  95369. * Sets the alpha value of the material
  95370. */
  95371. set alpha(value: number);
  95372. /**
  95373. * Gets the alpha value of the material
  95374. */
  95375. get alpha(): number;
  95376. /**
  95377. * Specifies if back face culling is enabled
  95378. */
  95379. protected _backFaceCulling: boolean;
  95380. /**
  95381. * Sets the back-face culling state
  95382. */
  95383. set backFaceCulling(value: boolean);
  95384. /**
  95385. * Gets the back-face culling state
  95386. */
  95387. get backFaceCulling(): boolean;
  95388. /**
  95389. * Stores the value for side orientation
  95390. */
  95391. sideOrientation: number;
  95392. /**
  95393. * Callback triggered when the material is compiled
  95394. */
  95395. onCompiled: Nullable<(effect: Effect) => void>;
  95396. /**
  95397. * Callback triggered when an error occurs
  95398. */
  95399. onError: Nullable<(effect: Effect, errors: string) => void>;
  95400. /**
  95401. * Callback triggered to get the render target textures
  95402. */
  95403. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95404. /**
  95405. * Gets a boolean indicating that current material needs to register RTT
  95406. */
  95407. get hasRenderTargetTextures(): boolean;
  95408. /**
  95409. * Specifies if the material should be serialized
  95410. */
  95411. doNotSerialize: boolean;
  95412. /**
  95413. * @hidden
  95414. */
  95415. _storeEffectOnSubMeshes: boolean;
  95416. /**
  95417. * Stores the animations for the material
  95418. */
  95419. animations: Nullable<Array<Animation>>;
  95420. /**
  95421. * An event triggered when the material is disposed
  95422. */
  95423. onDisposeObservable: Observable<Material>;
  95424. /**
  95425. * An observer which watches for dispose events
  95426. */
  95427. private _onDisposeObserver;
  95428. private _onUnBindObservable;
  95429. /**
  95430. * Called during a dispose event
  95431. */
  95432. set onDispose(callback: () => void);
  95433. private _onBindObservable;
  95434. /**
  95435. * An event triggered when the material is bound
  95436. */
  95437. get onBindObservable(): Observable<AbstractMesh>;
  95438. /**
  95439. * An observer which watches for bind events
  95440. */
  95441. private _onBindObserver;
  95442. /**
  95443. * Called during a bind event
  95444. */
  95445. set onBind(callback: (Mesh: AbstractMesh) => void);
  95446. /**
  95447. * An event triggered when the material is unbound
  95448. */
  95449. get onUnBindObservable(): Observable<Material>;
  95450. /**
  95451. * Stores the value of the alpha mode
  95452. */
  95453. private _alphaMode;
  95454. /**
  95455. * Sets the value of the alpha mode.
  95456. *
  95457. * | Value | Type | Description |
  95458. * | --- | --- | --- |
  95459. * | 0 | ALPHA_DISABLE | |
  95460. * | 1 | ALPHA_ADD | |
  95461. * | 2 | ALPHA_COMBINE | |
  95462. * | 3 | ALPHA_SUBTRACT | |
  95463. * | 4 | ALPHA_MULTIPLY | |
  95464. * | 5 | ALPHA_MAXIMIZED | |
  95465. * | 6 | ALPHA_ONEONE | |
  95466. * | 7 | ALPHA_PREMULTIPLIED | |
  95467. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95468. * | 9 | ALPHA_INTERPOLATE | |
  95469. * | 10 | ALPHA_SCREENMODE | |
  95470. *
  95471. */
  95472. set alphaMode(value: number);
  95473. /**
  95474. * Gets the value of the alpha mode
  95475. */
  95476. get alphaMode(): number;
  95477. /**
  95478. * Stores the state of the need depth pre-pass value
  95479. */
  95480. private _needDepthPrePass;
  95481. /**
  95482. * Sets the need depth pre-pass value
  95483. */
  95484. set needDepthPrePass(value: boolean);
  95485. /**
  95486. * Gets the depth pre-pass value
  95487. */
  95488. get needDepthPrePass(): boolean;
  95489. /**
  95490. * Specifies if depth writing should be disabled
  95491. */
  95492. disableDepthWrite: boolean;
  95493. /**
  95494. * Specifies if depth writing should be forced
  95495. */
  95496. forceDepthWrite: boolean;
  95497. /**
  95498. * Specifies the depth function that should be used. 0 means the default engine function
  95499. */
  95500. depthFunction: number;
  95501. /**
  95502. * Specifies if there should be a separate pass for culling
  95503. */
  95504. separateCullingPass: boolean;
  95505. /**
  95506. * Stores the state specifing if fog should be enabled
  95507. */
  95508. private _fogEnabled;
  95509. /**
  95510. * Sets the state for enabling fog
  95511. */
  95512. set fogEnabled(value: boolean);
  95513. /**
  95514. * Gets the value of the fog enabled state
  95515. */
  95516. get fogEnabled(): boolean;
  95517. /**
  95518. * Stores the size of points
  95519. */
  95520. pointSize: number;
  95521. /**
  95522. * Stores the z offset value
  95523. */
  95524. zOffset: number;
  95525. /**
  95526. * Gets a value specifying if wireframe mode is enabled
  95527. */
  95528. get wireframe(): boolean;
  95529. /**
  95530. * Sets the state of wireframe mode
  95531. */
  95532. set wireframe(value: boolean);
  95533. /**
  95534. * Gets the value specifying if point clouds are enabled
  95535. */
  95536. get pointsCloud(): boolean;
  95537. /**
  95538. * Sets the state of point cloud mode
  95539. */
  95540. set pointsCloud(value: boolean);
  95541. /**
  95542. * Gets the material fill mode
  95543. */
  95544. get fillMode(): number;
  95545. /**
  95546. * Sets the material fill mode
  95547. */
  95548. set fillMode(value: number);
  95549. /**
  95550. * @hidden
  95551. * Stores the effects for the material
  95552. */
  95553. _effect: Nullable<Effect>;
  95554. /**
  95555. * Specifies if uniform buffers should be used
  95556. */
  95557. private _useUBO;
  95558. /**
  95559. * Stores a reference to the scene
  95560. */
  95561. private _scene;
  95562. /**
  95563. * Stores the fill mode state
  95564. */
  95565. private _fillMode;
  95566. /**
  95567. * Specifies if the depth write state should be cached
  95568. */
  95569. private _cachedDepthWriteState;
  95570. /**
  95571. * Specifies if the depth function state should be cached
  95572. */
  95573. private _cachedDepthFunctionState;
  95574. /**
  95575. * Stores the uniform buffer
  95576. */
  95577. protected _uniformBuffer: UniformBuffer;
  95578. /** @hidden */
  95579. _indexInSceneMaterialArray: number;
  95580. /** @hidden */
  95581. meshMap: Nullable<{
  95582. [id: string]: AbstractMesh | undefined;
  95583. }>;
  95584. /**
  95585. * Creates a material instance
  95586. * @param name defines the name of the material
  95587. * @param scene defines the scene to reference
  95588. * @param doNotAdd specifies if the material should be added to the scene
  95589. */
  95590. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95591. /**
  95592. * Returns a string representation of the current material
  95593. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95594. * @returns a string with material information
  95595. */
  95596. toString(fullDetails?: boolean): string;
  95597. /**
  95598. * Gets the class name of the material
  95599. * @returns a string with the class name of the material
  95600. */
  95601. getClassName(): string;
  95602. /**
  95603. * Specifies if updates for the material been locked
  95604. */
  95605. get isFrozen(): boolean;
  95606. /**
  95607. * Locks updates for the material
  95608. */
  95609. freeze(): void;
  95610. /**
  95611. * Unlocks updates for the material
  95612. */
  95613. unfreeze(): void;
  95614. /**
  95615. * Specifies if the material is ready to be used
  95616. * @param mesh defines the mesh to check
  95617. * @param useInstances specifies if instances should be used
  95618. * @returns a boolean indicating if the material is ready to be used
  95619. */
  95620. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95621. /**
  95622. * Specifies that the submesh is ready to be used
  95623. * @param mesh defines the mesh to check
  95624. * @param subMesh defines which submesh to check
  95625. * @param useInstances specifies that instances should be used
  95626. * @returns a boolean indicating that the submesh is ready or not
  95627. */
  95628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95629. /**
  95630. * Returns the material effect
  95631. * @returns the effect associated with the material
  95632. */
  95633. getEffect(): Nullable<Effect>;
  95634. /**
  95635. * Returns the current scene
  95636. * @returns a Scene
  95637. */
  95638. getScene(): Scene;
  95639. /**
  95640. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95641. */
  95642. protected _forceAlphaTest: boolean;
  95643. /**
  95644. * The transparency mode of the material.
  95645. */
  95646. protected _transparencyMode: Nullable<number>;
  95647. /**
  95648. * Gets the current transparency mode.
  95649. */
  95650. get transparencyMode(): Nullable<number>;
  95651. /**
  95652. * Sets the transparency mode of the material.
  95653. *
  95654. * | Value | Type | Description |
  95655. * | ----- | ----------------------------------- | ----------- |
  95656. * | 0 | OPAQUE | |
  95657. * | 1 | ALPHATEST | |
  95658. * | 2 | ALPHABLEND | |
  95659. * | 3 | ALPHATESTANDBLEND | |
  95660. *
  95661. */
  95662. set transparencyMode(value: Nullable<number>);
  95663. /**
  95664. * Returns true if alpha blending should be disabled.
  95665. */
  95666. protected get _disableAlphaBlending(): boolean;
  95667. /**
  95668. * Specifies whether or not this material should be rendered in alpha blend mode.
  95669. * @returns a boolean specifying if alpha blending is needed
  95670. */
  95671. needAlphaBlending(): boolean;
  95672. /**
  95673. * Specifies if the mesh will require alpha blending
  95674. * @param mesh defines the mesh to check
  95675. * @returns a boolean specifying if alpha blending is needed for the mesh
  95676. */
  95677. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95678. /**
  95679. * Specifies whether or not this material should be rendered in alpha test mode.
  95680. * @returns a boolean specifying if an alpha test is needed.
  95681. */
  95682. needAlphaTesting(): boolean;
  95683. /**
  95684. * Specifies if material alpha testing should be turned on for the mesh
  95685. * @param mesh defines the mesh to check
  95686. */
  95687. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95688. /**
  95689. * Gets the texture used for the alpha test
  95690. * @returns the texture to use for alpha testing
  95691. */
  95692. getAlphaTestTexture(): Nullable<BaseTexture>;
  95693. /**
  95694. * Marks the material to indicate that it needs to be re-calculated
  95695. */
  95696. markDirty(): void;
  95697. /** @hidden */
  95698. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95699. /**
  95700. * Binds the material to the mesh
  95701. * @param world defines the world transformation matrix
  95702. * @param mesh defines the mesh to bind the material to
  95703. */
  95704. bind(world: Matrix, mesh?: Mesh): void;
  95705. /**
  95706. * Binds the submesh to the material
  95707. * @param world defines the world transformation matrix
  95708. * @param mesh defines the mesh containing the submesh
  95709. * @param subMesh defines the submesh to bind the material to
  95710. */
  95711. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95712. /**
  95713. * Binds the world matrix to the material
  95714. * @param world defines the world transformation matrix
  95715. */
  95716. bindOnlyWorldMatrix(world: Matrix): void;
  95717. /**
  95718. * Binds the scene's uniform buffer to the effect.
  95719. * @param effect defines the effect to bind to the scene uniform buffer
  95720. * @param sceneUbo defines the uniform buffer storing scene data
  95721. */
  95722. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95723. /**
  95724. * Binds the view matrix to the effect
  95725. * @param effect defines the effect to bind the view matrix to
  95726. */
  95727. bindView(effect: Effect): void;
  95728. /**
  95729. * Binds the view projection matrix to the effect
  95730. * @param effect defines the effect to bind the view projection matrix to
  95731. */
  95732. bindViewProjection(effect: Effect): void;
  95733. /**
  95734. * Processes to execute after binding the material to a mesh
  95735. * @param mesh defines the rendered mesh
  95736. */
  95737. protected _afterBind(mesh?: Mesh): void;
  95738. /**
  95739. * Unbinds the material from the mesh
  95740. */
  95741. unbind(): void;
  95742. /**
  95743. * Gets the active textures from the material
  95744. * @returns an array of textures
  95745. */
  95746. getActiveTextures(): BaseTexture[];
  95747. /**
  95748. * Specifies if the material uses a texture
  95749. * @param texture defines the texture to check against the material
  95750. * @returns a boolean specifying if the material uses the texture
  95751. */
  95752. hasTexture(texture: BaseTexture): boolean;
  95753. /**
  95754. * Makes a duplicate of the material, and gives it a new name
  95755. * @param name defines the new name for the duplicated material
  95756. * @returns the cloned material
  95757. */
  95758. clone(name: string): Nullable<Material>;
  95759. /**
  95760. * Gets the meshes bound to the material
  95761. * @returns an array of meshes bound to the material
  95762. */
  95763. getBindedMeshes(): AbstractMesh[];
  95764. /**
  95765. * Force shader compilation
  95766. * @param mesh defines the mesh associated with this material
  95767. * @param onCompiled defines a function to execute once the material is compiled
  95768. * @param options defines the options to configure the compilation
  95769. * @param onError defines a function to execute if the material fails compiling
  95770. */
  95771. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95772. /**
  95773. * Force shader compilation
  95774. * @param mesh defines the mesh that will use this material
  95775. * @param options defines additional options for compiling the shaders
  95776. * @returns a promise that resolves when the compilation completes
  95777. */
  95778. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95779. private static readonly _AllDirtyCallBack;
  95780. private static readonly _ImageProcessingDirtyCallBack;
  95781. private static readonly _TextureDirtyCallBack;
  95782. private static readonly _FresnelDirtyCallBack;
  95783. private static readonly _MiscDirtyCallBack;
  95784. private static readonly _LightsDirtyCallBack;
  95785. private static readonly _AttributeDirtyCallBack;
  95786. private static _FresnelAndMiscDirtyCallBack;
  95787. private static _TextureAndMiscDirtyCallBack;
  95788. private static readonly _DirtyCallbackArray;
  95789. private static readonly _RunDirtyCallBacks;
  95790. /**
  95791. * Marks a define in the material to indicate that it needs to be re-computed
  95792. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95793. */
  95794. markAsDirty(flag: number): void;
  95795. /**
  95796. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95797. * @param func defines a function which checks material defines against the submeshes
  95798. */
  95799. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95800. /**
  95801. * Indicates that we need to re-calculated for all submeshes
  95802. */
  95803. protected _markAllSubMeshesAsAllDirty(): void;
  95804. /**
  95805. * Indicates that image processing needs to be re-calculated for all submeshes
  95806. */
  95807. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95808. /**
  95809. * Indicates that textures need to be re-calculated for all submeshes
  95810. */
  95811. protected _markAllSubMeshesAsTexturesDirty(): void;
  95812. /**
  95813. * Indicates that fresnel needs to be re-calculated for all submeshes
  95814. */
  95815. protected _markAllSubMeshesAsFresnelDirty(): void;
  95816. /**
  95817. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95818. */
  95819. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95820. /**
  95821. * Indicates that lights need to be re-calculated for all submeshes
  95822. */
  95823. protected _markAllSubMeshesAsLightsDirty(): void;
  95824. /**
  95825. * Indicates that attributes need to be re-calculated for all submeshes
  95826. */
  95827. protected _markAllSubMeshesAsAttributesDirty(): void;
  95828. /**
  95829. * Indicates that misc needs to be re-calculated for all submeshes
  95830. */
  95831. protected _markAllSubMeshesAsMiscDirty(): void;
  95832. /**
  95833. * Indicates that textures and misc need to be re-calculated for all submeshes
  95834. */
  95835. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95836. /**
  95837. * Disposes the material
  95838. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95839. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95840. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95841. */
  95842. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95843. /** @hidden */
  95844. private releaseVertexArrayObject;
  95845. /**
  95846. * Serializes this material
  95847. * @returns the serialized material object
  95848. */
  95849. serialize(): any;
  95850. /**
  95851. * Creates a material from parsed material data
  95852. * @param parsedMaterial defines parsed material data
  95853. * @param scene defines the hosting scene
  95854. * @param rootUrl defines the root URL to use to load textures
  95855. * @returns a new material
  95856. */
  95857. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95858. }
  95859. }
  95860. declare module BABYLON {
  95861. /**
  95862. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95863. * separate meshes. This can be use to improve performances.
  95864. * @see http://doc.babylonjs.com/how_to/multi_materials
  95865. */
  95866. export class MultiMaterial extends Material {
  95867. private _subMaterials;
  95868. /**
  95869. * Gets or Sets the list of Materials used within the multi material.
  95870. * They need to be ordered according to the submeshes order in the associated mesh
  95871. */
  95872. get subMaterials(): Nullable<Material>[];
  95873. set subMaterials(value: Nullable<Material>[]);
  95874. /**
  95875. * Function used to align with Node.getChildren()
  95876. * @returns the list of Materials used within the multi material
  95877. */
  95878. getChildren(): Nullable<Material>[];
  95879. /**
  95880. * Instantiates a new Multi Material
  95881. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95882. * separate meshes. This can be use to improve performances.
  95883. * @see http://doc.babylonjs.com/how_to/multi_materials
  95884. * @param name Define the name in the scene
  95885. * @param scene Define the scene the material belongs to
  95886. */
  95887. constructor(name: string, scene: Scene);
  95888. private _hookArray;
  95889. /**
  95890. * Get one of the submaterial by its index in the submaterials array
  95891. * @param index The index to look the sub material at
  95892. * @returns The Material if the index has been defined
  95893. */
  95894. getSubMaterial(index: number): Nullable<Material>;
  95895. /**
  95896. * Get the list of active textures for the whole sub materials list.
  95897. * @returns All the textures that will be used during the rendering
  95898. */
  95899. getActiveTextures(): BaseTexture[];
  95900. /**
  95901. * Gets the current class name of the material e.g. "MultiMaterial"
  95902. * Mainly use in serialization.
  95903. * @returns the class name
  95904. */
  95905. getClassName(): string;
  95906. /**
  95907. * Checks if the material is ready to render the requested sub mesh
  95908. * @param mesh Define the mesh the submesh belongs to
  95909. * @param subMesh Define the sub mesh to look readyness for
  95910. * @param useInstances Define whether or not the material is used with instances
  95911. * @returns true if ready, otherwise false
  95912. */
  95913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95914. /**
  95915. * Clones the current material and its related sub materials
  95916. * @param name Define the name of the newly cloned material
  95917. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95918. * @returns the cloned material
  95919. */
  95920. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95921. /**
  95922. * Serializes the materials into a JSON representation.
  95923. * @returns the JSON representation
  95924. */
  95925. serialize(): any;
  95926. /**
  95927. * Dispose the material and release its associated resources
  95928. * @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)
  95929. * @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)
  95930. * @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)
  95931. */
  95932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95933. /**
  95934. * Creates a MultiMaterial from parsed MultiMaterial data.
  95935. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95936. * @param scene defines the hosting scene
  95937. * @returns a new MultiMaterial
  95938. */
  95939. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95940. }
  95941. }
  95942. declare module BABYLON {
  95943. /**
  95944. * Base class for submeshes
  95945. */
  95946. export class BaseSubMesh {
  95947. /** @hidden */
  95948. _materialDefines: Nullable<MaterialDefines>;
  95949. /** @hidden */
  95950. _materialEffect: Nullable<Effect>;
  95951. /**
  95952. * Gets material defines used by the effect associated to the sub mesh
  95953. */
  95954. get materialDefines(): Nullable<MaterialDefines>;
  95955. /**
  95956. * Sets material defines used by the effect associated to the sub mesh
  95957. */
  95958. set materialDefines(defines: Nullable<MaterialDefines>);
  95959. /**
  95960. * Gets associated effect
  95961. */
  95962. get effect(): Nullable<Effect>;
  95963. /**
  95964. * Sets associated effect (effect used to render this submesh)
  95965. * @param effect defines the effect to associate with
  95966. * @param defines defines the set of defines used to compile this effect
  95967. */
  95968. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95969. }
  95970. /**
  95971. * Defines a subdivision inside a mesh
  95972. */
  95973. export class SubMesh extends BaseSubMesh implements ICullable {
  95974. /** the material index to use */
  95975. materialIndex: number;
  95976. /** vertex index start */
  95977. verticesStart: number;
  95978. /** vertices count */
  95979. verticesCount: number;
  95980. /** index start */
  95981. indexStart: number;
  95982. /** indices count */
  95983. indexCount: number;
  95984. /** @hidden */
  95985. _linesIndexCount: number;
  95986. private _mesh;
  95987. private _renderingMesh;
  95988. private _boundingInfo;
  95989. private _linesIndexBuffer;
  95990. /** @hidden */
  95991. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95992. /** @hidden */
  95993. _trianglePlanes: Plane[];
  95994. /** @hidden */
  95995. _lastColliderTransformMatrix: Nullable<Matrix>;
  95996. /** @hidden */
  95997. _renderId: number;
  95998. /** @hidden */
  95999. _alphaIndex: number;
  96000. /** @hidden */
  96001. _distanceToCamera: number;
  96002. /** @hidden */
  96003. _id: number;
  96004. private _currentMaterial;
  96005. /**
  96006. * Add a new submesh to a mesh
  96007. * @param materialIndex defines the material index to use
  96008. * @param verticesStart defines vertex index start
  96009. * @param verticesCount defines vertices count
  96010. * @param indexStart defines index start
  96011. * @param indexCount defines indices count
  96012. * @param mesh defines the parent mesh
  96013. * @param renderingMesh defines an optional rendering mesh
  96014. * @param createBoundingBox defines if bounding box should be created for this submesh
  96015. * @returns the new submesh
  96016. */
  96017. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96018. /**
  96019. * Creates a new submesh
  96020. * @param materialIndex defines the material index to use
  96021. * @param verticesStart defines vertex index start
  96022. * @param verticesCount defines vertices count
  96023. * @param indexStart defines index start
  96024. * @param indexCount defines indices count
  96025. * @param mesh defines the parent mesh
  96026. * @param renderingMesh defines an optional rendering mesh
  96027. * @param createBoundingBox defines if bounding box should be created for this submesh
  96028. */
  96029. constructor(
  96030. /** the material index to use */
  96031. materialIndex: number,
  96032. /** vertex index start */
  96033. verticesStart: number,
  96034. /** vertices count */
  96035. verticesCount: number,
  96036. /** index start */
  96037. indexStart: number,
  96038. /** indices count */
  96039. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96040. /**
  96041. * Returns true if this submesh covers the entire parent mesh
  96042. * @ignorenaming
  96043. */
  96044. get IsGlobal(): boolean;
  96045. /**
  96046. * Returns the submesh BoudingInfo object
  96047. * @returns current bounding info (or mesh's one if the submesh is global)
  96048. */
  96049. getBoundingInfo(): BoundingInfo;
  96050. /**
  96051. * Sets the submesh BoundingInfo
  96052. * @param boundingInfo defines the new bounding info to use
  96053. * @returns the SubMesh
  96054. */
  96055. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96056. /**
  96057. * Returns the mesh of the current submesh
  96058. * @return the parent mesh
  96059. */
  96060. getMesh(): AbstractMesh;
  96061. /**
  96062. * Returns the rendering mesh of the submesh
  96063. * @returns the rendering mesh (could be different from parent mesh)
  96064. */
  96065. getRenderingMesh(): Mesh;
  96066. /**
  96067. * Returns the submesh material
  96068. * @returns null or the current material
  96069. */
  96070. getMaterial(): Nullable<Material>;
  96071. /**
  96072. * Sets a new updated BoundingInfo object to the submesh
  96073. * @param data defines an optional position array to use to determine the bounding info
  96074. * @returns the SubMesh
  96075. */
  96076. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96077. /** @hidden */
  96078. _checkCollision(collider: Collider): boolean;
  96079. /**
  96080. * Updates the submesh BoundingInfo
  96081. * @param world defines the world matrix to use to update the bounding info
  96082. * @returns the submesh
  96083. */
  96084. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96085. /**
  96086. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96087. * @param frustumPlanes defines the frustum planes
  96088. * @returns true if the submesh is intersecting with the frustum
  96089. */
  96090. isInFrustum(frustumPlanes: Plane[]): boolean;
  96091. /**
  96092. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96093. * @param frustumPlanes defines the frustum planes
  96094. * @returns true if the submesh is inside the frustum
  96095. */
  96096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96097. /**
  96098. * Renders the submesh
  96099. * @param enableAlphaMode defines if alpha needs to be used
  96100. * @returns the submesh
  96101. */
  96102. render(enableAlphaMode: boolean): SubMesh;
  96103. /**
  96104. * @hidden
  96105. */
  96106. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96107. /**
  96108. * Checks if the submesh intersects with a ray
  96109. * @param ray defines the ray to test
  96110. * @returns true is the passed ray intersects the submesh bounding box
  96111. */
  96112. canIntersects(ray: Ray): boolean;
  96113. /**
  96114. * Intersects current submesh with a ray
  96115. * @param ray defines the ray to test
  96116. * @param positions defines mesh's positions array
  96117. * @param indices defines mesh's indices array
  96118. * @param fastCheck defines if only bounding info should be used
  96119. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96120. * @returns intersection info or null if no intersection
  96121. */
  96122. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96123. /** @hidden */
  96124. private _intersectLines;
  96125. /** @hidden */
  96126. private _intersectUnIndexedLines;
  96127. /** @hidden */
  96128. private _intersectTriangles;
  96129. /** @hidden */
  96130. private _intersectUnIndexedTriangles;
  96131. /** @hidden */
  96132. _rebuild(): void;
  96133. /**
  96134. * Creates a new submesh from the passed mesh
  96135. * @param newMesh defines the new hosting mesh
  96136. * @param newRenderingMesh defines an optional rendering mesh
  96137. * @returns the new submesh
  96138. */
  96139. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96140. /**
  96141. * Release associated resources
  96142. */
  96143. dispose(): void;
  96144. /**
  96145. * Gets the class name
  96146. * @returns the string "SubMesh".
  96147. */
  96148. getClassName(): string;
  96149. /**
  96150. * Creates a new submesh from indices data
  96151. * @param materialIndex the index of the main mesh material
  96152. * @param startIndex the index where to start the copy in the mesh indices array
  96153. * @param indexCount the number of indices to copy then from the startIndex
  96154. * @param mesh the main mesh to create the submesh from
  96155. * @param renderingMesh the optional rendering mesh
  96156. * @returns a new submesh
  96157. */
  96158. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96159. }
  96160. }
  96161. declare module BABYLON {
  96162. /**
  96163. * Class used to represent data loading progression
  96164. */
  96165. export class SceneLoaderFlags {
  96166. private static _ForceFullSceneLoadingForIncremental;
  96167. private static _ShowLoadingScreen;
  96168. private static _CleanBoneMatrixWeights;
  96169. private static _loggingLevel;
  96170. /**
  96171. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96172. */
  96173. static get ForceFullSceneLoadingForIncremental(): boolean;
  96174. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96175. /**
  96176. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96177. */
  96178. static get ShowLoadingScreen(): boolean;
  96179. static set ShowLoadingScreen(value: boolean);
  96180. /**
  96181. * Defines the current logging level (while loading the scene)
  96182. * @ignorenaming
  96183. */
  96184. static get loggingLevel(): number;
  96185. static set loggingLevel(value: number);
  96186. /**
  96187. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96188. */
  96189. static get CleanBoneMatrixWeights(): boolean;
  96190. static set CleanBoneMatrixWeights(value: boolean);
  96191. }
  96192. }
  96193. declare module BABYLON {
  96194. /**
  96195. * Class used to store geometry data (vertex buffers + index buffer)
  96196. */
  96197. export class Geometry implements IGetSetVerticesData {
  96198. /**
  96199. * Gets or sets the ID of the geometry
  96200. */
  96201. id: string;
  96202. /**
  96203. * Gets or sets the unique ID of the geometry
  96204. */
  96205. uniqueId: number;
  96206. /**
  96207. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96208. */
  96209. delayLoadState: number;
  96210. /**
  96211. * Gets the file containing the data to load when running in delay load state
  96212. */
  96213. delayLoadingFile: Nullable<string>;
  96214. /**
  96215. * Callback called when the geometry is updated
  96216. */
  96217. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96218. private _scene;
  96219. private _engine;
  96220. private _meshes;
  96221. private _totalVertices;
  96222. /** @hidden */
  96223. _indices: IndicesArray;
  96224. /** @hidden */
  96225. _vertexBuffers: {
  96226. [key: string]: VertexBuffer;
  96227. };
  96228. private _isDisposed;
  96229. private _extend;
  96230. private _boundingBias;
  96231. /** @hidden */
  96232. _delayInfo: Array<string>;
  96233. private _indexBuffer;
  96234. private _indexBufferIsUpdatable;
  96235. /** @hidden */
  96236. _boundingInfo: Nullable<BoundingInfo>;
  96237. /** @hidden */
  96238. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96239. /** @hidden */
  96240. _softwareSkinningFrameId: number;
  96241. private _vertexArrayObjects;
  96242. private _updatable;
  96243. /** @hidden */
  96244. _positions: Nullable<Vector3[]>;
  96245. /**
  96246. * 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
  96247. */
  96248. get boundingBias(): Vector2;
  96249. /**
  96250. * 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
  96251. */
  96252. set boundingBias(value: Vector2);
  96253. /**
  96254. * Static function used to attach a new empty geometry to a mesh
  96255. * @param mesh defines the mesh to attach the geometry to
  96256. * @returns the new Geometry
  96257. */
  96258. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96259. /** Get the list of meshes using this geometry */
  96260. get meshes(): Mesh[];
  96261. /**
  96262. * Creates a new geometry
  96263. * @param id defines the unique ID
  96264. * @param scene defines the hosting scene
  96265. * @param vertexData defines the VertexData used to get geometry data
  96266. * @param updatable defines if geometry must be updatable (false by default)
  96267. * @param mesh defines the mesh that will be associated with the geometry
  96268. */
  96269. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96270. /**
  96271. * Gets the current extend of the geometry
  96272. */
  96273. get extend(): {
  96274. minimum: Vector3;
  96275. maximum: Vector3;
  96276. };
  96277. /**
  96278. * Gets the hosting scene
  96279. * @returns the hosting Scene
  96280. */
  96281. getScene(): Scene;
  96282. /**
  96283. * Gets the hosting engine
  96284. * @returns the hosting Engine
  96285. */
  96286. getEngine(): Engine;
  96287. /**
  96288. * Defines if the geometry is ready to use
  96289. * @returns true if the geometry is ready to be used
  96290. */
  96291. isReady(): boolean;
  96292. /**
  96293. * Gets a value indicating that the geometry should not be serialized
  96294. */
  96295. get doNotSerialize(): boolean;
  96296. /** @hidden */
  96297. _rebuild(): void;
  96298. /**
  96299. * Affects all geometry data in one call
  96300. * @param vertexData defines the geometry data
  96301. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96302. */
  96303. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96304. /**
  96305. * Set specific vertex data
  96306. * @param kind defines the data kind (Position, normal, etc...)
  96307. * @param data defines the vertex data to use
  96308. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96309. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96310. */
  96311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96312. /**
  96313. * Removes a specific vertex data
  96314. * @param kind defines the data kind (Position, normal, etc...)
  96315. */
  96316. removeVerticesData(kind: string): void;
  96317. /**
  96318. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96319. * @param buffer defines the vertex buffer to use
  96320. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96321. */
  96322. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96323. /**
  96324. * Update a specific vertex buffer
  96325. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96326. * It will do nothing if the buffer is not updatable
  96327. * @param kind defines the data kind (Position, normal, etc...)
  96328. * @param data defines the data to use
  96329. * @param offset defines the offset in the target buffer where to store the data
  96330. * @param useBytes set to true if the offset is in bytes
  96331. */
  96332. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96333. /**
  96334. * Update a specific vertex buffer
  96335. * This function will create a new buffer if the current one is not updatable
  96336. * @param kind defines the data kind (Position, normal, etc...)
  96337. * @param data defines the data to use
  96338. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96339. */
  96340. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96341. private _updateBoundingInfo;
  96342. /** @hidden */
  96343. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96344. /**
  96345. * Gets total number of vertices
  96346. * @returns the total number of vertices
  96347. */
  96348. getTotalVertices(): number;
  96349. /**
  96350. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96351. * @param kind defines the data kind (Position, normal, etc...)
  96352. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96353. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96354. * @returns a float array containing vertex data
  96355. */
  96356. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96357. /**
  96358. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96359. * @param kind defines the data kind (Position, normal, etc...)
  96360. * @returns true if the vertex buffer with the specified kind is updatable
  96361. */
  96362. isVertexBufferUpdatable(kind: string): boolean;
  96363. /**
  96364. * Gets a specific vertex buffer
  96365. * @param kind defines the data kind (Position, normal, etc...)
  96366. * @returns a VertexBuffer
  96367. */
  96368. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96369. /**
  96370. * Returns all vertex buffers
  96371. * @return an object holding all vertex buffers indexed by kind
  96372. */
  96373. getVertexBuffers(): Nullable<{
  96374. [key: string]: VertexBuffer;
  96375. }>;
  96376. /**
  96377. * Gets a boolean indicating if specific vertex buffer is present
  96378. * @param kind defines the data kind (Position, normal, etc...)
  96379. * @returns true if data is present
  96380. */
  96381. isVerticesDataPresent(kind: string): boolean;
  96382. /**
  96383. * Gets a list of all attached data kinds (Position, normal, etc...)
  96384. * @returns a list of string containing all kinds
  96385. */
  96386. getVerticesDataKinds(): string[];
  96387. /**
  96388. * Update index buffer
  96389. * @param indices defines the indices to store in the index buffer
  96390. * @param offset defines the offset in the target buffer where to store the data
  96391. * @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)
  96392. */
  96393. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96394. /**
  96395. * Creates a new index buffer
  96396. * @param indices defines the indices to store in the index buffer
  96397. * @param totalVertices defines the total number of vertices (could be null)
  96398. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96399. */
  96400. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96401. /**
  96402. * Return the total number of indices
  96403. * @returns the total number of indices
  96404. */
  96405. getTotalIndices(): number;
  96406. /**
  96407. * Gets the index buffer array
  96408. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96409. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96410. * @returns the index buffer array
  96411. */
  96412. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96413. /**
  96414. * Gets the index buffer
  96415. * @return the index buffer
  96416. */
  96417. getIndexBuffer(): Nullable<DataBuffer>;
  96418. /** @hidden */
  96419. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96420. /**
  96421. * Release the associated resources for a specific mesh
  96422. * @param mesh defines the source mesh
  96423. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96424. */
  96425. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96426. /**
  96427. * Apply current geometry to a given mesh
  96428. * @param mesh defines the mesh to apply geometry to
  96429. */
  96430. applyToMesh(mesh: Mesh): void;
  96431. private _updateExtend;
  96432. private _applyToMesh;
  96433. private notifyUpdate;
  96434. /**
  96435. * Load the geometry if it was flagged as delay loaded
  96436. * @param scene defines the hosting scene
  96437. * @param onLoaded defines a callback called when the geometry is loaded
  96438. */
  96439. load(scene: Scene, onLoaded?: () => void): void;
  96440. private _queueLoad;
  96441. /**
  96442. * Invert the geometry to move from a right handed system to a left handed one.
  96443. */
  96444. toLeftHanded(): void;
  96445. /** @hidden */
  96446. _resetPointsArrayCache(): void;
  96447. /** @hidden */
  96448. _generatePointsArray(): boolean;
  96449. /**
  96450. * Gets a value indicating if the geometry is disposed
  96451. * @returns true if the geometry was disposed
  96452. */
  96453. isDisposed(): boolean;
  96454. private _disposeVertexArrayObjects;
  96455. /**
  96456. * Free all associated resources
  96457. */
  96458. dispose(): void;
  96459. /**
  96460. * Clone the current geometry into a new geometry
  96461. * @param id defines the unique ID of the new geometry
  96462. * @returns a new geometry object
  96463. */
  96464. copy(id: string): Geometry;
  96465. /**
  96466. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96467. * @return a JSON representation of the current geometry data (without the vertices data)
  96468. */
  96469. serialize(): any;
  96470. private toNumberArray;
  96471. /**
  96472. * Serialize all vertices data into a JSON oject
  96473. * @returns a JSON representation of the current geometry data
  96474. */
  96475. serializeVerticeData(): any;
  96476. /**
  96477. * Extracts a clone of a mesh geometry
  96478. * @param mesh defines the source mesh
  96479. * @param id defines the unique ID of the new geometry object
  96480. * @returns the new geometry object
  96481. */
  96482. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96483. /**
  96484. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96485. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96486. * Be aware Math.random() could cause collisions, but:
  96487. * "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"
  96488. * @returns a string containing a new GUID
  96489. */
  96490. static RandomId(): string;
  96491. /** @hidden */
  96492. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96493. private static _CleanMatricesWeights;
  96494. /**
  96495. * Create a new geometry from persisted data (Using .babylon file format)
  96496. * @param parsedVertexData defines the persisted data
  96497. * @param scene defines the hosting scene
  96498. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96499. * @returns the new geometry object
  96500. */
  96501. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96502. }
  96503. }
  96504. declare module BABYLON {
  96505. /**
  96506. * Define an interface for all classes that will get and set the data on vertices
  96507. */
  96508. export interface IGetSetVerticesData {
  96509. /**
  96510. * Gets a boolean indicating if specific vertex data is present
  96511. * @param kind defines the vertex data kind to use
  96512. * @returns true is data kind is present
  96513. */
  96514. isVerticesDataPresent(kind: string): boolean;
  96515. /**
  96516. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96517. * @param kind defines the data kind (Position, normal, etc...)
  96518. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96519. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96520. * @returns a float array containing vertex data
  96521. */
  96522. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96523. /**
  96524. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96525. * @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.
  96526. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96527. * @returns the indices array or an empty array if the mesh has no geometry
  96528. */
  96529. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96530. /**
  96531. * Set specific vertex data
  96532. * @param kind defines the data kind (Position, normal, etc...)
  96533. * @param data defines the vertex data to use
  96534. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96535. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96536. */
  96537. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96538. /**
  96539. * Update a specific associated vertex buffer
  96540. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96541. * - VertexBuffer.PositionKind
  96542. * - VertexBuffer.UVKind
  96543. * - VertexBuffer.UV2Kind
  96544. * - VertexBuffer.UV3Kind
  96545. * - VertexBuffer.UV4Kind
  96546. * - VertexBuffer.UV5Kind
  96547. * - VertexBuffer.UV6Kind
  96548. * - VertexBuffer.ColorKind
  96549. * - VertexBuffer.MatricesIndicesKind
  96550. * - VertexBuffer.MatricesIndicesExtraKind
  96551. * - VertexBuffer.MatricesWeightsKind
  96552. * - VertexBuffer.MatricesWeightsExtraKind
  96553. * @param data defines the data source
  96554. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96555. * @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)
  96556. */
  96557. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96558. /**
  96559. * Creates a new index buffer
  96560. * @param indices defines the indices to store in the index buffer
  96561. * @param totalVertices defines the total number of vertices (could be null)
  96562. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96563. */
  96564. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96565. }
  96566. /**
  96567. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96568. */
  96569. export class VertexData {
  96570. /**
  96571. * Mesh side orientation : usually the external or front surface
  96572. */
  96573. static readonly FRONTSIDE: number;
  96574. /**
  96575. * Mesh side orientation : usually the internal or back surface
  96576. */
  96577. static readonly BACKSIDE: number;
  96578. /**
  96579. * Mesh side orientation : both internal and external or front and back surfaces
  96580. */
  96581. static readonly DOUBLESIDE: number;
  96582. /**
  96583. * Mesh side orientation : by default, `FRONTSIDE`
  96584. */
  96585. static readonly DEFAULTSIDE: number;
  96586. /**
  96587. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96588. */
  96589. positions: Nullable<FloatArray>;
  96590. /**
  96591. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96592. */
  96593. normals: Nullable<FloatArray>;
  96594. /**
  96595. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96596. */
  96597. tangents: Nullable<FloatArray>;
  96598. /**
  96599. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96600. */
  96601. uvs: Nullable<FloatArray>;
  96602. /**
  96603. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96604. */
  96605. uvs2: Nullable<FloatArray>;
  96606. /**
  96607. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96608. */
  96609. uvs3: Nullable<FloatArray>;
  96610. /**
  96611. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96612. */
  96613. uvs4: Nullable<FloatArray>;
  96614. /**
  96615. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96616. */
  96617. uvs5: Nullable<FloatArray>;
  96618. /**
  96619. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96620. */
  96621. uvs6: Nullable<FloatArray>;
  96622. /**
  96623. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96624. */
  96625. colors: Nullable<FloatArray>;
  96626. /**
  96627. * 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).
  96628. */
  96629. matricesIndices: Nullable<FloatArray>;
  96630. /**
  96631. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96632. */
  96633. matricesWeights: Nullable<FloatArray>;
  96634. /**
  96635. * An array extending the number of possible indices
  96636. */
  96637. matricesIndicesExtra: Nullable<FloatArray>;
  96638. /**
  96639. * An array extending the number of possible weights when the number of indices is extended
  96640. */
  96641. matricesWeightsExtra: Nullable<FloatArray>;
  96642. /**
  96643. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96644. */
  96645. indices: Nullable<IndicesArray>;
  96646. /**
  96647. * Uses the passed data array to set the set the values for the specified kind of data
  96648. * @param data a linear array of floating numbers
  96649. * @param kind the type of data that is being set, eg positions, colors etc
  96650. */
  96651. set(data: FloatArray, kind: string): void;
  96652. /**
  96653. * Associates the vertexData to the passed Mesh.
  96654. * Sets it as updatable or not (default `false`)
  96655. * @param mesh the mesh the vertexData is applied to
  96656. * @param updatable when used and having the value true allows new data to update the vertexData
  96657. * @returns the VertexData
  96658. */
  96659. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96660. /**
  96661. * Associates the vertexData to the passed Geometry.
  96662. * Sets it as updatable or not (default `false`)
  96663. * @param geometry the geometry the vertexData is applied to
  96664. * @param updatable when used and having the value true allows new data to update the vertexData
  96665. * @returns VertexData
  96666. */
  96667. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96668. /**
  96669. * Updates the associated mesh
  96670. * @param mesh the mesh to be updated
  96671. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96672. * @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
  96673. * @returns VertexData
  96674. */
  96675. updateMesh(mesh: Mesh): VertexData;
  96676. /**
  96677. * Updates the associated geometry
  96678. * @param geometry the geometry to be updated
  96679. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96680. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  96681. * @returns VertexData.
  96682. */
  96683. updateGeometry(geometry: Geometry): VertexData;
  96684. private _applyTo;
  96685. private _update;
  96686. /**
  96687. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96688. * @param matrix the transforming matrix
  96689. * @returns the VertexData
  96690. */
  96691. transform(matrix: Matrix): VertexData;
  96692. /**
  96693. * Merges the passed VertexData into the current one
  96694. * @param other the VertexData to be merged into the current one
  96695. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96696. * @returns the modified VertexData
  96697. */
  96698. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96699. private _mergeElement;
  96700. private _validate;
  96701. /**
  96702. * Serializes the VertexData
  96703. * @returns a serialized object
  96704. */
  96705. serialize(): any;
  96706. /**
  96707. * Extracts the vertexData from a mesh
  96708. * @param mesh the mesh from which to extract the VertexData
  96709. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96710. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96711. * @returns the object VertexData associated to the passed mesh
  96712. */
  96713. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96714. /**
  96715. * Extracts the vertexData from the geometry
  96716. * @param geometry the geometry from which to extract the VertexData
  96717. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96718. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96719. * @returns the object VertexData associated to the passed mesh
  96720. */
  96721. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96722. private static _ExtractFrom;
  96723. /**
  96724. * Creates the VertexData for a Ribbon
  96725. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96726. * * pathArray array of paths, each of which an array of successive Vector3
  96727. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96728. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96729. * * 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
  96730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96731. * * 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)
  96732. * * 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)
  96733. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96734. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96735. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96736. * @returns the VertexData of the ribbon
  96737. */
  96738. static CreateRibbon(options: {
  96739. pathArray: Vector3[][];
  96740. closeArray?: boolean;
  96741. closePath?: boolean;
  96742. offset?: number;
  96743. sideOrientation?: number;
  96744. frontUVs?: Vector4;
  96745. backUVs?: Vector4;
  96746. invertUV?: boolean;
  96747. uvs?: Vector2[];
  96748. colors?: Color4[];
  96749. }): VertexData;
  96750. /**
  96751. * Creates the VertexData for a box
  96752. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96753. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96754. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96755. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96756. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  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. * * 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)
  96761. * * 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)
  96762. * @returns the VertexData of the box
  96763. */
  96764. static CreateBox(options: {
  96765. size?: number;
  96766. width?: number;
  96767. height?: number;
  96768. depth?: number;
  96769. faceUV?: Vector4[];
  96770. faceColors?: Color4[];
  96771. sideOrientation?: number;
  96772. frontUVs?: Vector4;
  96773. backUVs?: Vector4;
  96774. }): VertexData;
  96775. /**
  96776. * Creates the VertexData for a tiled box
  96777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96778. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96779. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96780. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96782. * @returns the VertexData of the box
  96783. */
  96784. static CreateTiledBox(options: {
  96785. pattern?: number;
  96786. width?: number;
  96787. height?: number;
  96788. depth?: number;
  96789. tileSize?: number;
  96790. tileWidth?: number;
  96791. tileHeight?: number;
  96792. alignHorizontal?: number;
  96793. alignVertical?: number;
  96794. faceUV?: Vector4[];
  96795. faceColors?: Color4[];
  96796. sideOrientation?: number;
  96797. }): VertexData;
  96798. /**
  96799. * Creates the VertexData for a tiled plane
  96800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96801. * * pattern a limited pattern arrangement depending on the number
  96802. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96803. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96804. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96805. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96806. * * 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)
  96807. * * 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)
  96808. * @returns the VertexData of the tiled plane
  96809. */
  96810. static CreateTiledPlane(options: {
  96811. pattern?: number;
  96812. tileSize?: number;
  96813. tileWidth?: number;
  96814. tileHeight?: number;
  96815. size?: number;
  96816. width?: number;
  96817. height?: number;
  96818. alignHorizontal?: number;
  96819. alignVertical?: number;
  96820. sideOrientation?: number;
  96821. frontUVs?: Vector4;
  96822. backUVs?: Vector4;
  96823. }): VertexData;
  96824. /**
  96825. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96826. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96827. * * segments sets the number of horizontal strips optional, default 32
  96828. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96829. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96830. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96831. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96832. * * 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
  96833. * * 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
  96834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96835. * * 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)
  96836. * * 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)
  96837. * @returns the VertexData of the ellipsoid
  96838. */
  96839. static CreateSphere(options: {
  96840. segments?: number;
  96841. diameter?: number;
  96842. diameterX?: number;
  96843. diameterY?: number;
  96844. diameterZ?: number;
  96845. arc?: number;
  96846. slice?: number;
  96847. sideOrientation?: number;
  96848. frontUVs?: Vector4;
  96849. backUVs?: Vector4;
  96850. }): VertexData;
  96851. /**
  96852. * Creates the VertexData for a cylinder, cone or prism
  96853. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96854. * * height sets the height (y direction) of the cylinder, optional, default 2
  96855. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96856. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96857. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96858. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96859. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96860. * * 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
  96861. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96862. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96863. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96864. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96865. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96866. * * 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)
  96867. * * 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)
  96868. * @returns the VertexData of the cylinder, cone or prism
  96869. */
  96870. static CreateCylinder(options: {
  96871. height?: number;
  96872. diameterTop?: number;
  96873. diameterBottom?: number;
  96874. diameter?: number;
  96875. tessellation?: number;
  96876. subdivisions?: number;
  96877. arc?: number;
  96878. faceColors?: Color4[];
  96879. faceUV?: Vector4[];
  96880. hasRings?: boolean;
  96881. enclose?: boolean;
  96882. sideOrientation?: number;
  96883. frontUVs?: Vector4;
  96884. backUVs?: Vector4;
  96885. }): VertexData;
  96886. /**
  96887. * Creates the VertexData for a torus
  96888. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96889. * * diameter the diameter of the torus, optional default 1
  96890. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96891. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96893. * * 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)
  96894. * * 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)
  96895. * @returns the VertexData of the torus
  96896. */
  96897. static CreateTorus(options: {
  96898. diameter?: number;
  96899. thickness?: number;
  96900. tessellation?: number;
  96901. sideOrientation?: number;
  96902. frontUVs?: Vector4;
  96903. backUVs?: Vector4;
  96904. }): VertexData;
  96905. /**
  96906. * Creates the VertexData of the LineSystem
  96907. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96908. * - lines an array of lines, each line being an array of successive Vector3
  96909. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96910. * @returns the VertexData of the LineSystem
  96911. */
  96912. static CreateLineSystem(options: {
  96913. lines: Vector3[][];
  96914. colors?: Nullable<Color4[][]>;
  96915. }): VertexData;
  96916. /**
  96917. * Create the VertexData for a DashedLines
  96918. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96919. * - points an array successive Vector3
  96920. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96921. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96922. * - dashNb the intended total number of dashes, optional, default 200
  96923. * @returns the VertexData for the DashedLines
  96924. */
  96925. static CreateDashedLines(options: {
  96926. points: Vector3[];
  96927. dashSize?: number;
  96928. gapSize?: number;
  96929. dashNb?: number;
  96930. }): VertexData;
  96931. /**
  96932. * Creates the VertexData for a Ground
  96933. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96934. * - width the width (x direction) of the ground, optional, default 1
  96935. * - height the height (z direction) of the ground, optional, default 1
  96936. * - subdivisions the number of subdivisions per side, optional, default 1
  96937. * @returns the VertexData of the Ground
  96938. */
  96939. static CreateGround(options: {
  96940. width?: number;
  96941. height?: number;
  96942. subdivisions?: number;
  96943. subdivisionsX?: number;
  96944. subdivisionsY?: number;
  96945. }): VertexData;
  96946. /**
  96947. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96948. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96949. * * xmin the ground minimum X coordinate, optional, default -1
  96950. * * zmin the ground minimum Z coordinate, optional, default -1
  96951. * * xmax the ground maximum X coordinate, optional, default 1
  96952. * * zmax the ground maximum Z coordinate, optional, default 1
  96953. * * 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}
  96954. * * 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}
  96955. * @returns the VertexData of the TiledGround
  96956. */
  96957. static CreateTiledGround(options: {
  96958. xmin: number;
  96959. zmin: number;
  96960. xmax: number;
  96961. zmax: number;
  96962. subdivisions?: {
  96963. w: number;
  96964. h: number;
  96965. };
  96966. precision?: {
  96967. w: number;
  96968. h: number;
  96969. };
  96970. }): VertexData;
  96971. /**
  96972. * Creates the VertexData of the Ground designed from a heightmap
  96973. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96974. * * width the width (x direction) of the ground
  96975. * * height the height (z direction) of the ground
  96976. * * subdivisions the number of subdivisions per side
  96977. * * minHeight the minimum altitude on the ground, optional, default 0
  96978. * * maxHeight the maximum altitude on the ground, optional default 1
  96979. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96980. * * buffer the array holding the image color data
  96981. * * bufferWidth the width of image
  96982. * * bufferHeight the height of image
  96983. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96984. * @returns the VertexData of the Ground designed from a heightmap
  96985. */
  96986. static CreateGroundFromHeightMap(options: {
  96987. width: number;
  96988. height: number;
  96989. subdivisions: number;
  96990. minHeight: number;
  96991. maxHeight: number;
  96992. colorFilter: Color3;
  96993. buffer: Uint8Array;
  96994. bufferWidth: number;
  96995. bufferHeight: number;
  96996. alphaFilter: number;
  96997. }): VertexData;
  96998. /**
  96999. * Creates the VertexData for a Plane
  97000. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  97001. * * size sets the width and height of the plane to the value of size, optional default 1
  97002. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  97003. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  97004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97005. * * 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)
  97006. * * 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)
  97007. * @returns the VertexData of the box
  97008. */
  97009. static CreatePlane(options: {
  97010. size?: number;
  97011. width?: number;
  97012. height?: number;
  97013. sideOrientation?: number;
  97014. frontUVs?: Vector4;
  97015. backUVs?: Vector4;
  97016. }): VertexData;
  97017. /**
  97018. * Creates the VertexData of the Disc or regular Polygon
  97019. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97020. * * radius the radius of the disc, optional default 0.5
  97021. * * tessellation the number of polygon sides, optional, default 64
  97022. * * 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
  97023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97024. * * 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)
  97025. * * 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)
  97026. * @returns the VertexData of the box
  97027. */
  97028. static CreateDisc(options: {
  97029. radius?: number;
  97030. tessellation?: number;
  97031. arc?: number;
  97032. sideOrientation?: number;
  97033. frontUVs?: Vector4;
  97034. backUVs?: Vector4;
  97035. }): VertexData;
  97036. /**
  97037. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97038. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97039. * @param polygon a mesh built from polygonTriangulation.build()
  97040. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97041. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97042. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97043. * @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)
  97044. * @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)
  97045. * @returns the VertexData of the Polygon
  97046. */
  97047. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97048. /**
  97049. * Creates the VertexData of the IcoSphere
  97050. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97051. * * radius the radius of the IcoSphere, optional default 1
  97052. * * radiusX allows stretching in the x direction, optional, default radius
  97053. * * radiusY allows stretching in the y direction, optional, default radius
  97054. * * radiusZ allows stretching in the z direction, optional, default radius
  97055. * * flat when true creates a flat shaded mesh, optional, default true
  97056. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97058. * * 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)
  97059. * * 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)
  97060. * @returns the VertexData of the IcoSphere
  97061. */
  97062. static CreateIcoSphere(options: {
  97063. radius?: number;
  97064. radiusX?: number;
  97065. radiusY?: number;
  97066. radiusZ?: number;
  97067. flat?: boolean;
  97068. subdivisions?: number;
  97069. sideOrientation?: number;
  97070. frontUVs?: Vector4;
  97071. backUVs?: Vector4;
  97072. }): VertexData;
  97073. /**
  97074. * Creates the VertexData for a Polyhedron
  97075. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97076. * * type provided types are:
  97077. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97078. * * 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)
  97079. * * size the size of the IcoSphere, optional default 1
  97080. * * sizeX allows stretching in the x direction, optional, default size
  97081. * * sizeY allows stretching in the y direction, optional, default size
  97082. * * sizeZ allows stretching in the z direction, optional, default size
  97083. * * 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
  97084. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97085. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97086. * * flat when true creates a flat shaded mesh, optional, default true
  97087. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97089. * * 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)
  97090. * * 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)
  97091. * @returns the VertexData of the Polyhedron
  97092. */
  97093. static CreatePolyhedron(options: {
  97094. type?: number;
  97095. size?: number;
  97096. sizeX?: number;
  97097. sizeY?: number;
  97098. sizeZ?: number;
  97099. custom?: any;
  97100. faceUV?: Vector4[];
  97101. faceColors?: Color4[];
  97102. flat?: boolean;
  97103. sideOrientation?: number;
  97104. frontUVs?: Vector4;
  97105. backUVs?: Vector4;
  97106. }): VertexData;
  97107. /**
  97108. * Creates the VertexData for a TorusKnot
  97109. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97110. * * radius the radius of the torus knot, optional, default 2
  97111. * * tube the thickness of the tube, optional, default 0.5
  97112. * * radialSegments the number of sides on each tube segments, optional, default 32
  97113. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97114. * * p the number of windings around the z axis, optional, default 2
  97115. * * q the number of windings around the x axis, optional, default 3
  97116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97117. * * 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)
  97118. * * 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)
  97119. * @returns the VertexData of the Torus Knot
  97120. */
  97121. static CreateTorusKnot(options: {
  97122. radius?: number;
  97123. tube?: number;
  97124. radialSegments?: number;
  97125. tubularSegments?: number;
  97126. p?: number;
  97127. q?: number;
  97128. sideOrientation?: number;
  97129. frontUVs?: Vector4;
  97130. backUVs?: Vector4;
  97131. }): VertexData;
  97132. /**
  97133. * Compute normals for given positions and indices
  97134. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97135. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97136. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97137. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97138. * * facetNormals : optional array of facet normals (vector3)
  97139. * * facetPositions : optional array of facet positions (vector3)
  97140. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97141. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97142. * * bInfo : optional bounding info, required for facetPartitioning computation
  97143. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97144. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97145. * * useRightHandedSystem: optional boolean to for right handed system computation
  97146. * * depthSort : optional boolean to enable the facet depth sort computation
  97147. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97148. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97149. */
  97150. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97151. facetNormals?: any;
  97152. facetPositions?: any;
  97153. facetPartitioning?: any;
  97154. ratio?: number;
  97155. bInfo?: any;
  97156. bbSize?: Vector3;
  97157. subDiv?: any;
  97158. useRightHandedSystem?: boolean;
  97159. depthSort?: boolean;
  97160. distanceTo?: Vector3;
  97161. depthSortedFacets?: any;
  97162. }): void;
  97163. /** @hidden */
  97164. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97165. /**
  97166. * Applies VertexData created from the imported parameters to the geometry
  97167. * @param parsedVertexData the parsed data from an imported file
  97168. * @param geometry the geometry to apply the VertexData to
  97169. */
  97170. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97171. }
  97172. }
  97173. declare module BABYLON {
  97174. /**
  97175. * Defines a target to use with MorphTargetManager
  97176. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97177. */
  97178. export class MorphTarget implements IAnimatable {
  97179. /** defines the name of the target */
  97180. name: string;
  97181. /**
  97182. * Gets or sets the list of animations
  97183. */
  97184. animations: Animation[];
  97185. private _scene;
  97186. private _positions;
  97187. private _normals;
  97188. private _tangents;
  97189. private _uvs;
  97190. private _influence;
  97191. private _uniqueId;
  97192. /**
  97193. * Observable raised when the influence changes
  97194. */
  97195. onInfluenceChanged: Observable<boolean>;
  97196. /** @hidden */
  97197. _onDataLayoutChanged: Observable<void>;
  97198. /**
  97199. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97200. */
  97201. get influence(): number;
  97202. set influence(influence: number);
  97203. /**
  97204. * Gets or sets the id of the morph Target
  97205. */
  97206. id: string;
  97207. private _animationPropertiesOverride;
  97208. /**
  97209. * Gets or sets the animation properties override
  97210. */
  97211. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97212. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97213. /**
  97214. * Creates a new MorphTarget
  97215. * @param name defines the name of the target
  97216. * @param influence defines the influence to use
  97217. * @param scene defines the scene the morphtarget belongs to
  97218. */
  97219. constructor(
  97220. /** defines the name of the target */
  97221. name: string, influence?: number, scene?: Nullable<Scene>);
  97222. /**
  97223. * Gets the unique ID of this manager
  97224. */
  97225. get uniqueId(): number;
  97226. /**
  97227. * Gets a boolean defining if the target contains position data
  97228. */
  97229. get hasPositions(): boolean;
  97230. /**
  97231. * Gets a boolean defining if the target contains normal data
  97232. */
  97233. get hasNormals(): boolean;
  97234. /**
  97235. * Gets a boolean defining if the target contains tangent data
  97236. */
  97237. get hasTangents(): boolean;
  97238. /**
  97239. * Gets a boolean defining if the target contains texture coordinates data
  97240. */
  97241. get hasUVs(): boolean;
  97242. /**
  97243. * Affects position data to this target
  97244. * @param data defines the position data to use
  97245. */
  97246. setPositions(data: Nullable<FloatArray>): void;
  97247. /**
  97248. * Gets the position data stored in this target
  97249. * @returns a FloatArray containing the position data (or null if not present)
  97250. */
  97251. getPositions(): Nullable<FloatArray>;
  97252. /**
  97253. * Affects normal data to this target
  97254. * @param data defines the normal data to use
  97255. */
  97256. setNormals(data: Nullable<FloatArray>): void;
  97257. /**
  97258. * Gets the normal data stored in this target
  97259. * @returns a FloatArray containing the normal data (or null if not present)
  97260. */
  97261. getNormals(): Nullable<FloatArray>;
  97262. /**
  97263. * Affects tangent data to this target
  97264. * @param data defines the tangent data to use
  97265. */
  97266. setTangents(data: Nullable<FloatArray>): void;
  97267. /**
  97268. * Gets the tangent data stored in this target
  97269. * @returns a FloatArray containing the tangent data (or null if not present)
  97270. */
  97271. getTangents(): Nullable<FloatArray>;
  97272. /**
  97273. * Affects texture coordinates data to this target
  97274. * @param data defines the texture coordinates data to use
  97275. */
  97276. setUVs(data: Nullable<FloatArray>): void;
  97277. /**
  97278. * Gets the texture coordinates data stored in this target
  97279. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97280. */
  97281. getUVs(): Nullable<FloatArray>;
  97282. /**
  97283. * Clone the current target
  97284. * @returns a new MorphTarget
  97285. */
  97286. clone(): MorphTarget;
  97287. /**
  97288. * Serializes the current target into a Serialization object
  97289. * @returns the serialized object
  97290. */
  97291. serialize(): any;
  97292. /**
  97293. * Returns the string "MorphTarget"
  97294. * @returns "MorphTarget"
  97295. */
  97296. getClassName(): string;
  97297. /**
  97298. * Creates a new target from serialized data
  97299. * @param serializationObject defines the serialized data to use
  97300. * @returns a new MorphTarget
  97301. */
  97302. static Parse(serializationObject: any): MorphTarget;
  97303. /**
  97304. * Creates a MorphTarget from mesh data
  97305. * @param mesh defines the source mesh
  97306. * @param name defines the name to use for the new target
  97307. * @param influence defines the influence to attach to the target
  97308. * @returns a new MorphTarget
  97309. */
  97310. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97311. }
  97312. }
  97313. declare module BABYLON {
  97314. /**
  97315. * This class is used to deform meshes using morphing between different targets
  97316. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97317. */
  97318. export class MorphTargetManager {
  97319. private _targets;
  97320. private _targetInfluenceChangedObservers;
  97321. private _targetDataLayoutChangedObservers;
  97322. private _activeTargets;
  97323. private _scene;
  97324. private _influences;
  97325. private _supportsNormals;
  97326. private _supportsTangents;
  97327. private _supportsUVs;
  97328. private _vertexCount;
  97329. private _uniqueId;
  97330. private _tempInfluences;
  97331. /**
  97332. * Gets or sets a boolean indicating if normals must be morphed
  97333. */
  97334. enableNormalMorphing: boolean;
  97335. /**
  97336. * Gets or sets a boolean indicating if tangents must be morphed
  97337. */
  97338. enableTangentMorphing: boolean;
  97339. /**
  97340. * Gets or sets a boolean indicating if UV must be morphed
  97341. */
  97342. enableUVMorphing: boolean;
  97343. /**
  97344. * Creates a new MorphTargetManager
  97345. * @param scene defines the current scene
  97346. */
  97347. constructor(scene?: Nullable<Scene>);
  97348. /**
  97349. * Gets the unique ID of this manager
  97350. */
  97351. get uniqueId(): number;
  97352. /**
  97353. * Gets the number of vertices handled by this manager
  97354. */
  97355. get vertexCount(): number;
  97356. /**
  97357. * Gets a boolean indicating if this manager supports morphing of normals
  97358. */
  97359. get supportsNormals(): boolean;
  97360. /**
  97361. * Gets a boolean indicating if this manager supports morphing of tangents
  97362. */
  97363. get supportsTangents(): boolean;
  97364. /**
  97365. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97366. */
  97367. get supportsUVs(): boolean;
  97368. /**
  97369. * Gets the number of targets stored in this manager
  97370. */
  97371. get numTargets(): number;
  97372. /**
  97373. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97374. */
  97375. get numInfluencers(): number;
  97376. /**
  97377. * Gets the list of influences (one per target)
  97378. */
  97379. get influences(): Float32Array;
  97380. /**
  97381. * Gets the active target at specified index. An active target is a target with an influence > 0
  97382. * @param index defines the index to check
  97383. * @returns the requested target
  97384. */
  97385. getActiveTarget(index: number): MorphTarget;
  97386. /**
  97387. * Gets the target at specified index
  97388. * @param index defines the index to check
  97389. * @returns the requested target
  97390. */
  97391. getTarget(index: number): MorphTarget;
  97392. /**
  97393. * Add a new target to this manager
  97394. * @param target defines the target to add
  97395. */
  97396. addTarget(target: MorphTarget): void;
  97397. /**
  97398. * Removes a target from the manager
  97399. * @param target defines the target to remove
  97400. */
  97401. removeTarget(target: MorphTarget): void;
  97402. /**
  97403. * Clone the current manager
  97404. * @returns a new MorphTargetManager
  97405. */
  97406. clone(): MorphTargetManager;
  97407. /**
  97408. * Serializes the current manager into a Serialization object
  97409. * @returns the serialized object
  97410. */
  97411. serialize(): any;
  97412. private _syncActiveTargets;
  97413. /**
  97414. * Syncrhonize the targets with all the meshes using this morph target manager
  97415. */
  97416. synchronize(): void;
  97417. /**
  97418. * Creates a new MorphTargetManager from serialized data
  97419. * @param serializationObject defines the serialized data
  97420. * @param scene defines the hosting scene
  97421. * @returns the new MorphTargetManager
  97422. */
  97423. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97424. }
  97425. }
  97426. declare module BABYLON {
  97427. /**
  97428. * Class used to represent a specific level of detail of a mesh
  97429. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97430. */
  97431. export class MeshLODLevel {
  97432. /** Defines the distance where this level should start being displayed */
  97433. distance: number;
  97434. /** Defines the mesh to use to render this level */
  97435. mesh: Nullable<Mesh>;
  97436. /**
  97437. * Creates a new LOD level
  97438. * @param distance defines the distance where this level should star being displayed
  97439. * @param mesh defines the mesh to use to render this level
  97440. */
  97441. constructor(
  97442. /** Defines the distance where this level should start being displayed */
  97443. distance: number,
  97444. /** Defines the mesh to use to render this level */
  97445. mesh: Nullable<Mesh>);
  97446. }
  97447. }
  97448. declare module BABYLON {
  97449. /**
  97450. * Mesh representing the gorund
  97451. */
  97452. export class GroundMesh extends Mesh {
  97453. /** If octree should be generated */
  97454. generateOctree: boolean;
  97455. private _heightQuads;
  97456. /** @hidden */
  97457. _subdivisionsX: number;
  97458. /** @hidden */
  97459. _subdivisionsY: number;
  97460. /** @hidden */
  97461. _width: number;
  97462. /** @hidden */
  97463. _height: number;
  97464. /** @hidden */
  97465. _minX: number;
  97466. /** @hidden */
  97467. _maxX: number;
  97468. /** @hidden */
  97469. _minZ: number;
  97470. /** @hidden */
  97471. _maxZ: number;
  97472. constructor(name: string, scene: Scene);
  97473. /**
  97474. * "GroundMesh"
  97475. * @returns "GroundMesh"
  97476. */
  97477. getClassName(): string;
  97478. /**
  97479. * The minimum of x and y subdivisions
  97480. */
  97481. get subdivisions(): number;
  97482. /**
  97483. * X subdivisions
  97484. */
  97485. get subdivisionsX(): number;
  97486. /**
  97487. * Y subdivisions
  97488. */
  97489. get subdivisionsY(): number;
  97490. /**
  97491. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97492. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97493. * @param chunksCount the number of subdivisions for x and y
  97494. * @param octreeBlocksSize (Default: 32)
  97495. */
  97496. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97497. /**
  97498. * Returns a height (y) value in the Worl system :
  97499. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97500. * @param x x coordinate
  97501. * @param z z coordinate
  97502. * @returns the ground y position if (x, z) are outside the ground surface.
  97503. */
  97504. getHeightAtCoordinates(x: number, z: number): number;
  97505. /**
  97506. * Returns a normalized vector (Vector3) orthogonal to the ground
  97507. * at the ground coordinates (x, z) expressed in the World system.
  97508. * @param x x coordinate
  97509. * @param z z coordinate
  97510. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97511. */
  97512. getNormalAtCoordinates(x: number, z: number): Vector3;
  97513. /**
  97514. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97515. * at the ground coordinates (x, z) expressed in the World system.
  97516. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97517. * @param x x coordinate
  97518. * @param z z coordinate
  97519. * @param ref vector to store the result
  97520. * @returns the GroundMesh.
  97521. */
  97522. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97523. /**
  97524. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97525. * if the ground has been updated.
  97526. * This can be used in the render loop.
  97527. * @returns the GroundMesh.
  97528. */
  97529. updateCoordinateHeights(): GroundMesh;
  97530. private _getFacetAt;
  97531. private _initHeightQuads;
  97532. private _computeHeightQuads;
  97533. /**
  97534. * Serializes this ground mesh
  97535. * @param serializationObject object to write serialization to
  97536. */
  97537. serialize(serializationObject: any): void;
  97538. /**
  97539. * Parses a serialized ground mesh
  97540. * @param parsedMesh the serialized mesh
  97541. * @param scene the scene to create the ground mesh in
  97542. * @returns the created ground mesh
  97543. */
  97544. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97545. }
  97546. }
  97547. declare module BABYLON {
  97548. /**
  97549. * Interface for Physics-Joint data
  97550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97551. */
  97552. export interface PhysicsJointData {
  97553. /**
  97554. * The main pivot of the joint
  97555. */
  97556. mainPivot?: Vector3;
  97557. /**
  97558. * The connected pivot of the joint
  97559. */
  97560. connectedPivot?: Vector3;
  97561. /**
  97562. * The main axis of the joint
  97563. */
  97564. mainAxis?: Vector3;
  97565. /**
  97566. * The connected axis of the joint
  97567. */
  97568. connectedAxis?: Vector3;
  97569. /**
  97570. * The collision of the joint
  97571. */
  97572. collision?: boolean;
  97573. /**
  97574. * Native Oimo/Cannon/Energy data
  97575. */
  97576. nativeParams?: any;
  97577. }
  97578. /**
  97579. * This is a holder class for the physics joint created by the physics plugin
  97580. * It holds a set of functions to control the underlying joint
  97581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97582. */
  97583. export class PhysicsJoint {
  97584. /**
  97585. * The type of the physics joint
  97586. */
  97587. type: number;
  97588. /**
  97589. * The data for the physics joint
  97590. */
  97591. jointData: PhysicsJointData;
  97592. private _physicsJoint;
  97593. protected _physicsPlugin: IPhysicsEnginePlugin;
  97594. /**
  97595. * Initializes the physics joint
  97596. * @param type The type of the physics joint
  97597. * @param jointData The data for the physics joint
  97598. */
  97599. constructor(
  97600. /**
  97601. * The type of the physics joint
  97602. */
  97603. type: number,
  97604. /**
  97605. * The data for the physics joint
  97606. */
  97607. jointData: PhysicsJointData);
  97608. /**
  97609. * Gets the physics joint
  97610. */
  97611. get physicsJoint(): any;
  97612. /**
  97613. * Sets the physics joint
  97614. */
  97615. set physicsJoint(newJoint: any);
  97616. /**
  97617. * Sets the physics plugin
  97618. */
  97619. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97620. /**
  97621. * Execute a function that is physics-plugin specific.
  97622. * @param {Function} func the function that will be executed.
  97623. * It accepts two parameters: the physics world and the physics joint
  97624. */
  97625. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97626. /**
  97627. * Distance-Joint type
  97628. */
  97629. static DistanceJoint: number;
  97630. /**
  97631. * Hinge-Joint type
  97632. */
  97633. static HingeJoint: number;
  97634. /**
  97635. * Ball-and-Socket joint type
  97636. */
  97637. static BallAndSocketJoint: number;
  97638. /**
  97639. * Wheel-Joint type
  97640. */
  97641. static WheelJoint: number;
  97642. /**
  97643. * Slider-Joint type
  97644. */
  97645. static SliderJoint: number;
  97646. /**
  97647. * Prismatic-Joint type
  97648. */
  97649. static PrismaticJoint: number;
  97650. /**
  97651. * Universal-Joint type
  97652. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97653. */
  97654. static UniversalJoint: number;
  97655. /**
  97656. * Hinge-Joint 2 type
  97657. */
  97658. static Hinge2Joint: number;
  97659. /**
  97660. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97661. */
  97662. static PointToPointJoint: number;
  97663. /**
  97664. * Spring-Joint type
  97665. */
  97666. static SpringJoint: number;
  97667. /**
  97668. * Lock-Joint type
  97669. */
  97670. static LockJoint: number;
  97671. }
  97672. /**
  97673. * A class representing a physics distance joint
  97674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97675. */
  97676. export class DistanceJoint extends PhysicsJoint {
  97677. /**
  97678. *
  97679. * @param jointData The data for the Distance-Joint
  97680. */
  97681. constructor(jointData: DistanceJointData);
  97682. /**
  97683. * Update the predefined distance.
  97684. * @param maxDistance The maximum preferred distance
  97685. * @param minDistance The minimum preferred distance
  97686. */
  97687. updateDistance(maxDistance: number, minDistance?: number): void;
  97688. }
  97689. /**
  97690. * Represents a Motor-Enabled Joint
  97691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97692. */
  97693. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97694. /**
  97695. * Initializes the Motor-Enabled Joint
  97696. * @param type The type of the joint
  97697. * @param jointData The physica joint data for the joint
  97698. */
  97699. constructor(type: number, jointData: PhysicsJointData);
  97700. /**
  97701. * Set the motor values.
  97702. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97703. * @param force the force to apply
  97704. * @param maxForce max force for this motor.
  97705. */
  97706. setMotor(force?: number, maxForce?: number): void;
  97707. /**
  97708. * Set the motor's limits.
  97709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97710. * @param upperLimit The upper limit of the motor
  97711. * @param lowerLimit The lower limit of the motor
  97712. */
  97713. setLimit(upperLimit: number, lowerLimit?: number): void;
  97714. }
  97715. /**
  97716. * This class represents a single physics Hinge-Joint
  97717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97718. */
  97719. export class HingeJoint extends MotorEnabledJoint {
  97720. /**
  97721. * Initializes the Hinge-Joint
  97722. * @param jointData The joint data for the Hinge-Joint
  97723. */
  97724. constructor(jointData: PhysicsJointData);
  97725. /**
  97726. * Set the motor values.
  97727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97728. * @param {number} force the force to apply
  97729. * @param {number} maxForce max force for this motor.
  97730. */
  97731. setMotor(force?: number, maxForce?: number): void;
  97732. /**
  97733. * Set the motor's limits.
  97734. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97735. * @param upperLimit The upper limit of the motor
  97736. * @param lowerLimit The lower limit of the motor
  97737. */
  97738. setLimit(upperLimit: number, lowerLimit?: number): void;
  97739. }
  97740. /**
  97741. * This class represents a dual hinge physics joint (same as wheel joint)
  97742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97743. */
  97744. export class Hinge2Joint extends MotorEnabledJoint {
  97745. /**
  97746. * Initializes the Hinge2-Joint
  97747. * @param jointData The joint data for the Hinge2-Joint
  97748. */
  97749. constructor(jointData: PhysicsJointData);
  97750. /**
  97751. * Set the motor values.
  97752. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97753. * @param {number} targetSpeed the speed the motor is to reach
  97754. * @param {number} maxForce max force for this motor.
  97755. * @param {motorIndex} the motor's index, 0 or 1.
  97756. */
  97757. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97758. /**
  97759. * Set the motor limits.
  97760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97761. * @param {number} upperLimit the upper limit
  97762. * @param {number} lowerLimit lower limit
  97763. * @param {motorIndex} the motor's index, 0 or 1.
  97764. */
  97765. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97766. }
  97767. /**
  97768. * Interface for a motor enabled joint
  97769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97770. */
  97771. export interface IMotorEnabledJoint {
  97772. /**
  97773. * Physics joint
  97774. */
  97775. physicsJoint: any;
  97776. /**
  97777. * Sets the motor of the motor-enabled joint
  97778. * @param force The force of the motor
  97779. * @param maxForce The maximum force of the motor
  97780. * @param motorIndex The index of the motor
  97781. */
  97782. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97783. /**
  97784. * Sets the limit of the motor
  97785. * @param upperLimit The upper limit of the motor
  97786. * @param lowerLimit The lower limit of the motor
  97787. * @param motorIndex The index of the motor
  97788. */
  97789. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97790. }
  97791. /**
  97792. * Joint data for a Distance-Joint
  97793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97794. */
  97795. export interface DistanceJointData extends PhysicsJointData {
  97796. /**
  97797. * Max distance the 2 joint objects can be apart
  97798. */
  97799. maxDistance: number;
  97800. }
  97801. /**
  97802. * Joint data from a spring joint
  97803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97804. */
  97805. export interface SpringJointData extends PhysicsJointData {
  97806. /**
  97807. * Length of the spring
  97808. */
  97809. length: number;
  97810. /**
  97811. * Stiffness of the spring
  97812. */
  97813. stiffness: number;
  97814. /**
  97815. * Damping of the spring
  97816. */
  97817. damping: number;
  97818. /** this callback will be called when applying the force to the impostors. */
  97819. forceApplicationCallback: () => void;
  97820. }
  97821. }
  97822. declare module BABYLON {
  97823. /**
  97824. * Holds the data for the raycast result
  97825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97826. */
  97827. export class PhysicsRaycastResult {
  97828. private _hasHit;
  97829. private _hitDistance;
  97830. private _hitNormalWorld;
  97831. private _hitPointWorld;
  97832. private _rayFromWorld;
  97833. private _rayToWorld;
  97834. /**
  97835. * Gets if there was a hit
  97836. */
  97837. get hasHit(): boolean;
  97838. /**
  97839. * Gets the distance from the hit
  97840. */
  97841. get hitDistance(): number;
  97842. /**
  97843. * Gets the hit normal/direction in the world
  97844. */
  97845. get hitNormalWorld(): Vector3;
  97846. /**
  97847. * Gets the hit point in the world
  97848. */
  97849. get hitPointWorld(): Vector3;
  97850. /**
  97851. * Gets the ray "start point" of the ray in the world
  97852. */
  97853. get rayFromWorld(): Vector3;
  97854. /**
  97855. * Gets the ray "end point" of the ray in the world
  97856. */
  97857. get rayToWorld(): Vector3;
  97858. /**
  97859. * Sets the hit data (normal & point in world space)
  97860. * @param hitNormalWorld defines the normal in world space
  97861. * @param hitPointWorld defines the point in world space
  97862. */
  97863. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97864. /**
  97865. * Sets the distance from the start point to the hit point
  97866. * @param distance
  97867. */
  97868. setHitDistance(distance: number): void;
  97869. /**
  97870. * Calculates the distance manually
  97871. */
  97872. calculateHitDistance(): void;
  97873. /**
  97874. * Resets all the values to default
  97875. * @param from The from point on world space
  97876. * @param to The to point on world space
  97877. */
  97878. reset(from?: Vector3, to?: Vector3): void;
  97879. }
  97880. /**
  97881. * Interface for the size containing width and height
  97882. */
  97883. interface IXYZ {
  97884. /**
  97885. * X
  97886. */
  97887. x: number;
  97888. /**
  97889. * Y
  97890. */
  97891. y: number;
  97892. /**
  97893. * Z
  97894. */
  97895. z: number;
  97896. }
  97897. }
  97898. declare module BABYLON {
  97899. /**
  97900. * Interface used to describe a physics joint
  97901. */
  97902. export interface PhysicsImpostorJoint {
  97903. /** Defines the main impostor to which the joint is linked */
  97904. mainImpostor: PhysicsImpostor;
  97905. /** Defines the impostor that is connected to the main impostor using this joint */
  97906. connectedImpostor: PhysicsImpostor;
  97907. /** Defines the joint itself */
  97908. joint: PhysicsJoint;
  97909. }
  97910. /** @hidden */
  97911. export interface IPhysicsEnginePlugin {
  97912. world: any;
  97913. name: string;
  97914. setGravity(gravity: Vector3): void;
  97915. setTimeStep(timeStep: number): void;
  97916. getTimeStep(): number;
  97917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97921. removePhysicsBody(impostor: PhysicsImpostor): void;
  97922. generateJoint(joint: PhysicsImpostorJoint): void;
  97923. removeJoint(joint: PhysicsImpostorJoint): void;
  97924. isSupported(): boolean;
  97925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97932. getBodyMass(impostor: PhysicsImpostor): number;
  97933. getBodyFriction(impostor: PhysicsImpostor): number;
  97934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97935. getBodyRestitution(impostor: PhysicsImpostor): number;
  97936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97937. getBodyPressure?(impostor: PhysicsImpostor): number;
  97938. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97939. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97940. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97941. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97942. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97943. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97944. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97945. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97946. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97947. sleepBody(impostor: PhysicsImpostor): void;
  97948. wakeUpBody(impostor: PhysicsImpostor): void;
  97949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97950. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97951. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97953. getRadius(impostor: PhysicsImpostor): number;
  97954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97955. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97956. dispose(): void;
  97957. }
  97958. /**
  97959. * Interface used to define a physics engine
  97960. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97961. */
  97962. export interface IPhysicsEngine {
  97963. /**
  97964. * Gets the gravity vector used by the simulation
  97965. */
  97966. gravity: Vector3;
  97967. /**
  97968. * Sets the gravity vector used by the simulation
  97969. * @param gravity defines the gravity vector to use
  97970. */
  97971. setGravity(gravity: Vector3): void;
  97972. /**
  97973. * Set the time step of the physics engine.
  97974. * Default is 1/60.
  97975. * To slow it down, enter 1/600 for example.
  97976. * To speed it up, 1/30
  97977. * @param newTimeStep the new timestep to apply to this world.
  97978. */
  97979. setTimeStep(newTimeStep: number): void;
  97980. /**
  97981. * Get the time step of the physics engine.
  97982. * @returns the current time step
  97983. */
  97984. getTimeStep(): number;
  97985. /**
  97986. * Set the sub time step of the physics engine.
  97987. * Default is 0 meaning there is no sub steps
  97988. * To increase physics resolution precision, set a small value (like 1 ms)
  97989. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97990. */
  97991. setSubTimeStep(subTimeStep: number): void;
  97992. /**
  97993. * Get the sub time step of the physics engine.
  97994. * @returns the current sub time step
  97995. */
  97996. getSubTimeStep(): number;
  97997. /**
  97998. * Release all resources
  97999. */
  98000. dispose(): void;
  98001. /**
  98002. * Gets the name of the current physics plugin
  98003. * @returns the name of the plugin
  98004. */
  98005. getPhysicsPluginName(): string;
  98006. /**
  98007. * Adding a new impostor for the impostor tracking.
  98008. * This will be done by the impostor itself.
  98009. * @param impostor the impostor to add
  98010. */
  98011. addImpostor(impostor: PhysicsImpostor): void;
  98012. /**
  98013. * Remove an impostor from the engine.
  98014. * This impostor and its mesh will not longer be updated by the physics engine.
  98015. * @param impostor the impostor to remove
  98016. */
  98017. removeImpostor(impostor: PhysicsImpostor): void;
  98018. /**
  98019. * Add a joint to the physics engine
  98020. * @param mainImpostor defines the main impostor to which the joint is added.
  98021. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98022. * @param joint defines the joint that will connect both impostors.
  98023. */
  98024. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98025. /**
  98026. * Removes a joint from the simulation
  98027. * @param mainImpostor defines the impostor used with the joint
  98028. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98029. * @param joint defines the joint to remove
  98030. */
  98031. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98032. /**
  98033. * Gets the current plugin used to run the simulation
  98034. * @returns current plugin
  98035. */
  98036. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98037. /**
  98038. * Gets the list of physic impostors
  98039. * @returns an array of PhysicsImpostor
  98040. */
  98041. getImpostors(): Array<PhysicsImpostor>;
  98042. /**
  98043. * Gets the impostor for a physics enabled object
  98044. * @param object defines the object impersonated by the impostor
  98045. * @returns the PhysicsImpostor or null if not found
  98046. */
  98047. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98048. /**
  98049. * Gets the impostor for a physics body object
  98050. * @param body defines physics body used by the impostor
  98051. * @returns the PhysicsImpostor or null if not found
  98052. */
  98053. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98054. /**
  98055. * Does a raycast in the physics world
  98056. * @param from when should the ray start?
  98057. * @param to when should the ray end?
  98058. * @returns PhysicsRaycastResult
  98059. */
  98060. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98061. /**
  98062. * Called by the scene. No need to call it.
  98063. * @param delta defines the timespam between frames
  98064. */
  98065. _step(delta: number): void;
  98066. }
  98067. }
  98068. declare module BABYLON {
  98069. /**
  98070. * The interface for the physics imposter parameters
  98071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98072. */
  98073. export interface PhysicsImpostorParameters {
  98074. /**
  98075. * The mass of the physics imposter
  98076. */
  98077. mass: number;
  98078. /**
  98079. * The friction of the physics imposter
  98080. */
  98081. friction?: number;
  98082. /**
  98083. * The coefficient of restitution of the physics imposter
  98084. */
  98085. restitution?: number;
  98086. /**
  98087. * The native options of the physics imposter
  98088. */
  98089. nativeOptions?: any;
  98090. /**
  98091. * Specifies if the parent should be ignored
  98092. */
  98093. ignoreParent?: boolean;
  98094. /**
  98095. * Specifies if bi-directional transformations should be disabled
  98096. */
  98097. disableBidirectionalTransformation?: boolean;
  98098. /**
  98099. * The pressure inside the physics imposter, soft object only
  98100. */
  98101. pressure?: number;
  98102. /**
  98103. * The stiffness the physics imposter, soft object only
  98104. */
  98105. stiffness?: number;
  98106. /**
  98107. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98108. */
  98109. velocityIterations?: number;
  98110. /**
  98111. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98112. */
  98113. positionIterations?: number;
  98114. /**
  98115. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98116. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98117. * Add to fix multiple points
  98118. */
  98119. fixedPoints?: number;
  98120. /**
  98121. * The collision margin around a soft object
  98122. */
  98123. margin?: number;
  98124. /**
  98125. * The collision margin around a soft object
  98126. */
  98127. damping?: number;
  98128. /**
  98129. * The path for a rope based on an extrusion
  98130. */
  98131. path?: any;
  98132. /**
  98133. * The shape of an extrusion used for a rope based on an extrusion
  98134. */
  98135. shape?: any;
  98136. }
  98137. /**
  98138. * Interface for a physics-enabled object
  98139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98140. */
  98141. export interface IPhysicsEnabledObject {
  98142. /**
  98143. * The position of the physics-enabled object
  98144. */
  98145. position: Vector3;
  98146. /**
  98147. * The rotation of the physics-enabled object
  98148. */
  98149. rotationQuaternion: Nullable<Quaternion>;
  98150. /**
  98151. * The scale of the physics-enabled object
  98152. */
  98153. scaling: Vector3;
  98154. /**
  98155. * The rotation of the physics-enabled object
  98156. */
  98157. rotation?: Vector3;
  98158. /**
  98159. * The parent of the physics-enabled object
  98160. */
  98161. parent?: any;
  98162. /**
  98163. * The bounding info of the physics-enabled object
  98164. * @returns The bounding info of the physics-enabled object
  98165. */
  98166. getBoundingInfo(): BoundingInfo;
  98167. /**
  98168. * Computes the world matrix
  98169. * @param force Specifies if the world matrix should be computed by force
  98170. * @returns A world matrix
  98171. */
  98172. computeWorldMatrix(force: boolean): Matrix;
  98173. /**
  98174. * Gets the world matrix
  98175. * @returns A world matrix
  98176. */
  98177. getWorldMatrix?(): Matrix;
  98178. /**
  98179. * Gets the child meshes
  98180. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98181. * @returns An array of abstract meshes
  98182. */
  98183. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98184. /**
  98185. * Gets the vertex data
  98186. * @param kind The type of vertex data
  98187. * @returns A nullable array of numbers, or a float32 array
  98188. */
  98189. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98190. /**
  98191. * Gets the indices from the mesh
  98192. * @returns A nullable array of index arrays
  98193. */
  98194. getIndices?(): Nullable<IndicesArray>;
  98195. /**
  98196. * Gets the scene from the mesh
  98197. * @returns the indices array or null
  98198. */
  98199. getScene?(): Scene;
  98200. /**
  98201. * Gets the absolute position from the mesh
  98202. * @returns the absolute position
  98203. */
  98204. getAbsolutePosition(): Vector3;
  98205. /**
  98206. * Gets the absolute pivot point from the mesh
  98207. * @returns the absolute pivot point
  98208. */
  98209. getAbsolutePivotPoint(): Vector3;
  98210. /**
  98211. * Rotates the mesh
  98212. * @param axis The axis of rotation
  98213. * @param amount The amount of rotation
  98214. * @param space The space of the rotation
  98215. * @returns The rotation transform node
  98216. */
  98217. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98218. /**
  98219. * Translates the mesh
  98220. * @param axis The axis of translation
  98221. * @param distance The distance of translation
  98222. * @param space The space of the translation
  98223. * @returns The transform node
  98224. */
  98225. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98226. /**
  98227. * Sets the absolute position of the mesh
  98228. * @param absolutePosition The absolute position of the mesh
  98229. * @returns The transform node
  98230. */
  98231. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98232. /**
  98233. * Gets the class name of the mesh
  98234. * @returns The class name
  98235. */
  98236. getClassName(): string;
  98237. }
  98238. /**
  98239. * Represents a physics imposter
  98240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98241. */
  98242. export class PhysicsImpostor {
  98243. /**
  98244. * The physics-enabled object used as the physics imposter
  98245. */
  98246. object: IPhysicsEnabledObject;
  98247. /**
  98248. * The type of the physics imposter
  98249. */
  98250. type: number;
  98251. private _options;
  98252. private _scene?;
  98253. /**
  98254. * The default object size of the imposter
  98255. */
  98256. static DEFAULT_OBJECT_SIZE: Vector3;
  98257. /**
  98258. * The identity quaternion of the imposter
  98259. */
  98260. static IDENTITY_QUATERNION: Quaternion;
  98261. /** @hidden */
  98262. _pluginData: any;
  98263. private _physicsEngine;
  98264. private _physicsBody;
  98265. private _bodyUpdateRequired;
  98266. private _onBeforePhysicsStepCallbacks;
  98267. private _onAfterPhysicsStepCallbacks;
  98268. /** @hidden */
  98269. _onPhysicsCollideCallbacks: Array<{
  98270. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98271. otherImpostors: Array<PhysicsImpostor>;
  98272. }>;
  98273. private _deltaPosition;
  98274. private _deltaRotation;
  98275. private _deltaRotationConjugated;
  98276. /** @hidden */
  98277. _isFromLine: boolean;
  98278. private _parent;
  98279. private _isDisposed;
  98280. private static _tmpVecs;
  98281. private static _tmpQuat;
  98282. /**
  98283. * Specifies if the physics imposter is disposed
  98284. */
  98285. get isDisposed(): boolean;
  98286. /**
  98287. * Gets the mass of the physics imposter
  98288. */
  98289. get mass(): number;
  98290. set mass(value: number);
  98291. /**
  98292. * Gets the coefficient of friction
  98293. */
  98294. get friction(): number;
  98295. /**
  98296. * Sets the coefficient of friction
  98297. */
  98298. set friction(value: number);
  98299. /**
  98300. * Gets the coefficient of restitution
  98301. */
  98302. get restitution(): number;
  98303. /**
  98304. * Sets the coefficient of restitution
  98305. */
  98306. set restitution(value: number);
  98307. /**
  98308. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98309. */
  98310. get pressure(): number;
  98311. /**
  98312. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98313. */
  98314. set pressure(value: number);
  98315. /**
  98316. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98317. */
  98318. get stiffness(): number;
  98319. /**
  98320. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98321. */
  98322. set stiffness(value: number);
  98323. /**
  98324. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98325. */
  98326. get velocityIterations(): number;
  98327. /**
  98328. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98329. */
  98330. set velocityIterations(value: number);
  98331. /**
  98332. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98333. */
  98334. get positionIterations(): number;
  98335. /**
  98336. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98337. */
  98338. set positionIterations(value: number);
  98339. /**
  98340. * The unique id of the physics imposter
  98341. * set by the physics engine when adding this impostor to the array
  98342. */
  98343. uniqueId: number;
  98344. /**
  98345. * @hidden
  98346. */
  98347. soft: boolean;
  98348. /**
  98349. * @hidden
  98350. */
  98351. segments: number;
  98352. private _joints;
  98353. /**
  98354. * Initializes the physics imposter
  98355. * @param object The physics-enabled object used as the physics imposter
  98356. * @param type The type of the physics imposter
  98357. * @param _options The options for the physics imposter
  98358. * @param _scene The Babylon scene
  98359. */
  98360. constructor(
  98361. /**
  98362. * The physics-enabled object used as the physics imposter
  98363. */
  98364. object: IPhysicsEnabledObject,
  98365. /**
  98366. * The type of the physics imposter
  98367. */
  98368. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98369. /**
  98370. * This function will completly initialize this impostor.
  98371. * It will create a new body - but only if this mesh has no parent.
  98372. * If it has, this impostor will not be used other than to define the impostor
  98373. * of the child mesh.
  98374. * @hidden
  98375. */
  98376. _init(): void;
  98377. private _getPhysicsParent;
  98378. /**
  98379. * Should a new body be generated.
  98380. * @returns boolean specifying if body initialization is required
  98381. */
  98382. isBodyInitRequired(): boolean;
  98383. /**
  98384. * Sets the updated scaling
  98385. * @param updated Specifies if the scaling is updated
  98386. */
  98387. setScalingUpdated(): void;
  98388. /**
  98389. * Force a regeneration of this or the parent's impostor's body.
  98390. * Use under cautious - This will remove all joints already implemented.
  98391. */
  98392. forceUpdate(): void;
  98393. /**
  98394. * Gets the body that holds this impostor. Either its own, or its parent.
  98395. */
  98396. get physicsBody(): any;
  98397. /**
  98398. * Get the parent of the physics imposter
  98399. * @returns Physics imposter or null
  98400. */
  98401. get parent(): Nullable<PhysicsImpostor>;
  98402. /**
  98403. * Sets the parent of the physics imposter
  98404. */
  98405. set parent(value: Nullable<PhysicsImpostor>);
  98406. /**
  98407. * Set the physics body. Used mainly by the physics engine/plugin
  98408. */
  98409. set physicsBody(physicsBody: any);
  98410. /**
  98411. * Resets the update flags
  98412. */
  98413. resetUpdateFlags(): void;
  98414. /**
  98415. * Gets the object extend size
  98416. * @returns the object extend size
  98417. */
  98418. getObjectExtendSize(): Vector3;
  98419. /**
  98420. * Gets the object center
  98421. * @returns The object center
  98422. */
  98423. getObjectCenter(): Vector3;
  98424. /**
  98425. * Get a specific parameter from the options parameters
  98426. * @param paramName The object parameter name
  98427. * @returns The object parameter
  98428. */
  98429. getParam(paramName: string): any;
  98430. /**
  98431. * Sets a specific parameter in the options given to the physics plugin
  98432. * @param paramName The parameter name
  98433. * @param value The value of the parameter
  98434. */
  98435. setParam(paramName: string, value: number): void;
  98436. /**
  98437. * Specifically change the body's mass option. Won't recreate the physics body object
  98438. * @param mass The mass of the physics imposter
  98439. */
  98440. setMass(mass: number): void;
  98441. /**
  98442. * Gets the linear velocity
  98443. * @returns linear velocity or null
  98444. */
  98445. getLinearVelocity(): Nullable<Vector3>;
  98446. /**
  98447. * Sets the linear velocity
  98448. * @param velocity linear velocity or null
  98449. */
  98450. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98451. /**
  98452. * Gets the angular velocity
  98453. * @returns angular velocity or null
  98454. */
  98455. getAngularVelocity(): Nullable<Vector3>;
  98456. /**
  98457. * Sets the angular velocity
  98458. * @param velocity The velocity or null
  98459. */
  98460. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98461. /**
  98462. * Execute a function with the physics plugin native code
  98463. * Provide a function the will have two variables - the world object and the physics body object
  98464. * @param func The function to execute with the physics plugin native code
  98465. */
  98466. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98467. /**
  98468. * Register a function that will be executed before the physics world is stepping forward
  98469. * @param func The function to execute before the physics world is stepped forward
  98470. */
  98471. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98472. /**
  98473. * Unregister a function that will be executed before the physics world is stepping forward
  98474. * @param func The function to execute before the physics world is stepped forward
  98475. */
  98476. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98477. /**
  98478. * Register a function that will be executed after the physics step
  98479. * @param func The function to execute after physics step
  98480. */
  98481. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98482. /**
  98483. * Unregisters a function that will be executed after the physics step
  98484. * @param func The function to execute after physics step
  98485. */
  98486. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98487. /**
  98488. * register a function that will be executed when this impostor collides against a different body
  98489. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98490. * @param func Callback that is executed on collision
  98491. */
  98492. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98493. /**
  98494. * Unregisters the physics imposter on contact
  98495. * @param collideAgainst The physics object to collide against
  98496. * @param func Callback to execute on collision
  98497. */
  98498. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98499. private _tmpQuat;
  98500. private _tmpQuat2;
  98501. /**
  98502. * Get the parent rotation
  98503. * @returns The parent rotation
  98504. */
  98505. getParentsRotation(): Quaternion;
  98506. /**
  98507. * this function is executed by the physics engine.
  98508. */
  98509. beforeStep: () => void;
  98510. /**
  98511. * this function is executed by the physics engine
  98512. */
  98513. afterStep: () => void;
  98514. /**
  98515. * Legacy collision detection event support
  98516. */
  98517. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98518. /**
  98519. * event and body object due to cannon's event-based architecture.
  98520. */
  98521. onCollide: (e: {
  98522. body: any;
  98523. }) => void;
  98524. /**
  98525. * Apply a force
  98526. * @param force The force to apply
  98527. * @param contactPoint The contact point for the force
  98528. * @returns The physics imposter
  98529. */
  98530. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98531. /**
  98532. * Apply an impulse
  98533. * @param force The impulse force
  98534. * @param contactPoint The contact point for the impulse force
  98535. * @returns The physics imposter
  98536. */
  98537. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98538. /**
  98539. * A help function to create a joint
  98540. * @param otherImpostor A physics imposter used to create a joint
  98541. * @param jointType The type of joint
  98542. * @param jointData The data for the joint
  98543. * @returns The physics imposter
  98544. */
  98545. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98546. /**
  98547. * Add a joint to this impostor with a different impostor
  98548. * @param otherImpostor A physics imposter used to add a joint
  98549. * @param joint The joint to add
  98550. * @returns The physics imposter
  98551. */
  98552. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98553. /**
  98554. * Add an anchor to a cloth impostor
  98555. * @param otherImpostor rigid impostor to anchor to
  98556. * @param width ratio across width from 0 to 1
  98557. * @param height ratio up height from 0 to 1
  98558. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98559. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98560. * @returns impostor the soft imposter
  98561. */
  98562. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98563. /**
  98564. * Add a hook to a rope impostor
  98565. * @param otherImpostor rigid impostor to anchor to
  98566. * @param length ratio across rope from 0 to 1
  98567. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98568. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98569. * @returns impostor the rope imposter
  98570. */
  98571. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98572. /**
  98573. * Will keep this body still, in a sleep mode.
  98574. * @returns the physics imposter
  98575. */
  98576. sleep(): PhysicsImpostor;
  98577. /**
  98578. * Wake the body up.
  98579. * @returns The physics imposter
  98580. */
  98581. wakeUp(): PhysicsImpostor;
  98582. /**
  98583. * Clones the physics imposter
  98584. * @param newObject The physics imposter clones to this physics-enabled object
  98585. * @returns A nullable physics imposter
  98586. */
  98587. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98588. /**
  98589. * Disposes the physics imposter
  98590. */
  98591. dispose(): void;
  98592. /**
  98593. * Sets the delta position
  98594. * @param position The delta position amount
  98595. */
  98596. setDeltaPosition(position: Vector3): void;
  98597. /**
  98598. * Sets the delta rotation
  98599. * @param rotation The delta rotation amount
  98600. */
  98601. setDeltaRotation(rotation: Quaternion): void;
  98602. /**
  98603. * Gets the box size of the physics imposter and stores the result in the input parameter
  98604. * @param result Stores the box size
  98605. * @returns The physics imposter
  98606. */
  98607. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98608. /**
  98609. * Gets the radius of the physics imposter
  98610. * @returns Radius of the physics imposter
  98611. */
  98612. getRadius(): number;
  98613. /**
  98614. * Sync a bone with this impostor
  98615. * @param bone The bone to sync to the impostor.
  98616. * @param boneMesh The mesh that the bone is influencing.
  98617. * @param jointPivot The pivot of the joint / bone in local space.
  98618. * @param distToJoint Optional distance from the impostor to the joint.
  98619. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98620. */
  98621. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98622. /**
  98623. * Sync impostor to a bone
  98624. * @param bone The bone that the impostor will be synced to.
  98625. * @param boneMesh The mesh that the bone is influencing.
  98626. * @param jointPivot The pivot of the joint / bone in local space.
  98627. * @param distToJoint Optional distance from the impostor to the joint.
  98628. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98629. * @param boneAxis Optional vector3 axis the bone is aligned with
  98630. */
  98631. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98632. /**
  98633. * No-Imposter type
  98634. */
  98635. static NoImpostor: number;
  98636. /**
  98637. * Sphere-Imposter type
  98638. */
  98639. static SphereImpostor: number;
  98640. /**
  98641. * Box-Imposter type
  98642. */
  98643. static BoxImpostor: number;
  98644. /**
  98645. * Plane-Imposter type
  98646. */
  98647. static PlaneImpostor: number;
  98648. /**
  98649. * Mesh-imposter type
  98650. */
  98651. static MeshImpostor: number;
  98652. /**
  98653. * Capsule-Impostor type (Ammo.js plugin only)
  98654. */
  98655. static CapsuleImpostor: number;
  98656. /**
  98657. * Cylinder-Imposter type
  98658. */
  98659. static CylinderImpostor: number;
  98660. /**
  98661. * Particle-Imposter type
  98662. */
  98663. static ParticleImpostor: number;
  98664. /**
  98665. * Heightmap-Imposter type
  98666. */
  98667. static HeightmapImpostor: number;
  98668. /**
  98669. * ConvexHull-Impostor type (Ammo.js plugin only)
  98670. */
  98671. static ConvexHullImpostor: number;
  98672. /**
  98673. * Custom-Imposter type (Ammo.js plugin only)
  98674. */
  98675. static CustomImpostor: number;
  98676. /**
  98677. * Rope-Imposter type
  98678. */
  98679. static RopeImpostor: number;
  98680. /**
  98681. * Cloth-Imposter type
  98682. */
  98683. static ClothImpostor: number;
  98684. /**
  98685. * Softbody-Imposter type
  98686. */
  98687. static SoftbodyImpostor: number;
  98688. }
  98689. }
  98690. declare module BABYLON {
  98691. /**
  98692. * @hidden
  98693. **/
  98694. export class _CreationDataStorage {
  98695. closePath?: boolean;
  98696. closeArray?: boolean;
  98697. idx: number[];
  98698. dashSize: number;
  98699. gapSize: number;
  98700. path3D: Path3D;
  98701. pathArray: Vector3[][];
  98702. arc: number;
  98703. radius: number;
  98704. cap: number;
  98705. tessellation: number;
  98706. }
  98707. /**
  98708. * @hidden
  98709. **/
  98710. class _InstanceDataStorage {
  98711. visibleInstances: any;
  98712. batchCache: _InstancesBatch;
  98713. instancesBufferSize: number;
  98714. instancesBuffer: Nullable<Buffer>;
  98715. instancesData: Float32Array;
  98716. overridenInstanceCount: number;
  98717. isFrozen: boolean;
  98718. previousBatch: Nullable<_InstancesBatch>;
  98719. hardwareInstancedRendering: boolean;
  98720. sideOrientation: number;
  98721. manualUpdate: boolean;
  98722. }
  98723. /**
  98724. * @hidden
  98725. **/
  98726. export class _InstancesBatch {
  98727. mustReturn: boolean;
  98728. visibleInstances: Nullable<InstancedMesh[]>[];
  98729. renderSelf: boolean[];
  98730. hardwareInstancedRendering: boolean[];
  98731. }
  98732. /**
  98733. * Class used to represent renderable models
  98734. */
  98735. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98736. /**
  98737. * Mesh side orientation : usually the external or front surface
  98738. */
  98739. static readonly FRONTSIDE: number;
  98740. /**
  98741. * Mesh side orientation : usually the internal or back surface
  98742. */
  98743. static readonly BACKSIDE: number;
  98744. /**
  98745. * Mesh side orientation : both internal and external or front and back surfaces
  98746. */
  98747. static readonly DOUBLESIDE: number;
  98748. /**
  98749. * Mesh side orientation : by default, `FRONTSIDE`
  98750. */
  98751. static readonly DEFAULTSIDE: number;
  98752. /**
  98753. * Mesh cap setting : no cap
  98754. */
  98755. static readonly NO_CAP: number;
  98756. /**
  98757. * Mesh cap setting : one cap at the beginning of the mesh
  98758. */
  98759. static readonly CAP_START: number;
  98760. /**
  98761. * Mesh cap setting : one cap at the end of the mesh
  98762. */
  98763. static readonly CAP_END: number;
  98764. /**
  98765. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98766. */
  98767. static readonly CAP_ALL: number;
  98768. /**
  98769. * Mesh pattern setting : no flip or rotate
  98770. */
  98771. static readonly NO_FLIP: number;
  98772. /**
  98773. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98774. */
  98775. static readonly FLIP_TILE: number;
  98776. /**
  98777. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98778. */
  98779. static readonly ROTATE_TILE: number;
  98780. /**
  98781. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98782. */
  98783. static readonly FLIP_ROW: number;
  98784. /**
  98785. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98786. */
  98787. static readonly ROTATE_ROW: number;
  98788. /**
  98789. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98790. */
  98791. static readonly FLIP_N_ROTATE_TILE: number;
  98792. /**
  98793. * Mesh pattern setting : rotate pattern and rotate
  98794. */
  98795. static readonly FLIP_N_ROTATE_ROW: number;
  98796. /**
  98797. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98798. */
  98799. static readonly CENTER: number;
  98800. /**
  98801. * Mesh tile positioning : part tiles on left
  98802. */
  98803. static readonly LEFT: number;
  98804. /**
  98805. * Mesh tile positioning : part tiles on right
  98806. */
  98807. static readonly RIGHT: number;
  98808. /**
  98809. * Mesh tile positioning : part tiles on top
  98810. */
  98811. static readonly TOP: number;
  98812. /**
  98813. * Mesh tile positioning : part tiles on bottom
  98814. */
  98815. static readonly BOTTOM: number;
  98816. /**
  98817. * Gets the default side orientation.
  98818. * @param orientation the orientation to value to attempt to get
  98819. * @returns the default orientation
  98820. * @hidden
  98821. */
  98822. static _GetDefaultSideOrientation(orientation?: number): number;
  98823. private _internalMeshDataInfo;
  98824. /**
  98825. * An event triggered before rendering the mesh
  98826. */
  98827. get onBeforeRenderObservable(): Observable<Mesh>;
  98828. /**
  98829. * An event triggered before binding the mesh
  98830. */
  98831. get onBeforeBindObservable(): Observable<Mesh>;
  98832. /**
  98833. * An event triggered after rendering the mesh
  98834. */
  98835. get onAfterRenderObservable(): Observable<Mesh>;
  98836. /**
  98837. * An event triggered before drawing the mesh
  98838. */
  98839. get onBeforeDrawObservable(): Observable<Mesh>;
  98840. private _onBeforeDrawObserver;
  98841. /**
  98842. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98843. */
  98844. set onBeforeDraw(callback: () => void);
  98845. get hasInstances(): boolean;
  98846. /**
  98847. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98848. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98849. */
  98850. delayLoadState: number;
  98851. /**
  98852. * Gets the list of instances created from this mesh
  98853. * it is not supposed to be modified manually.
  98854. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98856. */
  98857. instances: InstancedMesh[];
  98858. /**
  98859. * Gets the file containing delay loading data for this mesh
  98860. */
  98861. delayLoadingFile: string;
  98862. /** @hidden */
  98863. _binaryInfo: any;
  98864. /**
  98865. * User defined function used to change how LOD level selection is done
  98866. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98867. */
  98868. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98869. /**
  98870. * Gets or sets the morph target manager
  98871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98872. */
  98873. get morphTargetManager(): Nullable<MorphTargetManager>;
  98874. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98875. /** @hidden */
  98876. _creationDataStorage: Nullable<_CreationDataStorage>;
  98877. /** @hidden */
  98878. _geometry: Nullable<Geometry>;
  98879. /** @hidden */
  98880. _delayInfo: Array<string>;
  98881. /** @hidden */
  98882. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98883. /** @hidden */
  98884. _instanceDataStorage: _InstanceDataStorage;
  98885. private _effectiveMaterial;
  98886. /** @hidden */
  98887. _shouldGenerateFlatShading: boolean;
  98888. /** @hidden */
  98889. _originalBuilderSideOrientation: number;
  98890. /**
  98891. * Use this property to change the original side orientation defined at construction time
  98892. */
  98893. overrideMaterialSideOrientation: Nullable<number>;
  98894. /**
  98895. * Gets the source mesh (the one used to clone this one from)
  98896. */
  98897. get source(): Nullable<Mesh>;
  98898. /**
  98899. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98900. */
  98901. get isUnIndexed(): boolean;
  98902. set isUnIndexed(value: boolean);
  98903. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98904. get worldMatrixInstancedBuffer(): Float32Array;
  98905. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98906. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98907. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98908. /**
  98909. * @constructor
  98910. * @param name The value used by scene.getMeshByName() to do a lookup.
  98911. * @param scene The scene to add this mesh to.
  98912. * @param parent The parent of this mesh, if it has one
  98913. * @param source An optional Mesh from which geometry is shared, cloned.
  98914. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98915. * When false, achieved by calling a clone(), also passing False.
  98916. * This will make creation of children, recursive.
  98917. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98918. */
  98919. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98920. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98921. doNotInstantiate: boolean;
  98922. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98923. /**
  98924. * Gets the class name
  98925. * @returns the string "Mesh".
  98926. */
  98927. getClassName(): string;
  98928. /** @hidden */
  98929. get _isMesh(): boolean;
  98930. /**
  98931. * Returns a description of this mesh
  98932. * @param fullDetails define if full details about this mesh must be used
  98933. * @returns a descriptive string representing this mesh
  98934. */
  98935. toString(fullDetails?: boolean): string;
  98936. /** @hidden */
  98937. _unBindEffect(): void;
  98938. /**
  98939. * Gets a boolean indicating if this mesh has LOD
  98940. */
  98941. get hasLODLevels(): boolean;
  98942. /**
  98943. * Gets the list of MeshLODLevel associated with the current mesh
  98944. * @returns an array of MeshLODLevel
  98945. */
  98946. getLODLevels(): MeshLODLevel[];
  98947. private _sortLODLevels;
  98948. /**
  98949. * Add a mesh as LOD level triggered at the given distance.
  98950. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98951. * @param distance The distance from the center of the object to show this level
  98952. * @param mesh The mesh to be added as LOD level (can be null)
  98953. * @return This mesh (for chaining)
  98954. */
  98955. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98956. /**
  98957. * Returns the LOD level mesh at the passed distance or null if not found.
  98958. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98959. * @param distance The distance from the center of the object to show this level
  98960. * @returns a Mesh or `null`
  98961. */
  98962. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98963. /**
  98964. * Remove a mesh from the LOD array
  98965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98966. * @param mesh defines the mesh to be removed
  98967. * @return This mesh (for chaining)
  98968. */
  98969. removeLODLevel(mesh: Mesh): Mesh;
  98970. /**
  98971. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98972. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98973. * @param camera defines the camera to use to compute distance
  98974. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98975. * @return This mesh (for chaining)
  98976. */
  98977. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98978. /**
  98979. * Gets the mesh internal Geometry object
  98980. */
  98981. get geometry(): Nullable<Geometry>;
  98982. /**
  98983. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98984. * @returns the total number of vertices
  98985. */
  98986. getTotalVertices(): number;
  98987. /**
  98988. * Returns the content of an associated vertex buffer
  98989. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98990. * - VertexBuffer.PositionKind
  98991. * - VertexBuffer.UVKind
  98992. * - VertexBuffer.UV2Kind
  98993. * - VertexBuffer.UV3Kind
  98994. * - VertexBuffer.UV4Kind
  98995. * - VertexBuffer.UV5Kind
  98996. * - VertexBuffer.UV6Kind
  98997. * - VertexBuffer.ColorKind
  98998. * - VertexBuffer.MatricesIndicesKind
  98999. * - VertexBuffer.MatricesIndicesExtraKind
  99000. * - VertexBuffer.MatricesWeightsKind
  99001. * - VertexBuffer.MatricesWeightsExtraKind
  99002. * @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
  99003. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  99004. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  99005. */
  99006. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  99007. /**
  99008. * Returns the mesh VertexBuffer object from the requested `kind`
  99009. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99010. * - VertexBuffer.PositionKind
  99011. * - VertexBuffer.NormalKind
  99012. * - VertexBuffer.UVKind
  99013. * - VertexBuffer.UV2Kind
  99014. * - VertexBuffer.UV3Kind
  99015. * - VertexBuffer.UV4Kind
  99016. * - VertexBuffer.UV5Kind
  99017. * - VertexBuffer.UV6Kind
  99018. * - VertexBuffer.ColorKind
  99019. * - VertexBuffer.MatricesIndicesKind
  99020. * - VertexBuffer.MatricesIndicesExtraKind
  99021. * - VertexBuffer.MatricesWeightsKind
  99022. * - VertexBuffer.MatricesWeightsExtraKind
  99023. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99024. */
  99025. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99026. /**
  99027. * Tests if a specific vertex buffer is associated with this mesh
  99028. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99029. * - VertexBuffer.PositionKind
  99030. * - VertexBuffer.NormalKind
  99031. * - VertexBuffer.UVKind
  99032. * - VertexBuffer.UV2Kind
  99033. * - VertexBuffer.UV3Kind
  99034. * - VertexBuffer.UV4Kind
  99035. * - VertexBuffer.UV5Kind
  99036. * - VertexBuffer.UV6Kind
  99037. * - VertexBuffer.ColorKind
  99038. * - VertexBuffer.MatricesIndicesKind
  99039. * - VertexBuffer.MatricesIndicesExtraKind
  99040. * - VertexBuffer.MatricesWeightsKind
  99041. * - VertexBuffer.MatricesWeightsExtraKind
  99042. * @returns a boolean
  99043. */
  99044. isVerticesDataPresent(kind: string): boolean;
  99045. /**
  99046. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99047. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99048. * - VertexBuffer.PositionKind
  99049. * - VertexBuffer.UVKind
  99050. * - VertexBuffer.UV2Kind
  99051. * - VertexBuffer.UV3Kind
  99052. * - VertexBuffer.UV4Kind
  99053. * - VertexBuffer.UV5Kind
  99054. * - VertexBuffer.UV6Kind
  99055. * - VertexBuffer.ColorKind
  99056. * - VertexBuffer.MatricesIndicesKind
  99057. * - VertexBuffer.MatricesIndicesExtraKind
  99058. * - VertexBuffer.MatricesWeightsKind
  99059. * - VertexBuffer.MatricesWeightsExtraKind
  99060. * @returns a boolean
  99061. */
  99062. isVertexBufferUpdatable(kind: string): boolean;
  99063. /**
  99064. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99065. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99066. * - VertexBuffer.PositionKind
  99067. * - VertexBuffer.NormalKind
  99068. * - VertexBuffer.UVKind
  99069. * - VertexBuffer.UV2Kind
  99070. * - VertexBuffer.UV3Kind
  99071. * - VertexBuffer.UV4Kind
  99072. * - VertexBuffer.UV5Kind
  99073. * - VertexBuffer.UV6Kind
  99074. * - VertexBuffer.ColorKind
  99075. * - VertexBuffer.MatricesIndicesKind
  99076. * - VertexBuffer.MatricesIndicesExtraKind
  99077. * - VertexBuffer.MatricesWeightsKind
  99078. * - VertexBuffer.MatricesWeightsExtraKind
  99079. * @returns an array of strings
  99080. */
  99081. getVerticesDataKinds(): string[];
  99082. /**
  99083. * Returns a positive integer : the total number of indices in this mesh geometry.
  99084. * @returns the numner of indices or zero if the mesh has no geometry.
  99085. */
  99086. getTotalIndices(): number;
  99087. /**
  99088. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99089. * @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.
  99090. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99091. * @returns the indices array or an empty array if the mesh has no geometry
  99092. */
  99093. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99094. get isBlocked(): boolean;
  99095. /**
  99096. * Determine if the current mesh is ready to be rendered
  99097. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99098. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99099. * @returns true if all associated assets are ready (material, textures, shaders)
  99100. */
  99101. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99102. /**
  99103. * 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.
  99104. */
  99105. get areNormalsFrozen(): boolean;
  99106. /**
  99107. * 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.
  99108. * @returns the current mesh
  99109. */
  99110. freezeNormals(): Mesh;
  99111. /**
  99112. * 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
  99113. * @returns the current mesh
  99114. */
  99115. unfreezeNormals(): Mesh;
  99116. /**
  99117. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99118. */
  99119. set overridenInstanceCount(count: number);
  99120. /** @hidden */
  99121. _preActivate(): Mesh;
  99122. /** @hidden */
  99123. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99124. /** @hidden */
  99125. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99126. /**
  99127. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99128. * This means the mesh underlying bounding box and sphere are recomputed.
  99129. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99130. * @returns the current mesh
  99131. */
  99132. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99133. /** @hidden */
  99134. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99135. /**
  99136. * This function will subdivide the mesh into multiple submeshes
  99137. * @param count defines the expected number of submeshes
  99138. */
  99139. subdivide(count: number): void;
  99140. /**
  99141. * Copy a FloatArray into a specific associated vertex buffer
  99142. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99143. * - VertexBuffer.PositionKind
  99144. * - VertexBuffer.UVKind
  99145. * - VertexBuffer.UV2Kind
  99146. * - VertexBuffer.UV3Kind
  99147. * - VertexBuffer.UV4Kind
  99148. * - VertexBuffer.UV5Kind
  99149. * - VertexBuffer.UV6Kind
  99150. * - VertexBuffer.ColorKind
  99151. * - VertexBuffer.MatricesIndicesKind
  99152. * - VertexBuffer.MatricesIndicesExtraKind
  99153. * - VertexBuffer.MatricesWeightsKind
  99154. * - VertexBuffer.MatricesWeightsExtraKind
  99155. * @param data defines the data source
  99156. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99157. * @param stride defines the data stride size (can be null)
  99158. * @returns the current mesh
  99159. */
  99160. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99161. /**
  99162. * Delete a vertex buffer associated with this mesh
  99163. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99164. * - VertexBuffer.PositionKind
  99165. * - VertexBuffer.UVKind
  99166. * - VertexBuffer.UV2Kind
  99167. * - VertexBuffer.UV3Kind
  99168. * - VertexBuffer.UV4Kind
  99169. * - VertexBuffer.UV5Kind
  99170. * - VertexBuffer.UV6Kind
  99171. * - VertexBuffer.ColorKind
  99172. * - VertexBuffer.MatricesIndicesKind
  99173. * - VertexBuffer.MatricesIndicesExtraKind
  99174. * - VertexBuffer.MatricesWeightsKind
  99175. * - VertexBuffer.MatricesWeightsExtraKind
  99176. */
  99177. removeVerticesData(kind: string): void;
  99178. /**
  99179. * Flags an associated vertex buffer as updatable
  99180. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99181. * - VertexBuffer.PositionKind
  99182. * - VertexBuffer.UVKind
  99183. * - VertexBuffer.UV2Kind
  99184. * - VertexBuffer.UV3Kind
  99185. * - VertexBuffer.UV4Kind
  99186. * - VertexBuffer.UV5Kind
  99187. * - VertexBuffer.UV6Kind
  99188. * - VertexBuffer.ColorKind
  99189. * - VertexBuffer.MatricesIndicesKind
  99190. * - VertexBuffer.MatricesIndicesExtraKind
  99191. * - VertexBuffer.MatricesWeightsKind
  99192. * - VertexBuffer.MatricesWeightsExtraKind
  99193. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99194. */
  99195. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99196. /**
  99197. * Sets the mesh global Vertex Buffer
  99198. * @param buffer defines the buffer to use
  99199. * @returns the current mesh
  99200. */
  99201. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99202. /**
  99203. * Update a specific associated vertex buffer
  99204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99205. * - VertexBuffer.PositionKind
  99206. * - VertexBuffer.UVKind
  99207. * - VertexBuffer.UV2Kind
  99208. * - VertexBuffer.UV3Kind
  99209. * - VertexBuffer.UV4Kind
  99210. * - VertexBuffer.UV5Kind
  99211. * - VertexBuffer.UV6Kind
  99212. * - VertexBuffer.ColorKind
  99213. * - VertexBuffer.MatricesIndicesKind
  99214. * - VertexBuffer.MatricesIndicesExtraKind
  99215. * - VertexBuffer.MatricesWeightsKind
  99216. * - VertexBuffer.MatricesWeightsExtraKind
  99217. * @param data defines the data source
  99218. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99219. * @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)
  99220. * @returns the current mesh
  99221. */
  99222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99223. /**
  99224. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99225. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99226. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99227. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99228. * @returns the current mesh
  99229. */
  99230. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99231. /**
  99232. * Creates a un-shared specific occurence of the geometry for the mesh.
  99233. * @returns the current mesh
  99234. */
  99235. makeGeometryUnique(): Mesh;
  99236. /**
  99237. * Set the index buffer of this mesh
  99238. * @param indices defines the source data
  99239. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99240. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99241. * @returns the current mesh
  99242. */
  99243. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99244. /**
  99245. * Update the current index buffer
  99246. * @param indices defines the source data
  99247. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99248. * @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)
  99249. * @returns the current mesh
  99250. */
  99251. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99252. /**
  99253. * Invert the geometry to move from a right handed system to a left handed one.
  99254. * @returns the current mesh
  99255. */
  99256. toLeftHanded(): Mesh;
  99257. /** @hidden */
  99258. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99259. /** @hidden */
  99260. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99261. /**
  99262. * Registers for this mesh a javascript function called just before the rendering process
  99263. * @param func defines the function to call before rendering this mesh
  99264. * @returns the current mesh
  99265. */
  99266. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99267. /**
  99268. * Disposes a previously registered javascript function called before the rendering
  99269. * @param func defines the function to remove
  99270. * @returns the current mesh
  99271. */
  99272. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99273. /**
  99274. * Registers for this mesh a javascript function called just after the rendering is complete
  99275. * @param func defines the function to call after rendering this mesh
  99276. * @returns the current mesh
  99277. */
  99278. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99279. /**
  99280. * Disposes a previously registered javascript function called after the rendering.
  99281. * @param func defines the function to remove
  99282. * @returns the current mesh
  99283. */
  99284. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99285. /** @hidden */
  99286. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99287. /** @hidden */
  99288. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99289. /** @hidden */
  99290. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99291. /** @hidden */
  99292. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99293. /** @hidden */
  99294. _rebuild(): void;
  99295. /** @hidden */
  99296. _freeze(): void;
  99297. /** @hidden */
  99298. _unFreeze(): void;
  99299. /**
  99300. * 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
  99301. * @param subMesh defines the subMesh to render
  99302. * @param enableAlphaMode defines if alpha mode can be changed
  99303. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99304. * @returns the current mesh
  99305. */
  99306. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99307. private _onBeforeDraw;
  99308. /**
  99309. * Renormalize the mesh and patch it up if there are no weights
  99310. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99311. * However in the case of zero weights then we set just a single influence to 1.
  99312. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99313. */
  99314. cleanMatrixWeights(): void;
  99315. private normalizeSkinFourWeights;
  99316. private normalizeSkinWeightsAndExtra;
  99317. /**
  99318. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99319. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99320. * the user know there was an issue with importing the mesh
  99321. * @returns a validation object with skinned, valid and report string
  99322. */
  99323. validateSkinning(): {
  99324. skinned: boolean;
  99325. valid: boolean;
  99326. report: string;
  99327. };
  99328. /** @hidden */
  99329. _checkDelayState(): Mesh;
  99330. private _queueLoad;
  99331. /**
  99332. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99333. * A mesh is in the frustum if its bounding box intersects the frustum
  99334. * @param frustumPlanes defines the frustum to test
  99335. * @returns true if the mesh is in the frustum planes
  99336. */
  99337. isInFrustum(frustumPlanes: Plane[]): boolean;
  99338. /**
  99339. * Sets the mesh material by the material or multiMaterial `id` property
  99340. * @param id is a string identifying the material or the multiMaterial
  99341. * @returns the current mesh
  99342. */
  99343. setMaterialByID(id: string): Mesh;
  99344. /**
  99345. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99346. * @returns an array of IAnimatable
  99347. */
  99348. getAnimatables(): IAnimatable[];
  99349. /**
  99350. * Modifies the mesh geometry according to the passed transformation matrix.
  99351. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99352. * The mesh normals are modified using the same transformation.
  99353. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99354. * @param transform defines the transform matrix to use
  99355. * @see http://doc.babylonjs.com/resources/baking_transformations
  99356. * @returns the current mesh
  99357. */
  99358. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99359. /**
  99360. * Modifies the mesh geometry according to its own current World Matrix.
  99361. * The mesh World Matrix is then reset.
  99362. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99363. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99364. * @see http://doc.babylonjs.com/resources/baking_transformations
  99365. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99366. * @returns the current mesh
  99367. */
  99368. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99369. /** @hidden */
  99370. get _positions(): Nullable<Vector3[]>;
  99371. /** @hidden */
  99372. _resetPointsArrayCache(): Mesh;
  99373. /** @hidden */
  99374. _generatePointsArray(): boolean;
  99375. /**
  99376. * Returns a new Mesh object generated from the current mesh properties.
  99377. * This method must not get confused with createInstance()
  99378. * @param name is a string, the name given to the new mesh
  99379. * @param newParent can be any Node object (default `null`)
  99380. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99381. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99382. * @returns a new mesh
  99383. */
  99384. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99385. /**
  99386. * Releases resources associated with this mesh.
  99387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99389. */
  99390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99391. /** @hidden */
  99392. _disposeInstanceSpecificData(): void;
  99393. /**
  99394. * Modifies the mesh geometry according to a displacement map.
  99395. * 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.
  99396. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99397. * @param url is a string, the URL from the image file is to be downloaded.
  99398. * @param minHeight is the lower limit of the displacement.
  99399. * @param maxHeight is the upper limit of the displacement.
  99400. * @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.
  99401. * @param uvOffset is an optional vector2 used to offset UV.
  99402. * @param uvScale is an optional vector2 used to scale UV.
  99403. * @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.
  99404. * @returns the Mesh.
  99405. */
  99406. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99407. /**
  99408. * Modifies the mesh geometry according to a displacementMap buffer.
  99409. * 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.
  99410. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99411. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99412. * @param heightMapWidth is the width of the buffer image.
  99413. * @param heightMapHeight is the height of the buffer image.
  99414. * @param minHeight is the lower limit of the displacement.
  99415. * @param maxHeight is the upper limit of the displacement.
  99416. * @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.
  99417. * @param uvOffset is an optional vector2 used to offset UV.
  99418. * @param uvScale is an optional vector2 used to scale UV.
  99419. * @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.
  99420. * @returns the Mesh.
  99421. */
  99422. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99423. /**
  99424. * Modify the mesh to get a flat shading rendering.
  99425. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99426. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99427. * @returns current mesh
  99428. */
  99429. convertToFlatShadedMesh(): Mesh;
  99430. /**
  99431. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99432. * In other words, more vertices, no more indices and a single bigger VBO.
  99433. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99434. * @returns current mesh
  99435. */
  99436. convertToUnIndexedMesh(): Mesh;
  99437. /**
  99438. * Inverses facet orientations.
  99439. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99440. * @param flipNormals will also inverts the normals
  99441. * @returns current mesh
  99442. */
  99443. flipFaces(flipNormals?: boolean): Mesh;
  99444. /**
  99445. * Increase the number of facets and hence vertices in a mesh
  99446. * Vertex normals are interpolated from existing vertex normals
  99447. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99448. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99449. */
  99450. increaseVertices(numberPerEdge: number): void;
  99451. /**
  99452. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99453. * This will undo any application of covertToFlatShadedMesh
  99454. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99455. */
  99456. forceSharedVertices(): void;
  99457. /** @hidden */
  99458. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99459. /** @hidden */
  99460. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99461. /**
  99462. * Creates a new InstancedMesh object from the mesh model.
  99463. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99464. * @param name defines the name of the new instance
  99465. * @returns a new InstancedMesh
  99466. */
  99467. createInstance(name: string): InstancedMesh;
  99468. /**
  99469. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99470. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99471. * @returns the current mesh
  99472. */
  99473. synchronizeInstances(): Mesh;
  99474. /**
  99475. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99476. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99477. * This should be used together with the simplification to avoid disappearing triangles.
  99478. * @param successCallback an optional success callback to be called after the optimization finished.
  99479. * @returns the current mesh
  99480. */
  99481. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99482. /**
  99483. * Serialize current mesh
  99484. * @param serializationObject defines the object which will receive the serialization data
  99485. */
  99486. serialize(serializationObject: any): void;
  99487. /** @hidden */
  99488. _syncGeometryWithMorphTargetManager(): void;
  99489. /** @hidden */
  99490. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99491. /**
  99492. * Returns a new Mesh object parsed from the source provided.
  99493. * @param parsedMesh is the source
  99494. * @param scene defines the hosting scene
  99495. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99496. * @returns a new Mesh
  99497. */
  99498. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99499. /**
  99500. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99501. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99502. * @param name defines the name of the mesh to create
  99503. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99504. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99505. * @param closePath creates a seam between the first and the last points of each path of the path array
  99506. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  99511. * @returns a new Mesh
  99512. */
  99513. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99514. /**
  99515. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99516. * @param name defines the name of the mesh to create
  99517. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99518. * @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
  99519. * @param scene defines the hosting scene
  99520. * @param updatable defines if the mesh must be flagged as updatable
  99521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99522. * @returns a new Mesh
  99523. */
  99524. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99525. /**
  99526. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99527. * @param name defines the name of the mesh to create
  99528. * @param size sets the size (float) of each box side (default 1)
  99529. * @param scene defines the hosting scene
  99530. * @param updatable defines if the mesh must be flagged as updatable
  99531. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99532. * @returns a new Mesh
  99533. */
  99534. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99535. /**
  99536. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99537. * @param name defines the name of the mesh to create
  99538. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99539. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99540. * @param scene defines the hosting scene
  99541. * @param updatable defines if the mesh must be flagged as updatable
  99542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99543. * @returns a new Mesh
  99544. */
  99545. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99546. /**
  99547. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99548. * @param name defines the name of the mesh to create
  99549. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99550. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99551. * @param scene defines the hosting scene
  99552. * @returns a new Mesh
  99553. */
  99554. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99555. /**
  99556. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99557. * @param name defines the name of the mesh to create
  99558. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99559. * @param diameterTop set the top cap diameter (floats, default 1)
  99560. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99561. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99562. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99563. * @param scene defines the hosting scene
  99564. * @param updatable defines if the mesh must be flagged as updatable
  99565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99566. * @returns a new Mesh
  99567. */
  99568. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99569. /**
  99570. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99571. * @param name defines the name of the mesh to create
  99572. * @param diameter sets the diameter size (float) of the torus (default 1)
  99573. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99574. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99575. * @param scene defines the hosting scene
  99576. * @param updatable defines if the mesh must be flagged as updatable
  99577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99578. * @returns a new Mesh
  99579. */
  99580. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99581. /**
  99582. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99583. * @param name defines the name of the mesh to create
  99584. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99585. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99586. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99587. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99588. * @param p the number of windings on X axis (positive integers, default 2)
  99589. * @param q the number of windings on Y axis (positive integers, default 3)
  99590. * @param scene defines the hosting scene
  99591. * @param updatable defines if the mesh must be flagged as updatable
  99592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99593. * @returns a new Mesh
  99594. */
  99595. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99596. /**
  99597. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99598. * @param name defines the name of the mesh to create
  99599. * @param points is an array successive Vector3
  99600. * @param scene defines the hosting scene
  99601. * @param updatable defines if the mesh must be flagged as updatable
  99602. * @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).
  99603. * @returns a new Mesh
  99604. */
  99605. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99606. /**
  99607. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99608. * @param name defines the name of the mesh to create
  99609. * @param points is an array successive Vector3
  99610. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99611. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99612. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99613. * @param scene defines the hosting scene
  99614. * @param updatable defines if the mesh must be flagged as updatable
  99615. * @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)
  99616. * @returns a new Mesh
  99617. */
  99618. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99619. /**
  99620. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99621. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99622. * 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.
  99623. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99624. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99625. * Remember you can only change the shape positions, not their number when updating a polygon.
  99626. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99627. * @param name defines the name of the mesh to create
  99628. * @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
  99629. * @param scene defines the hosting scene
  99630. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99631. * @param updatable defines if the mesh must be flagged as updatable
  99632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99633. * @param earcutInjection can be used to inject your own earcut reference
  99634. * @returns a new Mesh
  99635. */
  99636. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99637. /**
  99638. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99639. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99640. * @param name defines the name of the mesh to create
  99641. * @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
  99642. * @param depth defines the height of extrusion
  99643. * @param scene defines the hosting scene
  99644. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99645. * @param updatable defines if the mesh must be flagged as updatable
  99646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99647. * @param earcutInjection can be used to inject your own earcut reference
  99648. * @returns a new Mesh
  99649. */
  99650. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99651. /**
  99652. * Creates an extruded shape mesh.
  99653. * 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
  99654. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99655. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99656. * @param name defines the name of the mesh to create
  99657. * @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
  99658. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99659. * @param scale is the value to scale the shape
  99660. * @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
  99661. * @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
  99662. * @param scene defines the hosting scene
  99663. * @param updatable defines if the mesh must be flagged as updatable
  99664. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99665. * @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)
  99666. * @returns a new Mesh
  99667. */
  99668. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99669. /**
  99670. * Creates an custom extruded shape mesh.
  99671. * The custom extrusion is a parametric shape.
  99672. * It has no predefined shape. Its final shape will depend on the input parameters.
  99673. * Please consider using the same method from the MeshBuilder class instead
  99674. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99675. * @param name defines the name of the mesh to create
  99676. * @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
  99677. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99678. * @param scaleFunction is a custom Javascript function called on each path point
  99679. * @param rotationFunction is a custom Javascript function called on each path point
  99680. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99681. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99682. * @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
  99683. * @param scene defines the hosting scene
  99684. * @param updatable defines if the mesh must be flagged as updatable
  99685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99686. * @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)
  99687. * @returns a new Mesh
  99688. */
  99689. 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;
  99690. /**
  99691. * Creates lathe mesh.
  99692. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99693. * Please consider using the same method from the MeshBuilder class instead
  99694. * @param name defines the name of the mesh to create
  99695. * @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
  99696. * @param radius is the radius value of the lathe
  99697. * @param tessellation is the side number of the lathe.
  99698. * @param scene defines the hosting scene
  99699. * @param updatable defines if the mesh must be flagged as updatable
  99700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99701. * @returns a new Mesh
  99702. */
  99703. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99704. /**
  99705. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99706. * @param name defines the name of the mesh to create
  99707. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99708. * @param scene defines the hosting scene
  99709. * @param updatable defines if the mesh must be flagged as updatable
  99710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99711. * @returns a new Mesh
  99712. */
  99713. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99714. /**
  99715. * Creates a ground mesh.
  99716. * Please consider using the same method from the MeshBuilder class instead
  99717. * @param name defines the name of the mesh to create
  99718. * @param width set the width of the ground
  99719. * @param height set the height of the ground
  99720. * @param subdivisions sets the number of subdivisions per side
  99721. * @param scene defines the hosting scene
  99722. * @param updatable defines if the mesh must be flagged as updatable
  99723. * @returns a new Mesh
  99724. */
  99725. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99726. /**
  99727. * Creates a tiled ground mesh.
  99728. * Please consider using the same method from the MeshBuilder class instead
  99729. * @param name defines the name of the mesh to create
  99730. * @param xmin set the ground minimum X coordinate
  99731. * @param zmin set the ground minimum Y coordinate
  99732. * @param xmax set the ground maximum X coordinate
  99733. * @param zmax set the ground maximum Z coordinate
  99734. * @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
  99735. * @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
  99736. * @param scene defines the hosting scene
  99737. * @param updatable defines if the mesh must be flagged as updatable
  99738. * @returns a new Mesh
  99739. */
  99740. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99741. w: number;
  99742. h: number;
  99743. }, precision: {
  99744. w: number;
  99745. h: number;
  99746. }, scene: Scene, updatable?: boolean): Mesh;
  99747. /**
  99748. * Creates a ground mesh from a height map.
  99749. * Please consider using the same method from the MeshBuilder class instead
  99750. * @see http://doc.babylonjs.com/babylon101/height_map
  99751. * @param name defines the name of the mesh to create
  99752. * @param url sets the URL of the height map image resource
  99753. * @param width set the ground width size
  99754. * @param height set the ground height size
  99755. * @param subdivisions sets the number of subdivision per side
  99756. * @param minHeight is the minimum altitude on the ground
  99757. * @param maxHeight is the maximum altitude on the ground
  99758. * @param scene defines the hosting scene
  99759. * @param updatable defines if the mesh must be flagged as updatable
  99760. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99761. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99762. * @returns a new Mesh
  99763. */
  99764. 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;
  99765. /**
  99766. * Creates a tube mesh.
  99767. * The tube is a parametric shape.
  99768. * It has no predefined shape. Its final shape will depend on the input parameters.
  99769. * Please consider using the same method from the MeshBuilder class instead
  99770. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99771. * @param name defines the name of the mesh to create
  99772. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99773. * @param radius sets the tube radius size
  99774. * @param tessellation is the number of sides on the tubular surface
  99775. * @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
  99776. * @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
  99777. * @param scene defines the hosting scene
  99778. * @param updatable defines if the mesh must be flagged as updatable
  99779. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99780. * @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)
  99781. * @returns a new Mesh
  99782. */
  99783. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99784. (i: number, distance: number): number;
  99785. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99786. /**
  99787. * Creates a polyhedron mesh.
  99788. * Please consider using the same method from the MeshBuilder class instead.
  99789. * * 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
  99790. * * The parameter `size` (positive float, default 1) sets the polygon size
  99791. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99792. * * 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`
  99793. * * 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
  99794. * * 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)`)
  99795. * * 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
  99796. * * 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
  99797. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99798. * * If you create a double-sided mesh, you can choose what parts of 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
  99799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99800. * @param name defines the name of the mesh to create
  99801. * @param options defines the options used to create the mesh
  99802. * @param scene defines the hosting scene
  99803. * @returns a new Mesh
  99804. */
  99805. static CreatePolyhedron(name: string, options: {
  99806. type?: number;
  99807. size?: number;
  99808. sizeX?: number;
  99809. sizeY?: number;
  99810. sizeZ?: number;
  99811. custom?: any;
  99812. faceUV?: Vector4[];
  99813. faceColors?: Color4[];
  99814. updatable?: boolean;
  99815. sideOrientation?: number;
  99816. }, scene: Scene): Mesh;
  99817. /**
  99818. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99819. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99820. * * 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`)
  99821. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99822. * * 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
  99823. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99824. * * If you create a double-sided mesh, you can choose what parts of 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
  99825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99826. * @param name defines the name of the mesh
  99827. * @param options defines the options used to create the mesh
  99828. * @param scene defines the hosting scene
  99829. * @returns a new Mesh
  99830. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99831. */
  99832. static CreateIcoSphere(name: string, options: {
  99833. radius?: number;
  99834. flat?: boolean;
  99835. subdivisions?: number;
  99836. sideOrientation?: number;
  99837. updatable?: boolean;
  99838. }, scene: Scene): Mesh;
  99839. /**
  99840. * Creates a decal mesh.
  99841. * Please consider using the same method from the MeshBuilder class instead.
  99842. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99843. * @param name defines the name of the mesh
  99844. * @param sourceMesh defines the mesh receiving the decal
  99845. * @param position sets the position of the decal in world coordinates
  99846. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99847. * @param size sets the decal scaling
  99848. * @param angle sets the angle to rotate the decal
  99849. * @returns a new Mesh
  99850. */
  99851. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99852. /**
  99853. * Prepare internal position array for software CPU skinning
  99854. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99855. */
  99856. setPositionsForCPUSkinning(): Float32Array;
  99857. /**
  99858. * Prepare internal normal array for software CPU skinning
  99859. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99860. */
  99861. setNormalsForCPUSkinning(): Float32Array;
  99862. /**
  99863. * Updates the vertex buffer by applying transformation from the bones
  99864. * @param skeleton defines the skeleton to apply to current mesh
  99865. * @returns the current mesh
  99866. */
  99867. applySkeleton(skeleton: Skeleton): Mesh;
  99868. /**
  99869. * 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
  99870. * @param meshes defines the list of meshes to scan
  99871. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99872. */
  99873. static MinMax(meshes: AbstractMesh[]): {
  99874. min: Vector3;
  99875. max: Vector3;
  99876. };
  99877. /**
  99878. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99879. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99880. * @returns a vector3
  99881. */
  99882. static Center(meshesOrMinMaxVector: {
  99883. min: Vector3;
  99884. max: Vector3;
  99885. } | AbstractMesh[]): Vector3;
  99886. /**
  99887. * Merge the array of meshes into a single mesh for performance reasons.
  99888. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99889. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99890. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99891. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99892. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99893. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99894. * @returns a new mesh
  99895. */
  99896. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99897. /** @hidden */
  99898. addInstance(instance: InstancedMesh): void;
  99899. /** @hidden */
  99900. removeInstance(instance: InstancedMesh): void;
  99901. }
  99902. }
  99903. declare module BABYLON {
  99904. /**
  99905. * This is the base class of all the camera used in the application.
  99906. * @see http://doc.babylonjs.com/features/cameras
  99907. */
  99908. export class Camera extends Node {
  99909. /** @hidden */
  99910. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99911. /**
  99912. * This is the default projection mode used by the cameras.
  99913. * It helps recreating a feeling of perspective and better appreciate depth.
  99914. * This is the best way to simulate real life cameras.
  99915. */
  99916. static readonly PERSPECTIVE_CAMERA: number;
  99917. /**
  99918. * This helps creating camera with an orthographic mode.
  99919. * 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.
  99920. */
  99921. static readonly ORTHOGRAPHIC_CAMERA: number;
  99922. /**
  99923. * This is the default FOV mode for perspective cameras.
  99924. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99925. */
  99926. static readonly FOVMODE_VERTICAL_FIXED: number;
  99927. /**
  99928. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99929. */
  99930. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99931. /**
  99932. * This specifies ther is no need for a camera rig.
  99933. * Basically only one eye is rendered corresponding to the camera.
  99934. */
  99935. static readonly RIG_MODE_NONE: number;
  99936. /**
  99937. * Simulates a camera Rig with one blue eye and one red eye.
  99938. * This can be use with 3d blue and red glasses.
  99939. */
  99940. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99941. /**
  99942. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99943. */
  99944. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99945. /**
  99946. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99947. */
  99948. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99949. /**
  99950. * Defines that both eyes of the camera will be rendered over under each other.
  99951. */
  99952. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99953. /**
  99954. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99955. */
  99956. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99957. /**
  99958. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99959. */
  99960. static readonly RIG_MODE_VR: number;
  99961. /**
  99962. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99963. */
  99964. static readonly RIG_MODE_WEBVR: number;
  99965. /**
  99966. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99967. */
  99968. static readonly RIG_MODE_CUSTOM: number;
  99969. /**
  99970. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99971. */
  99972. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99973. /**
  99974. * Define the input manager associated with the camera.
  99975. */
  99976. inputs: CameraInputsManager<Camera>;
  99977. /** @hidden */
  99978. _position: Vector3;
  99979. /**
  99980. * Define the current local position of the camera in the scene
  99981. */
  99982. get position(): Vector3;
  99983. set position(newPosition: Vector3);
  99984. /**
  99985. * The vector the camera should consider as up.
  99986. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99987. */
  99988. upVector: Vector3;
  99989. /**
  99990. * Define the current limit on the left side for an orthographic camera
  99991. * In scene unit
  99992. */
  99993. orthoLeft: Nullable<number>;
  99994. /**
  99995. * Define the current limit on the right side for an orthographic camera
  99996. * In scene unit
  99997. */
  99998. orthoRight: Nullable<number>;
  99999. /**
  100000. * Define the current limit on the bottom side for an orthographic camera
  100001. * In scene unit
  100002. */
  100003. orthoBottom: Nullable<number>;
  100004. /**
  100005. * Define the current limit on the top side for an orthographic camera
  100006. * In scene unit
  100007. */
  100008. orthoTop: Nullable<number>;
  100009. /**
  100010. * Field Of View is set in Radians. (default is 0.8)
  100011. */
  100012. fov: number;
  100013. /**
  100014. * Define the minimum distance the camera can see from.
  100015. * This is important to note that the depth buffer are not infinite and the closer it starts
  100016. * the more your scene might encounter depth fighting issue.
  100017. */
  100018. minZ: number;
  100019. /**
  100020. * Define the maximum distance the camera can see to.
  100021. * This is important to note that the depth buffer are not infinite and the further it end
  100022. * the more your scene might encounter depth fighting issue.
  100023. */
  100024. maxZ: number;
  100025. /**
  100026. * Define the default inertia of the camera.
  100027. * This helps giving a smooth feeling to the camera movement.
  100028. */
  100029. inertia: number;
  100030. /**
  100031. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100032. */
  100033. mode: number;
  100034. /**
  100035. * Define whether the camera is intermediate.
  100036. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100037. */
  100038. isIntermediate: boolean;
  100039. /**
  100040. * Define the viewport of the camera.
  100041. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100042. */
  100043. viewport: Viewport;
  100044. /**
  100045. * Restricts the camera to viewing objects with the same layerMask.
  100046. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100047. */
  100048. layerMask: number;
  100049. /**
  100050. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100051. */
  100052. fovMode: number;
  100053. /**
  100054. * Rig mode of the camera.
  100055. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100056. * This is normally controlled byt the camera themselves as internal use.
  100057. */
  100058. cameraRigMode: number;
  100059. /**
  100060. * Defines the distance between both "eyes" in case of a RIG
  100061. */
  100062. interaxialDistance: number;
  100063. /**
  100064. * Defines if stereoscopic rendering is done side by side or over under.
  100065. */
  100066. isStereoscopicSideBySide: boolean;
  100067. /**
  100068. * 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
  100069. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100070. * else in the scene. (Eg. security camera)
  100071. *
  100072. * 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)
  100073. */
  100074. customRenderTargets: RenderTargetTexture[];
  100075. /**
  100076. * When set, the camera will render to this render target instead of the default canvas
  100077. *
  100078. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100079. */
  100080. outputRenderTarget: Nullable<RenderTargetTexture>;
  100081. /**
  100082. * Observable triggered when the camera view matrix has changed.
  100083. */
  100084. onViewMatrixChangedObservable: Observable<Camera>;
  100085. /**
  100086. * Observable triggered when the camera Projection matrix has changed.
  100087. */
  100088. onProjectionMatrixChangedObservable: Observable<Camera>;
  100089. /**
  100090. * Observable triggered when the inputs have been processed.
  100091. */
  100092. onAfterCheckInputsObservable: Observable<Camera>;
  100093. /**
  100094. * Observable triggered when reset has been called and applied to the camera.
  100095. */
  100096. onRestoreStateObservable: Observable<Camera>;
  100097. /**
  100098. * Is this camera a part of a rig system?
  100099. */
  100100. isRigCamera: boolean;
  100101. /**
  100102. * If isRigCamera set to true this will be set with the parent camera.
  100103. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100104. */
  100105. rigParent?: Camera;
  100106. /** @hidden */
  100107. _cameraRigParams: any;
  100108. /** @hidden */
  100109. _rigCameras: Camera[];
  100110. /** @hidden */
  100111. _rigPostProcess: Nullable<PostProcess>;
  100112. protected _webvrViewMatrix: Matrix;
  100113. /** @hidden */
  100114. _skipRendering: boolean;
  100115. /** @hidden */
  100116. _projectionMatrix: Matrix;
  100117. /** @hidden */
  100118. _postProcesses: Nullable<PostProcess>[];
  100119. /** @hidden */
  100120. _activeMeshes: SmartArray<AbstractMesh>;
  100121. protected _globalPosition: Vector3;
  100122. /** @hidden */
  100123. _computedViewMatrix: Matrix;
  100124. private _doNotComputeProjectionMatrix;
  100125. private _transformMatrix;
  100126. private _frustumPlanes;
  100127. private _refreshFrustumPlanes;
  100128. private _storedFov;
  100129. private _stateStored;
  100130. /**
  100131. * Instantiates a new camera object.
  100132. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100133. * @see http://doc.babylonjs.com/features/cameras
  100134. * @param name Defines the name of the camera in the scene
  100135. * @param position Defines the position of the camera
  100136. * @param scene Defines the scene the camera belongs too
  100137. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100138. */
  100139. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100140. /**
  100141. * Store current camera state (fov, position, etc..)
  100142. * @returns the camera
  100143. */
  100144. storeState(): Camera;
  100145. /**
  100146. * Restores the camera state values if it has been stored. You must call storeState() first
  100147. */
  100148. protected _restoreStateValues(): boolean;
  100149. /**
  100150. * Restored camera state. You must call storeState() first.
  100151. * @returns true if restored and false otherwise
  100152. */
  100153. restoreState(): boolean;
  100154. /**
  100155. * Gets the class name of the camera.
  100156. * @returns the class name
  100157. */
  100158. getClassName(): string;
  100159. /** @hidden */
  100160. readonly _isCamera: boolean;
  100161. /**
  100162. * Gets a string representation of the camera useful for debug purpose.
  100163. * @param fullDetails Defines that a more verboe level of logging is required
  100164. * @returns the string representation
  100165. */
  100166. toString(fullDetails?: boolean): string;
  100167. /**
  100168. * Gets the current world space position of the camera.
  100169. */
  100170. get globalPosition(): Vector3;
  100171. /**
  100172. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100173. * @returns the active meshe list
  100174. */
  100175. getActiveMeshes(): SmartArray<AbstractMesh>;
  100176. /**
  100177. * Check whether a mesh is part of the current active mesh list of the camera
  100178. * @param mesh Defines the mesh to check
  100179. * @returns true if active, false otherwise
  100180. */
  100181. isActiveMesh(mesh: Mesh): boolean;
  100182. /**
  100183. * Is this camera ready to be used/rendered
  100184. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100185. * @return true if the camera is ready
  100186. */
  100187. isReady(completeCheck?: boolean): boolean;
  100188. /** @hidden */
  100189. _initCache(): void;
  100190. /** @hidden */
  100191. _updateCache(ignoreParentClass?: boolean): void;
  100192. /** @hidden */
  100193. _isSynchronized(): boolean;
  100194. /** @hidden */
  100195. _isSynchronizedViewMatrix(): boolean;
  100196. /** @hidden */
  100197. _isSynchronizedProjectionMatrix(): boolean;
  100198. /**
  100199. * Attach the input controls to a specific dom element to get the input from.
  100200. * @param element Defines the element the controls should be listened from
  100201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100202. */
  100203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100204. /**
  100205. * Detach the current controls from the specified dom element.
  100206. * @param element Defines the element to stop listening the inputs from
  100207. */
  100208. detachControl(element: HTMLElement): void;
  100209. /**
  100210. * Update the camera state according to the different inputs gathered during the frame.
  100211. */
  100212. update(): void;
  100213. /** @hidden */
  100214. _checkInputs(): void;
  100215. /** @hidden */
  100216. get rigCameras(): Camera[];
  100217. /**
  100218. * Gets the post process used by the rig cameras
  100219. */
  100220. get rigPostProcess(): Nullable<PostProcess>;
  100221. /**
  100222. * Internal, gets the first post proces.
  100223. * @returns the first post process to be run on this camera.
  100224. */
  100225. _getFirstPostProcess(): Nullable<PostProcess>;
  100226. private _cascadePostProcessesToRigCams;
  100227. /**
  100228. * Attach a post process to the camera.
  100229. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100230. * @param postProcess The post process to attach to the camera
  100231. * @param insertAt The position of the post process in case several of them are in use in the scene
  100232. * @returns the position the post process has been inserted at
  100233. */
  100234. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100235. /**
  100236. * Detach a post process to the camera.
  100237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100238. * @param postProcess The post process to detach from the camera
  100239. */
  100240. detachPostProcess(postProcess: PostProcess): void;
  100241. /**
  100242. * Gets the current world matrix of the camera
  100243. */
  100244. getWorldMatrix(): Matrix;
  100245. /** @hidden */
  100246. _getViewMatrix(): Matrix;
  100247. /**
  100248. * Gets the current view matrix of the camera.
  100249. * @param force forces the camera to recompute the matrix without looking at the cached state
  100250. * @returns the view matrix
  100251. */
  100252. getViewMatrix(force?: boolean): Matrix;
  100253. /**
  100254. * Freeze the projection matrix.
  100255. * It will prevent the cache check of the camera projection compute and can speed up perf
  100256. * if no parameter of the camera are meant to change
  100257. * @param projection Defines manually a projection if necessary
  100258. */
  100259. freezeProjectionMatrix(projection?: Matrix): void;
  100260. /**
  100261. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100262. */
  100263. unfreezeProjectionMatrix(): void;
  100264. /**
  100265. * Gets the current projection matrix of the camera.
  100266. * @param force forces the camera to recompute the matrix without looking at the cached state
  100267. * @returns the projection matrix
  100268. */
  100269. getProjectionMatrix(force?: boolean): Matrix;
  100270. /**
  100271. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100272. * @returns a Matrix
  100273. */
  100274. getTransformationMatrix(): Matrix;
  100275. private _updateFrustumPlanes;
  100276. /**
  100277. * Checks if a cullable object (mesh...) is in the camera frustum
  100278. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100279. * @param target The object to check
  100280. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100281. * @returns true if the object is in frustum otherwise false
  100282. */
  100283. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100284. /**
  100285. * Checks if a cullable object (mesh...) is in the camera frustum
  100286. * Unlike isInFrustum this cheks the full bounding box
  100287. * @param target The object to check
  100288. * @returns true if the object is in frustum otherwise false
  100289. */
  100290. isCompletelyInFrustum(target: ICullable): boolean;
  100291. /**
  100292. * Gets a ray in the forward direction from the camera.
  100293. * @param length Defines the length of the ray to create
  100294. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100295. * @param origin Defines the start point of the ray which defaults to the camera position
  100296. * @returns the forward ray
  100297. */
  100298. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100299. /**
  100300. * Releases resources associated with this node.
  100301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100303. */
  100304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100305. /** @hidden */
  100306. _isLeftCamera: boolean;
  100307. /**
  100308. * Gets the left camera of a rig setup in case of Rigged Camera
  100309. */
  100310. get isLeftCamera(): boolean;
  100311. /** @hidden */
  100312. _isRightCamera: boolean;
  100313. /**
  100314. * Gets the right camera of a rig setup in case of Rigged Camera
  100315. */
  100316. get isRightCamera(): boolean;
  100317. /**
  100318. * Gets the left camera of a rig setup in case of Rigged Camera
  100319. */
  100320. get leftCamera(): Nullable<FreeCamera>;
  100321. /**
  100322. * Gets the right camera of a rig setup in case of Rigged Camera
  100323. */
  100324. get rightCamera(): Nullable<FreeCamera>;
  100325. /**
  100326. * Gets the left camera target of a rig setup in case of Rigged Camera
  100327. * @returns the target position
  100328. */
  100329. getLeftTarget(): Nullable<Vector3>;
  100330. /**
  100331. * Gets the right camera target of a rig setup in case of Rigged Camera
  100332. * @returns the target position
  100333. */
  100334. getRightTarget(): Nullable<Vector3>;
  100335. /**
  100336. * @hidden
  100337. */
  100338. setCameraRigMode(mode: number, rigParams: any): void;
  100339. /** @hidden */
  100340. static _setStereoscopicRigMode(camera: Camera): void;
  100341. /** @hidden */
  100342. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100343. /** @hidden */
  100344. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100345. /** @hidden */
  100346. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100347. /** @hidden */
  100348. _getVRProjectionMatrix(): Matrix;
  100349. protected _updateCameraRotationMatrix(): void;
  100350. protected _updateWebVRCameraRotationMatrix(): void;
  100351. /**
  100352. * This function MUST be overwritten by the different WebVR cameras available.
  100353. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100354. * @hidden
  100355. */
  100356. _getWebVRProjectionMatrix(): Matrix;
  100357. /**
  100358. * This function MUST be overwritten by the different WebVR cameras available.
  100359. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100360. * @hidden
  100361. */
  100362. _getWebVRViewMatrix(): Matrix;
  100363. /** @hidden */
  100364. setCameraRigParameter(name: string, value: any): void;
  100365. /**
  100366. * needs to be overridden by children so sub has required properties to be copied
  100367. * @hidden
  100368. */
  100369. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100370. /**
  100371. * May need to be overridden by children
  100372. * @hidden
  100373. */
  100374. _updateRigCameras(): void;
  100375. /** @hidden */
  100376. _setupInputs(): void;
  100377. /**
  100378. * Serialiaze the camera setup to a json represention
  100379. * @returns the JSON representation
  100380. */
  100381. serialize(): any;
  100382. /**
  100383. * Clones the current camera.
  100384. * @param name The cloned camera name
  100385. * @returns the cloned camera
  100386. */
  100387. clone(name: string): Camera;
  100388. /**
  100389. * Gets the direction of the camera relative to a given local axis.
  100390. * @param localAxis Defines the reference axis to provide a relative direction.
  100391. * @return the direction
  100392. */
  100393. getDirection(localAxis: Vector3): Vector3;
  100394. /**
  100395. * Returns the current camera absolute rotation
  100396. */
  100397. get absoluteRotation(): Quaternion;
  100398. /**
  100399. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100400. * @param localAxis Defines the reference axis to provide a relative direction.
  100401. * @param result Defines the vector to store the result in
  100402. */
  100403. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100404. /**
  100405. * Gets a camera constructor for a given camera type
  100406. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100407. * @param name The name of the camera the result will be able to instantiate
  100408. * @param scene The scene the result will construct the camera in
  100409. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100410. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100411. * @returns a factory method to construc the camera
  100412. */
  100413. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100414. /**
  100415. * Compute the world matrix of the camera.
  100416. * @returns the camera world matrix
  100417. */
  100418. computeWorldMatrix(): Matrix;
  100419. /**
  100420. * Parse a JSON and creates the camera from the parsed information
  100421. * @param parsedCamera The JSON to parse
  100422. * @param scene The scene to instantiate the camera in
  100423. * @returns the newly constructed camera
  100424. */
  100425. static Parse(parsedCamera: any, scene: Scene): Camera;
  100426. }
  100427. }
  100428. declare module BABYLON {
  100429. /**
  100430. * Class containing static functions to help procedurally build meshes
  100431. */
  100432. export class DiscBuilder {
  100433. /**
  100434. * Creates a plane polygonal mesh. By default, this is a disc
  100435. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100436. * * 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
  100437. * * 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
  100438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100441. * @param name defines the name of the mesh
  100442. * @param options defines the options used to create the mesh
  100443. * @param scene defines the hosting scene
  100444. * @returns the plane polygonal mesh
  100445. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100446. */
  100447. static CreateDisc(name: string, options: {
  100448. radius?: number;
  100449. tessellation?: number;
  100450. arc?: number;
  100451. updatable?: boolean;
  100452. sideOrientation?: number;
  100453. frontUVs?: Vector4;
  100454. backUVs?: Vector4;
  100455. }, scene?: Nullable<Scene>): Mesh;
  100456. }
  100457. }
  100458. declare module BABYLON {
  100459. /**
  100460. * Options to be used when creating a FresnelParameters.
  100461. */
  100462. export type IFresnelParametersCreationOptions = {
  100463. /**
  100464. * Define the color used on edges (grazing angle)
  100465. */
  100466. leftColor?: Color3;
  100467. /**
  100468. * Define the color used on center
  100469. */
  100470. rightColor?: Color3;
  100471. /**
  100472. * Define bias applied to computed fresnel term
  100473. */
  100474. bias?: number;
  100475. /**
  100476. * Defined the power exponent applied to fresnel term
  100477. */
  100478. power?: number;
  100479. /**
  100480. * Define if the fresnel effect is enable or not.
  100481. */
  100482. isEnabled?: boolean;
  100483. };
  100484. /**
  100485. * Serialized format for FresnelParameters.
  100486. */
  100487. export type IFresnelParametersSerialized = {
  100488. /**
  100489. * Define the color used on edges (grazing angle) [as an array]
  100490. */
  100491. leftColor: number[];
  100492. /**
  100493. * Define the color used on center [as an array]
  100494. */
  100495. rightColor: number[];
  100496. /**
  100497. * Define bias applied to computed fresnel term
  100498. */
  100499. bias: number;
  100500. /**
  100501. * Defined the power exponent applied to fresnel term
  100502. */
  100503. power?: number;
  100504. /**
  100505. * Define if the fresnel effect is enable or not.
  100506. */
  100507. isEnabled: boolean;
  100508. };
  100509. /**
  100510. * This represents all the required information to add a fresnel effect on a material:
  100511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100512. */
  100513. export class FresnelParameters {
  100514. private _isEnabled;
  100515. /**
  100516. * Define if the fresnel effect is enable or not.
  100517. */
  100518. get isEnabled(): boolean;
  100519. set isEnabled(value: boolean);
  100520. /**
  100521. * Define the color used on edges (grazing angle)
  100522. */
  100523. leftColor: Color3;
  100524. /**
  100525. * Define the color used on center
  100526. */
  100527. rightColor: Color3;
  100528. /**
  100529. * Define bias applied to computed fresnel term
  100530. */
  100531. bias: number;
  100532. /**
  100533. * Defined the power exponent applied to fresnel term
  100534. */
  100535. power: number;
  100536. /**
  100537. * Creates a new FresnelParameters object.
  100538. *
  100539. * @param options provide your own settings to optionally to override defaults
  100540. */
  100541. constructor(options?: IFresnelParametersCreationOptions);
  100542. /**
  100543. * Clones the current fresnel and its valuues
  100544. * @returns a clone fresnel configuration
  100545. */
  100546. clone(): FresnelParameters;
  100547. /**
  100548. * Determines equality between FresnelParameters objects
  100549. * @param otherFresnelParameters defines the second operand
  100550. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100551. */
  100552. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100553. /**
  100554. * Serializes the current fresnel parameters to a JSON representation.
  100555. * @return the JSON serialization
  100556. */
  100557. serialize(): IFresnelParametersSerialized;
  100558. /**
  100559. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100560. * @param parsedFresnelParameters Define the JSON representation
  100561. * @returns the parsed parameters
  100562. */
  100563. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100564. }
  100565. }
  100566. declare module BABYLON {
  100567. /**
  100568. * Base class of materials working in push mode in babylon JS
  100569. * @hidden
  100570. */
  100571. export class PushMaterial extends Material {
  100572. protected _activeEffect: Effect;
  100573. protected _normalMatrix: Matrix;
  100574. /**
  100575. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100576. * This means that the material can keep using a previous shader while a new one is being compiled.
  100577. * This is mostly used when shader parallel compilation is supported (true by default)
  100578. */
  100579. allowShaderHotSwapping: boolean;
  100580. constructor(name: string, scene: Scene);
  100581. getEffect(): Effect;
  100582. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100583. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100584. /**
  100585. * Binds the given world matrix to the active effect
  100586. *
  100587. * @param world the matrix to bind
  100588. */
  100589. bindOnlyWorldMatrix(world: Matrix): void;
  100590. /**
  100591. * Binds the given normal matrix to the active effect
  100592. *
  100593. * @param normalMatrix the matrix to bind
  100594. */
  100595. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100596. bind(world: Matrix, mesh?: Mesh): void;
  100597. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100598. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100599. }
  100600. }
  100601. declare module BABYLON {
  100602. /**
  100603. * This groups all the flags used to control the materials channel.
  100604. */
  100605. export class MaterialFlags {
  100606. private static _DiffuseTextureEnabled;
  100607. /**
  100608. * Are diffuse textures enabled in the application.
  100609. */
  100610. static get DiffuseTextureEnabled(): boolean;
  100611. static set DiffuseTextureEnabled(value: boolean);
  100612. private static _AmbientTextureEnabled;
  100613. /**
  100614. * Are ambient textures enabled in the application.
  100615. */
  100616. static get AmbientTextureEnabled(): boolean;
  100617. static set AmbientTextureEnabled(value: boolean);
  100618. private static _OpacityTextureEnabled;
  100619. /**
  100620. * Are opacity textures enabled in the application.
  100621. */
  100622. static get OpacityTextureEnabled(): boolean;
  100623. static set OpacityTextureEnabled(value: boolean);
  100624. private static _ReflectionTextureEnabled;
  100625. /**
  100626. * Are reflection textures enabled in the application.
  100627. */
  100628. static get ReflectionTextureEnabled(): boolean;
  100629. static set ReflectionTextureEnabled(value: boolean);
  100630. private static _EmissiveTextureEnabled;
  100631. /**
  100632. * Are emissive textures enabled in the application.
  100633. */
  100634. static get EmissiveTextureEnabled(): boolean;
  100635. static set EmissiveTextureEnabled(value: boolean);
  100636. private static _SpecularTextureEnabled;
  100637. /**
  100638. * Are specular textures enabled in the application.
  100639. */
  100640. static get SpecularTextureEnabled(): boolean;
  100641. static set SpecularTextureEnabled(value: boolean);
  100642. private static _BumpTextureEnabled;
  100643. /**
  100644. * Are bump textures enabled in the application.
  100645. */
  100646. static get BumpTextureEnabled(): boolean;
  100647. static set BumpTextureEnabled(value: boolean);
  100648. private static _LightmapTextureEnabled;
  100649. /**
  100650. * Are lightmap textures enabled in the application.
  100651. */
  100652. static get LightmapTextureEnabled(): boolean;
  100653. static set LightmapTextureEnabled(value: boolean);
  100654. private static _RefractionTextureEnabled;
  100655. /**
  100656. * Are refraction textures enabled in the application.
  100657. */
  100658. static get RefractionTextureEnabled(): boolean;
  100659. static set RefractionTextureEnabled(value: boolean);
  100660. private static _ColorGradingTextureEnabled;
  100661. /**
  100662. * Are color grading textures enabled in the application.
  100663. */
  100664. static get ColorGradingTextureEnabled(): boolean;
  100665. static set ColorGradingTextureEnabled(value: boolean);
  100666. private static _FresnelEnabled;
  100667. /**
  100668. * Are fresnels enabled in the application.
  100669. */
  100670. static get FresnelEnabled(): boolean;
  100671. static set FresnelEnabled(value: boolean);
  100672. private static _ClearCoatTextureEnabled;
  100673. /**
  100674. * Are clear coat textures enabled in the application.
  100675. */
  100676. static get ClearCoatTextureEnabled(): boolean;
  100677. static set ClearCoatTextureEnabled(value: boolean);
  100678. private static _ClearCoatBumpTextureEnabled;
  100679. /**
  100680. * Are clear coat bump textures enabled in the application.
  100681. */
  100682. static get ClearCoatBumpTextureEnabled(): boolean;
  100683. static set ClearCoatBumpTextureEnabled(value: boolean);
  100684. private static _ClearCoatTintTextureEnabled;
  100685. /**
  100686. * Are clear coat tint textures enabled in the application.
  100687. */
  100688. static get ClearCoatTintTextureEnabled(): boolean;
  100689. static set ClearCoatTintTextureEnabled(value: boolean);
  100690. private static _SheenTextureEnabled;
  100691. /**
  100692. * Are sheen textures enabled in the application.
  100693. */
  100694. static get SheenTextureEnabled(): boolean;
  100695. static set SheenTextureEnabled(value: boolean);
  100696. private static _AnisotropicTextureEnabled;
  100697. /**
  100698. * Are anisotropic textures enabled in the application.
  100699. */
  100700. static get AnisotropicTextureEnabled(): boolean;
  100701. static set AnisotropicTextureEnabled(value: boolean);
  100702. private static _ThicknessTextureEnabled;
  100703. /**
  100704. * Are thickness textures enabled in the application.
  100705. */
  100706. static get ThicknessTextureEnabled(): boolean;
  100707. static set ThicknessTextureEnabled(value: boolean);
  100708. }
  100709. }
  100710. declare module BABYLON {
  100711. /** @hidden */
  100712. export var defaultFragmentDeclaration: {
  100713. name: string;
  100714. shader: string;
  100715. };
  100716. }
  100717. declare module BABYLON {
  100718. /** @hidden */
  100719. export var defaultUboDeclaration: {
  100720. name: string;
  100721. shader: string;
  100722. };
  100723. }
  100724. declare module BABYLON {
  100725. /** @hidden */
  100726. export var lightFragmentDeclaration: {
  100727. name: string;
  100728. shader: string;
  100729. };
  100730. }
  100731. declare module BABYLON {
  100732. /** @hidden */
  100733. export var lightUboDeclaration: {
  100734. name: string;
  100735. shader: string;
  100736. };
  100737. }
  100738. declare module BABYLON {
  100739. /** @hidden */
  100740. export var lightsFragmentFunctions: {
  100741. name: string;
  100742. shader: string;
  100743. };
  100744. }
  100745. declare module BABYLON {
  100746. /** @hidden */
  100747. export var shadowsFragmentFunctions: {
  100748. name: string;
  100749. shader: string;
  100750. };
  100751. }
  100752. declare module BABYLON {
  100753. /** @hidden */
  100754. export var fresnelFunction: {
  100755. name: string;
  100756. shader: string;
  100757. };
  100758. }
  100759. declare module BABYLON {
  100760. /** @hidden */
  100761. export var reflectionFunction: {
  100762. name: string;
  100763. shader: string;
  100764. };
  100765. }
  100766. declare module BABYLON {
  100767. /** @hidden */
  100768. export var bumpFragmentFunctions: {
  100769. name: string;
  100770. shader: string;
  100771. };
  100772. }
  100773. declare module BABYLON {
  100774. /** @hidden */
  100775. export var logDepthDeclaration: {
  100776. name: string;
  100777. shader: string;
  100778. };
  100779. }
  100780. declare module BABYLON {
  100781. /** @hidden */
  100782. export var bumpFragment: {
  100783. name: string;
  100784. shader: string;
  100785. };
  100786. }
  100787. declare module BABYLON {
  100788. /** @hidden */
  100789. export var depthPrePass: {
  100790. name: string;
  100791. shader: string;
  100792. };
  100793. }
  100794. declare module BABYLON {
  100795. /** @hidden */
  100796. export var lightFragment: {
  100797. name: string;
  100798. shader: string;
  100799. };
  100800. }
  100801. declare module BABYLON {
  100802. /** @hidden */
  100803. export var logDepthFragment: {
  100804. name: string;
  100805. shader: string;
  100806. };
  100807. }
  100808. declare module BABYLON {
  100809. /** @hidden */
  100810. export var defaultPixelShader: {
  100811. name: string;
  100812. shader: string;
  100813. };
  100814. }
  100815. declare module BABYLON {
  100816. /** @hidden */
  100817. export var defaultVertexDeclaration: {
  100818. name: string;
  100819. shader: string;
  100820. };
  100821. }
  100822. declare module BABYLON {
  100823. /** @hidden */
  100824. export var bumpVertexDeclaration: {
  100825. name: string;
  100826. shader: string;
  100827. };
  100828. }
  100829. declare module BABYLON {
  100830. /** @hidden */
  100831. export var bumpVertex: {
  100832. name: string;
  100833. shader: string;
  100834. };
  100835. }
  100836. declare module BABYLON {
  100837. /** @hidden */
  100838. export var fogVertex: {
  100839. name: string;
  100840. shader: string;
  100841. };
  100842. }
  100843. declare module BABYLON {
  100844. /** @hidden */
  100845. export var shadowsVertex: {
  100846. name: string;
  100847. shader: string;
  100848. };
  100849. }
  100850. declare module BABYLON {
  100851. /** @hidden */
  100852. export var pointCloudVertex: {
  100853. name: string;
  100854. shader: string;
  100855. };
  100856. }
  100857. declare module BABYLON {
  100858. /** @hidden */
  100859. export var logDepthVertex: {
  100860. name: string;
  100861. shader: string;
  100862. };
  100863. }
  100864. declare module BABYLON {
  100865. /** @hidden */
  100866. export var defaultVertexShader: {
  100867. name: string;
  100868. shader: string;
  100869. };
  100870. }
  100871. declare module BABYLON {
  100872. /** @hidden */
  100873. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100874. MAINUV1: boolean;
  100875. MAINUV2: boolean;
  100876. DIFFUSE: boolean;
  100877. DIFFUSEDIRECTUV: number;
  100878. AMBIENT: boolean;
  100879. AMBIENTDIRECTUV: number;
  100880. OPACITY: boolean;
  100881. OPACITYDIRECTUV: number;
  100882. OPACITYRGB: boolean;
  100883. REFLECTION: boolean;
  100884. EMISSIVE: boolean;
  100885. EMISSIVEDIRECTUV: number;
  100886. SPECULAR: boolean;
  100887. SPECULARDIRECTUV: number;
  100888. BUMP: boolean;
  100889. BUMPDIRECTUV: number;
  100890. PARALLAX: boolean;
  100891. PARALLAXOCCLUSION: boolean;
  100892. SPECULAROVERALPHA: boolean;
  100893. CLIPPLANE: boolean;
  100894. CLIPPLANE2: boolean;
  100895. CLIPPLANE3: boolean;
  100896. CLIPPLANE4: boolean;
  100897. CLIPPLANE5: boolean;
  100898. CLIPPLANE6: boolean;
  100899. ALPHATEST: boolean;
  100900. DEPTHPREPASS: boolean;
  100901. ALPHAFROMDIFFUSE: boolean;
  100902. POINTSIZE: boolean;
  100903. FOG: boolean;
  100904. SPECULARTERM: boolean;
  100905. DIFFUSEFRESNEL: boolean;
  100906. OPACITYFRESNEL: boolean;
  100907. REFLECTIONFRESNEL: boolean;
  100908. REFRACTIONFRESNEL: boolean;
  100909. EMISSIVEFRESNEL: boolean;
  100910. FRESNEL: boolean;
  100911. NORMAL: boolean;
  100912. UV1: boolean;
  100913. UV2: boolean;
  100914. VERTEXCOLOR: boolean;
  100915. VERTEXALPHA: boolean;
  100916. NUM_BONE_INFLUENCERS: number;
  100917. BonesPerMesh: number;
  100918. BONETEXTURE: boolean;
  100919. INSTANCES: boolean;
  100920. GLOSSINESS: boolean;
  100921. ROUGHNESS: boolean;
  100922. EMISSIVEASILLUMINATION: boolean;
  100923. LINKEMISSIVEWITHDIFFUSE: boolean;
  100924. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100925. LIGHTMAP: boolean;
  100926. LIGHTMAPDIRECTUV: number;
  100927. OBJECTSPACE_NORMALMAP: boolean;
  100928. USELIGHTMAPASSHADOWMAP: boolean;
  100929. REFLECTIONMAP_3D: boolean;
  100930. REFLECTIONMAP_SPHERICAL: boolean;
  100931. REFLECTIONMAP_PLANAR: boolean;
  100932. REFLECTIONMAP_CUBIC: boolean;
  100933. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100934. REFLECTIONMAP_PROJECTION: boolean;
  100935. REFLECTIONMAP_SKYBOX: boolean;
  100936. REFLECTIONMAP_EXPLICIT: boolean;
  100937. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100938. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100939. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100940. INVERTCUBICMAP: boolean;
  100941. LOGARITHMICDEPTH: boolean;
  100942. REFRACTION: boolean;
  100943. REFRACTIONMAP_3D: boolean;
  100944. REFLECTIONOVERALPHA: boolean;
  100945. TWOSIDEDLIGHTING: boolean;
  100946. SHADOWFLOAT: boolean;
  100947. MORPHTARGETS: boolean;
  100948. MORPHTARGETS_NORMAL: boolean;
  100949. MORPHTARGETS_TANGENT: boolean;
  100950. MORPHTARGETS_UV: boolean;
  100951. NUM_MORPH_INFLUENCERS: number;
  100952. NONUNIFORMSCALING: boolean;
  100953. PREMULTIPLYALPHA: boolean;
  100954. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100955. ALPHABLEND: boolean;
  100956. IMAGEPROCESSING: boolean;
  100957. VIGNETTE: boolean;
  100958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100959. VIGNETTEBLENDMODEOPAQUE: boolean;
  100960. TONEMAPPING: boolean;
  100961. TONEMAPPING_ACES: boolean;
  100962. CONTRAST: boolean;
  100963. COLORCURVES: boolean;
  100964. COLORGRADING: boolean;
  100965. COLORGRADING3D: boolean;
  100966. SAMPLER3DGREENDEPTH: boolean;
  100967. SAMPLER3DBGRMAP: boolean;
  100968. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100969. MULTIVIEW: boolean;
  100970. /**
  100971. * If the reflection texture on this material is in linear color space
  100972. * @hidden
  100973. */
  100974. IS_REFLECTION_LINEAR: boolean;
  100975. /**
  100976. * If the refraction texture on this material is in linear color space
  100977. * @hidden
  100978. */
  100979. IS_REFRACTION_LINEAR: boolean;
  100980. EXPOSURE: boolean;
  100981. constructor();
  100982. setReflectionMode(modeToEnable: string): void;
  100983. }
  100984. /**
  100985. * This is the default material used in Babylon. It is the best trade off between quality
  100986. * and performances.
  100987. * @see http://doc.babylonjs.com/babylon101/materials
  100988. */
  100989. export class StandardMaterial extends PushMaterial {
  100990. private _diffuseTexture;
  100991. /**
  100992. * The basic texture of the material as viewed under a light.
  100993. */
  100994. diffuseTexture: Nullable<BaseTexture>;
  100995. private _ambientTexture;
  100996. /**
  100997. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100998. */
  100999. ambientTexture: Nullable<BaseTexture>;
  101000. private _opacityTexture;
  101001. /**
  101002. * Define the transparency of the material from a texture.
  101003. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101004. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101005. */
  101006. opacityTexture: Nullable<BaseTexture>;
  101007. private _reflectionTexture;
  101008. /**
  101009. * Define the texture used to display the reflection.
  101010. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101011. */
  101012. reflectionTexture: Nullable<BaseTexture>;
  101013. private _emissiveTexture;
  101014. /**
  101015. * Define texture of the material as if self lit.
  101016. * This will be mixed in the final result even in the absence of light.
  101017. */
  101018. emissiveTexture: Nullable<BaseTexture>;
  101019. private _specularTexture;
  101020. /**
  101021. * Define how the color and intensity of the highlight given by the light in the material.
  101022. */
  101023. specularTexture: Nullable<BaseTexture>;
  101024. private _bumpTexture;
  101025. /**
  101026. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101027. * 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.
  101028. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101029. */
  101030. bumpTexture: Nullable<BaseTexture>;
  101031. private _lightmapTexture;
  101032. /**
  101033. * Complex lighting can be computationally expensive to compute at runtime.
  101034. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101035. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101036. */
  101037. lightmapTexture: Nullable<BaseTexture>;
  101038. private _refractionTexture;
  101039. /**
  101040. * Define the texture used to display the refraction.
  101041. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101042. */
  101043. refractionTexture: Nullable<BaseTexture>;
  101044. /**
  101045. * The color of the material lit by the environmental background lighting.
  101046. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101047. */
  101048. ambientColor: Color3;
  101049. /**
  101050. * The basic color of the material as viewed under a light.
  101051. */
  101052. diffuseColor: Color3;
  101053. /**
  101054. * Define how the color and intensity of the highlight given by the light in the material.
  101055. */
  101056. specularColor: Color3;
  101057. /**
  101058. * Define the color of the material as if self lit.
  101059. * This will be mixed in the final result even in the absence of light.
  101060. */
  101061. emissiveColor: Color3;
  101062. /**
  101063. * Defines how sharp are the highlights in the material.
  101064. * The bigger the value the sharper giving a more glossy feeling to the result.
  101065. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101066. */
  101067. specularPower: number;
  101068. private _useAlphaFromDiffuseTexture;
  101069. /**
  101070. * Does the transparency come from the diffuse texture alpha channel.
  101071. */
  101072. useAlphaFromDiffuseTexture: boolean;
  101073. private _useEmissiveAsIllumination;
  101074. /**
  101075. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101076. */
  101077. useEmissiveAsIllumination: boolean;
  101078. private _linkEmissiveWithDiffuse;
  101079. /**
  101080. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101081. * the emissive level when the final color is close to one.
  101082. */
  101083. linkEmissiveWithDiffuse: boolean;
  101084. private _useSpecularOverAlpha;
  101085. /**
  101086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101088. */
  101089. useSpecularOverAlpha: boolean;
  101090. private _useReflectionOverAlpha;
  101091. /**
  101092. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101093. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101094. */
  101095. useReflectionOverAlpha: boolean;
  101096. private _disableLighting;
  101097. /**
  101098. * Does lights from the scene impacts this material.
  101099. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101100. */
  101101. disableLighting: boolean;
  101102. private _useObjectSpaceNormalMap;
  101103. /**
  101104. * Allows using an object space normal map (instead of tangent space).
  101105. */
  101106. useObjectSpaceNormalMap: boolean;
  101107. private _useParallax;
  101108. /**
  101109. * Is parallax enabled or not.
  101110. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101111. */
  101112. useParallax: boolean;
  101113. private _useParallaxOcclusion;
  101114. /**
  101115. * Is parallax occlusion enabled or not.
  101116. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101117. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101118. */
  101119. useParallaxOcclusion: boolean;
  101120. /**
  101121. * 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.
  101122. */
  101123. parallaxScaleBias: number;
  101124. private _roughness;
  101125. /**
  101126. * Helps to define how blurry the reflections should appears in the material.
  101127. */
  101128. roughness: number;
  101129. /**
  101130. * In case of refraction, define the value of the index of refraction.
  101131. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101132. */
  101133. indexOfRefraction: number;
  101134. /**
  101135. * Invert the refraction texture alongside the y axis.
  101136. * It can be useful with procedural textures or probe for instance.
  101137. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101138. */
  101139. invertRefractionY: boolean;
  101140. /**
  101141. * Defines the alpha limits in alpha test mode.
  101142. */
  101143. alphaCutOff: number;
  101144. private _useLightmapAsShadowmap;
  101145. /**
  101146. * In case of light mapping, define whether the map contains light or shadow informations.
  101147. */
  101148. useLightmapAsShadowmap: boolean;
  101149. private _diffuseFresnelParameters;
  101150. /**
  101151. * Define the diffuse fresnel parameters of the material.
  101152. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101153. */
  101154. diffuseFresnelParameters: FresnelParameters;
  101155. private _opacityFresnelParameters;
  101156. /**
  101157. * Define the opacity fresnel parameters of the material.
  101158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101159. */
  101160. opacityFresnelParameters: FresnelParameters;
  101161. private _reflectionFresnelParameters;
  101162. /**
  101163. * Define the reflection fresnel parameters of the material.
  101164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101165. */
  101166. reflectionFresnelParameters: FresnelParameters;
  101167. private _refractionFresnelParameters;
  101168. /**
  101169. * Define the refraction fresnel parameters of the material.
  101170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101171. */
  101172. refractionFresnelParameters: FresnelParameters;
  101173. private _emissiveFresnelParameters;
  101174. /**
  101175. * Define the emissive fresnel parameters of the material.
  101176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101177. */
  101178. emissiveFresnelParameters: FresnelParameters;
  101179. private _useReflectionFresnelFromSpecular;
  101180. /**
  101181. * If true automatically deducts the fresnels values from the material specularity.
  101182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101183. */
  101184. useReflectionFresnelFromSpecular: boolean;
  101185. private _useGlossinessFromSpecularMapAlpha;
  101186. /**
  101187. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101188. */
  101189. useGlossinessFromSpecularMapAlpha: boolean;
  101190. private _maxSimultaneousLights;
  101191. /**
  101192. * Defines the maximum number of lights that can be used in the material
  101193. */
  101194. maxSimultaneousLights: number;
  101195. private _invertNormalMapX;
  101196. /**
  101197. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101198. */
  101199. invertNormalMapX: boolean;
  101200. private _invertNormalMapY;
  101201. /**
  101202. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101203. */
  101204. invertNormalMapY: boolean;
  101205. private _twoSidedLighting;
  101206. /**
  101207. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101208. */
  101209. twoSidedLighting: boolean;
  101210. /**
  101211. * Default configuration related to image processing available in the standard Material.
  101212. */
  101213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101214. /**
  101215. * Gets the image processing configuration used either in this material.
  101216. */
  101217. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101218. /**
  101219. * Sets the Default image processing configuration used either in the this material.
  101220. *
  101221. * If sets to null, the scene one is in use.
  101222. */
  101223. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101224. /**
  101225. * Keep track of the image processing observer to allow dispose and replace.
  101226. */
  101227. private _imageProcessingObserver;
  101228. /**
  101229. * Attaches a new image processing configuration to the Standard Material.
  101230. * @param configuration
  101231. */
  101232. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101233. /**
  101234. * Gets wether the color curves effect is enabled.
  101235. */
  101236. get cameraColorCurvesEnabled(): boolean;
  101237. /**
  101238. * Sets wether the color curves effect is enabled.
  101239. */
  101240. set cameraColorCurvesEnabled(value: boolean);
  101241. /**
  101242. * Gets wether the color grading effect is enabled.
  101243. */
  101244. get cameraColorGradingEnabled(): boolean;
  101245. /**
  101246. * Gets wether the color grading effect is enabled.
  101247. */
  101248. set cameraColorGradingEnabled(value: boolean);
  101249. /**
  101250. * Gets wether tonemapping is enabled or not.
  101251. */
  101252. get cameraToneMappingEnabled(): boolean;
  101253. /**
  101254. * Sets wether tonemapping is enabled or not
  101255. */
  101256. set cameraToneMappingEnabled(value: boolean);
  101257. /**
  101258. * The camera exposure used on this material.
  101259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101260. * This corresponds to a photographic exposure.
  101261. */
  101262. get cameraExposure(): number;
  101263. /**
  101264. * The camera exposure used on this material.
  101265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101266. * This corresponds to a photographic exposure.
  101267. */
  101268. set cameraExposure(value: number);
  101269. /**
  101270. * Gets The camera contrast used on this material.
  101271. */
  101272. get cameraContrast(): number;
  101273. /**
  101274. * Sets The camera contrast used on this material.
  101275. */
  101276. set cameraContrast(value: number);
  101277. /**
  101278. * Gets the Color Grading 2D Lookup Texture.
  101279. */
  101280. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101281. /**
  101282. * Sets the Color Grading 2D Lookup Texture.
  101283. */
  101284. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101285. /**
  101286. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101287. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101288. * 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;
  101289. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101290. */
  101291. get cameraColorCurves(): Nullable<ColorCurves>;
  101292. /**
  101293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101295. * 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;
  101296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101297. */
  101298. set cameraColorCurves(value: Nullable<ColorCurves>);
  101299. /**
  101300. * Custom callback helping to override the default shader used in the material.
  101301. */
  101302. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101303. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101304. protected _worldViewProjectionMatrix: Matrix;
  101305. protected _globalAmbientColor: Color3;
  101306. protected _useLogarithmicDepth: boolean;
  101307. protected _rebuildInParallel: boolean;
  101308. /**
  101309. * Instantiates a new standard material.
  101310. * This is the default material used in Babylon. It is the best trade off between quality
  101311. * and performances.
  101312. * @see http://doc.babylonjs.com/babylon101/materials
  101313. * @param name Define the name of the material in the scene
  101314. * @param scene Define the scene the material belong to
  101315. */
  101316. constructor(name: string, scene: Scene);
  101317. /**
  101318. * Gets a boolean indicating that current material needs to register RTT
  101319. */
  101320. get hasRenderTargetTextures(): boolean;
  101321. /**
  101322. * Gets the current class name of the material e.g. "StandardMaterial"
  101323. * Mainly use in serialization.
  101324. * @returns the class name
  101325. */
  101326. getClassName(): string;
  101327. /**
  101328. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101329. * You can try switching to logarithmic depth.
  101330. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101331. */
  101332. get useLogarithmicDepth(): boolean;
  101333. set useLogarithmicDepth(value: boolean);
  101334. /**
  101335. * Specifies if the material will require alpha blending
  101336. * @returns a boolean specifying if alpha blending is needed
  101337. */
  101338. needAlphaBlending(): boolean;
  101339. /**
  101340. * Specifies if this material should be rendered in alpha test mode
  101341. * @returns a boolean specifying if an alpha test is needed.
  101342. */
  101343. needAlphaTesting(): boolean;
  101344. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101345. /**
  101346. * Get the texture used for alpha test purpose.
  101347. * @returns the diffuse texture in case of the standard material.
  101348. */
  101349. getAlphaTestTexture(): Nullable<BaseTexture>;
  101350. /**
  101351. * Get if the submesh is ready to be used and all its information available.
  101352. * Child classes can use it to update shaders
  101353. * @param mesh defines the mesh to check
  101354. * @param subMesh defines which submesh to check
  101355. * @param useInstances specifies that instances should be used
  101356. * @returns a boolean indicating that the submesh is ready or not
  101357. */
  101358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101359. /**
  101360. * Builds the material UBO layouts.
  101361. * Used internally during the effect preparation.
  101362. */
  101363. buildUniformLayout(): void;
  101364. /**
  101365. * Unbinds the material from the mesh
  101366. */
  101367. unbind(): void;
  101368. /**
  101369. * Binds the submesh to this material by preparing the effect and shader to draw
  101370. * @param world defines the world transformation matrix
  101371. * @param mesh defines the mesh containing the submesh
  101372. * @param subMesh defines the submesh to bind the material to
  101373. */
  101374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101375. /**
  101376. * Get the list of animatables in the material.
  101377. * @returns the list of animatables object used in the material
  101378. */
  101379. getAnimatables(): IAnimatable[];
  101380. /**
  101381. * Gets the active textures from the material
  101382. * @returns an array of textures
  101383. */
  101384. getActiveTextures(): BaseTexture[];
  101385. /**
  101386. * Specifies if the material uses a texture
  101387. * @param texture defines the texture to check against the material
  101388. * @returns a boolean specifying if the material uses the texture
  101389. */
  101390. hasTexture(texture: BaseTexture): boolean;
  101391. /**
  101392. * Disposes the material
  101393. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101394. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101395. */
  101396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101397. /**
  101398. * Makes a duplicate of the material, and gives it a new name
  101399. * @param name defines the new name for the duplicated material
  101400. * @returns the cloned material
  101401. */
  101402. clone(name: string): StandardMaterial;
  101403. /**
  101404. * Serializes this material in a JSON representation
  101405. * @returns the serialized material object
  101406. */
  101407. serialize(): any;
  101408. /**
  101409. * Creates a standard material from parsed material data
  101410. * @param source defines the JSON representation of the material
  101411. * @param scene defines the hosting scene
  101412. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101413. * @returns a new standard material
  101414. */
  101415. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101416. /**
  101417. * Are diffuse textures enabled in the application.
  101418. */
  101419. static get DiffuseTextureEnabled(): boolean;
  101420. static set DiffuseTextureEnabled(value: boolean);
  101421. /**
  101422. * Are ambient textures enabled in the application.
  101423. */
  101424. static get AmbientTextureEnabled(): boolean;
  101425. static set AmbientTextureEnabled(value: boolean);
  101426. /**
  101427. * Are opacity textures enabled in the application.
  101428. */
  101429. static get OpacityTextureEnabled(): boolean;
  101430. static set OpacityTextureEnabled(value: boolean);
  101431. /**
  101432. * Are reflection textures enabled in the application.
  101433. */
  101434. static get ReflectionTextureEnabled(): boolean;
  101435. static set ReflectionTextureEnabled(value: boolean);
  101436. /**
  101437. * Are emissive textures enabled in the application.
  101438. */
  101439. static get EmissiveTextureEnabled(): boolean;
  101440. static set EmissiveTextureEnabled(value: boolean);
  101441. /**
  101442. * Are specular textures enabled in the application.
  101443. */
  101444. static get SpecularTextureEnabled(): boolean;
  101445. static set SpecularTextureEnabled(value: boolean);
  101446. /**
  101447. * Are bump textures enabled in the application.
  101448. */
  101449. static get BumpTextureEnabled(): boolean;
  101450. static set BumpTextureEnabled(value: boolean);
  101451. /**
  101452. * Are lightmap textures enabled in the application.
  101453. */
  101454. static get LightmapTextureEnabled(): boolean;
  101455. static set LightmapTextureEnabled(value: boolean);
  101456. /**
  101457. * Are refraction textures enabled in the application.
  101458. */
  101459. static get RefractionTextureEnabled(): boolean;
  101460. static set RefractionTextureEnabled(value: boolean);
  101461. /**
  101462. * Are color grading textures enabled in the application.
  101463. */
  101464. static get ColorGradingTextureEnabled(): boolean;
  101465. static set ColorGradingTextureEnabled(value: boolean);
  101466. /**
  101467. * Are fresnels enabled in the application.
  101468. */
  101469. static get FresnelEnabled(): boolean;
  101470. static set FresnelEnabled(value: boolean);
  101471. }
  101472. }
  101473. declare module BABYLON {
  101474. /**
  101475. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101476. *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.
  101477. * The SPS is also a particle system. It provides some methods to manage the particles.
  101478. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101479. *
  101480. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101481. */
  101482. export class SolidParticleSystem implements IDisposable {
  101483. /**
  101484. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101485. * Example : var p = SPS.particles[i];
  101486. */
  101487. particles: SolidParticle[];
  101488. /**
  101489. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101490. */
  101491. nbParticles: number;
  101492. /**
  101493. * If the particles must ever face the camera (default false). Useful for planar particles.
  101494. */
  101495. billboard: boolean;
  101496. /**
  101497. * Recompute normals when adding a shape
  101498. */
  101499. recomputeNormals: boolean;
  101500. /**
  101501. * This a counter ofr your own usage. It's not set by any SPS functions.
  101502. */
  101503. counter: number;
  101504. /**
  101505. * The SPS name. This name is also given to the underlying mesh.
  101506. */
  101507. name: string;
  101508. /**
  101509. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101510. */
  101511. mesh: Mesh;
  101512. /**
  101513. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101514. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101515. */
  101516. vars: any;
  101517. /**
  101518. * This array is populated when the SPS is set as 'pickable'.
  101519. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101520. * Each element of this array is an object `{idx: int, faceId: int}`.
  101521. * `idx` is the picked particle index in the `SPS.particles` array
  101522. * `faceId` is the picked face index counted within this particle.
  101523. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101524. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101525. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101526. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101527. */
  101528. pickedParticles: {
  101529. idx: number;
  101530. faceId: number;
  101531. }[];
  101532. /**
  101533. * This array is populated when the SPS is set as 'pickable'
  101534. * Each key of this array is a submesh index.
  101535. * Each element of this array is a second array defined like this :
  101536. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101537. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101538. * `idx` is the picked particle index in the `SPS.particles` array
  101539. * `faceId` is the picked face index counted within this particle.
  101540. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101541. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101542. */
  101543. pickedBySubMesh: {
  101544. idx: number;
  101545. faceId: number;
  101546. }[][];
  101547. /**
  101548. * This array is populated when `enableDepthSort` is set to true.
  101549. * Each element of this array is an instance of the class DepthSortedParticle.
  101550. */
  101551. depthSortedParticles: DepthSortedParticle[];
  101552. /**
  101553. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101554. * @hidden
  101555. */
  101556. _bSphereOnly: boolean;
  101557. /**
  101558. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101559. * @hidden
  101560. */
  101561. _bSphereRadiusFactor: number;
  101562. private _scene;
  101563. private _positions;
  101564. private _indices;
  101565. private _normals;
  101566. private _colors;
  101567. private _uvs;
  101568. private _indices32;
  101569. private _positions32;
  101570. private _normals32;
  101571. private _fixedNormal32;
  101572. private _colors32;
  101573. private _uvs32;
  101574. private _index;
  101575. private _updatable;
  101576. private _pickable;
  101577. private _isVisibilityBoxLocked;
  101578. private _alwaysVisible;
  101579. private _depthSort;
  101580. private _expandable;
  101581. private _shapeCounter;
  101582. private _copy;
  101583. private _color;
  101584. private _computeParticleColor;
  101585. private _computeParticleTexture;
  101586. private _computeParticleRotation;
  101587. private _computeParticleVertex;
  101588. private _computeBoundingBox;
  101589. private _depthSortParticles;
  101590. private _camera;
  101591. private _mustUnrotateFixedNormals;
  101592. private _particlesIntersect;
  101593. private _needs32Bits;
  101594. private _isNotBuilt;
  101595. private _lastParticleId;
  101596. private _idxOfId;
  101597. private _multimaterialEnabled;
  101598. private _useModelMaterial;
  101599. private _indicesByMaterial;
  101600. private _materialIndexes;
  101601. private _depthSortFunction;
  101602. private _materialSortFunction;
  101603. private _materials;
  101604. private _multimaterial;
  101605. private _materialIndexesById;
  101606. private _defaultMaterial;
  101607. private _autoUpdateSubMeshes;
  101608. /**
  101609. * Creates a SPS (Solid Particle System) object.
  101610. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101611. * @param scene (Scene) is the scene in which the SPS is added.
  101612. * @param options defines the options of the sps e.g.
  101613. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101614. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101615. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101616. * * 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.
  101617. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101618. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101619. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101620. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101621. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101622. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101623. */
  101624. constructor(name: string, scene: Scene, options?: {
  101625. updatable?: boolean;
  101626. isPickable?: boolean;
  101627. enableDepthSort?: boolean;
  101628. particleIntersection?: boolean;
  101629. boundingSphereOnly?: boolean;
  101630. bSphereRadiusFactor?: number;
  101631. expandable?: boolean;
  101632. useModelMaterial?: boolean;
  101633. enableMultiMaterial?: boolean;
  101634. });
  101635. /**
  101636. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101637. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101638. * @returns the created mesh
  101639. */
  101640. buildMesh(): Mesh;
  101641. /**
  101642. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101643. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101644. * Thus the particles generated from `digest()` have their property `position` set yet.
  101645. * @param mesh ( Mesh ) is the mesh to be digested
  101646. * @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
  101647. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101648. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101649. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101650. * @returns the current SPS
  101651. */
  101652. digest(mesh: Mesh, options?: {
  101653. facetNb?: number;
  101654. number?: number;
  101655. delta?: number;
  101656. storage?: [];
  101657. }): SolidParticleSystem;
  101658. /**
  101659. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101660. * @hidden
  101661. */
  101662. private _unrotateFixedNormals;
  101663. /**
  101664. * Resets the temporary working copy particle
  101665. * @hidden
  101666. */
  101667. private _resetCopy;
  101668. /**
  101669. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101670. * @param p the current index in the positions array to be updated
  101671. * @param ind the current index in the indices array
  101672. * @param shape a Vector3 array, the shape geometry
  101673. * @param positions the positions array to be updated
  101674. * @param meshInd the shape indices array
  101675. * @param indices the indices array to be updated
  101676. * @param meshUV the shape uv array
  101677. * @param uvs the uv array to be updated
  101678. * @param meshCol the shape color array
  101679. * @param colors the color array to be updated
  101680. * @param meshNor the shape normals array
  101681. * @param normals the normals array to be updated
  101682. * @param idx the particle index
  101683. * @param idxInShape the particle index in its shape
  101684. * @param options the addShape() method passed options
  101685. * @model the particle model
  101686. * @hidden
  101687. */
  101688. private _meshBuilder;
  101689. /**
  101690. * Returns a shape Vector3 array from positions float array
  101691. * @param positions float array
  101692. * @returns a vector3 array
  101693. * @hidden
  101694. */
  101695. private _posToShape;
  101696. /**
  101697. * Returns a shapeUV array from a float uvs (array deep copy)
  101698. * @param uvs as a float array
  101699. * @returns a shapeUV array
  101700. * @hidden
  101701. */
  101702. private _uvsToShapeUV;
  101703. /**
  101704. * Adds a new particle object in the particles array
  101705. * @param idx particle index in particles array
  101706. * @param id particle id
  101707. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101708. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101709. * @param model particle ModelShape object
  101710. * @param shapeId model shape identifier
  101711. * @param idxInShape index of the particle in the current model
  101712. * @param bInfo model bounding info object
  101713. * @param storage target storage array, if any
  101714. * @hidden
  101715. */
  101716. private _addParticle;
  101717. /**
  101718. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101719. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101720. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101721. * @param nb (positive integer) the number of particles to be created from this model
  101722. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101723. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101724. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101725. * @returns the number of shapes in the system
  101726. */
  101727. addShape(mesh: Mesh, nb: number, options?: {
  101728. positionFunction?: any;
  101729. vertexFunction?: any;
  101730. storage?: [];
  101731. }): number;
  101732. /**
  101733. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101734. * @hidden
  101735. */
  101736. private _rebuildParticle;
  101737. /**
  101738. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101739. * @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.
  101740. * @returns the SPS.
  101741. */
  101742. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101743. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101744. * Returns an array with the removed particles.
  101745. * 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.
  101746. * The SPS can't be empty so at least one particle needs to remain in place.
  101747. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101748. * @param start index of the first particle to remove
  101749. * @param end index of the last particle to remove (included)
  101750. * @returns an array populated with the removed particles
  101751. */
  101752. removeParticles(start: number, end: number): SolidParticle[];
  101753. /**
  101754. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101755. * @param solidParticleArray an array populated with Solid Particles objects
  101756. * @returns the SPS
  101757. */
  101758. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101759. /**
  101760. * Creates a new particle and modifies the SPS mesh geometry :
  101761. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101762. * - calls _addParticle() to populate the particle array
  101763. * factorized code from addShape() and insertParticlesFromArray()
  101764. * @param idx particle index in the particles array
  101765. * @param i particle index in its shape
  101766. * @param modelShape particle ModelShape object
  101767. * @param shape shape vertex array
  101768. * @param meshInd shape indices array
  101769. * @param meshUV shape uv array
  101770. * @param meshCol shape color array
  101771. * @param meshNor shape normals array
  101772. * @param bbInfo shape bounding info
  101773. * @param storage target particle storage
  101774. * @options addShape() passed options
  101775. * @hidden
  101776. */
  101777. private _insertNewParticle;
  101778. /**
  101779. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101780. * This method calls `updateParticle()` for each particle of the SPS.
  101781. * For an animated SPS, it is usually called within the render loop.
  101782. * 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.
  101783. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101784. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101785. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101786. * @returns the SPS.
  101787. */
  101788. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101789. /**
  101790. * Disposes the SPS.
  101791. */
  101792. dispose(): void;
  101793. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101794. * idx is the particle index in the SPS
  101795. * faceId is the picked face index counted within this particle.
  101796. * Returns null if the pickInfo can't identify a picked particle.
  101797. * @param pickingInfo (PickingInfo object)
  101798. * @returns {idx: number, faceId: number} or null
  101799. */
  101800. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101801. idx: number;
  101802. faceId: number;
  101803. }>;
  101804. /**
  101805. * Returns a SolidParticle object from its identifier : particle.id
  101806. * @param id (integer) the particle Id
  101807. * @returns the searched particle or null if not found in the SPS.
  101808. */
  101809. getParticleById(id: number): Nullable<SolidParticle>;
  101810. /**
  101811. * Returns a new array populated with the particles having the passed shapeId.
  101812. * @param shapeId (integer) the shape identifier
  101813. * @returns a new solid particle array
  101814. */
  101815. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101816. /**
  101817. * Populates the passed array "ref" with the particles having the passed shapeId.
  101818. * @param shapeId the shape identifier
  101819. * @returns the SPS
  101820. * @param ref
  101821. */
  101822. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101823. /**
  101824. * Computes the required SubMeshes according the materials assigned to the particles.
  101825. * @returns the solid particle system.
  101826. * Does nothing if called before the SPS mesh is built.
  101827. */
  101828. computeSubMeshes(): SolidParticleSystem;
  101829. /**
  101830. * Sorts the solid particles by material when MultiMaterial is enabled.
  101831. * Updates the indices32 array.
  101832. * Updates the indicesByMaterial array.
  101833. * Updates the mesh indices array.
  101834. * @returns the SPS
  101835. * @hidden
  101836. */
  101837. private _sortParticlesByMaterial;
  101838. /**
  101839. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101840. * @hidden
  101841. */
  101842. private _setMaterialIndexesById;
  101843. /**
  101844. * Returns an array with unique values of Materials from the passed array
  101845. * @param array the material array to be checked and filtered
  101846. * @hidden
  101847. */
  101848. private _filterUniqueMaterialId;
  101849. /**
  101850. * Sets a new Standard Material as _defaultMaterial if not already set.
  101851. * @hidden
  101852. */
  101853. private _setDefaultMaterial;
  101854. /**
  101855. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101856. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101857. * @returns the SPS.
  101858. */
  101859. refreshVisibleSize(): SolidParticleSystem;
  101860. /**
  101861. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101862. * @param size the size (float) of the visibility box
  101863. * note : this doesn't lock the SPS mesh bounding box.
  101864. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101865. */
  101866. setVisibilityBox(size: number): void;
  101867. /**
  101868. * Gets whether the SPS as always visible or not
  101869. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101870. */
  101871. get isAlwaysVisible(): boolean;
  101872. /**
  101873. * Sets the SPS as always visible or not
  101874. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101875. */
  101876. set isAlwaysVisible(val: boolean);
  101877. /**
  101878. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101880. */
  101881. set isVisibilityBoxLocked(val: boolean);
  101882. /**
  101883. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101885. */
  101886. get isVisibilityBoxLocked(): boolean;
  101887. /**
  101888. * Tells to `setParticles()` to compute the particle rotations or not.
  101889. * Default value : true. The SPS is faster when it's set to false.
  101890. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101891. */
  101892. set computeParticleRotation(val: boolean);
  101893. /**
  101894. * Tells to `setParticles()` to compute the particle colors or not.
  101895. * Default value : true. The SPS is faster when it's set to false.
  101896. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101897. */
  101898. set computeParticleColor(val: boolean);
  101899. set computeParticleTexture(val: boolean);
  101900. /**
  101901. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101902. * Default value : false. The SPS is faster when it's set to false.
  101903. * Note : the particle custom vertex positions aren't stored values.
  101904. */
  101905. set computeParticleVertex(val: boolean);
  101906. /**
  101907. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101908. */
  101909. set computeBoundingBox(val: boolean);
  101910. /**
  101911. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101912. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101913. * Default : `true`
  101914. */
  101915. set depthSortParticles(val: boolean);
  101916. /**
  101917. * Gets if `setParticles()` computes the particle rotations or not.
  101918. * Default value : true. The SPS is faster when it's set to false.
  101919. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101920. */
  101921. get computeParticleRotation(): boolean;
  101922. /**
  101923. * Gets if `setParticles()` computes the particle colors or not.
  101924. * Default value : true. The SPS is faster when it's set to false.
  101925. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101926. */
  101927. get computeParticleColor(): boolean;
  101928. /**
  101929. * Gets if `setParticles()` computes the particle textures or not.
  101930. * Default value : true. The SPS is faster when it's set to false.
  101931. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101932. */
  101933. get computeParticleTexture(): boolean;
  101934. /**
  101935. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101936. * Default value : false. The SPS is faster when it's set to false.
  101937. * Note : the particle custom vertex positions aren't stored values.
  101938. */
  101939. get computeParticleVertex(): boolean;
  101940. /**
  101941. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101942. */
  101943. get computeBoundingBox(): boolean;
  101944. /**
  101945. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101946. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101947. * Default : `true`
  101948. */
  101949. get depthSortParticles(): boolean;
  101950. /**
  101951. * Gets if the SPS is created as expandable at construction time.
  101952. * Default : `false`
  101953. */
  101954. get expandable(): boolean;
  101955. /**
  101956. * Gets if the SPS supports the Multi Materials
  101957. */
  101958. get multimaterialEnabled(): boolean;
  101959. /**
  101960. * Gets if the SPS uses the model materials for its own multimaterial.
  101961. */
  101962. get useModelMaterial(): boolean;
  101963. /**
  101964. * The SPS used material array.
  101965. */
  101966. get materials(): Material[];
  101967. /**
  101968. * Sets the SPS MultiMaterial from the passed materials.
  101969. * Note : the passed array is internally copied and not used then by reference.
  101970. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101971. */
  101972. setMultiMaterial(materials: Material[]): void;
  101973. /**
  101974. * The SPS computed multimaterial object
  101975. */
  101976. get multimaterial(): MultiMaterial;
  101977. set multimaterial(mm: MultiMaterial);
  101978. /**
  101979. * If the subMeshes must be updated on the next call to setParticles()
  101980. */
  101981. get autoUpdateSubMeshes(): boolean;
  101982. set autoUpdateSubMeshes(val: boolean);
  101983. /**
  101984. * This function does nothing. It may be overwritten to set all the particle first values.
  101985. * The SPS doesn't call this function, you may have to call it by your own.
  101986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101987. */
  101988. initParticles(): void;
  101989. /**
  101990. * This function does nothing. It may be overwritten to recycle a particle.
  101991. * The SPS doesn't call this function, you may have to call it by your own.
  101992. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101993. * @param particle The particle to recycle
  101994. * @returns the recycled particle
  101995. */
  101996. recycleParticle(particle: SolidParticle): SolidParticle;
  101997. /**
  101998. * Updates a particle : this function should be overwritten by the user.
  101999. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  102000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102001. * @example : just set a particle position or velocity and recycle conditions
  102002. * @param particle The particle to update
  102003. * @returns the updated particle
  102004. */
  102005. updateParticle(particle: SolidParticle): SolidParticle;
  102006. /**
  102007. * Updates a vertex of a particle : it can be overwritten by the user.
  102008. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  102009. * @param particle the current particle
  102010. * @param vertex the current index of the current particle
  102011. * @param pt the index of the current vertex in the particle shape
  102012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  102013. * @example : just set a vertex particle position
  102014. * @returns the updated vertex
  102015. */
  102016. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102017. /**
  102018. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102019. * This does nothing and may be overwritten by the user.
  102020. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102021. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102022. * @param update the boolean update value actually passed to setParticles()
  102023. */
  102024. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102025. /**
  102026. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102027. * This will be passed three parameters.
  102028. * This does nothing and may be overwritten by the user.
  102029. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102030. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102031. * @param update the boolean update value actually passed to setParticles()
  102032. */
  102033. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102034. }
  102035. }
  102036. declare module BABYLON {
  102037. /**
  102038. * Represents one particle of a solid particle system.
  102039. */
  102040. export class SolidParticle {
  102041. /**
  102042. * particle global index
  102043. */
  102044. idx: number;
  102045. /**
  102046. * particle identifier
  102047. */
  102048. id: number;
  102049. /**
  102050. * The color of the particle
  102051. */
  102052. color: Nullable<Color4>;
  102053. /**
  102054. * The world space position of the particle.
  102055. */
  102056. position: Vector3;
  102057. /**
  102058. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102059. */
  102060. rotation: Vector3;
  102061. /**
  102062. * The world space rotation quaternion of the particle.
  102063. */
  102064. rotationQuaternion: Nullable<Quaternion>;
  102065. /**
  102066. * The scaling of the particle.
  102067. */
  102068. scaling: Vector3;
  102069. /**
  102070. * The uvs of the particle.
  102071. */
  102072. uvs: Vector4;
  102073. /**
  102074. * The current speed of the particle.
  102075. */
  102076. velocity: Vector3;
  102077. /**
  102078. * The pivot point in the particle local space.
  102079. */
  102080. pivot: Vector3;
  102081. /**
  102082. * Must the particle be translated from its pivot point in its local space ?
  102083. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102084. * Default : false
  102085. */
  102086. translateFromPivot: boolean;
  102087. /**
  102088. * Is the particle active or not ?
  102089. */
  102090. alive: boolean;
  102091. /**
  102092. * Is the particle visible or not ?
  102093. */
  102094. isVisible: boolean;
  102095. /**
  102096. * Index of this particle in the global "positions" array (Internal use)
  102097. * @hidden
  102098. */
  102099. _pos: number;
  102100. /**
  102101. * @hidden Index of this particle in the global "indices" array (Internal use)
  102102. */
  102103. _ind: number;
  102104. /**
  102105. * @hidden ModelShape of this particle (Internal use)
  102106. */
  102107. _model: ModelShape;
  102108. /**
  102109. * ModelShape id of this particle
  102110. */
  102111. shapeId: number;
  102112. /**
  102113. * Index of the particle in its shape id
  102114. */
  102115. idxInShape: number;
  102116. /**
  102117. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102118. */
  102119. _modelBoundingInfo: BoundingInfo;
  102120. /**
  102121. * @hidden Particle BoundingInfo object (Internal use)
  102122. */
  102123. _boundingInfo: BoundingInfo;
  102124. /**
  102125. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102126. */
  102127. _sps: SolidParticleSystem;
  102128. /**
  102129. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102130. */
  102131. _stillInvisible: boolean;
  102132. /**
  102133. * @hidden Last computed particle rotation matrix
  102134. */
  102135. _rotationMatrix: number[];
  102136. /**
  102137. * Parent particle Id, if any.
  102138. * Default null.
  102139. */
  102140. parentId: Nullable<number>;
  102141. /**
  102142. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102143. */
  102144. materialIndex: Nullable<number>;
  102145. /**
  102146. * Custom object or properties.
  102147. */
  102148. props: Nullable<any>;
  102149. /**
  102150. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102151. * The possible values are :
  102152. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102153. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102154. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102156. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102157. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102158. * */
  102159. cullingStrategy: number;
  102160. /**
  102161. * @hidden Internal global position in the SPS.
  102162. */
  102163. _globalPosition: Vector3;
  102164. /**
  102165. * Creates a Solid Particle object.
  102166. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102167. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102168. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102169. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102170. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102171. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102172. * @param shapeId (integer) is the model shape identifier in the SPS.
  102173. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102174. * @param sps defines the sps it is associated to
  102175. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102176. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102177. */
  102178. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102179. /**
  102180. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102181. * @param target the particle target
  102182. * @returns the current particle
  102183. */
  102184. copyToRef(target: SolidParticle): SolidParticle;
  102185. /**
  102186. * Legacy support, changed scale to scaling
  102187. */
  102188. get scale(): Vector3;
  102189. /**
  102190. * Legacy support, changed scale to scaling
  102191. */
  102192. set scale(scale: Vector3);
  102193. /**
  102194. * Legacy support, changed quaternion to rotationQuaternion
  102195. */
  102196. get quaternion(): Nullable<Quaternion>;
  102197. /**
  102198. * Legacy support, changed quaternion to rotationQuaternion
  102199. */
  102200. set quaternion(q: Nullable<Quaternion>);
  102201. /**
  102202. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102203. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102204. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102205. * @returns true if it intersects
  102206. */
  102207. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102208. /**
  102209. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102210. * A particle is in the frustum if its bounding box intersects the frustum
  102211. * @param frustumPlanes defines the frustum to test
  102212. * @returns true if the particle is in the frustum planes
  102213. */
  102214. isInFrustum(frustumPlanes: Plane[]): boolean;
  102215. /**
  102216. * get the rotation matrix of the particle
  102217. * @hidden
  102218. */
  102219. getRotationMatrix(m: Matrix): void;
  102220. }
  102221. /**
  102222. * Represents the shape of the model used by one particle of a solid particle system.
  102223. * SPS internal tool, don't use it manually.
  102224. */
  102225. export class ModelShape {
  102226. /**
  102227. * The shape id
  102228. * @hidden
  102229. */
  102230. shapeID: number;
  102231. /**
  102232. * flat array of model positions (internal use)
  102233. * @hidden
  102234. */
  102235. _shape: Vector3[];
  102236. /**
  102237. * flat array of model UVs (internal use)
  102238. * @hidden
  102239. */
  102240. _shapeUV: number[];
  102241. /**
  102242. * color array of the model
  102243. * @hidden
  102244. */
  102245. _shapeColors: number[];
  102246. /**
  102247. * indices array of the model
  102248. * @hidden
  102249. */
  102250. _indices: number[];
  102251. /**
  102252. * normals array of the model
  102253. * @hidden
  102254. */
  102255. _normals: number[];
  102256. /**
  102257. * length of the shape in the model indices array (internal use)
  102258. * @hidden
  102259. */
  102260. _indicesLength: number;
  102261. /**
  102262. * Custom position function (internal use)
  102263. * @hidden
  102264. */
  102265. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102266. /**
  102267. * Custom vertex function (internal use)
  102268. * @hidden
  102269. */
  102270. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102271. /**
  102272. * Model material (internal use)
  102273. * @hidden
  102274. */
  102275. _material: Nullable<Material>;
  102276. /**
  102277. * 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.
  102278. * SPS internal tool, don't use it manually.
  102279. * @hidden
  102280. */
  102281. 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>);
  102282. }
  102283. /**
  102284. * Represents a Depth Sorted Particle in the solid particle system.
  102285. * @hidden
  102286. */
  102287. export class DepthSortedParticle {
  102288. /**
  102289. * Particle index
  102290. */
  102291. idx: number;
  102292. /**
  102293. * Index of the particle in the "indices" array
  102294. */
  102295. ind: number;
  102296. /**
  102297. * Length of the particle shape in the "indices" array
  102298. */
  102299. indicesLength: number;
  102300. /**
  102301. * Squared distance from the particle to the camera
  102302. */
  102303. sqDistance: number;
  102304. /**
  102305. * Material index when used with MultiMaterials
  102306. */
  102307. materialIndex: number;
  102308. /**
  102309. * Creates a new sorted particle
  102310. * @param materialIndex
  102311. */
  102312. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102313. }
  102314. }
  102315. declare module BABYLON {
  102316. /**
  102317. * @hidden
  102318. */
  102319. export class _MeshCollisionData {
  102320. _checkCollisions: boolean;
  102321. _collisionMask: number;
  102322. _collisionGroup: number;
  102323. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102324. _collider: Nullable<Collider>;
  102325. _oldPositionForCollisions: Vector3;
  102326. _diffPositionForCollisions: Vector3;
  102327. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102328. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102329. }
  102330. }
  102331. declare module BABYLON {
  102332. /** @hidden */
  102333. class _FacetDataStorage {
  102334. facetPositions: Vector3[];
  102335. facetNormals: Vector3[];
  102336. facetPartitioning: number[][];
  102337. facetNb: number;
  102338. partitioningSubdivisions: number;
  102339. partitioningBBoxRatio: number;
  102340. facetDataEnabled: boolean;
  102341. facetParameters: any;
  102342. bbSize: Vector3;
  102343. subDiv: {
  102344. max: number;
  102345. X: number;
  102346. Y: number;
  102347. Z: number;
  102348. };
  102349. facetDepthSort: boolean;
  102350. facetDepthSortEnabled: boolean;
  102351. depthSortedIndices: IndicesArray;
  102352. depthSortedFacets: {
  102353. ind: number;
  102354. sqDistance: number;
  102355. }[];
  102356. facetDepthSortFunction: (f1: {
  102357. ind: number;
  102358. sqDistance: number;
  102359. }, f2: {
  102360. ind: number;
  102361. sqDistance: number;
  102362. }) => number;
  102363. facetDepthSortFrom: Vector3;
  102364. facetDepthSortOrigin: Vector3;
  102365. invertedMatrix: Matrix;
  102366. }
  102367. /**
  102368. * @hidden
  102369. **/
  102370. class _InternalAbstractMeshDataInfo {
  102371. _hasVertexAlpha: boolean;
  102372. _useVertexColors: boolean;
  102373. _numBoneInfluencers: number;
  102374. _applyFog: boolean;
  102375. _receiveShadows: boolean;
  102376. _facetData: _FacetDataStorage;
  102377. _visibility: number;
  102378. _skeleton: Nullable<Skeleton>;
  102379. _layerMask: number;
  102380. _computeBonesUsingShaders: boolean;
  102381. _isActive: boolean;
  102382. _onlyForInstances: boolean;
  102383. _isActiveIntermediate: boolean;
  102384. _onlyForInstancesIntermediate: boolean;
  102385. _actAsRegularMesh: boolean;
  102386. }
  102387. /**
  102388. * Class used to store all common mesh properties
  102389. */
  102390. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102391. /** No occlusion */
  102392. static OCCLUSION_TYPE_NONE: number;
  102393. /** Occlusion set to optimisitic */
  102394. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102395. /** Occlusion set to strict */
  102396. static OCCLUSION_TYPE_STRICT: number;
  102397. /** Use an accurante occlusion algorithm */
  102398. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102399. /** Use a conservative occlusion algorithm */
  102400. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102401. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102402. * Test order :
  102403. * Is the bounding sphere outside the frustum ?
  102404. * If not, are the bounding box vertices outside the frustum ?
  102405. * It not, then the cullable object is in the frustum.
  102406. */
  102407. static readonly CULLINGSTRATEGY_STANDARD: number;
  102408. /** Culling strategy : Bounding Sphere Only.
  102409. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102410. * It's also less accurate than the standard because some not visible objects can still be selected.
  102411. * Test : is the bounding sphere outside the frustum ?
  102412. * If not, then the cullable object is in the frustum.
  102413. */
  102414. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102415. /** Culling strategy : Optimistic Inclusion.
  102416. * This in an inclusion test first, then the standard exclusion test.
  102417. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102418. * 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.
  102419. * Anyway, it's as accurate as the standard strategy.
  102420. * Test :
  102421. * Is the cullable object bounding sphere center in the frustum ?
  102422. * If not, apply the default culling strategy.
  102423. */
  102424. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102425. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102426. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102427. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102428. * 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.
  102429. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102430. * Test :
  102431. * Is the cullable object bounding sphere center in the frustum ?
  102432. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102433. */
  102434. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102435. /**
  102436. * No billboard
  102437. */
  102438. static get BILLBOARDMODE_NONE(): number;
  102439. /** Billboard on X axis */
  102440. static get BILLBOARDMODE_X(): number;
  102441. /** Billboard on Y axis */
  102442. static get BILLBOARDMODE_Y(): number;
  102443. /** Billboard on Z axis */
  102444. static get BILLBOARDMODE_Z(): number;
  102445. /** Billboard on all axes */
  102446. static get BILLBOARDMODE_ALL(): number;
  102447. /** Billboard on using position instead of orientation */
  102448. static get BILLBOARDMODE_USE_POSITION(): number;
  102449. /** @hidden */
  102450. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102451. /**
  102452. * The culling strategy to use to check whether the mesh must be rendered or not.
  102453. * This value can be changed at any time and will be used on the next render mesh selection.
  102454. * The possible values are :
  102455. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102456. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102457. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102458. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102459. * Please read each static variable documentation to get details about the culling process.
  102460. * */
  102461. cullingStrategy: number;
  102462. /**
  102463. * Gets the number of facets in the mesh
  102464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102465. */
  102466. get facetNb(): number;
  102467. /**
  102468. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102470. */
  102471. get partitioningSubdivisions(): number;
  102472. set partitioningSubdivisions(nb: number);
  102473. /**
  102474. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102475. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102477. */
  102478. get partitioningBBoxRatio(): number;
  102479. set partitioningBBoxRatio(ratio: number);
  102480. /**
  102481. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102482. * Works only for updatable meshes.
  102483. * Doesn't work with multi-materials
  102484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102485. */
  102486. get mustDepthSortFacets(): boolean;
  102487. set mustDepthSortFacets(sort: boolean);
  102488. /**
  102489. * The location (Vector3) where the facet depth sort must be computed from.
  102490. * By default, the active camera position.
  102491. * Used only when facet depth sort is enabled
  102492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102493. */
  102494. get facetDepthSortFrom(): Vector3;
  102495. set facetDepthSortFrom(location: Vector3);
  102496. /**
  102497. * gets a boolean indicating if facetData is enabled
  102498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102499. */
  102500. get isFacetDataEnabled(): boolean;
  102501. /** @hidden */
  102502. _updateNonUniformScalingState(value: boolean): boolean;
  102503. /**
  102504. * An event triggered when this mesh collides with another one
  102505. */
  102506. onCollideObservable: Observable<AbstractMesh>;
  102507. /** Set a function to call when this mesh collides with another one */
  102508. set onCollide(callback: () => void);
  102509. /**
  102510. * An event triggered when the collision's position changes
  102511. */
  102512. onCollisionPositionChangeObservable: Observable<Vector3>;
  102513. /** Set a function to call when the collision's position changes */
  102514. set onCollisionPositionChange(callback: () => void);
  102515. /**
  102516. * An event triggered when material is changed
  102517. */
  102518. onMaterialChangedObservable: Observable<AbstractMesh>;
  102519. /**
  102520. * Gets or sets the orientation for POV movement & rotation
  102521. */
  102522. definedFacingForward: boolean;
  102523. /** @hidden */
  102524. _occlusionQuery: Nullable<WebGLQuery>;
  102525. /** @hidden */
  102526. _renderingGroup: Nullable<RenderingGroup>;
  102527. /**
  102528. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102529. */
  102530. get visibility(): number;
  102531. /**
  102532. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102533. */
  102534. set visibility(value: number);
  102535. /** Gets or sets the alpha index used to sort transparent meshes
  102536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102537. */
  102538. alphaIndex: number;
  102539. /**
  102540. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102541. */
  102542. isVisible: boolean;
  102543. /**
  102544. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102545. */
  102546. isPickable: boolean;
  102547. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102548. showSubMeshesBoundingBox: boolean;
  102549. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102550. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102551. */
  102552. isBlocker: boolean;
  102553. /**
  102554. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102555. */
  102556. enablePointerMoveEvents: boolean;
  102557. /**
  102558. * Specifies the rendering group id for this mesh (0 by default)
  102559. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102560. */
  102561. renderingGroupId: number;
  102562. private _material;
  102563. /** Gets or sets current material */
  102564. get material(): Nullable<Material>;
  102565. set material(value: Nullable<Material>);
  102566. /**
  102567. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102568. * @see http://doc.babylonjs.com/babylon101/shadows
  102569. */
  102570. get receiveShadows(): boolean;
  102571. set receiveShadows(value: boolean);
  102572. /** Defines color to use when rendering outline */
  102573. outlineColor: Color3;
  102574. /** Define width to use when rendering outline */
  102575. outlineWidth: number;
  102576. /** Defines color to use when rendering overlay */
  102577. overlayColor: Color3;
  102578. /** Defines alpha to use when rendering overlay */
  102579. overlayAlpha: number;
  102580. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102581. get hasVertexAlpha(): boolean;
  102582. set hasVertexAlpha(value: boolean);
  102583. /** 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) */
  102584. get useVertexColors(): boolean;
  102585. set useVertexColors(value: boolean);
  102586. /**
  102587. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102588. */
  102589. get computeBonesUsingShaders(): boolean;
  102590. set computeBonesUsingShaders(value: boolean);
  102591. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102592. get numBoneInfluencers(): number;
  102593. set numBoneInfluencers(value: number);
  102594. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102595. get applyFog(): boolean;
  102596. set applyFog(value: boolean);
  102597. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102598. useOctreeForRenderingSelection: boolean;
  102599. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102600. useOctreeForPicking: boolean;
  102601. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102602. useOctreeForCollisions: boolean;
  102603. /**
  102604. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102605. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102606. */
  102607. get layerMask(): number;
  102608. set layerMask(value: number);
  102609. /**
  102610. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102611. */
  102612. alwaysSelectAsActiveMesh: boolean;
  102613. /**
  102614. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102615. */
  102616. doNotSyncBoundingInfo: boolean;
  102617. /**
  102618. * Gets or sets the current action manager
  102619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102620. */
  102621. actionManager: Nullable<AbstractActionManager>;
  102622. private _meshCollisionData;
  102623. /**
  102624. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102626. */
  102627. ellipsoid: Vector3;
  102628. /**
  102629. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102631. */
  102632. ellipsoidOffset: Vector3;
  102633. /**
  102634. * Gets or sets a collision mask used to mask collisions (default is -1).
  102635. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102636. */
  102637. get collisionMask(): number;
  102638. set collisionMask(mask: number);
  102639. /**
  102640. * Gets or sets the current collision group mask (-1 by default).
  102641. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102642. */
  102643. get collisionGroup(): number;
  102644. set collisionGroup(mask: number);
  102645. /**
  102646. * Gets or sets current surrounding meshes (null by default).
  102647. *
  102648. * By default collision detection is tested against every mesh in the scene.
  102649. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102650. * meshes will be tested for the collision.
  102651. *
  102652. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102653. */
  102654. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102655. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102656. /**
  102657. * Defines edge width used when edgesRenderer is enabled
  102658. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102659. */
  102660. edgesWidth: number;
  102661. /**
  102662. * Defines edge color used when edgesRenderer is enabled
  102663. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102664. */
  102665. edgesColor: Color4;
  102666. /** @hidden */
  102667. _edgesRenderer: Nullable<IEdgesRenderer>;
  102668. /** @hidden */
  102669. _masterMesh: Nullable<AbstractMesh>;
  102670. /** @hidden */
  102671. _boundingInfo: Nullable<BoundingInfo>;
  102672. /** @hidden */
  102673. _renderId: number;
  102674. /**
  102675. * Gets or sets the list of subMeshes
  102676. * @see http://doc.babylonjs.com/how_to/multi_materials
  102677. */
  102678. subMeshes: SubMesh[];
  102679. /** @hidden */
  102680. _intersectionsInProgress: AbstractMesh[];
  102681. /** @hidden */
  102682. _unIndexed: boolean;
  102683. /** @hidden */
  102684. _lightSources: Light[];
  102685. /** Gets the list of lights affecting that mesh */
  102686. get lightSources(): Light[];
  102687. /** @hidden */
  102688. get _positions(): Nullable<Vector3[]>;
  102689. /** @hidden */
  102690. _waitingData: {
  102691. lods: Nullable<any>;
  102692. actions: Nullable<any>;
  102693. freezeWorldMatrix: Nullable<boolean>;
  102694. };
  102695. /** @hidden */
  102696. _bonesTransformMatrices: Nullable<Float32Array>;
  102697. /** @hidden */
  102698. _transformMatrixTexture: Nullable<RawTexture>;
  102699. /**
  102700. * Gets or sets a skeleton to apply skining transformations
  102701. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102702. */
  102703. set skeleton(value: Nullable<Skeleton>);
  102704. get skeleton(): Nullable<Skeleton>;
  102705. /**
  102706. * An event triggered when the mesh is rebuilt.
  102707. */
  102708. onRebuildObservable: Observable<AbstractMesh>;
  102709. /**
  102710. * Creates a new AbstractMesh
  102711. * @param name defines the name of the mesh
  102712. * @param scene defines the hosting scene
  102713. */
  102714. constructor(name: string, scene?: Nullable<Scene>);
  102715. /**
  102716. * Returns the string "AbstractMesh"
  102717. * @returns "AbstractMesh"
  102718. */
  102719. getClassName(): string;
  102720. /**
  102721. * Gets a string representation of the current mesh
  102722. * @param fullDetails defines a boolean indicating if full details must be included
  102723. * @returns a string representation of the current mesh
  102724. */
  102725. toString(fullDetails?: boolean): string;
  102726. /**
  102727. * @hidden
  102728. */
  102729. protected _getEffectiveParent(): Nullable<Node>;
  102730. /** @hidden */
  102731. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102732. /** @hidden */
  102733. _rebuild(): void;
  102734. /** @hidden */
  102735. _resyncLightSources(): void;
  102736. /** @hidden */
  102737. _resyncLightSource(light: Light): void;
  102738. /** @hidden */
  102739. _unBindEffect(): void;
  102740. /** @hidden */
  102741. _removeLightSource(light: Light, dispose: boolean): void;
  102742. private _markSubMeshesAsDirty;
  102743. /** @hidden */
  102744. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102745. /** @hidden */
  102746. _markSubMeshesAsAttributesDirty(): void;
  102747. /** @hidden */
  102748. _markSubMeshesAsMiscDirty(): void;
  102749. /**
  102750. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102751. */
  102752. get scaling(): Vector3;
  102753. set scaling(newScaling: Vector3);
  102754. /**
  102755. * Returns true if the mesh is blocked. Implemented by child classes
  102756. */
  102757. get isBlocked(): boolean;
  102758. /**
  102759. * Returns the mesh itself by default. Implemented by child classes
  102760. * @param camera defines the camera to use to pick the right LOD level
  102761. * @returns the currentAbstractMesh
  102762. */
  102763. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102764. /**
  102765. * Returns 0 by default. Implemented by child classes
  102766. * @returns an integer
  102767. */
  102768. getTotalVertices(): number;
  102769. /**
  102770. * Returns a positive integer : the total number of indices in this mesh geometry.
  102771. * @returns the numner of indices or zero if the mesh has no geometry.
  102772. */
  102773. getTotalIndices(): number;
  102774. /**
  102775. * Returns null by default. Implemented by child classes
  102776. * @returns null
  102777. */
  102778. getIndices(): Nullable<IndicesArray>;
  102779. /**
  102780. * Returns the array of the requested vertex data kind. Implemented by child classes
  102781. * @param kind defines the vertex data kind to use
  102782. * @returns null
  102783. */
  102784. getVerticesData(kind: string): Nullable<FloatArray>;
  102785. /**
  102786. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102787. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102788. * Note that a new underlying VertexBuffer object is created each call.
  102789. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102790. * @param kind defines vertex data kind:
  102791. * * VertexBuffer.PositionKind
  102792. * * VertexBuffer.UVKind
  102793. * * VertexBuffer.UV2Kind
  102794. * * VertexBuffer.UV3Kind
  102795. * * VertexBuffer.UV4Kind
  102796. * * VertexBuffer.UV5Kind
  102797. * * VertexBuffer.UV6Kind
  102798. * * VertexBuffer.ColorKind
  102799. * * VertexBuffer.MatricesIndicesKind
  102800. * * VertexBuffer.MatricesIndicesExtraKind
  102801. * * VertexBuffer.MatricesWeightsKind
  102802. * * VertexBuffer.MatricesWeightsExtraKind
  102803. * @param data defines the data source
  102804. * @param updatable defines if the data must be flagged as updatable (or static)
  102805. * @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
  102806. * @returns the current mesh
  102807. */
  102808. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102809. /**
  102810. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102811. * If the mesh has no geometry, it is simply returned as it is.
  102812. * @param kind defines vertex data kind:
  102813. * * VertexBuffer.PositionKind
  102814. * * VertexBuffer.UVKind
  102815. * * VertexBuffer.UV2Kind
  102816. * * VertexBuffer.UV3Kind
  102817. * * VertexBuffer.UV4Kind
  102818. * * VertexBuffer.UV5Kind
  102819. * * VertexBuffer.UV6Kind
  102820. * * VertexBuffer.ColorKind
  102821. * * VertexBuffer.MatricesIndicesKind
  102822. * * VertexBuffer.MatricesIndicesExtraKind
  102823. * * VertexBuffer.MatricesWeightsKind
  102824. * * VertexBuffer.MatricesWeightsExtraKind
  102825. * @param data defines the data source
  102826. * @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
  102827. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102828. * @returns the current mesh
  102829. */
  102830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102831. /**
  102832. * Sets the mesh indices,
  102833. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102834. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102835. * @param totalVertices Defines the total number of vertices
  102836. * @returns the current mesh
  102837. */
  102838. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102839. /**
  102840. * Gets a boolean indicating if specific vertex data is present
  102841. * @param kind defines the vertex data kind to use
  102842. * @returns true is data kind is present
  102843. */
  102844. isVerticesDataPresent(kind: string): boolean;
  102845. /**
  102846. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102847. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102848. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102849. * @returns a BoundingInfo
  102850. */
  102851. getBoundingInfo(): BoundingInfo;
  102852. /**
  102853. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102854. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102855. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102856. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102857. * @returns the current mesh
  102858. */
  102859. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102860. /**
  102861. * Overwrite the current bounding info
  102862. * @param boundingInfo defines the new bounding info
  102863. * @returns the current mesh
  102864. */
  102865. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102866. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102867. get useBones(): boolean;
  102868. /** @hidden */
  102869. _preActivate(): void;
  102870. /** @hidden */
  102871. _preActivateForIntermediateRendering(renderId: number): void;
  102872. /** @hidden */
  102873. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102874. /** @hidden */
  102875. _postActivate(): void;
  102876. /** @hidden */
  102877. _freeze(): void;
  102878. /** @hidden */
  102879. _unFreeze(): void;
  102880. /**
  102881. * Gets the current world matrix
  102882. * @returns a Matrix
  102883. */
  102884. getWorldMatrix(): Matrix;
  102885. /** @hidden */
  102886. _getWorldMatrixDeterminant(): number;
  102887. /**
  102888. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102889. */
  102890. get isAnInstance(): boolean;
  102891. /**
  102892. * Gets a boolean indicating if this mesh has instances
  102893. */
  102894. get hasInstances(): boolean;
  102895. /**
  102896. * Perform relative position change from the point of view of behind the front of the mesh.
  102897. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102898. * Supports definition of mesh facing forward or backward
  102899. * @param amountRight defines the distance on the right axis
  102900. * @param amountUp defines the distance on the up axis
  102901. * @param amountForward defines the distance on the forward axis
  102902. * @returns the current mesh
  102903. */
  102904. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102905. /**
  102906. * Calculate relative position change from the point of view of behind the front of the mesh.
  102907. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102908. * Supports definition of mesh facing forward or backward
  102909. * @param amountRight defines the distance on the right axis
  102910. * @param amountUp defines the distance on the up axis
  102911. * @param amountForward defines the distance on the forward axis
  102912. * @returns the new displacement vector
  102913. */
  102914. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102915. /**
  102916. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102917. * Supports definition of mesh facing forward or backward
  102918. * @param flipBack defines the flip
  102919. * @param twirlClockwise defines the twirl
  102920. * @param tiltRight defines the tilt
  102921. * @returns the current mesh
  102922. */
  102923. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102924. /**
  102925. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102926. * Supports definition of mesh facing forward or backward.
  102927. * @param flipBack defines the flip
  102928. * @param twirlClockwise defines the twirl
  102929. * @param tiltRight defines the tilt
  102930. * @returns the new rotation vector
  102931. */
  102932. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102933. /**
  102934. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102935. * This means the mesh underlying bounding box and sphere are recomputed.
  102936. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102937. * @returns the current mesh
  102938. */
  102939. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102940. /** @hidden */
  102941. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102942. /** @hidden */
  102943. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102944. /** @hidden */
  102945. _updateBoundingInfo(): AbstractMesh;
  102946. /** @hidden */
  102947. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102948. /** @hidden */
  102949. protected _afterComputeWorldMatrix(): void;
  102950. /** @hidden */
  102951. get _effectiveMesh(): AbstractMesh;
  102952. /**
  102953. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102954. * A mesh is in the frustum if its bounding box intersects the frustum
  102955. * @param frustumPlanes defines the frustum to test
  102956. * @returns true if the mesh is in the frustum planes
  102957. */
  102958. isInFrustum(frustumPlanes: Plane[]): boolean;
  102959. /**
  102960. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102961. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102962. * @param frustumPlanes defines the frustum to test
  102963. * @returns true if the mesh is completely in the frustum planes
  102964. */
  102965. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102966. /**
  102967. * True if the mesh intersects another mesh or a SolidParticle object
  102968. * @param mesh defines a target mesh or SolidParticle to test
  102969. * @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)
  102970. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102971. * @returns true if there is an intersection
  102972. */
  102973. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102974. /**
  102975. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102976. * @param point defines the point to test
  102977. * @returns true if there is an intersection
  102978. */
  102979. intersectsPoint(point: Vector3): boolean;
  102980. /**
  102981. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102983. */
  102984. get checkCollisions(): boolean;
  102985. set checkCollisions(collisionEnabled: boolean);
  102986. /**
  102987. * Gets Collider object used to compute collisions (not physics)
  102988. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102989. */
  102990. get collider(): Nullable<Collider>;
  102991. /**
  102992. * Move the mesh using collision engine
  102993. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102994. * @param displacement defines the requested displacement vector
  102995. * @returns the current mesh
  102996. */
  102997. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102998. private _onCollisionPositionChange;
  102999. /** @hidden */
  103000. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  103001. /** @hidden */
  103002. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  103003. /** @hidden */
  103004. _checkCollision(collider: Collider): AbstractMesh;
  103005. /** @hidden */
  103006. _generatePointsArray(): boolean;
  103007. /**
  103008. * Checks if the passed Ray intersects with the mesh
  103009. * @param ray defines the ray to use
  103010. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  103011. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103012. * @returns the picking info
  103013. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  103014. */
  103015. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  103016. /**
  103017. * Clones the current mesh
  103018. * @param name defines the mesh name
  103019. * @param newParent defines the new mesh parent
  103020. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103021. * @returns the new mesh
  103022. */
  103023. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103024. /**
  103025. * Disposes all the submeshes of the current meshnp
  103026. * @returns the current mesh
  103027. */
  103028. releaseSubMeshes(): AbstractMesh;
  103029. /**
  103030. * Releases resources associated with this abstract mesh.
  103031. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103032. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103033. */
  103034. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103035. /**
  103036. * Adds the passed mesh as a child to the current mesh
  103037. * @param mesh defines the child mesh
  103038. * @returns the current mesh
  103039. */
  103040. addChild(mesh: AbstractMesh): AbstractMesh;
  103041. /**
  103042. * Removes the passed mesh from the current mesh children list
  103043. * @param mesh defines the child mesh
  103044. * @returns the current mesh
  103045. */
  103046. removeChild(mesh: AbstractMesh): AbstractMesh;
  103047. /** @hidden */
  103048. private _initFacetData;
  103049. /**
  103050. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103051. * This method can be called within the render loop.
  103052. * 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
  103053. * @returns the current mesh
  103054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103055. */
  103056. updateFacetData(): AbstractMesh;
  103057. /**
  103058. * Returns the facetLocalNormals array.
  103059. * The normals are expressed in the mesh local spac
  103060. * @returns an array of Vector3
  103061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103062. */
  103063. getFacetLocalNormals(): Vector3[];
  103064. /**
  103065. * Returns the facetLocalPositions array.
  103066. * The facet positions are expressed in the mesh local space
  103067. * @returns an array of Vector3
  103068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103069. */
  103070. getFacetLocalPositions(): Vector3[];
  103071. /**
  103072. * Returns the facetLocalPartioning array
  103073. * @returns an array of array of numbers
  103074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103075. */
  103076. getFacetLocalPartitioning(): number[][];
  103077. /**
  103078. * Returns the i-th facet position in the world system.
  103079. * This method allocates a new Vector3 per call
  103080. * @param i defines the facet index
  103081. * @returns a new Vector3
  103082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103083. */
  103084. getFacetPosition(i: number): Vector3;
  103085. /**
  103086. * Sets the reference Vector3 with the i-th facet position in the world system
  103087. * @param i defines the facet index
  103088. * @param ref defines the target vector
  103089. * @returns the current mesh
  103090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103091. */
  103092. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103093. /**
  103094. * Returns the i-th facet normal in the world system.
  103095. * This method allocates a new Vector3 per call
  103096. * @param i defines the facet index
  103097. * @returns a new Vector3
  103098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103099. */
  103100. getFacetNormal(i: number): Vector3;
  103101. /**
  103102. * Sets the reference Vector3 with the i-th facet normal in the world system
  103103. * @param i defines the facet index
  103104. * @param ref defines the target vector
  103105. * @returns the current mesh
  103106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103107. */
  103108. getFacetNormalToRef(i: number, ref: Vector3): this;
  103109. /**
  103110. * 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)
  103111. * @param x defines x coordinate
  103112. * @param y defines y coordinate
  103113. * @param z defines z coordinate
  103114. * @returns the array of facet indexes
  103115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103116. */
  103117. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103118. /**
  103119. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103120. * @param projected sets as the (x,y,z) world projection on the facet
  103121. * @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
  103122. * @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
  103123. * @param x defines x coordinate
  103124. * @param y defines y coordinate
  103125. * @param z defines z coordinate
  103126. * @returns the face index if found (or null instead)
  103127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103128. */
  103129. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103130. /**
  103131. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103132. * @param projected sets as the (x,y,z) local projection on the facet
  103133. * @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
  103134. * @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
  103135. * @param x defines x coordinate
  103136. * @param y defines y coordinate
  103137. * @param z defines z coordinate
  103138. * @returns the face index if found (or null instead)
  103139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103140. */
  103141. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103142. /**
  103143. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103144. * @returns the parameters
  103145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103146. */
  103147. getFacetDataParameters(): any;
  103148. /**
  103149. * Disables the feature FacetData and frees the related memory
  103150. * @returns the current mesh
  103151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103152. */
  103153. disableFacetData(): AbstractMesh;
  103154. /**
  103155. * Updates the AbstractMesh indices array
  103156. * @param indices defines the data source
  103157. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103158. * @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)
  103159. * @returns the current mesh
  103160. */
  103161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103162. /**
  103163. * Creates new normals data for the mesh
  103164. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103165. * @returns the current mesh
  103166. */
  103167. createNormals(updatable: boolean): AbstractMesh;
  103168. /**
  103169. * Align the mesh with a normal
  103170. * @param normal defines the normal to use
  103171. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103172. * @returns the current mesh
  103173. */
  103174. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103175. /** @hidden */
  103176. _checkOcclusionQuery(): boolean;
  103177. /**
  103178. * Disables the mesh edge rendering mode
  103179. * @returns the currentAbstractMesh
  103180. */
  103181. disableEdgesRendering(): AbstractMesh;
  103182. /**
  103183. * Enables the edge rendering mode on the mesh.
  103184. * This mode makes the mesh edges visible
  103185. * @param epsilon defines the maximal distance between two angles to detect a face
  103186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103187. * @returns the currentAbstractMesh
  103188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103189. */
  103190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103191. }
  103192. }
  103193. declare module BABYLON {
  103194. /**
  103195. * Interface used to define ActionEvent
  103196. */
  103197. export interface IActionEvent {
  103198. /** The mesh or sprite that triggered the action */
  103199. source: any;
  103200. /** The X mouse cursor position at the time of the event */
  103201. pointerX: number;
  103202. /** The Y mouse cursor position at the time of the event */
  103203. pointerY: number;
  103204. /** The mesh that is currently pointed at (can be null) */
  103205. meshUnderPointer: Nullable<AbstractMesh>;
  103206. /** the original (browser) event that triggered the ActionEvent */
  103207. sourceEvent?: any;
  103208. /** additional data for the event */
  103209. additionalData?: any;
  103210. }
  103211. /**
  103212. * ActionEvent is the event being sent when an action is triggered.
  103213. */
  103214. export class ActionEvent implements IActionEvent {
  103215. /** The mesh or sprite that triggered the action */
  103216. source: any;
  103217. /** The X mouse cursor position at the time of the event */
  103218. pointerX: number;
  103219. /** The Y mouse cursor position at the time of the event */
  103220. pointerY: number;
  103221. /** The mesh that is currently pointed at (can be null) */
  103222. meshUnderPointer: Nullable<AbstractMesh>;
  103223. /** the original (browser) event that triggered the ActionEvent */
  103224. sourceEvent?: any;
  103225. /** additional data for the event */
  103226. additionalData?: any;
  103227. /**
  103228. * Creates a new ActionEvent
  103229. * @param source The mesh or sprite that triggered the action
  103230. * @param pointerX The X mouse cursor position at the time of the event
  103231. * @param pointerY The Y mouse cursor position at the time of the event
  103232. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103233. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103234. * @param additionalData additional data for the event
  103235. */
  103236. constructor(
  103237. /** The mesh or sprite that triggered the action */
  103238. source: any,
  103239. /** The X mouse cursor position at the time of the event */
  103240. pointerX: number,
  103241. /** The Y mouse cursor position at the time of the event */
  103242. pointerY: number,
  103243. /** The mesh that is currently pointed at (can be null) */
  103244. meshUnderPointer: Nullable<AbstractMesh>,
  103245. /** the original (browser) event that triggered the ActionEvent */
  103246. sourceEvent?: any,
  103247. /** additional data for the event */
  103248. additionalData?: any);
  103249. /**
  103250. * Helper function to auto-create an ActionEvent from a source mesh.
  103251. * @param source The source mesh that triggered the event
  103252. * @param evt The original (browser) event
  103253. * @param additionalData additional data for the event
  103254. * @returns the new ActionEvent
  103255. */
  103256. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103257. /**
  103258. * Helper function to auto-create an ActionEvent from a source sprite
  103259. * @param source The source sprite that triggered the event
  103260. * @param scene Scene associated with the sprite
  103261. * @param evt The original (browser) event
  103262. * @param additionalData additional data for the event
  103263. * @returns the new ActionEvent
  103264. */
  103265. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103266. /**
  103267. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103268. * @param scene the scene where the event occurred
  103269. * @param evt The original (browser) event
  103270. * @returns the new ActionEvent
  103271. */
  103272. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103273. /**
  103274. * Helper function to auto-create an ActionEvent from a primitive
  103275. * @param prim defines the target primitive
  103276. * @param pointerPos defines the pointer position
  103277. * @param evt The original (browser) event
  103278. * @param additionalData additional data for the event
  103279. * @returns the new ActionEvent
  103280. */
  103281. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103282. }
  103283. }
  103284. declare module BABYLON {
  103285. /**
  103286. * Abstract class used to decouple action Manager from scene and meshes.
  103287. * Do not instantiate.
  103288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103289. */
  103290. export abstract class AbstractActionManager implements IDisposable {
  103291. /** Gets the list of active triggers */
  103292. static Triggers: {
  103293. [key: string]: number;
  103294. };
  103295. /** Gets the cursor to use when hovering items */
  103296. hoverCursor: string;
  103297. /** Gets the list of actions */
  103298. actions: IAction[];
  103299. /**
  103300. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103301. */
  103302. isRecursive: boolean;
  103303. /**
  103304. * Releases all associated resources
  103305. */
  103306. abstract dispose(): void;
  103307. /**
  103308. * Does this action manager has pointer triggers
  103309. */
  103310. abstract get hasPointerTriggers(): boolean;
  103311. /**
  103312. * Does this action manager has pick triggers
  103313. */
  103314. abstract get hasPickTriggers(): boolean;
  103315. /**
  103316. * Process a specific trigger
  103317. * @param trigger defines the trigger to process
  103318. * @param evt defines the event details to be processed
  103319. */
  103320. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103321. /**
  103322. * Does this action manager handles actions of any of the given triggers
  103323. * @param triggers defines the triggers to be tested
  103324. * @return a boolean indicating whether one (or more) of the triggers is handled
  103325. */
  103326. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103327. /**
  103328. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103329. * speed.
  103330. * @param triggerA defines the trigger to be tested
  103331. * @param triggerB defines the trigger to be tested
  103332. * @return a boolean indicating whether one (or more) of the triggers is handled
  103333. */
  103334. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103335. /**
  103336. * Does this action manager handles actions of a given trigger
  103337. * @param trigger defines the trigger to be tested
  103338. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103339. * @return whether the trigger is handled
  103340. */
  103341. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103342. /**
  103343. * Serialize this manager to a JSON object
  103344. * @param name defines the property name to store this manager
  103345. * @returns a JSON representation of this manager
  103346. */
  103347. abstract serialize(name: string): any;
  103348. /**
  103349. * Registers an action to this action manager
  103350. * @param action defines the action to be registered
  103351. * @return the action amended (prepared) after registration
  103352. */
  103353. abstract registerAction(action: IAction): Nullable<IAction>;
  103354. /**
  103355. * Unregisters an action to this action manager
  103356. * @param action defines the action to be unregistered
  103357. * @return a boolean indicating whether the action has been unregistered
  103358. */
  103359. abstract unregisterAction(action: IAction): Boolean;
  103360. /**
  103361. * Does exist one action manager with at least one trigger
  103362. **/
  103363. static get HasTriggers(): boolean;
  103364. /**
  103365. * Does exist one action manager with at least one pick trigger
  103366. **/
  103367. static get HasPickTriggers(): boolean;
  103368. /**
  103369. * Does exist one action manager that handles actions of a given trigger
  103370. * @param trigger defines the trigger to be tested
  103371. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103372. **/
  103373. static HasSpecificTrigger(trigger: number): boolean;
  103374. }
  103375. }
  103376. declare module BABYLON {
  103377. /**
  103378. * Defines how a node can be built from a string name.
  103379. */
  103380. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103381. /**
  103382. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103383. */
  103384. export class Node implements IBehaviorAware<Node> {
  103385. /** @hidden */
  103386. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103387. private static _NodeConstructors;
  103388. /**
  103389. * Add a new node constructor
  103390. * @param type defines the type name of the node to construct
  103391. * @param constructorFunc defines the constructor function
  103392. */
  103393. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103394. /**
  103395. * Returns a node constructor based on type name
  103396. * @param type defines the type name
  103397. * @param name defines the new node name
  103398. * @param scene defines the hosting scene
  103399. * @param options defines optional options to transmit to constructors
  103400. * @returns the new constructor or null
  103401. */
  103402. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103403. /**
  103404. * Gets or sets the name of the node
  103405. */
  103406. name: string;
  103407. /**
  103408. * Gets or sets the id of the node
  103409. */
  103410. id: string;
  103411. /**
  103412. * Gets or sets the unique id of the node
  103413. */
  103414. uniqueId: number;
  103415. /**
  103416. * Gets or sets a string used to store user defined state for the node
  103417. */
  103418. state: string;
  103419. /**
  103420. * Gets or sets an object used to store user defined information for the node
  103421. */
  103422. metadata: any;
  103423. /**
  103424. * For internal use only. Please do not use.
  103425. */
  103426. reservedDataStore: any;
  103427. /**
  103428. * List of inspectable custom properties (used by the Inspector)
  103429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103430. */
  103431. inspectableCustomProperties: IInspectable[];
  103432. private _doNotSerialize;
  103433. /**
  103434. * Gets or sets a boolean used to define if the node must be serialized
  103435. */
  103436. get doNotSerialize(): boolean;
  103437. set doNotSerialize(value: boolean);
  103438. /** @hidden */
  103439. _isDisposed: boolean;
  103440. /**
  103441. * Gets a list of Animations associated with the node
  103442. */
  103443. animations: Animation[];
  103444. protected _ranges: {
  103445. [name: string]: Nullable<AnimationRange>;
  103446. };
  103447. /**
  103448. * Callback raised when the node is ready to be used
  103449. */
  103450. onReady: Nullable<(node: Node) => void>;
  103451. private _isEnabled;
  103452. private _isParentEnabled;
  103453. private _isReady;
  103454. /** @hidden */
  103455. _currentRenderId: number;
  103456. private _parentUpdateId;
  103457. /** @hidden */
  103458. _childUpdateId: number;
  103459. /** @hidden */
  103460. _waitingParentId: Nullable<string>;
  103461. /** @hidden */
  103462. _scene: Scene;
  103463. /** @hidden */
  103464. _cache: any;
  103465. private _parentNode;
  103466. private _children;
  103467. /** @hidden */
  103468. _worldMatrix: Matrix;
  103469. /** @hidden */
  103470. _worldMatrixDeterminant: number;
  103471. /** @hidden */
  103472. _worldMatrixDeterminantIsDirty: boolean;
  103473. /** @hidden */
  103474. private _sceneRootNodesIndex;
  103475. /**
  103476. * Gets a boolean indicating if the node has been disposed
  103477. * @returns true if the node was disposed
  103478. */
  103479. isDisposed(): boolean;
  103480. /**
  103481. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103482. * @see https://doc.babylonjs.com/how_to/parenting
  103483. */
  103484. set parent(parent: Nullable<Node>);
  103485. get parent(): Nullable<Node>;
  103486. /** @hidden */
  103487. _addToSceneRootNodes(): void;
  103488. /** @hidden */
  103489. _removeFromSceneRootNodes(): void;
  103490. private _animationPropertiesOverride;
  103491. /**
  103492. * Gets or sets the animation properties override
  103493. */
  103494. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103495. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103496. /**
  103497. * Gets a string idenfifying the name of the class
  103498. * @returns "Node" string
  103499. */
  103500. getClassName(): string;
  103501. /** @hidden */
  103502. readonly _isNode: boolean;
  103503. /**
  103504. * An event triggered when the mesh is disposed
  103505. */
  103506. onDisposeObservable: Observable<Node>;
  103507. private _onDisposeObserver;
  103508. /**
  103509. * Sets a callback that will be raised when the node will be disposed
  103510. */
  103511. set onDispose(callback: () => void);
  103512. /**
  103513. * Creates a new Node
  103514. * @param name the name and id to be given to this node
  103515. * @param scene the scene this node will be added to
  103516. */
  103517. constructor(name: string, scene?: Nullable<Scene>);
  103518. /**
  103519. * Gets the scene of the node
  103520. * @returns a scene
  103521. */
  103522. getScene(): Scene;
  103523. /**
  103524. * Gets the engine of the node
  103525. * @returns a Engine
  103526. */
  103527. getEngine(): Engine;
  103528. private _behaviors;
  103529. /**
  103530. * Attach a behavior to the node
  103531. * @see http://doc.babylonjs.com/features/behaviour
  103532. * @param behavior defines the behavior to attach
  103533. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103534. * @returns the current Node
  103535. */
  103536. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103537. /**
  103538. * Remove an attached behavior
  103539. * @see http://doc.babylonjs.com/features/behaviour
  103540. * @param behavior defines the behavior to attach
  103541. * @returns the current Node
  103542. */
  103543. removeBehavior(behavior: Behavior<Node>): Node;
  103544. /**
  103545. * Gets the list of attached behaviors
  103546. * @see http://doc.babylonjs.com/features/behaviour
  103547. */
  103548. get behaviors(): Behavior<Node>[];
  103549. /**
  103550. * Gets an attached behavior by name
  103551. * @param name defines the name of the behavior to look for
  103552. * @see http://doc.babylonjs.com/features/behaviour
  103553. * @returns null if behavior was not found else the requested behavior
  103554. */
  103555. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103556. /**
  103557. * Returns the latest update of the World matrix
  103558. * @returns a Matrix
  103559. */
  103560. getWorldMatrix(): Matrix;
  103561. /** @hidden */
  103562. _getWorldMatrixDeterminant(): number;
  103563. /**
  103564. * Returns directly the latest state of the mesh World matrix.
  103565. * A Matrix is returned.
  103566. */
  103567. get worldMatrixFromCache(): Matrix;
  103568. /** @hidden */
  103569. _initCache(): void;
  103570. /** @hidden */
  103571. updateCache(force?: boolean): void;
  103572. /** @hidden */
  103573. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103574. /** @hidden */
  103575. _updateCache(ignoreParentClass?: boolean): void;
  103576. /** @hidden */
  103577. _isSynchronized(): boolean;
  103578. /** @hidden */
  103579. _markSyncedWithParent(): void;
  103580. /** @hidden */
  103581. isSynchronizedWithParent(): boolean;
  103582. /** @hidden */
  103583. isSynchronized(): boolean;
  103584. /**
  103585. * Is this node ready to be used/rendered
  103586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103587. * @return true if the node is ready
  103588. */
  103589. isReady(completeCheck?: boolean): boolean;
  103590. /**
  103591. * Is this node enabled?
  103592. * 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
  103593. * @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
  103594. * @return whether this node (and its parent) is enabled
  103595. */
  103596. isEnabled(checkAncestors?: boolean): boolean;
  103597. /** @hidden */
  103598. protected _syncParentEnabledState(): void;
  103599. /**
  103600. * Set the enabled state of this node
  103601. * @param value defines the new enabled state
  103602. */
  103603. setEnabled(value: boolean): void;
  103604. /**
  103605. * Is this node a descendant of the given node?
  103606. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103607. * @param ancestor defines the parent node to inspect
  103608. * @returns a boolean indicating if this node is a descendant of the given node
  103609. */
  103610. isDescendantOf(ancestor: Node): boolean;
  103611. /** @hidden */
  103612. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103613. /**
  103614. * Will return all nodes that have this node as ascendant
  103615. * @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
  103616. * @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
  103617. * @return all children nodes of all types
  103618. */
  103619. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103620. /**
  103621. * Get all child-meshes of this node
  103622. * @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)
  103623. * @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
  103624. * @returns an array of AbstractMesh
  103625. */
  103626. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103627. /**
  103628. * Get all direct children of this node
  103629. * @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
  103630. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  103631. * @returns an array of Node
  103632. */
  103633. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103634. /** @hidden */
  103635. _setReady(state: boolean): void;
  103636. /**
  103637. * Get an animation by name
  103638. * @param name defines the name of the animation to look for
  103639. * @returns null if not found else the requested animation
  103640. */
  103641. getAnimationByName(name: string): Nullable<Animation>;
  103642. /**
  103643. * Creates an animation range for this node
  103644. * @param name defines the name of the range
  103645. * @param from defines the starting key
  103646. * @param to defines the end key
  103647. */
  103648. createAnimationRange(name: string, from: number, to: number): void;
  103649. /**
  103650. * Delete a specific animation range
  103651. * @param name defines the name of the range to delete
  103652. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103653. */
  103654. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103655. /**
  103656. * Get an animation range by name
  103657. * @param name defines the name of the animation range to look for
  103658. * @returns null if not found else the requested animation range
  103659. */
  103660. getAnimationRange(name: string): Nullable<AnimationRange>;
  103661. /**
  103662. * Gets the list of all animation ranges defined on this node
  103663. * @returns an array
  103664. */
  103665. getAnimationRanges(): Nullable<AnimationRange>[];
  103666. /**
  103667. * Will start the animation sequence
  103668. * @param name defines the range frames for animation sequence
  103669. * @param loop defines if the animation should loop (false by default)
  103670. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103671. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103672. * @returns the object created for this animation. If range does not exist, it will return null
  103673. */
  103674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103675. /**
  103676. * Serialize animation ranges into a JSON compatible object
  103677. * @returns serialization object
  103678. */
  103679. serializeAnimationRanges(): any;
  103680. /**
  103681. * Computes the world matrix of the node
  103682. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103683. * @returns the world matrix
  103684. */
  103685. computeWorldMatrix(force?: boolean): Matrix;
  103686. /**
  103687. * Releases resources associated with this node.
  103688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103690. */
  103691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103692. /**
  103693. * Parse animation range data from a serialization object and store them into a given node
  103694. * @param node defines where to store the animation ranges
  103695. * @param parsedNode defines the serialization object to read data from
  103696. * @param scene defines the hosting scene
  103697. */
  103698. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103699. /**
  103700. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103701. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103702. * @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
  103703. * @returns the new bounding vectors
  103704. */
  103705. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103706. min: Vector3;
  103707. max: Vector3;
  103708. };
  103709. }
  103710. }
  103711. declare module BABYLON {
  103712. /**
  103713. * @hidden
  103714. */
  103715. export class _IAnimationState {
  103716. key: number;
  103717. repeatCount: number;
  103718. workValue?: any;
  103719. loopMode?: number;
  103720. offsetValue?: any;
  103721. highLimitValue?: any;
  103722. }
  103723. /**
  103724. * Class used to store any kind of animation
  103725. */
  103726. export class Animation {
  103727. /**Name of the animation */
  103728. name: string;
  103729. /**Property to animate */
  103730. targetProperty: string;
  103731. /**The frames per second of the animation */
  103732. framePerSecond: number;
  103733. /**The data type of the animation */
  103734. dataType: number;
  103735. /**The loop mode of the animation */
  103736. loopMode?: number | undefined;
  103737. /**Specifies if blending should be enabled */
  103738. enableBlending?: boolean | undefined;
  103739. /**
  103740. * Use matrix interpolation instead of using direct key value when animating matrices
  103741. */
  103742. static AllowMatricesInterpolation: boolean;
  103743. /**
  103744. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103745. */
  103746. static AllowMatrixDecomposeForInterpolation: boolean;
  103747. /**
  103748. * Stores the key frames of the animation
  103749. */
  103750. private _keys;
  103751. /**
  103752. * Stores the easing function of the animation
  103753. */
  103754. private _easingFunction;
  103755. /**
  103756. * @hidden Internal use only
  103757. */
  103758. _runtimeAnimations: RuntimeAnimation[];
  103759. /**
  103760. * The set of event that will be linked to this animation
  103761. */
  103762. private _events;
  103763. /**
  103764. * Stores an array of target property paths
  103765. */
  103766. targetPropertyPath: string[];
  103767. /**
  103768. * Stores the blending speed of the animation
  103769. */
  103770. blendingSpeed: number;
  103771. /**
  103772. * Stores the animation ranges for the animation
  103773. */
  103774. private _ranges;
  103775. /**
  103776. * @hidden Internal use
  103777. */
  103778. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103779. /**
  103780. * Sets up an animation
  103781. * @param property The property to animate
  103782. * @param animationType The animation type to apply
  103783. * @param framePerSecond The frames per second of the animation
  103784. * @param easingFunction The easing function used in the animation
  103785. * @returns The created animation
  103786. */
  103787. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103788. /**
  103789. * Create and start an animation on a node
  103790. * @param name defines the name of the global animation that will be run on all nodes
  103791. * @param node defines the root node where the animation will take place
  103792. * @param targetProperty defines property to animate
  103793. * @param framePerSecond defines the number of frame per second yo use
  103794. * @param totalFrame defines the number of frames in total
  103795. * @param from defines the initial value
  103796. * @param to defines the final value
  103797. * @param loopMode defines which loop mode you want to use (off by default)
  103798. * @param easingFunction defines the easing function to use (linear by default)
  103799. * @param onAnimationEnd defines the callback to call when animation end
  103800. * @returns the animatable created for this animation
  103801. */
  103802. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103803. /**
  103804. * Create and start an animation on a node and its descendants
  103805. * @param name defines the name of the global animation that will be run on all nodes
  103806. * @param node defines the root node where the animation will take place
  103807. * @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
  103808. * @param targetProperty defines property to animate
  103809. * @param framePerSecond defines the number of frame per second to use
  103810. * @param totalFrame defines the number of frames in total
  103811. * @param from defines the initial value
  103812. * @param to defines the final value
  103813. * @param loopMode defines which loop mode you want to use (off by default)
  103814. * @param easingFunction defines the easing function to use (linear by default)
  103815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103816. * @returns the list of animatables created for all nodes
  103817. * @example https://www.babylonjs-playground.com/#MH0VLI
  103818. */
  103819. 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[]>;
  103820. /**
  103821. * Creates a new animation, merges it with the existing animations and starts it
  103822. * @param name Name of the animation
  103823. * @param node Node which contains the scene that begins the animations
  103824. * @param targetProperty Specifies which property to animate
  103825. * @param framePerSecond The frames per second of the animation
  103826. * @param totalFrame The total number of frames
  103827. * @param from The frame at the beginning of the animation
  103828. * @param to The frame at the end of the animation
  103829. * @param loopMode Specifies the loop mode of the animation
  103830. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103831. * @param onAnimationEnd Callback to run once the animation is complete
  103832. * @returns Nullable animation
  103833. */
  103834. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103835. /**
  103836. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103837. * @param sourceAnimation defines the Animation containing keyframes to convert
  103838. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103839. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103840. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103841. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103842. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103843. */
  103844. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103845. /**
  103846. * Transition property of an host to the target Value
  103847. * @param property The property to transition
  103848. * @param targetValue The target Value of the property
  103849. * @param host The object where the property to animate belongs
  103850. * @param scene Scene used to run the animation
  103851. * @param frameRate Framerate (in frame/s) to use
  103852. * @param transition The transition type we want to use
  103853. * @param duration The duration of the animation, in milliseconds
  103854. * @param onAnimationEnd Callback trigger at the end of the animation
  103855. * @returns Nullable animation
  103856. */
  103857. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103858. /**
  103859. * Return the array of runtime animations currently using this animation
  103860. */
  103861. get runtimeAnimations(): RuntimeAnimation[];
  103862. /**
  103863. * Specifies if any of the runtime animations are currently running
  103864. */
  103865. get hasRunningRuntimeAnimations(): boolean;
  103866. /**
  103867. * Initializes the animation
  103868. * @param name Name of the animation
  103869. * @param targetProperty Property to animate
  103870. * @param framePerSecond The frames per second of the animation
  103871. * @param dataType The data type of the animation
  103872. * @param loopMode The loop mode of the animation
  103873. * @param enableBlending Specifies if blending should be enabled
  103874. */
  103875. constructor(
  103876. /**Name of the animation */
  103877. name: string,
  103878. /**Property to animate */
  103879. targetProperty: string,
  103880. /**The frames per second of the animation */
  103881. framePerSecond: number,
  103882. /**The data type of the animation */
  103883. dataType: number,
  103884. /**The loop mode of the animation */
  103885. loopMode?: number | undefined,
  103886. /**Specifies if blending should be enabled */
  103887. enableBlending?: boolean | undefined);
  103888. /**
  103889. * Converts the animation to a string
  103890. * @param fullDetails support for multiple levels of logging within scene loading
  103891. * @returns String form of the animation
  103892. */
  103893. toString(fullDetails?: boolean): string;
  103894. /**
  103895. * Add an event to this animation
  103896. * @param event Event to add
  103897. */
  103898. addEvent(event: AnimationEvent): void;
  103899. /**
  103900. * Remove all events found at the given frame
  103901. * @param frame The frame to remove events from
  103902. */
  103903. removeEvents(frame: number): void;
  103904. /**
  103905. * Retrieves all the events from the animation
  103906. * @returns Events from the animation
  103907. */
  103908. getEvents(): AnimationEvent[];
  103909. /**
  103910. * Creates an animation range
  103911. * @param name Name of the animation range
  103912. * @param from Starting frame of the animation range
  103913. * @param to Ending frame of the animation
  103914. */
  103915. createRange(name: string, from: number, to: number): void;
  103916. /**
  103917. * Deletes an animation range by name
  103918. * @param name Name of the animation range to delete
  103919. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103920. */
  103921. deleteRange(name: string, deleteFrames?: boolean): void;
  103922. /**
  103923. * Gets the animation range by name, or null if not defined
  103924. * @param name Name of the animation range
  103925. * @returns Nullable animation range
  103926. */
  103927. getRange(name: string): Nullable<AnimationRange>;
  103928. /**
  103929. * Gets the key frames from the animation
  103930. * @returns The key frames of the animation
  103931. */
  103932. getKeys(): Array<IAnimationKey>;
  103933. /**
  103934. * Gets the highest frame rate of the animation
  103935. * @returns Highest frame rate of the animation
  103936. */
  103937. getHighestFrame(): number;
  103938. /**
  103939. * Gets the easing function of the animation
  103940. * @returns Easing function of the animation
  103941. */
  103942. getEasingFunction(): IEasingFunction;
  103943. /**
  103944. * Sets the easing function of the animation
  103945. * @param easingFunction A custom mathematical formula for animation
  103946. */
  103947. setEasingFunction(easingFunction: EasingFunction): void;
  103948. /**
  103949. * Interpolates a scalar linearly
  103950. * @param startValue Start value of the animation curve
  103951. * @param endValue End value of the animation curve
  103952. * @param gradient Scalar amount to interpolate
  103953. * @returns Interpolated scalar value
  103954. */
  103955. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103956. /**
  103957. * Interpolates a scalar cubically
  103958. * @param startValue Start value of the animation curve
  103959. * @param outTangent End tangent of the animation
  103960. * @param endValue End value of the animation curve
  103961. * @param inTangent Start tangent of the animation curve
  103962. * @param gradient Scalar amount to interpolate
  103963. * @returns Interpolated scalar value
  103964. */
  103965. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103966. /**
  103967. * Interpolates a quaternion using a spherical linear interpolation
  103968. * @param startValue Start value of the animation curve
  103969. * @param endValue End value of the animation curve
  103970. * @param gradient Scalar amount to interpolate
  103971. * @returns Interpolated quaternion value
  103972. */
  103973. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103974. /**
  103975. * Interpolates a quaternion cubically
  103976. * @param startValue Start value of the animation curve
  103977. * @param outTangent End tangent of the animation curve
  103978. * @param endValue End value of the animation curve
  103979. * @param inTangent Start tangent of the animation curve
  103980. * @param gradient Scalar amount to interpolate
  103981. * @returns Interpolated quaternion value
  103982. */
  103983. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103984. /**
  103985. * Interpolates a Vector3 linearl
  103986. * @param startValue Start value of the animation curve
  103987. * @param endValue End value of the animation curve
  103988. * @param gradient Scalar amount to interpolate
  103989. * @returns Interpolated scalar value
  103990. */
  103991. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103992. /**
  103993. * Interpolates a Vector3 cubically
  103994. * @param startValue Start value of the animation curve
  103995. * @param outTangent End tangent of the animation
  103996. * @param endValue End value of the animation curve
  103997. * @param inTangent Start tangent of the animation curve
  103998. * @param gradient Scalar amount to interpolate
  103999. * @returns InterpolatedVector3 value
  104000. */
  104001. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  104002. /**
  104003. * Interpolates a Vector2 linearly
  104004. * @param startValue Start value of the animation curve
  104005. * @param endValue End value of the animation curve
  104006. * @param gradient Scalar amount to interpolate
  104007. * @returns Interpolated Vector2 value
  104008. */
  104009. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  104010. /**
  104011. * Interpolates a Vector2 cubically
  104012. * @param startValue Start value of the animation curve
  104013. * @param outTangent End tangent of the animation
  104014. * @param endValue End value of the animation curve
  104015. * @param inTangent Start tangent of the animation curve
  104016. * @param gradient Scalar amount to interpolate
  104017. * @returns Interpolated Vector2 value
  104018. */
  104019. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104020. /**
  104021. * Interpolates a size linearly
  104022. * @param startValue Start value of the animation curve
  104023. * @param endValue End value of the animation curve
  104024. * @param gradient Scalar amount to interpolate
  104025. * @returns Interpolated Size value
  104026. */
  104027. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104028. /**
  104029. * Interpolates a Color3 linearly
  104030. * @param startValue Start value of the animation curve
  104031. * @param endValue End value of the animation curve
  104032. * @param gradient Scalar amount to interpolate
  104033. * @returns Interpolated Color3 value
  104034. */
  104035. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104036. /**
  104037. * Interpolates a Color4 linearly
  104038. * @param startValue Start value of the animation curve
  104039. * @param endValue End value of the animation curve
  104040. * @param gradient Scalar amount to interpolate
  104041. * @returns Interpolated Color3 value
  104042. */
  104043. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104044. /**
  104045. * @hidden Internal use only
  104046. */
  104047. _getKeyValue(value: any): any;
  104048. /**
  104049. * @hidden Internal use only
  104050. */
  104051. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104052. /**
  104053. * Defines the function to use to interpolate matrices
  104054. * @param startValue defines the start matrix
  104055. * @param endValue defines the end matrix
  104056. * @param gradient defines the gradient between both matrices
  104057. * @param result defines an optional target matrix where to store the interpolation
  104058. * @returns the interpolated matrix
  104059. */
  104060. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104061. /**
  104062. * Makes a copy of the animation
  104063. * @returns Cloned animation
  104064. */
  104065. clone(): Animation;
  104066. /**
  104067. * Sets the key frames of the animation
  104068. * @param values The animation key frames to set
  104069. */
  104070. setKeys(values: Array<IAnimationKey>): void;
  104071. /**
  104072. * Serializes the animation to an object
  104073. * @returns Serialized object
  104074. */
  104075. serialize(): any;
  104076. /**
  104077. * Float animation type
  104078. */
  104079. static readonly ANIMATIONTYPE_FLOAT: number;
  104080. /**
  104081. * Vector3 animation type
  104082. */
  104083. static readonly ANIMATIONTYPE_VECTOR3: number;
  104084. /**
  104085. * Quaternion animation type
  104086. */
  104087. static readonly ANIMATIONTYPE_QUATERNION: number;
  104088. /**
  104089. * Matrix animation type
  104090. */
  104091. static readonly ANIMATIONTYPE_MATRIX: number;
  104092. /**
  104093. * Color3 animation type
  104094. */
  104095. static readonly ANIMATIONTYPE_COLOR3: number;
  104096. /**
  104097. * Color3 animation type
  104098. */
  104099. static readonly ANIMATIONTYPE_COLOR4: number;
  104100. /**
  104101. * Vector2 animation type
  104102. */
  104103. static readonly ANIMATIONTYPE_VECTOR2: number;
  104104. /**
  104105. * Size animation type
  104106. */
  104107. static readonly ANIMATIONTYPE_SIZE: number;
  104108. /**
  104109. * Relative Loop Mode
  104110. */
  104111. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104112. /**
  104113. * Cycle Loop Mode
  104114. */
  104115. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104116. /**
  104117. * Constant Loop Mode
  104118. */
  104119. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104120. /** @hidden */
  104121. static _UniversalLerp(left: any, right: any, amount: number): any;
  104122. /**
  104123. * Parses an animation object and creates an animation
  104124. * @param parsedAnimation Parsed animation object
  104125. * @returns Animation object
  104126. */
  104127. static Parse(parsedAnimation: any): Animation;
  104128. /**
  104129. * Appends the serialized animations from the source animations
  104130. * @param source Source containing the animations
  104131. * @param destination Target to store the animations
  104132. */
  104133. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104134. }
  104135. }
  104136. declare module BABYLON {
  104137. /**
  104138. * Interface containing an array of animations
  104139. */
  104140. export interface IAnimatable {
  104141. /**
  104142. * Array of animations
  104143. */
  104144. animations: Nullable<Array<Animation>>;
  104145. }
  104146. }
  104147. declare module BABYLON {
  104148. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104149. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104150. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104151. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104152. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104153. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104154. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104155. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104156. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104157. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104158. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104159. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104160. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104161. /**
  104162. * Decorator used to define property that can be serialized as reference to a camera
  104163. * @param sourceName defines the name of the property to decorate
  104164. */
  104165. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104166. /**
  104167. * Class used to help serialization objects
  104168. */
  104169. export class SerializationHelper {
  104170. /** @hidden */
  104171. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104172. /** @hidden */
  104173. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104174. /** @hidden */
  104175. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104176. /** @hidden */
  104177. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104178. /**
  104179. * Appends the serialized animations from the source animations
  104180. * @param source Source containing the animations
  104181. * @param destination Target to store the animations
  104182. */
  104183. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104184. /**
  104185. * Static function used to serialized a specific entity
  104186. * @param entity defines the entity to serialize
  104187. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104188. * @returns a JSON compatible object representing the serialization of the entity
  104189. */
  104190. static Serialize<T>(entity: T, serializationObject?: any): any;
  104191. /**
  104192. * Creates a new entity from a serialization data object
  104193. * @param creationFunction defines a function used to instanciated the new entity
  104194. * @param source defines the source serialization data
  104195. * @param scene defines the hosting scene
  104196. * @param rootUrl defines the root url for resources
  104197. * @returns a new entity
  104198. */
  104199. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104200. /**
  104201. * Clones an object
  104202. * @param creationFunction defines the function used to instanciate the new object
  104203. * @param source defines the source object
  104204. * @returns the cloned object
  104205. */
  104206. static Clone<T>(creationFunction: () => T, source: T): T;
  104207. /**
  104208. * Instanciates a new object based on a source one (some data will be shared between both object)
  104209. * @param creationFunction defines the function used to instanciate the new object
  104210. * @param source defines the source object
  104211. * @returns the new object
  104212. */
  104213. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104214. }
  104215. }
  104216. declare module BABYLON {
  104217. /**
  104218. * Class used to manipulate GUIDs
  104219. */
  104220. export class GUID {
  104221. /**
  104222. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104223. * Be aware Math.random() could cause collisions, but:
  104224. * "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"
  104225. * @returns a pseudo random id
  104226. */
  104227. static RandomId(): string;
  104228. }
  104229. }
  104230. declare module BABYLON {
  104231. /**
  104232. * Base class of all the textures in babylon.
  104233. * It groups all the common properties the materials, post process, lights... might need
  104234. * in order to make a correct use of the texture.
  104235. */
  104236. export class BaseTexture implements IAnimatable {
  104237. /**
  104238. * Default anisotropic filtering level for the application.
  104239. * It is set to 4 as a good tradeoff between perf and quality.
  104240. */
  104241. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104242. /**
  104243. * Gets or sets the unique id of the texture
  104244. */
  104245. uniqueId: number;
  104246. /**
  104247. * Define the name of the texture.
  104248. */
  104249. name: string;
  104250. /**
  104251. * Gets or sets an object used to store user defined information.
  104252. */
  104253. metadata: any;
  104254. /**
  104255. * For internal use only. Please do not use.
  104256. */
  104257. reservedDataStore: any;
  104258. private _hasAlpha;
  104259. /**
  104260. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104261. */
  104262. set hasAlpha(value: boolean);
  104263. get hasAlpha(): boolean;
  104264. /**
  104265. * Defines if the alpha value should be determined via the rgb values.
  104266. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104267. */
  104268. getAlphaFromRGB: boolean;
  104269. /**
  104270. * Intensity or strength of the texture.
  104271. * It is commonly used by materials to fine tune the intensity of the texture
  104272. */
  104273. level: number;
  104274. /**
  104275. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104276. * This is part of the texture as textures usually maps to one uv set.
  104277. */
  104278. coordinatesIndex: number;
  104279. private _coordinatesMode;
  104280. /**
  104281. * How a texture is mapped.
  104282. *
  104283. * | Value | Type | Description |
  104284. * | ----- | ----------------------------------- | ----------- |
  104285. * | 0 | EXPLICIT_MODE | |
  104286. * | 1 | SPHERICAL_MODE | |
  104287. * | 2 | PLANAR_MODE | |
  104288. * | 3 | CUBIC_MODE | |
  104289. * | 4 | PROJECTION_MODE | |
  104290. * | 5 | SKYBOX_MODE | |
  104291. * | 6 | INVCUBIC_MODE | |
  104292. * | 7 | EQUIRECTANGULAR_MODE | |
  104293. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104294. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104295. */
  104296. set coordinatesMode(value: number);
  104297. get coordinatesMode(): number;
  104298. /**
  104299. * | Value | Type | Description |
  104300. * | ----- | ------------------ | ----------- |
  104301. * | 0 | CLAMP_ADDRESSMODE | |
  104302. * | 1 | WRAP_ADDRESSMODE | |
  104303. * | 2 | MIRROR_ADDRESSMODE | |
  104304. */
  104305. wrapU: number;
  104306. /**
  104307. * | Value | Type | Description |
  104308. * | ----- | ------------------ | ----------- |
  104309. * | 0 | CLAMP_ADDRESSMODE | |
  104310. * | 1 | WRAP_ADDRESSMODE | |
  104311. * | 2 | MIRROR_ADDRESSMODE | |
  104312. */
  104313. wrapV: number;
  104314. /**
  104315. * | Value | Type | Description |
  104316. * | ----- | ------------------ | ----------- |
  104317. * | 0 | CLAMP_ADDRESSMODE | |
  104318. * | 1 | WRAP_ADDRESSMODE | |
  104319. * | 2 | MIRROR_ADDRESSMODE | |
  104320. */
  104321. wrapR: number;
  104322. /**
  104323. * With compliant hardware and browser (supporting anisotropic filtering)
  104324. * this defines the level of anisotropic filtering in the texture.
  104325. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104326. */
  104327. anisotropicFilteringLevel: number;
  104328. /**
  104329. * Define if the texture is a cube texture or if false a 2d texture.
  104330. */
  104331. get isCube(): boolean;
  104332. set isCube(value: boolean);
  104333. /**
  104334. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104335. */
  104336. get is3D(): boolean;
  104337. set is3D(value: boolean);
  104338. /**
  104339. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104340. */
  104341. get is2DArray(): boolean;
  104342. set is2DArray(value: boolean);
  104343. /**
  104344. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104345. * HDR texture are usually stored in linear space.
  104346. * This only impacts the PBR and Background materials
  104347. */
  104348. gammaSpace: boolean;
  104349. /**
  104350. * Gets or sets whether or not the texture contains RGBD data.
  104351. */
  104352. get isRGBD(): boolean;
  104353. set isRGBD(value: boolean);
  104354. /**
  104355. * Is Z inverted in the texture (useful in a cube texture).
  104356. */
  104357. invertZ: boolean;
  104358. /**
  104359. * Are mip maps generated for this texture or not.
  104360. */
  104361. get noMipmap(): boolean;
  104362. /**
  104363. * @hidden
  104364. */
  104365. lodLevelInAlpha: boolean;
  104366. /**
  104367. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104368. */
  104369. get lodGenerationOffset(): number;
  104370. set lodGenerationOffset(value: number);
  104371. /**
  104372. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104373. */
  104374. get lodGenerationScale(): number;
  104375. set lodGenerationScale(value: number);
  104376. /**
  104377. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104378. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104379. * average roughness values.
  104380. */
  104381. get linearSpecularLOD(): boolean;
  104382. set linearSpecularLOD(value: boolean);
  104383. /**
  104384. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104385. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104386. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104387. */
  104388. get irradianceTexture(): Nullable<BaseTexture>;
  104389. set irradianceTexture(value: Nullable<BaseTexture>);
  104390. /**
  104391. * Define if the texture is a render target.
  104392. */
  104393. isRenderTarget: boolean;
  104394. /**
  104395. * Define the unique id of the texture in the scene.
  104396. */
  104397. get uid(): string;
  104398. /**
  104399. * Return a string representation of the texture.
  104400. * @returns the texture as a string
  104401. */
  104402. toString(): string;
  104403. /**
  104404. * Get the class name of the texture.
  104405. * @returns "BaseTexture"
  104406. */
  104407. getClassName(): string;
  104408. /**
  104409. * Define the list of animation attached to the texture.
  104410. */
  104411. animations: Animation[];
  104412. /**
  104413. * An event triggered when the texture is disposed.
  104414. */
  104415. onDisposeObservable: Observable<BaseTexture>;
  104416. private _onDisposeObserver;
  104417. /**
  104418. * Callback triggered when the texture has been disposed.
  104419. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104420. */
  104421. set onDispose(callback: () => void);
  104422. /**
  104423. * Define the current state of the loading sequence when in delayed load mode.
  104424. */
  104425. delayLoadState: number;
  104426. private _scene;
  104427. /** @hidden */
  104428. _texture: Nullable<InternalTexture>;
  104429. private _uid;
  104430. /**
  104431. * Define if the texture is preventinga material to render or not.
  104432. * If not and the texture is not ready, the engine will use a default black texture instead.
  104433. */
  104434. get isBlocking(): boolean;
  104435. /**
  104436. * Instantiates a new BaseTexture.
  104437. * Base class of all the textures in babylon.
  104438. * It groups all the common properties the materials, post process, lights... might need
  104439. * in order to make a correct use of the texture.
  104440. * @param scene Define the scene the texture blongs to
  104441. */
  104442. constructor(scene: Nullable<Scene>);
  104443. /**
  104444. * Get the scene the texture belongs to.
  104445. * @returns the scene or null if undefined
  104446. */
  104447. getScene(): Nullable<Scene>;
  104448. /**
  104449. * Get the texture transform matrix used to offset tile the texture for istance.
  104450. * @returns the transformation matrix
  104451. */
  104452. getTextureMatrix(): Matrix;
  104453. /**
  104454. * Get the texture reflection matrix used to rotate/transform the reflection.
  104455. * @returns the reflection matrix
  104456. */
  104457. getReflectionTextureMatrix(): Matrix;
  104458. /**
  104459. * Get the underlying lower level texture from Babylon.
  104460. * @returns the insternal texture
  104461. */
  104462. getInternalTexture(): Nullable<InternalTexture>;
  104463. /**
  104464. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104465. * @returns true if ready or not blocking
  104466. */
  104467. isReadyOrNotBlocking(): boolean;
  104468. /**
  104469. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104470. * @returns true if fully ready
  104471. */
  104472. isReady(): boolean;
  104473. private _cachedSize;
  104474. /**
  104475. * Get the size of the texture.
  104476. * @returns the texture size.
  104477. */
  104478. getSize(): ISize;
  104479. /**
  104480. * Get the base size of the texture.
  104481. * It can be different from the size if the texture has been resized for POT for instance
  104482. * @returns the base size
  104483. */
  104484. getBaseSize(): ISize;
  104485. /**
  104486. * Update the sampling mode of the texture.
  104487. * Default is Trilinear mode.
  104488. *
  104489. * | Value | Type | Description |
  104490. * | ----- | ------------------ | ----------- |
  104491. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104492. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104493. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104494. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104495. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104496. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104497. * | 7 | NEAREST_LINEAR | |
  104498. * | 8 | NEAREST_NEAREST | |
  104499. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104500. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104501. * | 11 | LINEAR_LINEAR | |
  104502. * | 12 | LINEAR_NEAREST | |
  104503. *
  104504. * > _mag_: magnification filter (close to the viewer)
  104505. * > _min_: minification filter (far from the viewer)
  104506. * > _mip_: filter used between mip map levels
  104507. *@param samplingMode Define the new sampling mode of the texture
  104508. */
  104509. updateSamplingMode(samplingMode: number): void;
  104510. /**
  104511. * Scales the texture if is `canRescale()`
  104512. * @param ratio the resize factor we want to use to rescale
  104513. */
  104514. scale(ratio: number): void;
  104515. /**
  104516. * Get if the texture can rescale.
  104517. */
  104518. get canRescale(): boolean;
  104519. /** @hidden */
  104520. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104521. /** @hidden */
  104522. _rebuild(): void;
  104523. /**
  104524. * Triggers the load sequence in delayed load mode.
  104525. */
  104526. delayLoad(): void;
  104527. /**
  104528. * Clones the texture.
  104529. * @returns the cloned texture
  104530. */
  104531. clone(): Nullable<BaseTexture>;
  104532. /**
  104533. * Get the texture underlying type (INT, FLOAT...)
  104534. */
  104535. get textureType(): number;
  104536. /**
  104537. * Get the texture underlying format (RGB, RGBA...)
  104538. */
  104539. get textureFormat(): number;
  104540. /**
  104541. * Indicates that textures need to be re-calculated for all materials
  104542. */
  104543. protected _markAllSubMeshesAsTexturesDirty(): void;
  104544. /**
  104545. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104546. * This will returns an RGBA array buffer containing either in values (0-255) or
  104547. * float values (0-1) depending of the underlying buffer type.
  104548. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104549. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104550. * @param buffer defines a user defined buffer to fill with data (can be null)
  104551. * @returns The Array buffer containing the pixels data.
  104552. */
  104553. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104554. /**
  104555. * Release and destroy the underlying lower level texture aka internalTexture.
  104556. */
  104557. releaseInternalTexture(): void;
  104558. /** @hidden */
  104559. get _lodTextureHigh(): Nullable<BaseTexture>;
  104560. /** @hidden */
  104561. get _lodTextureMid(): Nullable<BaseTexture>;
  104562. /** @hidden */
  104563. get _lodTextureLow(): Nullable<BaseTexture>;
  104564. /**
  104565. * Dispose the texture and release its associated resources.
  104566. */
  104567. dispose(): void;
  104568. /**
  104569. * Serialize the texture into a JSON representation that can be parsed later on.
  104570. * @returns the JSON representation of the texture
  104571. */
  104572. serialize(): any;
  104573. /**
  104574. * Helper function to be called back once a list of texture contains only ready textures.
  104575. * @param textures Define the list of textures to wait for
  104576. * @param callback Define the callback triggered once the entire list will be ready
  104577. */
  104578. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104579. }
  104580. }
  104581. declare module BABYLON {
  104582. /**
  104583. * Options to be used when creating an effect.
  104584. */
  104585. export interface IEffectCreationOptions {
  104586. /**
  104587. * Atrributes that will be used in the shader.
  104588. */
  104589. attributes: string[];
  104590. /**
  104591. * Uniform varible names that will be set in the shader.
  104592. */
  104593. uniformsNames: string[];
  104594. /**
  104595. * Uniform buffer variable names that will be set in the shader.
  104596. */
  104597. uniformBuffersNames: string[];
  104598. /**
  104599. * Sampler texture variable names that will be set in the shader.
  104600. */
  104601. samplers: string[];
  104602. /**
  104603. * Define statements that will be set in the shader.
  104604. */
  104605. defines: any;
  104606. /**
  104607. * Possible fallbacks for this effect to improve performance when needed.
  104608. */
  104609. fallbacks: Nullable<IEffectFallbacks>;
  104610. /**
  104611. * Callback that will be called when the shader is compiled.
  104612. */
  104613. onCompiled: Nullable<(effect: Effect) => void>;
  104614. /**
  104615. * Callback that will be called if an error occurs during shader compilation.
  104616. */
  104617. onError: Nullable<(effect: Effect, errors: string) => void>;
  104618. /**
  104619. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104620. */
  104621. indexParameters?: any;
  104622. /**
  104623. * Max number of lights that can be used in the shader.
  104624. */
  104625. maxSimultaneousLights?: number;
  104626. /**
  104627. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104628. */
  104629. transformFeedbackVaryings?: Nullable<string[]>;
  104630. }
  104631. /**
  104632. * Effect containing vertex and fragment shader that can be executed on an object.
  104633. */
  104634. export class Effect implements IDisposable {
  104635. /**
  104636. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104637. */
  104638. static ShadersRepository: string;
  104639. /**
  104640. * Enable logging of the shader code when a compilation error occurs
  104641. */
  104642. static LogShaderCodeOnCompilationError: boolean;
  104643. /**
  104644. * Name of the effect.
  104645. */
  104646. name: any;
  104647. /**
  104648. * String container all the define statements that should be set on the shader.
  104649. */
  104650. defines: string;
  104651. /**
  104652. * Callback that will be called when the shader is compiled.
  104653. */
  104654. onCompiled: Nullable<(effect: Effect) => void>;
  104655. /**
  104656. * Callback that will be called if an error occurs during shader compilation.
  104657. */
  104658. onError: Nullable<(effect: Effect, errors: string) => void>;
  104659. /**
  104660. * Callback that will be called when effect is bound.
  104661. */
  104662. onBind: Nullable<(effect: Effect) => void>;
  104663. /**
  104664. * Unique ID of the effect.
  104665. */
  104666. uniqueId: number;
  104667. /**
  104668. * Observable that will be called when the shader is compiled.
  104669. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104670. */
  104671. onCompileObservable: Observable<Effect>;
  104672. /**
  104673. * Observable that will be called if an error occurs during shader compilation.
  104674. */
  104675. onErrorObservable: Observable<Effect>;
  104676. /** @hidden */
  104677. _onBindObservable: Nullable<Observable<Effect>>;
  104678. /**
  104679. * @hidden
  104680. * Specifies if the effect was previously ready
  104681. */
  104682. _wasPreviouslyReady: boolean;
  104683. /**
  104684. * Observable that will be called when effect is bound.
  104685. */
  104686. get onBindObservable(): Observable<Effect>;
  104687. /** @hidden */
  104688. _bonesComputationForcedToCPU: boolean;
  104689. private static _uniqueIdSeed;
  104690. private _engine;
  104691. private _uniformBuffersNames;
  104692. private _uniformsNames;
  104693. private _samplerList;
  104694. private _samplers;
  104695. private _isReady;
  104696. private _compilationError;
  104697. private _allFallbacksProcessed;
  104698. private _attributesNames;
  104699. private _attributes;
  104700. private _attributeLocationByName;
  104701. private _uniforms;
  104702. /**
  104703. * Key for the effect.
  104704. * @hidden
  104705. */
  104706. _key: string;
  104707. private _indexParameters;
  104708. private _fallbacks;
  104709. private _vertexSourceCode;
  104710. private _fragmentSourceCode;
  104711. private _vertexSourceCodeOverride;
  104712. private _fragmentSourceCodeOverride;
  104713. private _transformFeedbackVaryings;
  104714. /**
  104715. * Compiled shader to webGL program.
  104716. * @hidden
  104717. */
  104718. _pipelineContext: Nullable<IPipelineContext>;
  104719. private _valueCache;
  104720. private static _baseCache;
  104721. /**
  104722. * Instantiates an effect.
  104723. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104724. * @param baseName Name of the effect.
  104725. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104726. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104727. * @param samplers List of sampler variables that will be passed to the shader.
  104728. * @param engine Engine to be used to render the effect
  104729. * @param defines Define statements to be added to the shader.
  104730. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104731. * @param onCompiled Callback that will be called when the shader is compiled.
  104732. * @param onError Callback that will be called if an error occurs during shader compilation.
  104733. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104734. */
  104735. 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);
  104736. private _useFinalCode;
  104737. /**
  104738. * Unique key for this effect
  104739. */
  104740. get key(): string;
  104741. /**
  104742. * If the effect has been compiled and prepared.
  104743. * @returns if the effect is compiled and prepared.
  104744. */
  104745. isReady(): boolean;
  104746. private _isReadyInternal;
  104747. /**
  104748. * The engine the effect was initialized with.
  104749. * @returns the engine.
  104750. */
  104751. getEngine(): Engine;
  104752. /**
  104753. * The pipeline context for this effect
  104754. * @returns the associated pipeline context
  104755. */
  104756. getPipelineContext(): Nullable<IPipelineContext>;
  104757. /**
  104758. * The set of names of attribute variables for the shader.
  104759. * @returns An array of attribute names.
  104760. */
  104761. getAttributesNames(): string[];
  104762. /**
  104763. * Returns the attribute at the given index.
  104764. * @param index The index of the attribute.
  104765. * @returns The location of the attribute.
  104766. */
  104767. getAttributeLocation(index: number): number;
  104768. /**
  104769. * Returns the attribute based on the name of the variable.
  104770. * @param name of the attribute to look up.
  104771. * @returns the attribute location.
  104772. */
  104773. getAttributeLocationByName(name: string): number;
  104774. /**
  104775. * The number of attributes.
  104776. * @returns the numnber of attributes.
  104777. */
  104778. getAttributesCount(): number;
  104779. /**
  104780. * Gets the index of a uniform variable.
  104781. * @param uniformName of the uniform to look up.
  104782. * @returns the index.
  104783. */
  104784. getUniformIndex(uniformName: string): number;
  104785. /**
  104786. * Returns the attribute based on the name of the variable.
  104787. * @param uniformName of the uniform to look up.
  104788. * @returns the location of the uniform.
  104789. */
  104790. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104791. /**
  104792. * Returns an array of sampler variable names
  104793. * @returns The array of sampler variable neames.
  104794. */
  104795. getSamplers(): string[];
  104796. /**
  104797. * The error from the last compilation.
  104798. * @returns the error string.
  104799. */
  104800. getCompilationError(): string;
  104801. /**
  104802. * Gets a boolean indicating that all fallbacks were used during compilation
  104803. * @returns true if all fallbacks were used
  104804. */
  104805. allFallbacksProcessed(): boolean;
  104806. /**
  104807. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104808. * @param func The callback to be used.
  104809. */
  104810. executeWhenCompiled(func: (effect: Effect) => void): void;
  104811. private _checkIsReady;
  104812. private _loadShader;
  104813. /**
  104814. * Recompiles the webGL program
  104815. * @param vertexSourceCode The source code for the vertex shader.
  104816. * @param fragmentSourceCode The source code for the fragment shader.
  104817. * @param onCompiled Callback called when completed.
  104818. * @param onError Callback called on error.
  104819. * @hidden
  104820. */
  104821. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104822. /**
  104823. * Prepares the effect
  104824. * @hidden
  104825. */
  104826. _prepareEffect(): void;
  104827. private _getShaderCodeAndErrorLine;
  104828. private _processCompilationErrors;
  104829. /**
  104830. * Checks if the effect is supported. (Must be called after compilation)
  104831. */
  104832. get isSupported(): boolean;
  104833. /**
  104834. * Binds a texture to the engine to be used as output of the shader.
  104835. * @param channel Name of the output variable.
  104836. * @param texture Texture to bind.
  104837. * @hidden
  104838. */
  104839. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104840. /**
  104841. * Sets a texture on the engine to be used in the shader.
  104842. * @param channel Name of the sampler variable.
  104843. * @param texture Texture to set.
  104844. */
  104845. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104846. /**
  104847. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104848. * @param channel Name of the sampler variable.
  104849. * @param texture Texture to set.
  104850. */
  104851. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104852. /**
  104853. * Sets an array of textures on the engine to be used in the shader.
  104854. * @param channel Name of the variable.
  104855. * @param textures Textures to set.
  104856. */
  104857. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104858. /**
  104859. * 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)
  104860. * @param channel Name of the sampler variable.
  104861. * @param postProcess Post process to get the input texture from.
  104862. */
  104863. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104864. /**
  104865. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104866. * 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)
  104867. * @param channel Name of the sampler variable.
  104868. * @param postProcess Post process to get the output texture from.
  104869. */
  104870. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104871. /** @hidden */
  104872. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104873. /** @hidden */
  104874. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104875. /** @hidden */
  104876. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104877. /** @hidden */
  104878. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104879. /**
  104880. * Binds a buffer to a uniform.
  104881. * @param buffer Buffer to bind.
  104882. * @param name Name of the uniform variable to bind to.
  104883. */
  104884. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104885. /**
  104886. * Binds block to a uniform.
  104887. * @param blockName Name of the block to bind.
  104888. * @param index Index to bind.
  104889. */
  104890. bindUniformBlock(blockName: string, index: number): void;
  104891. /**
  104892. * Sets an interger value on a uniform variable.
  104893. * @param uniformName Name of the variable.
  104894. * @param value Value to be set.
  104895. * @returns this effect.
  104896. */
  104897. setInt(uniformName: string, value: number): Effect;
  104898. /**
  104899. * Sets an int array on a uniform variable.
  104900. * @param uniformName Name of the variable.
  104901. * @param array array to be set.
  104902. * @returns this effect.
  104903. */
  104904. setIntArray(uniformName: string, array: Int32Array): Effect;
  104905. /**
  104906. * 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)
  104907. * @param uniformName Name of the variable.
  104908. * @param array array to be set.
  104909. * @returns this effect.
  104910. */
  104911. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104912. /**
  104913. * 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)
  104914. * @param uniformName Name of the variable.
  104915. * @param array array to be set.
  104916. * @returns this effect.
  104917. */
  104918. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104919. /**
  104920. * 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)
  104921. * @param uniformName Name of the variable.
  104922. * @param array array to be set.
  104923. * @returns this effect.
  104924. */
  104925. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104926. /**
  104927. * Sets an float array on a uniform variable.
  104928. * @param uniformName Name of the variable.
  104929. * @param array array to be set.
  104930. * @returns this effect.
  104931. */
  104932. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104933. /**
  104934. * 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)
  104935. * @param uniformName Name of the variable.
  104936. * @param array array to be set.
  104937. * @returns this effect.
  104938. */
  104939. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104940. /**
  104941. * 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)
  104942. * @param uniformName Name of the variable.
  104943. * @param array array to be set.
  104944. * @returns this effect.
  104945. */
  104946. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104947. /**
  104948. * 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)
  104949. * @param uniformName Name of the variable.
  104950. * @param array array to be set.
  104951. * @returns this effect.
  104952. */
  104953. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104954. /**
  104955. * Sets an array on a uniform variable.
  104956. * @param uniformName Name of the variable.
  104957. * @param array array to be set.
  104958. * @returns this effect.
  104959. */
  104960. setArray(uniformName: string, array: number[]): Effect;
  104961. /**
  104962. * 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)
  104963. * @param uniformName Name of the variable.
  104964. * @param array array to be set.
  104965. * @returns this effect.
  104966. */
  104967. setArray2(uniformName: string, array: number[]): Effect;
  104968. /**
  104969. * 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)
  104970. * @param uniformName Name of the variable.
  104971. * @param array array to be set.
  104972. * @returns this effect.
  104973. */
  104974. setArray3(uniformName: string, array: number[]): Effect;
  104975. /**
  104976. * 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)
  104977. * @param uniformName Name of the variable.
  104978. * @param array array to be set.
  104979. * @returns this effect.
  104980. */
  104981. setArray4(uniformName: string, array: number[]): Effect;
  104982. /**
  104983. * Sets matrices on a uniform variable.
  104984. * @param uniformName Name of the variable.
  104985. * @param matrices matrices to be set.
  104986. * @returns this effect.
  104987. */
  104988. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104989. /**
  104990. * Sets matrix on a uniform variable.
  104991. * @param uniformName Name of the variable.
  104992. * @param matrix matrix to be set.
  104993. * @returns this effect.
  104994. */
  104995. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104996. /**
  104997. * 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)
  104998. * @param uniformName Name of the variable.
  104999. * @param matrix matrix to be set.
  105000. * @returns this effect.
  105001. */
  105002. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  105003. /**
  105004. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  105005. * @param uniformName Name of the variable.
  105006. * @param matrix matrix to be set.
  105007. * @returns this effect.
  105008. */
  105009. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  105010. /**
  105011. * Sets a float on a uniform variable.
  105012. * @param uniformName Name of the variable.
  105013. * @param value value to be set.
  105014. * @returns this effect.
  105015. */
  105016. setFloat(uniformName: string, value: number): Effect;
  105017. /**
  105018. * Sets a boolean on a uniform variable.
  105019. * @param uniformName Name of the variable.
  105020. * @param bool value to be set.
  105021. * @returns this effect.
  105022. */
  105023. setBool(uniformName: string, bool: boolean): Effect;
  105024. /**
  105025. * Sets a Vector2 on a uniform variable.
  105026. * @param uniformName Name of the variable.
  105027. * @param vector2 vector2 to be set.
  105028. * @returns this effect.
  105029. */
  105030. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105031. /**
  105032. * Sets a float2 on a uniform variable.
  105033. * @param uniformName Name of the variable.
  105034. * @param x First float in float2.
  105035. * @param y Second float in float2.
  105036. * @returns this effect.
  105037. */
  105038. setFloat2(uniformName: string, x: number, y: number): Effect;
  105039. /**
  105040. * Sets a Vector3 on a uniform variable.
  105041. * @param uniformName Name of the variable.
  105042. * @param vector3 Value to be set.
  105043. * @returns this effect.
  105044. */
  105045. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105046. /**
  105047. * Sets a float3 on a uniform variable.
  105048. * @param uniformName Name of the variable.
  105049. * @param x First float in float3.
  105050. * @param y Second float in float3.
  105051. * @param z Third float in float3.
  105052. * @returns this effect.
  105053. */
  105054. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105055. /**
  105056. * Sets a Vector4 on a uniform variable.
  105057. * @param uniformName Name of the variable.
  105058. * @param vector4 Value to be set.
  105059. * @returns this effect.
  105060. */
  105061. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105062. /**
  105063. * Sets a float4 on a uniform variable.
  105064. * @param uniformName Name of the variable.
  105065. * @param x First float in float4.
  105066. * @param y Second float in float4.
  105067. * @param z Third float in float4.
  105068. * @param w Fourth float in float4.
  105069. * @returns this effect.
  105070. */
  105071. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105072. /**
  105073. * Sets a Color3 on a uniform variable.
  105074. * @param uniformName Name of the variable.
  105075. * @param color3 Value to be set.
  105076. * @returns this effect.
  105077. */
  105078. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105079. /**
  105080. * Sets a Color4 on a uniform variable.
  105081. * @param uniformName Name of the variable.
  105082. * @param color3 Value to be set.
  105083. * @param alpha Alpha value to be set.
  105084. * @returns this effect.
  105085. */
  105086. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105087. /**
  105088. * Sets a Color4 on a uniform variable
  105089. * @param uniformName defines the name of the variable
  105090. * @param color4 defines the value to be set
  105091. * @returns this effect.
  105092. */
  105093. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105094. /** Release all associated resources */
  105095. dispose(): void;
  105096. /**
  105097. * This function will add a new shader to the shader store
  105098. * @param name the name of the shader
  105099. * @param pixelShader optional pixel shader content
  105100. * @param vertexShader optional vertex shader content
  105101. */
  105102. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105103. /**
  105104. * Store of each shader (The can be looked up using effect.key)
  105105. */
  105106. static ShadersStore: {
  105107. [key: string]: string;
  105108. };
  105109. /**
  105110. * Store of each included file for a shader (The can be looked up using effect.key)
  105111. */
  105112. static IncludesShadersStore: {
  105113. [key: string]: string;
  105114. };
  105115. /**
  105116. * Resets the cache of effects.
  105117. */
  105118. static ResetCache(): void;
  105119. }
  105120. }
  105121. declare module BABYLON {
  105122. /**
  105123. * Interface used to describe the capabilities of the engine relatively to the current browser
  105124. */
  105125. export interface EngineCapabilities {
  105126. /** Maximum textures units per fragment shader */
  105127. maxTexturesImageUnits: number;
  105128. /** Maximum texture units per vertex shader */
  105129. maxVertexTextureImageUnits: number;
  105130. /** Maximum textures units in the entire pipeline */
  105131. maxCombinedTexturesImageUnits: number;
  105132. /** Maximum texture size */
  105133. maxTextureSize: number;
  105134. /** Maximum texture samples */
  105135. maxSamples?: number;
  105136. /** Maximum cube texture size */
  105137. maxCubemapTextureSize: number;
  105138. /** Maximum render texture size */
  105139. maxRenderTextureSize: number;
  105140. /** Maximum number of vertex attributes */
  105141. maxVertexAttribs: number;
  105142. /** Maximum number of varyings */
  105143. maxVaryingVectors: number;
  105144. /** Maximum number of uniforms per vertex shader */
  105145. maxVertexUniformVectors: number;
  105146. /** Maximum number of uniforms per fragment shader */
  105147. maxFragmentUniformVectors: number;
  105148. /** Defines if standard derivates (dx/dy) are supported */
  105149. standardDerivatives: boolean;
  105150. /** Defines if s3tc texture compression is supported */
  105151. s3tc?: WEBGL_compressed_texture_s3tc;
  105152. /** Defines if pvrtc texture compression is supported */
  105153. pvrtc: any;
  105154. /** Defines if etc1 texture compression is supported */
  105155. etc1: any;
  105156. /** Defines if etc2 texture compression is supported */
  105157. etc2: any;
  105158. /** Defines if astc texture compression is supported */
  105159. astc: any;
  105160. /** Defines if float textures are supported */
  105161. textureFloat: boolean;
  105162. /** Defines if vertex array objects are supported */
  105163. vertexArrayObject: boolean;
  105164. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105165. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105166. /** Gets the maximum level of anisotropy supported */
  105167. maxAnisotropy: number;
  105168. /** Defines if instancing is supported */
  105169. instancedArrays: boolean;
  105170. /** Defines if 32 bits indices are supported */
  105171. uintIndices: boolean;
  105172. /** Defines if high precision shaders are supported */
  105173. highPrecisionShaderSupported: boolean;
  105174. /** Defines if depth reading in the fragment shader is supported */
  105175. fragmentDepthSupported: boolean;
  105176. /** Defines if float texture linear filtering is supported*/
  105177. textureFloatLinearFiltering: boolean;
  105178. /** Defines if rendering to float textures is supported */
  105179. textureFloatRender: boolean;
  105180. /** Defines if half float textures are supported*/
  105181. textureHalfFloat: boolean;
  105182. /** Defines if half float texture linear filtering is supported*/
  105183. textureHalfFloatLinearFiltering: boolean;
  105184. /** Defines if rendering to half float textures is supported */
  105185. textureHalfFloatRender: boolean;
  105186. /** Defines if textureLOD shader command is supported */
  105187. textureLOD: boolean;
  105188. /** Defines if draw buffers extension is supported */
  105189. drawBuffersExtension: boolean;
  105190. /** Defines if depth textures are supported */
  105191. depthTextureExtension: boolean;
  105192. /** Defines if float color buffer are supported */
  105193. colorBufferFloat: boolean;
  105194. /** Gets disjoint timer query extension (null if not supported) */
  105195. timerQuery?: EXT_disjoint_timer_query;
  105196. /** Defines if timestamp can be used with timer query */
  105197. canUseTimestampForTimerQuery: boolean;
  105198. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105199. multiview?: any;
  105200. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105201. oculusMultiview?: any;
  105202. /** Function used to let the system compiles shaders in background */
  105203. parallelShaderCompile?: {
  105204. COMPLETION_STATUS_KHR: number;
  105205. };
  105206. /** Max number of texture samples for MSAA */
  105207. maxMSAASamples: number;
  105208. /** Defines if the blend min max extension is supported */
  105209. blendMinMax: boolean;
  105210. }
  105211. }
  105212. declare module BABYLON {
  105213. /**
  105214. * @hidden
  105215. **/
  105216. export class DepthCullingState {
  105217. private _isDepthTestDirty;
  105218. private _isDepthMaskDirty;
  105219. private _isDepthFuncDirty;
  105220. private _isCullFaceDirty;
  105221. private _isCullDirty;
  105222. private _isZOffsetDirty;
  105223. private _isFrontFaceDirty;
  105224. private _depthTest;
  105225. private _depthMask;
  105226. private _depthFunc;
  105227. private _cull;
  105228. private _cullFace;
  105229. private _zOffset;
  105230. private _frontFace;
  105231. /**
  105232. * Initializes the state.
  105233. */
  105234. constructor();
  105235. get isDirty(): boolean;
  105236. get zOffset(): number;
  105237. set zOffset(value: number);
  105238. get cullFace(): Nullable<number>;
  105239. set cullFace(value: Nullable<number>);
  105240. get cull(): Nullable<boolean>;
  105241. set cull(value: Nullable<boolean>);
  105242. get depthFunc(): Nullable<number>;
  105243. set depthFunc(value: Nullable<number>);
  105244. get depthMask(): boolean;
  105245. set depthMask(value: boolean);
  105246. get depthTest(): boolean;
  105247. set depthTest(value: boolean);
  105248. get frontFace(): Nullable<number>;
  105249. set frontFace(value: Nullable<number>);
  105250. reset(): void;
  105251. apply(gl: WebGLRenderingContext): void;
  105252. }
  105253. }
  105254. declare module BABYLON {
  105255. /**
  105256. * @hidden
  105257. **/
  105258. export class StencilState {
  105259. /** 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 */
  105260. static readonly ALWAYS: number;
  105261. /** Passed to stencilOperation to specify that stencil value must be kept */
  105262. static readonly KEEP: number;
  105263. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105264. static readonly REPLACE: number;
  105265. private _isStencilTestDirty;
  105266. private _isStencilMaskDirty;
  105267. private _isStencilFuncDirty;
  105268. private _isStencilOpDirty;
  105269. private _stencilTest;
  105270. private _stencilMask;
  105271. private _stencilFunc;
  105272. private _stencilFuncRef;
  105273. private _stencilFuncMask;
  105274. private _stencilOpStencilFail;
  105275. private _stencilOpDepthFail;
  105276. private _stencilOpStencilDepthPass;
  105277. get isDirty(): boolean;
  105278. get stencilFunc(): number;
  105279. set stencilFunc(value: number);
  105280. get stencilFuncRef(): number;
  105281. set stencilFuncRef(value: number);
  105282. get stencilFuncMask(): number;
  105283. set stencilFuncMask(value: number);
  105284. get stencilOpStencilFail(): number;
  105285. set stencilOpStencilFail(value: number);
  105286. get stencilOpDepthFail(): number;
  105287. set stencilOpDepthFail(value: number);
  105288. get stencilOpStencilDepthPass(): number;
  105289. set stencilOpStencilDepthPass(value: number);
  105290. get stencilMask(): number;
  105291. set stencilMask(value: number);
  105292. get stencilTest(): boolean;
  105293. set stencilTest(value: boolean);
  105294. constructor();
  105295. reset(): void;
  105296. apply(gl: WebGLRenderingContext): void;
  105297. }
  105298. }
  105299. declare module BABYLON {
  105300. /**
  105301. * @hidden
  105302. **/
  105303. export class AlphaState {
  105304. private _isAlphaBlendDirty;
  105305. private _isBlendFunctionParametersDirty;
  105306. private _isBlendEquationParametersDirty;
  105307. private _isBlendConstantsDirty;
  105308. private _alphaBlend;
  105309. private _blendFunctionParameters;
  105310. private _blendEquationParameters;
  105311. private _blendConstants;
  105312. /**
  105313. * Initializes the state.
  105314. */
  105315. constructor();
  105316. get isDirty(): boolean;
  105317. get alphaBlend(): boolean;
  105318. set alphaBlend(value: boolean);
  105319. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105320. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105321. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105322. reset(): void;
  105323. apply(gl: WebGLRenderingContext): void;
  105324. }
  105325. }
  105326. declare module BABYLON {
  105327. /** @hidden */
  105328. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105329. attributeProcessor(attribute: string): string;
  105330. varyingProcessor(varying: string, isFragment: boolean): string;
  105331. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105332. }
  105333. }
  105334. declare module BABYLON {
  105335. /**
  105336. * Interface for attribute information associated with buffer instanciation
  105337. */
  105338. export interface InstancingAttributeInfo {
  105339. /**
  105340. * Name of the GLSL attribute
  105341. * if attribute index is not specified, this is used to retrieve the index from the effect
  105342. */
  105343. attributeName: string;
  105344. /**
  105345. * Index/offset of the attribute in the vertex shader
  105346. * if not specified, this will be computes from the name.
  105347. */
  105348. index?: number;
  105349. /**
  105350. * size of the attribute, 1, 2, 3 or 4
  105351. */
  105352. attributeSize: number;
  105353. /**
  105354. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105355. */
  105356. offset: number;
  105357. /**
  105358. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105359. * default to 1
  105360. */
  105361. divisor?: number;
  105362. /**
  105363. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105364. * default is FLOAT
  105365. */
  105366. attributeType?: number;
  105367. /**
  105368. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105369. */
  105370. normalized?: boolean;
  105371. }
  105372. }
  105373. declare module BABYLON {
  105374. interface ThinEngine {
  105375. /**
  105376. * Update a video texture
  105377. * @param texture defines the texture to update
  105378. * @param video defines the video element to use
  105379. * @param invertY defines if data must be stored with Y axis inverted
  105380. */
  105381. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105382. }
  105383. }
  105384. declare module BABYLON {
  105385. /**
  105386. * Settings for finer control over video usage
  105387. */
  105388. export interface VideoTextureSettings {
  105389. /**
  105390. * Applies `autoplay` to video, if specified
  105391. */
  105392. autoPlay?: boolean;
  105393. /**
  105394. * Applies `loop` to video, if specified
  105395. */
  105396. loop?: boolean;
  105397. /**
  105398. * Automatically updates internal texture from video at every frame in the render loop
  105399. */
  105400. autoUpdateTexture: boolean;
  105401. /**
  105402. * Image src displayed during the video loading or until the user interacts with the video.
  105403. */
  105404. poster?: string;
  105405. }
  105406. /**
  105407. * If you want to display a video in your scene, this is the special texture for that.
  105408. * This special texture works similar to other textures, with the exception of a few parameters.
  105409. * @see https://doc.babylonjs.com/how_to/video_texture
  105410. */
  105411. export class VideoTexture extends Texture {
  105412. /**
  105413. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105414. */
  105415. readonly autoUpdateTexture: boolean;
  105416. /**
  105417. * The video instance used by the texture internally
  105418. */
  105419. readonly video: HTMLVideoElement;
  105420. private _onUserActionRequestedObservable;
  105421. /**
  105422. * Event triggerd when a dom action is required by the user to play the video.
  105423. * This happens due to recent changes in browser policies preventing video to auto start.
  105424. */
  105425. get onUserActionRequestedObservable(): Observable<Texture>;
  105426. private _generateMipMaps;
  105427. private _engine;
  105428. private _stillImageCaptured;
  105429. private _displayingPosterTexture;
  105430. private _settings;
  105431. private _createInternalTextureOnEvent;
  105432. private _frameId;
  105433. private _currentSrc;
  105434. /**
  105435. * Creates a video texture.
  105436. * If you want to display a video in your scene, this is the special texture for that.
  105437. * This special texture works similar to other textures, with the exception of a few parameters.
  105438. * @see https://doc.babylonjs.com/how_to/video_texture
  105439. * @param name optional name, will detect from video source, if not defined
  105440. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105441. * @param scene is obviously the current scene.
  105442. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105443. * @param invertY is false by default but can be used to invert video on Y axis
  105444. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105445. * @param settings allows finer control over video usage
  105446. */
  105447. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105448. private _getName;
  105449. private _getVideo;
  105450. private _createInternalTexture;
  105451. private reset;
  105452. /**
  105453. * @hidden Internal method to initiate `update`.
  105454. */
  105455. _rebuild(): void;
  105456. /**
  105457. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105458. */
  105459. update(): void;
  105460. /**
  105461. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105462. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105463. */
  105464. updateTexture(isVisible: boolean): void;
  105465. protected _updateInternalTexture: () => void;
  105466. /**
  105467. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105468. * @param url New url.
  105469. */
  105470. updateURL(url: string): void;
  105471. /**
  105472. * Clones the texture.
  105473. * @returns the cloned texture
  105474. */
  105475. clone(): VideoTexture;
  105476. /**
  105477. * Dispose the texture and release its associated resources.
  105478. */
  105479. dispose(): void;
  105480. /**
  105481. * Creates a video texture straight from a stream.
  105482. * @param scene Define the scene the texture should be created in
  105483. * @param stream Define the stream the texture should be created from
  105484. * @returns The created video texture as a promise
  105485. */
  105486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105487. /**
  105488. * Creates a video texture straight from your WebCam video feed.
  105489. * @param scene Define the scene the texture should be created in
  105490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105492. * @returns The created video texture as a promise
  105493. */
  105494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105495. minWidth: number;
  105496. maxWidth: number;
  105497. minHeight: number;
  105498. maxHeight: number;
  105499. deviceId: string;
  105500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105501. /**
  105502. * Creates a video texture straight from your WebCam video feed.
  105503. * @param scene Define the scene the texture should be created in
  105504. * @param onReady Define a callback to triggered once the texture will be ready
  105505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105507. */
  105508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105509. minWidth: number;
  105510. maxWidth: number;
  105511. minHeight: number;
  105512. maxHeight: number;
  105513. deviceId: string;
  105514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105515. }
  105516. }
  105517. declare module BABYLON {
  105518. /**
  105519. * Defines the interface used by objects working like Scene
  105520. * @hidden
  105521. */
  105522. export interface ISceneLike {
  105523. _addPendingData(data: any): void;
  105524. _removePendingData(data: any): void;
  105525. offlineProvider: IOfflineProvider;
  105526. }
  105527. /** Interface defining initialization parameters for Engine class */
  105528. export interface EngineOptions extends WebGLContextAttributes {
  105529. /**
  105530. * Defines if the engine should no exceed a specified device ratio
  105531. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105532. */
  105533. limitDeviceRatio?: number;
  105534. /**
  105535. * Defines if webvr should be enabled automatically
  105536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105537. */
  105538. autoEnableWebVR?: boolean;
  105539. /**
  105540. * Defines if webgl2 should be turned off even if supported
  105541. * @see http://doc.babylonjs.com/features/webgl2
  105542. */
  105543. disableWebGL2Support?: boolean;
  105544. /**
  105545. * Defines if webaudio should be initialized as well
  105546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105547. */
  105548. audioEngine?: boolean;
  105549. /**
  105550. * Defines if animations should run using a deterministic lock step
  105551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105552. */
  105553. deterministicLockstep?: boolean;
  105554. /** Defines the maximum steps to use with deterministic lock step mode */
  105555. lockstepMaxSteps?: number;
  105556. /** Defines the seconds between each deterministic lock step */
  105557. timeStep?: number;
  105558. /**
  105559. * Defines that engine should ignore context lost events
  105560. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105561. */
  105562. doNotHandleContextLost?: boolean;
  105563. /**
  105564. * Defines that engine should ignore modifying touch action attribute and style
  105565. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105566. */
  105567. doNotHandleTouchAction?: boolean;
  105568. /**
  105569. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105570. */
  105571. useHighPrecisionFloats?: boolean;
  105572. }
  105573. /**
  105574. * The base engine class (root of all engines)
  105575. */
  105576. export class ThinEngine {
  105577. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105578. static ExceptionList: ({
  105579. key: string;
  105580. capture: string;
  105581. captureConstraint: number;
  105582. targets: string[];
  105583. } | {
  105584. key: string;
  105585. capture: null;
  105586. captureConstraint: null;
  105587. targets: string[];
  105588. })[];
  105589. /** @hidden */
  105590. static _TextureLoaders: IInternalTextureLoader[];
  105591. /**
  105592. * Returns the current npm package of the sdk
  105593. */
  105594. static get NpmPackage(): string;
  105595. /**
  105596. * Returns the current version of the framework
  105597. */
  105598. static get Version(): string;
  105599. /**
  105600. * Returns a string describing the current engine
  105601. */
  105602. get description(): string;
  105603. /**
  105604. * Gets or sets the epsilon value used by collision engine
  105605. */
  105606. static CollisionsEpsilon: number;
  105607. /**
  105608. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105609. */
  105610. static get ShadersRepository(): string;
  105611. static set ShadersRepository(value: string);
  105612. /** @hidden */
  105613. _shaderProcessor: IShaderProcessor;
  105614. /**
  105615. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105616. */
  105617. forcePOTTextures: boolean;
  105618. /**
  105619. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105620. */
  105621. isFullscreen: boolean;
  105622. /**
  105623. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105624. */
  105625. cullBackFaces: boolean;
  105626. /**
  105627. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105628. */
  105629. renderEvenInBackground: boolean;
  105630. /**
  105631. * Gets or sets a boolean indicating that cache can be kept between frames
  105632. */
  105633. preventCacheWipeBetweenFrames: boolean;
  105634. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105635. validateShaderPrograms: boolean;
  105636. /**
  105637. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105638. * This can provide greater z depth for distant objects.
  105639. */
  105640. useReverseDepthBuffer: boolean;
  105641. /**
  105642. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105643. */
  105644. disableUniformBuffers: boolean;
  105645. /** @hidden */
  105646. _uniformBuffers: UniformBuffer[];
  105647. /**
  105648. * Gets a boolean indicating that the engine supports uniform buffers
  105649. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105650. */
  105651. get supportsUniformBuffers(): boolean;
  105652. /** @hidden */
  105653. _gl: WebGLRenderingContext;
  105654. /** @hidden */
  105655. _webGLVersion: number;
  105656. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105657. protected _windowIsBackground: boolean;
  105658. protected _creationOptions: EngineOptions;
  105659. protected _highPrecisionShadersAllowed: boolean;
  105660. /** @hidden */
  105661. get _shouldUseHighPrecisionShader(): boolean;
  105662. /**
  105663. * Gets a boolean indicating that only power of 2 textures are supported
  105664. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105665. */
  105666. get needPOTTextures(): boolean;
  105667. /** @hidden */
  105668. _badOS: boolean;
  105669. /** @hidden */
  105670. _badDesktopOS: boolean;
  105671. private _hardwareScalingLevel;
  105672. /** @hidden */
  105673. _caps: EngineCapabilities;
  105674. private _isStencilEnable;
  105675. private _glVersion;
  105676. private _glRenderer;
  105677. private _glVendor;
  105678. /** @hidden */
  105679. _videoTextureSupported: boolean;
  105680. protected _renderingQueueLaunched: boolean;
  105681. protected _activeRenderLoops: (() => void)[];
  105682. /**
  105683. * Observable signaled when a context lost event is raised
  105684. */
  105685. onContextLostObservable: Observable<ThinEngine>;
  105686. /**
  105687. * Observable signaled when a context restored event is raised
  105688. */
  105689. onContextRestoredObservable: Observable<ThinEngine>;
  105690. private _onContextLost;
  105691. private _onContextRestored;
  105692. protected _contextWasLost: boolean;
  105693. /** @hidden */
  105694. _doNotHandleContextLost: boolean;
  105695. /**
  105696. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105698. */
  105699. get doNotHandleContextLost(): boolean;
  105700. set doNotHandleContextLost(value: boolean);
  105701. /**
  105702. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105703. */
  105704. disableVertexArrayObjects: boolean;
  105705. /** @hidden */
  105706. protected _colorWrite: boolean;
  105707. /** @hidden */
  105708. protected _colorWriteChanged: boolean;
  105709. /** @hidden */
  105710. protected _depthCullingState: DepthCullingState;
  105711. /** @hidden */
  105712. protected _stencilState: StencilState;
  105713. /** @hidden */
  105714. _alphaState: AlphaState;
  105715. /** @hidden */
  105716. _alphaMode: number;
  105717. /** @hidden */
  105718. _alphaEquation: number;
  105719. /** @hidden */
  105720. _internalTexturesCache: InternalTexture[];
  105721. /** @hidden */
  105722. protected _activeChannel: number;
  105723. private _currentTextureChannel;
  105724. /** @hidden */
  105725. protected _boundTexturesCache: {
  105726. [key: string]: Nullable<InternalTexture>;
  105727. };
  105728. /** @hidden */
  105729. protected _currentEffect: Nullable<Effect>;
  105730. /** @hidden */
  105731. protected _currentProgram: Nullable<WebGLProgram>;
  105732. private _compiledEffects;
  105733. private _vertexAttribArraysEnabled;
  105734. /** @hidden */
  105735. protected _cachedViewport: Nullable<IViewportLike>;
  105736. private _cachedVertexArrayObject;
  105737. /** @hidden */
  105738. protected _cachedVertexBuffers: any;
  105739. /** @hidden */
  105740. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105741. /** @hidden */
  105742. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105743. /** @hidden */
  105744. _currentRenderTarget: Nullable<InternalTexture>;
  105745. private _uintIndicesCurrentlySet;
  105746. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105747. /** @hidden */
  105748. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105749. private _currentBufferPointers;
  105750. private _currentInstanceLocations;
  105751. private _currentInstanceBuffers;
  105752. private _textureUnits;
  105753. /** @hidden */
  105754. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105755. /** @hidden */
  105756. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105757. /** @hidden */
  105758. _boundRenderFunction: any;
  105759. private _vaoRecordInProgress;
  105760. private _mustWipeVertexAttributes;
  105761. private _emptyTexture;
  105762. private _emptyCubeTexture;
  105763. private _emptyTexture3D;
  105764. private _emptyTexture2DArray;
  105765. /** @hidden */
  105766. _frameHandler: number;
  105767. private _nextFreeTextureSlots;
  105768. private _maxSimultaneousTextures;
  105769. private _activeRequests;
  105770. /** @hidden */
  105771. _transformTextureUrl: Nullable<(url: string) => string>;
  105772. protected get _supportsHardwareTextureRescaling(): boolean;
  105773. private _framebufferDimensionsObject;
  105774. /**
  105775. * sets the object from which width and height will be taken from when getting render width and height
  105776. * Will fallback to the gl object
  105777. * @param dimensions the framebuffer width and height that will be used.
  105778. */
  105779. set framebufferDimensionsObject(dimensions: Nullable<{
  105780. framebufferWidth: number;
  105781. framebufferHeight: number;
  105782. }>);
  105783. /**
  105784. * Gets the current viewport
  105785. */
  105786. get currentViewport(): Nullable<IViewportLike>;
  105787. /**
  105788. * Gets the default empty texture
  105789. */
  105790. get emptyTexture(): InternalTexture;
  105791. /**
  105792. * Gets the default empty 3D texture
  105793. */
  105794. get emptyTexture3D(): InternalTexture;
  105795. /**
  105796. * Gets the default empty 2D array texture
  105797. */
  105798. get emptyTexture2DArray(): InternalTexture;
  105799. /**
  105800. * Gets the default empty cube texture
  105801. */
  105802. get emptyCubeTexture(): InternalTexture;
  105803. /**
  105804. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105805. */
  105806. readonly premultipliedAlpha: boolean;
  105807. /**
  105808. * Observable event triggered before each texture is initialized
  105809. */
  105810. onBeforeTextureInitObservable: Observable<Texture>;
  105811. /**
  105812. * Creates a new engine
  105813. * @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
  105814. * @param antialias defines enable antialiasing (default: false)
  105815. * @param options defines further options to be sent to the getContext() function
  105816. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105817. */
  105818. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105819. private _rebuildInternalTextures;
  105820. private _rebuildEffects;
  105821. /**
  105822. * Gets a boolean indicating if all created effects are ready
  105823. * @returns true if all effects are ready
  105824. */
  105825. areAllEffectsReady(): boolean;
  105826. protected _rebuildBuffers(): void;
  105827. protected _initGLContext(): void;
  105828. /**
  105829. * Gets version of the current webGL context
  105830. */
  105831. get webGLVersion(): number;
  105832. /**
  105833. * Gets a string idenfifying the name of the class
  105834. * @returns "Engine" string
  105835. */
  105836. getClassName(): string;
  105837. /**
  105838. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105839. */
  105840. get isStencilEnable(): boolean;
  105841. /** @hidden */
  105842. _prepareWorkingCanvas(): void;
  105843. /**
  105844. * Reset the texture cache to empty state
  105845. */
  105846. resetTextureCache(): void;
  105847. /**
  105848. * Gets an object containing information about the current webGL context
  105849. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105850. */
  105851. getGlInfo(): {
  105852. vendor: string;
  105853. renderer: string;
  105854. version: string;
  105855. };
  105856. /**
  105857. * Defines the hardware scaling level.
  105858. * By default the hardware scaling level is computed from the window device ratio.
  105859. * 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.
  105860. * @param level defines the level to use
  105861. */
  105862. setHardwareScalingLevel(level: number): void;
  105863. /**
  105864. * Gets the current hardware scaling level.
  105865. * By default the hardware scaling level is computed from the window device ratio.
  105866. * 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.
  105867. * @returns a number indicating the current hardware scaling level
  105868. */
  105869. getHardwareScalingLevel(): number;
  105870. /**
  105871. * Gets the list of loaded textures
  105872. * @returns an array containing all loaded textures
  105873. */
  105874. getLoadedTexturesCache(): InternalTexture[];
  105875. /**
  105876. * Gets the object containing all engine capabilities
  105877. * @returns the EngineCapabilities object
  105878. */
  105879. getCaps(): EngineCapabilities;
  105880. /**
  105881. * stop executing a render loop function and remove it from the execution array
  105882. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105883. */
  105884. stopRenderLoop(renderFunction?: () => void): void;
  105885. /** @hidden */
  105886. _renderLoop(): void;
  105887. /**
  105888. * Gets the HTML canvas attached with the current webGL context
  105889. * @returns a HTML canvas
  105890. */
  105891. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105892. /**
  105893. * Gets host window
  105894. * @returns the host window object
  105895. */
  105896. getHostWindow(): Nullable<Window>;
  105897. /**
  105898. * Gets the current render width
  105899. * @param useScreen defines if screen size must be used (or the current render target if any)
  105900. * @returns a number defining the current render width
  105901. */
  105902. getRenderWidth(useScreen?: boolean): number;
  105903. /**
  105904. * Gets the current render height
  105905. * @param useScreen defines if screen size must be used (or the current render target if any)
  105906. * @returns a number defining the current render height
  105907. */
  105908. getRenderHeight(useScreen?: boolean): number;
  105909. /**
  105910. * Can be used to override the current requestAnimationFrame requester.
  105911. * @hidden
  105912. */
  105913. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105914. /**
  105915. * Register and execute a render loop. The engine can have more than one render function
  105916. * @param renderFunction defines the function to continuously execute
  105917. */
  105918. runRenderLoop(renderFunction: () => void): void;
  105919. /**
  105920. * Clear the current render buffer or the current render target (if any is set up)
  105921. * @param color defines the color to use
  105922. * @param backBuffer defines if the back buffer must be cleared
  105923. * @param depth defines if the depth buffer must be cleared
  105924. * @param stencil defines if the stencil buffer must be cleared
  105925. */
  105926. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105927. private _viewportCached;
  105928. /** @hidden */
  105929. _viewport(x: number, y: number, width: number, height: number): void;
  105930. /**
  105931. * Set the WebGL's viewport
  105932. * @param viewport defines the viewport element to be used
  105933. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105934. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105935. */
  105936. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105937. /**
  105938. * Begin a new frame
  105939. */
  105940. beginFrame(): void;
  105941. /**
  105942. * Enf the current frame
  105943. */
  105944. endFrame(): void;
  105945. /**
  105946. * Resize the view according to the canvas' size
  105947. */
  105948. resize(): void;
  105949. /**
  105950. * Force a specific size of the canvas
  105951. * @param width defines the new canvas' width
  105952. * @param height defines the new canvas' height
  105953. */
  105954. setSize(width: number, height: number): void;
  105955. /**
  105956. * Binds the frame buffer to the specified texture.
  105957. * @param texture The texture to render to or null for the default canvas
  105958. * @param faceIndex The face of the texture to render to in case of cube texture
  105959. * @param requiredWidth The width of the target to render to
  105960. * @param requiredHeight The height of the target to render to
  105961. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105962. * @param lodLevel defines the lod level to bind to the frame buffer
  105963. * @param layer defines the 2d array index to bind to frame buffer to
  105964. */
  105965. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105966. /** @hidden */
  105967. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105968. /**
  105969. * Unbind the current render target texture from the webGL context
  105970. * @param texture defines the render target texture to unbind
  105971. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105972. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105973. */
  105974. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105975. /**
  105976. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105977. */
  105978. flushFramebuffer(): void;
  105979. /**
  105980. * Unbind the current render target and bind the default framebuffer
  105981. */
  105982. restoreDefaultFramebuffer(): void;
  105983. /** @hidden */
  105984. protected _resetVertexBufferBinding(): void;
  105985. /**
  105986. * Creates a vertex buffer
  105987. * @param data the data for the vertex buffer
  105988. * @returns the new WebGL static buffer
  105989. */
  105990. createVertexBuffer(data: DataArray): DataBuffer;
  105991. private _createVertexBuffer;
  105992. /**
  105993. * Creates a dynamic vertex buffer
  105994. * @param data the data for the dynamic vertex buffer
  105995. * @returns the new WebGL dynamic buffer
  105996. */
  105997. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105998. protected _resetIndexBufferBinding(): void;
  105999. /**
  106000. * Creates a new index buffer
  106001. * @param indices defines the content of the index buffer
  106002. * @param updatable defines if the index buffer must be updatable
  106003. * @returns a new webGL buffer
  106004. */
  106005. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  106006. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  106007. /**
  106008. * Bind a webGL buffer to the webGL context
  106009. * @param buffer defines the buffer to bind
  106010. */
  106011. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  106012. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  106013. private bindBuffer;
  106014. /**
  106015. * update the bound buffer with the given data
  106016. * @param data defines the data to update
  106017. */
  106018. updateArrayBuffer(data: Float32Array): void;
  106019. private _vertexAttribPointer;
  106020. /** @hidden */
  106021. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106022. private _bindVertexBuffersAttributes;
  106023. /**
  106024. * Records a vertex array object
  106025. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106026. * @param vertexBuffers defines the list of vertex buffers to store
  106027. * @param indexBuffer defines the index buffer to store
  106028. * @param effect defines the effect to store
  106029. * @returns the new vertex array object
  106030. */
  106031. recordVertexArrayObject(vertexBuffers: {
  106032. [key: string]: VertexBuffer;
  106033. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106034. /**
  106035. * Bind a specific vertex array object
  106036. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106037. * @param vertexArrayObject defines the vertex array object to bind
  106038. * @param indexBuffer defines the index buffer to bind
  106039. */
  106040. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106041. /**
  106042. * Bind webGl buffers directly to the webGL context
  106043. * @param vertexBuffer defines the vertex buffer to bind
  106044. * @param indexBuffer defines the index buffer to bind
  106045. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106046. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106047. * @param effect defines the effect associated with the vertex buffer
  106048. */
  106049. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106050. private _unbindVertexArrayObject;
  106051. /**
  106052. * Bind a list of vertex buffers to the webGL context
  106053. * @param vertexBuffers defines the list of vertex buffers to bind
  106054. * @param indexBuffer defines the index buffer to bind
  106055. * @param effect defines the effect associated with the vertex buffers
  106056. */
  106057. bindBuffers(vertexBuffers: {
  106058. [key: string]: Nullable<VertexBuffer>;
  106059. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106060. /**
  106061. * Unbind all instance attributes
  106062. */
  106063. unbindInstanceAttributes(): void;
  106064. /**
  106065. * Release and free the memory of a vertex array object
  106066. * @param vao defines the vertex array object to delete
  106067. */
  106068. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106069. /** @hidden */
  106070. _releaseBuffer(buffer: DataBuffer): boolean;
  106071. protected _deleteBuffer(buffer: DataBuffer): void;
  106072. /**
  106073. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106074. * @param instancesBuffer defines the webGL buffer to update and bind
  106075. * @param data defines the data to store in the buffer
  106076. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106077. */
  106078. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106079. /**
  106080. * Bind the content of a webGL buffer used with instantiation
  106081. * @param instancesBuffer defines the webGL buffer to bind
  106082. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106083. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106084. */
  106085. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106086. /**
  106087. * Disable the instance attribute corresponding to the name in parameter
  106088. * @param name defines the name of the attribute to disable
  106089. */
  106090. disableInstanceAttributeByName(name: string): void;
  106091. /**
  106092. * Disable the instance attribute corresponding to the location in parameter
  106093. * @param attributeLocation defines the attribute location of the attribute to disable
  106094. */
  106095. disableInstanceAttribute(attributeLocation: number): void;
  106096. /**
  106097. * Disable the attribute corresponding to the location in parameter
  106098. * @param attributeLocation defines the attribute location of the attribute to disable
  106099. */
  106100. disableAttributeByIndex(attributeLocation: number): void;
  106101. /**
  106102. * Send a draw order
  106103. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  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. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106109. /**
  106110. * Draw a list of points
  106111. * @param verticesStart defines the index of first vertex to draw
  106112. * @param verticesCount defines the count of vertices to draw
  106113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106114. */
  106115. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106116. /**
  106117. * Draw a list of unindexed primitives
  106118. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106119. * @param verticesStart defines the index of first vertex to draw
  106120. * @param verticesCount defines the count of vertices to draw
  106121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106122. */
  106123. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106124. /**
  106125. * Draw a list of indexed primitives
  106126. * @param fillMode defines the primitive to use
  106127. * @param indexStart defines the starting index
  106128. * @param indexCount defines the number of index to draw
  106129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106130. */
  106131. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106132. /**
  106133. * Draw a list of unindexed primitives
  106134. * @param fillMode defines the primitive to use
  106135. * @param verticesStart defines the index of first vertex to draw
  106136. * @param verticesCount defines the count of vertices to draw
  106137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106138. */
  106139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106140. private _drawMode;
  106141. /** @hidden */
  106142. protected _reportDrawCall(): void;
  106143. /** @hidden */
  106144. _releaseEffect(effect: Effect): void;
  106145. /** @hidden */
  106146. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106147. /**
  106148. * Create a new effect (used to store vertex/fragment shaders)
  106149. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106150. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106151. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106152. * @param samplers defines an array of string used to represent textures
  106153. * @param defines defines the string containing the defines to use to compile the shaders
  106154. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106155. * @param onCompiled defines a function to call when the effect creation is successful
  106156. * @param onError defines a function to call when the effect creation has failed
  106157. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106158. * @returns the new Effect
  106159. */
  106160. 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;
  106161. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106162. private _compileShader;
  106163. private _compileRawShader;
  106164. /** @hidden */
  106165. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106166. /**
  106167. * Directly creates a webGL program
  106168. * @param pipelineContext defines the pipeline context to attach to
  106169. * @param vertexCode defines the vertex shader code to use
  106170. * @param fragmentCode defines the fragment shader code to use
  106171. * @param context defines the webGL context to use (if not set, the current one will be used)
  106172. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106173. * @returns the new webGL program
  106174. */
  106175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106176. /**
  106177. * Creates a webGL program
  106178. * @param pipelineContext defines the pipeline context to attach to
  106179. * @param vertexCode defines the vertex shader code to use
  106180. * @param fragmentCode defines the fragment shader code to use
  106181. * @param defines defines the string containing the defines to use to compile the shaders
  106182. * @param context defines the webGL context to use (if not set, the current one will be used)
  106183. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106184. * @returns the new webGL program
  106185. */
  106186. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106187. /**
  106188. * Creates a new pipeline context
  106189. * @returns the new pipeline
  106190. */
  106191. createPipelineContext(): IPipelineContext;
  106192. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106193. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106194. /** @hidden */
  106195. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106196. /** @hidden */
  106197. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106198. /** @hidden */
  106199. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106200. /**
  106201. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106202. * @param pipelineContext defines the pipeline context to use
  106203. * @param uniformsNames defines the list of uniform names
  106204. * @returns an array of webGL uniform locations
  106205. */
  106206. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106207. /**
  106208. * Gets the lsit of active attributes for a given webGL program
  106209. * @param pipelineContext defines the pipeline context to use
  106210. * @param attributesNames defines the list of attribute names to get
  106211. * @returns an array of indices indicating the offset of each attribute
  106212. */
  106213. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106214. /**
  106215. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106216. * @param effect defines the effect to activate
  106217. */
  106218. enableEffect(effect: Nullable<Effect>): void;
  106219. /**
  106220. * Set the value of an uniform to a number (int)
  106221. * @param uniform defines the webGL uniform location where to store the value
  106222. * @param value defines the int number to store
  106223. */
  106224. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106225. /**
  106226. * Set the value of an uniform to an array of int32
  106227. * @param uniform defines the webGL uniform location where to store the value
  106228. * @param array defines the array of int32 to store
  106229. */
  106230. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106231. /**
  106232. * Set the value of an uniform to an array of int32 (stored as vec2)
  106233. * @param uniform defines the webGL uniform location where to store the value
  106234. * @param array defines the array of int32 to store
  106235. */
  106236. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106237. /**
  106238. * Set the value of an uniform to an array of int32 (stored as vec3)
  106239. * @param uniform defines the webGL uniform location where to store the value
  106240. * @param array defines the array of int32 to store
  106241. */
  106242. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106243. /**
  106244. * Set the value of an uniform to an array of int32 (stored as vec4)
  106245. * @param uniform defines the webGL uniform location where to store the value
  106246. * @param array defines the array of int32 to store
  106247. */
  106248. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106249. /**
  106250. * Set the value of an uniform to an array of number
  106251. * @param uniform defines the webGL uniform location where to store the value
  106252. * @param array defines the array of number to store
  106253. */
  106254. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106255. /**
  106256. * Set the value of an uniform to an array of number (stored as vec2)
  106257. * @param uniform defines the webGL uniform location where to store the value
  106258. * @param array defines the array of number to store
  106259. */
  106260. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106261. /**
  106262. * Set the value of an uniform to an array of number (stored as vec3)
  106263. * @param uniform defines the webGL uniform location where to store the value
  106264. * @param array defines the array of number to store
  106265. */
  106266. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106267. /**
  106268. * Set the value of an uniform to an array of number (stored as vec4)
  106269. * @param uniform defines the webGL uniform location where to store the value
  106270. * @param array defines the array of number to store
  106271. */
  106272. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106273. /**
  106274. * Set the value of an uniform to an array of float32 (stored as matrices)
  106275. * @param uniform defines the webGL uniform location where to store the value
  106276. * @param matrices defines the array of float32 to store
  106277. */
  106278. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106279. /**
  106280. * Set the value of an uniform to a matrix (3x3)
  106281. * @param uniform defines the webGL uniform location where to store the value
  106282. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106283. */
  106284. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106285. /**
  106286. * Set the value of an uniform to a matrix (2x2)
  106287. * @param uniform defines the webGL uniform location where to store the value
  106288. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106289. */
  106290. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106291. /**
  106292. * Set the value of an uniform to a number (float)
  106293. * @param uniform defines the webGL uniform location where to store the value
  106294. * @param value defines the float number to store
  106295. */
  106296. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106297. /**
  106298. * Set the value of an uniform to a vec2
  106299. * @param uniform defines the webGL uniform location where to store the value
  106300. * @param x defines the 1st component of the value
  106301. * @param y defines the 2nd component of the value
  106302. */
  106303. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106304. /**
  106305. * Set the value of an uniform to a vec3
  106306. * @param uniform defines the webGL uniform location where to store the value
  106307. * @param x defines the 1st component of the value
  106308. * @param y defines the 2nd component of the value
  106309. * @param z defines the 3rd component of the value
  106310. */
  106311. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106312. /**
  106313. * Set the value of an uniform to a vec4
  106314. * @param uniform defines the webGL uniform location where to store the value
  106315. * @param x defines the 1st component of the value
  106316. * @param y defines the 2nd component of the value
  106317. * @param z defines the 3rd component of the value
  106318. * @param w defines the 4th component of the value
  106319. */
  106320. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106321. /**
  106322. * Apply all cached states (depth, culling, stencil and alpha)
  106323. */
  106324. applyStates(): void;
  106325. /**
  106326. * Enable or disable color writing
  106327. * @param enable defines the state to set
  106328. */
  106329. setColorWrite(enable: boolean): void;
  106330. /**
  106331. * Gets a boolean indicating if color writing is enabled
  106332. * @returns the current color writing state
  106333. */
  106334. getColorWrite(): boolean;
  106335. /**
  106336. * Gets the depth culling state manager
  106337. */
  106338. get depthCullingState(): DepthCullingState;
  106339. /**
  106340. * Gets the alpha state manager
  106341. */
  106342. get alphaState(): AlphaState;
  106343. /**
  106344. * Gets the stencil state manager
  106345. */
  106346. get stencilState(): StencilState;
  106347. /**
  106348. * Clears the list of texture accessible through engine.
  106349. * This can help preventing texture load conflict due to name collision.
  106350. */
  106351. clearInternalTexturesCache(): void;
  106352. /**
  106353. * Force the entire cache to be cleared
  106354. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106355. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106356. */
  106357. wipeCaches(bruteForce?: boolean): void;
  106358. /** @hidden */
  106359. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106360. min: number;
  106361. mag: number;
  106362. };
  106363. /** @hidden */
  106364. _createTexture(): WebGLTexture;
  106365. /**
  106366. * Usually called from Texture.ts.
  106367. * Passed information to create a WebGLTexture
  106368. * @param url defines a value which contains one of the following:
  106369. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106370. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106371. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106372. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106373. * @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)
  106374. * @param scene needed for loading to the correct scene
  106375. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106376. * @param onLoad optional callback to be called upon successful completion
  106377. * @param onError optional callback to be called upon failure
  106378. * @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
  106379. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106380. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106381. * @param forcedExtension defines the extension to use to pick the right loader
  106382. * @param mimeType defines an optional mime type
  106383. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106384. */
  106385. 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;
  106386. /**
  106387. * Loads an image as an HTMLImageElement.
  106388. * @param input url string, ArrayBuffer, or Blob to load
  106389. * @param onLoad callback called when the image successfully loads
  106390. * @param onError callback called when the image fails to load
  106391. * @param offlineProvider offline provider for caching
  106392. * @param mimeType optional mime type
  106393. * @returns the HTMLImageElement of the loaded image
  106394. * @hidden
  106395. */
  106396. 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>;
  106397. /**
  106398. * @hidden
  106399. */
  106400. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106401. /**
  106402. * Creates a raw texture
  106403. * @param data defines the data to store in the texture
  106404. * @param width defines the width of the texture
  106405. * @param height defines the height of the texture
  106406. * @param format defines the format of the data
  106407. * @param generateMipMaps defines if the engine should generate the mip levels
  106408. * @param invertY defines if data must be stored with Y axis inverted
  106409. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106410. * @param compression defines the compression used (null by default)
  106411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106412. * @returns the raw texture inside an InternalTexture
  106413. */
  106414. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106415. /**
  106416. * Creates a new raw cube texture
  106417. * @param data defines the array of data to use to create each face
  106418. * @param size defines the size of the textures
  106419. * @param format defines the format of the data
  106420. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106421. * @param generateMipMaps defines if the engine should generate the mip levels
  106422. * @param invertY defines if data must be stored with Y axis inverted
  106423. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106424. * @param compression defines the compression used (null by default)
  106425. * @returns the cube texture as an InternalTexture
  106426. */
  106427. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106428. /**
  106429. * Creates a new raw 3D texture
  106430. * @param data defines the data used to create the texture
  106431. * @param width defines the width of the texture
  106432. * @param height defines the height of the texture
  106433. * @param depth defines the depth of the texture
  106434. * @param format defines the format of the texture
  106435. * @param generateMipMaps defines if the engine must generate mip levels
  106436. * @param invertY defines if data must be stored with Y axis inverted
  106437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106438. * @param compression defines the compressed used (can be null)
  106439. * @param textureType defines the compressed used (can be null)
  106440. * @returns a new raw 3D texture (stored in an InternalTexture)
  106441. */
  106442. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106443. /**
  106444. * Creates a new raw 2D array texture
  106445. * @param data defines the data used to create the texture
  106446. * @param width defines the width of the texture
  106447. * @param height defines the height of the texture
  106448. * @param depth defines the number of layers of the texture
  106449. * @param format defines the format of the texture
  106450. * @param generateMipMaps defines if the engine must generate mip levels
  106451. * @param invertY defines if data must be stored with Y axis inverted
  106452. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106453. * @param compression defines the compressed used (can be null)
  106454. * @param textureType defines the compressed used (can be null)
  106455. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106456. */
  106457. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106458. private _unpackFlipYCached;
  106459. /**
  106460. * In case you are sharing the context with other applications, it might
  106461. * be interested to not cache the unpack flip y state to ensure a consistent
  106462. * value would be set.
  106463. */
  106464. enableUnpackFlipYCached: boolean;
  106465. /** @hidden */
  106466. _unpackFlipY(value: boolean): void;
  106467. /** @hidden */
  106468. _getUnpackAlignement(): number;
  106469. private _getTextureTarget;
  106470. /**
  106471. * Update the sampling mode of a given texture
  106472. * @param samplingMode defines the required sampling mode
  106473. * @param texture defines the texture to update
  106474. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106475. */
  106476. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106477. /**
  106478. * Update the sampling mode of a given texture
  106479. * @param texture defines the texture to update
  106480. * @param wrapU defines the texture wrap mode of the u coordinates
  106481. * @param wrapV defines the texture wrap mode of the v coordinates
  106482. * @param wrapR defines the texture wrap mode of the r coordinates
  106483. */
  106484. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106485. /** @hidden */
  106486. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106487. width: number;
  106488. height: number;
  106489. layers?: number;
  106490. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106491. /** @hidden */
  106492. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106493. /** @hidden */
  106494. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106495. /**
  106496. * Update a portion of an internal texture
  106497. * @param texture defines the texture to update
  106498. * @param imageData defines the data to store into the texture
  106499. * @param xOffset defines the x coordinates of the update rectangle
  106500. * @param yOffset defines the y coordinates of the update rectangle
  106501. * @param width defines the width of the update rectangle
  106502. * @param height defines the height of the update rectangle
  106503. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106504. * @param lod defines the lod level to update (0 by default)
  106505. */
  106506. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106507. /** @hidden */
  106508. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106509. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106510. private _prepareWebGLTexture;
  106511. /** @hidden */
  106512. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106513. private _getDepthStencilBuffer;
  106514. /** @hidden */
  106515. _releaseFramebufferObjects(texture: InternalTexture): void;
  106516. /** @hidden */
  106517. _releaseTexture(texture: InternalTexture): void;
  106518. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106519. protected _setProgram(program: WebGLProgram): void;
  106520. protected _boundUniforms: {
  106521. [key: number]: WebGLUniformLocation;
  106522. };
  106523. /**
  106524. * Binds an effect to the webGL context
  106525. * @param effect defines the effect to bind
  106526. */
  106527. bindSamplers(effect: Effect): void;
  106528. private _activateCurrentTexture;
  106529. /** @hidden */
  106530. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106531. /** @hidden */
  106532. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106533. /**
  106534. * Unbind all textures from the webGL context
  106535. */
  106536. unbindAllTextures(): void;
  106537. /**
  106538. * Sets a texture to the according uniform.
  106539. * @param channel The texture channel
  106540. * @param uniform The uniform to set
  106541. * @param texture The texture to apply
  106542. */
  106543. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106544. private _bindSamplerUniformToChannel;
  106545. private _getTextureWrapMode;
  106546. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106547. /**
  106548. * Sets an array of texture to the webGL context
  106549. * @param channel defines the channel where the texture array must be set
  106550. * @param uniform defines the associated uniform location
  106551. * @param textures defines the array of textures to bind
  106552. */
  106553. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106554. /** @hidden */
  106555. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106556. private _setTextureParameterFloat;
  106557. private _setTextureParameterInteger;
  106558. /**
  106559. * Unbind all vertex attributes from the webGL context
  106560. */
  106561. unbindAllAttributes(): void;
  106562. /**
  106563. * 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
  106564. */
  106565. releaseEffects(): void;
  106566. /**
  106567. * Dispose and release all associated resources
  106568. */
  106569. dispose(): void;
  106570. /**
  106571. * Attach a new callback raised when context lost event is fired
  106572. * @param callback defines the callback to call
  106573. */
  106574. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106575. /**
  106576. * Attach a new callback raised when context restored event is fired
  106577. * @param callback defines the callback to call
  106578. */
  106579. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106580. /**
  106581. * Get the current error code of the webGL context
  106582. * @returns the error code
  106583. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106584. */
  106585. getError(): number;
  106586. private _canRenderToFloatFramebuffer;
  106587. private _canRenderToHalfFloatFramebuffer;
  106588. private _canRenderToFramebuffer;
  106589. /** @hidden */
  106590. _getWebGLTextureType(type: number): number;
  106591. /** @hidden */
  106592. _getInternalFormat(format: number): number;
  106593. /** @hidden */
  106594. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106595. /** @hidden */
  106596. _getRGBAMultiSampleBufferFormat(type: number): number;
  106597. /** @hidden */
  106598. _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;
  106599. /**
  106600. * Loads a file from a url
  106601. * @param url url to load
  106602. * @param onSuccess callback called when the file successfully loads
  106603. * @param onProgress callback called while file is loading (if the server supports this mode)
  106604. * @param offlineProvider defines the offline provider for caching
  106605. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106606. * @param onError callback called when the file fails to load
  106607. * @returns a file request object
  106608. * @hidden
  106609. */
  106610. 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;
  106611. /**
  106612. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106613. * @param x defines the x coordinate of the rectangle where pixels must be read
  106614. * @param y defines the y coordinate of the rectangle where pixels must be read
  106615. * @param width defines the width of the rectangle where pixels must be read
  106616. * @param height defines the height of the rectangle where pixels must be read
  106617. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106618. * @returns a Uint8Array containing RGBA colors
  106619. */
  106620. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106621. private static _isSupported;
  106622. /**
  106623. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106624. * @returns true if the engine can be created
  106625. * @ignorenaming
  106626. */
  106627. static isSupported(): boolean;
  106628. /**
  106629. * Find the next highest power of two.
  106630. * @param x Number to start search from.
  106631. * @return Next highest power of two.
  106632. */
  106633. static CeilingPOT(x: number): number;
  106634. /**
  106635. * Find the next lowest power of two.
  106636. * @param x Number to start search from.
  106637. * @return Next lowest power of two.
  106638. */
  106639. static FloorPOT(x: number): number;
  106640. /**
  106641. * Find the nearest power of two.
  106642. * @param x Number to start search from.
  106643. * @return Next nearest power of two.
  106644. */
  106645. static NearestPOT(x: number): number;
  106646. /**
  106647. * Get the closest exponent of two
  106648. * @param value defines the value to approximate
  106649. * @param max defines the maximum value to return
  106650. * @param mode defines how to define the closest value
  106651. * @returns closest exponent of two of the given value
  106652. */
  106653. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106654. /**
  106655. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106656. * @param func - the function to be called
  106657. * @param requester - the object that will request the next frame. Falls back to window.
  106658. * @returns frame number
  106659. */
  106660. static QueueNewFrame(func: () => void, requester?: any): number;
  106661. /**
  106662. * Gets host document
  106663. * @returns the host document object
  106664. */
  106665. getHostDocument(): Nullable<Document>;
  106666. }
  106667. }
  106668. declare module BABYLON {
  106669. /**
  106670. * Class representing spherical harmonics coefficients to the 3rd degree
  106671. */
  106672. export class SphericalHarmonics {
  106673. /**
  106674. * Defines whether or not the harmonics have been prescaled for rendering.
  106675. */
  106676. preScaled: boolean;
  106677. /**
  106678. * The l0,0 coefficients of the spherical harmonics
  106679. */
  106680. l00: Vector3;
  106681. /**
  106682. * The l1,-1 coefficients of the spherical harmonics
  106683. */
  106684. l1_1: Vector3;
  106685. /**
  106686. * The l1,0 coefficients of the spherical harmonics
  106687. */
  106688. l10: Vector3;
  106689. /**
  106690. * The l1,1 coefficients of the spherical harmonics
  106691. */
  106692. l11: Vector3;
  106693. /**
  106694. * The l2,-2 coefficients of the spherical harmonics
  106695. */
  106696. l2_2: Vector3;
  106697. /**
  106698. * The l2,-1 coefficients of the spherical harmonics
  106699. */
  106700. l2_1: Vector3;
  106701. /**
  106702. * The l2,0 coefficients of the spherical harmonics
  106703. */
  106704. l20: Vector3;
  106705. /**
  106706. * The l2,1 coefficients of the spherical harmonics
  106707. */
  106708. l21: Vector3;
  106709. /**
  106710. * The l2,2 coefficients of the spherical harmonics
  106711. */
  106712. l22: Vector3;
  106713. /**
  106714. * Adds a light to the spherical harmonics
  106715. * @param direction the direction of the light
  106716. * @param color the color of the light
  106717. * @param deltaSolidAngle the delta solid angle of the light
  106718. */
  106719. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106720. /**
  106721. * Scales the spherical harmonics by the given amount
  106722. * @param scale the amount to scale
  106723. */
  106724. scaleInPlace(scale: number): void;
  106725. /**
  106726. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106727. *
  106728. * ```
  106729. * E_lm = A_l * L_lm
  106730. * ```
  106731. *
  106732. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106733. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106734. * the scaling factors are given in equation 9.
  106735. */
  106736. convertIncidentRadianceToIrradiance(): void;
  106737. /**
  106738. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106739. *
  106740. * ```
  106741. * L = (1/pi) * E * rho
  106742. * ```
  106743. *
  106744. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106745. */
  106746. convertIrradianceToLambertianRadiance(): void;
  106747. /**
  106748. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106749. * required operations at run time.
  106750. *
  106751. * This is simply done by scaling back the SH with Ylm constants parameter.
  106752. * The trigonometric part being applied by the shader at run time.
  106753. */
  106754. preScaleForRendering(): void;
  106755. /**
  106756. * Constructs a spherical harmonics from an array.
  106757. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106758. * @returns the spherical harmonics
  106759. */
  106760. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106761. /**
  106762. * Gets the spherical harmonics from polynomial
  106763. * @param polynomial the spherical polynomial
  106764. * @returns the spherical harmonics
  106765. */
  106766. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106767. }
  106768. /**
  106769. * Class representing spherical polynomial coefficients to the 3rd degree
  106770. */
  106771. export class SphericalPolynomial {
  106772. private _harmonics;
  106773. /**
  106774. * The spherical harmonics used to create the polynomials.
  106775. */
  106776. get preScaledHarmonics(): SphericalHarmonics;
  106777. /**
  106778. * The x coefficients of the spherical polynomial
  106779. */
  106780. x: Vector3;
  106781. /**
  106782. * The y coefficients of the spherical polynomial
  106783. */
  106784. y: Vector3;
  106785. /**
  106786. * The z coefficients of the spherical polynomial
  106787. */
  106788. z: Vector3;
  106789. /**
  106790. * The xx coefficients of the spherical polynomial
  106791. */
  106792. xx: Vector3;
  106793. /**
  106794. * The yy coefficients of the spherical polynomial
  106795. */
  106796. yy: Vector3;
  106797. /**
  106798. * The zz coefficients of the spherical polynomial
  106799. */
  106800. zz: Vector3;
  106801. /**
  106802. * The xy coefficients of the spherical polynomial
  106803. */
  106804. xy: Vector3;
  106805. /**
  106806. * The yz coefficients of the spherical polynomial
  106807. */
  106808. yz: Vector3;
  106809. /**
  106810. * The zx coefficients of the spherical polynomial
  106811. */
  106812. zx: Vector3;
  106813. /**
  106814. * Adds an ambient color to the spherical polynomial
  106815. * @param color the color to add
  106816. */
  106817. addAmbient(color: Color3): void;
  106818. /**
  106819. * Scales the spherical polynomial by the given amount
  106820. * @param scale the amount to scale
  106821. */
  106822. scaleInPlace(scale: number): void;
  106823. /**
  106824. * Gets the spherical polynomial from harmonics
  106825. * @param harmonics the spherical harmonics
  106826. * @returns the spherical polynomial
  106827. */
  106828. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106829. /**
  106830. * Constructs a spherical polynomial from an array.
  106831. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106832. * @returns the spherical polynomial
  106833. */
  106834. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106835. }
  106836. }
  106837. declare module BABYLON {
  106838. /**
  106839. * Defines the source of the internal texture
  106840. */
  106841. export enum InternalTextureSource {
  106842. /**
  106843. * The source of the texture data is unknown
  106844. */
  106845. Unknown = 0,
  106846. /**
  106847. * Texture data comes from an URL
  106848. */
  106849. Url = 1,
  106850. /**
  106851. * Texture data is only used for temporary storage
  106852. */
  106853. Temp = 2,
  106854. /**
  106855. * Texture data comes from raw data (ArrayBuffer)
  106856. */
  106857. Raw = 3,
  106858. /**
  106859. * Texture content is dynamic (video or dynamic texture)
  106860. */
  106861. Dynamic = 4,
  106862. /**
  106863. * Texture content is generated by rendering to it
  106864. */
  106865. RenderTarget = 5,
  106866. /**
  106867. * Texture content is part of a multi render target process
  106868. */
  106869. MultiRenderTarget = 6,
  106870. /**
  106871. * Texture data comes from a cube data file
  106872. */
  106873. Cube = 7,
  106874. /**
  106875. * Texture data comes from a raw cube data
  106876. */
  106877. CubeRaw = 8,
  106878. /**
  106879. * Texture data come from a prefiltered cube data file
  106880. */
  106881. CubePrefiltered = 9,
  106882. /**
  106883. * Texture content is raw 3D data
  106884. */
  106885. Raw3D = 10,
  106886. /**
  106887. * Texture content is raw 2D array data
  106888. */
  106889. Raw2DArray = 11,
  106890. /**
  106891. * Texture content is a depth texture
  106892. */
  106893. Depth = 12,
  106894. /**
  106895. * Texture data comes from a raw cube data encoded with RGBD
  106896. */
  106897. CubeRawRGBD = 13
  106898. }
  106899. /**
  106900. * Class used to store data associated with WebGL texture data for the engine
  106901. * This class should not be used directly
  106902. */
  106903. export class InternalTexture {
  106904. /** @hidden */
  106905. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106906. /**
  106907. * Defines if the texture is ready
  106908. */
  106909. isReady: boolean;
  106910. /**
  106911. * Defines if the texture is a cube texture
  106912. */
  106913. isCube: boolean;
  106914. /**
  106915. * Defines if the texture contains 3D data
  106916. */
  106917. is3D: boolean;
  106918. /**
  106919. * Defines if the texture contains 2D array data
  106920. */
  106921. is2DArray: boolean;
  106922. /**
  106923. * Defines if the texture contains multiview data
  106924. */
  106925. isMultiview: boolean;
  106926. /**
  106927. * Gets the URL used to load this texture
  106928. */
  106929. url: string;
  106930. /**
  106931. * Gets the sampling mode of the texture
  106932. */
  106933. samplingMode: number;
  106934. /**
  106935. * Gets a boolean indicating if the texture needs mipmaps generation
  106936. */
  106937. generateMipMaps: boolean;
  106938. /**
  106939. * Gets the number of samples used by the texture (WebGL2+ only)
  106940. */
  106941. samples: number;
  106942. /**
  106943. * Gets the type of the texture (int, float...)
  106944. */
  106945. type: number;
  106946. /**
  106947. * Gets the format of the texture (RGB, RGBA...)
  106948. */
  106949. format: number;
  106950. /**
  106951. * Observable called when the texture is loaded
  106952. */
  106953. onLoadedObservable: Observable<InternalTexture>;
  106954. /**
  106955. * Gets the width of the texture
  106956. */
  106957. width: number;
  106958. /**
  106959. * Gets the height of the texture
  106960. */
  106961. height: number;
  106962. /**
  106963. * Gets the depth of the texture
  106964. */
  106965. depth: number;
  106966. /**
  106967. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106968. */
  106969. baseWidth: number;
  106970. /**
  106971. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106972. */
  106973. baseHeight: number;
  106974. /**
  106975. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106976. */
  106977. baseDepth: number;
  106978. /**
  106979. * Gets a boolean indicating if the texture is inverted on Y axis
  106980. */
  106981. invertY: boolean;
  106982. /** @hidden */
  106983. _invertVScale: boolean;
  106984. /** @hidden */
  106985. _associatedChannel: number;
  106986. /** @hidden */
  106987. _source: InternalTextureSource;
  106988. /** @hidden */
  106989. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106990. /** @hidden */
  106991. _bufferView: Nullable<ArrayBufferView>;
  106992. /** @hidden */
  106993. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106994. /** @hidden */
  106995. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106996. /** @hidden */
  106997. _size: number;
  106998. /** @hidden */
  106999. _extension: string;
  107000. /** @hidden */
  107001. _files: Nullable<string[]>;
  107002. /** @hidden */
  107003. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107004. /** @hidden */
  107005. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107006. /** @hidden */
  107007. _framebuffer: Nullable<WebGLFramebuffer>;
  107008. /** @hidden */
  107009. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  107010. /** @hidden */
  107011. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  107012. /** @hidden */
  107013. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  107014. /** @hidden */
  107015. _attachments: Nullable<number[]>;
  107016. /** @hidden */
  107017. _cachedCoordinatesMode: Nullable<number>;
  107018. /** @hidden */
  107019. _cachedWrapU: Nullable<number>;
  107020. /** @hidden */
  107021. _cachedWrapV: Nullable<number>;
  107022. /** @hidden */
  107023. _cachedWrapR: Nullable<number>;
  107024. /** @hidden */
  107025. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107026. /** @hidden */
  107027. _isDisabled: boolean;
  107028. /** @hidden */
  107029. _compression: Nullable<string>;
  107030. /** @hidden */
  107031. _generateStencilBuffer: boolean;
  107032. /** @hidden */
  107033. _generateDepthBuffer: boolean;
  107034. /** @hidden */
  107035. _comparisonFunction: number;
  107036. /** @hidden */
  107037. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107038. /** @hidden */
  107039. _lodGenerationScale: number;
  107040. /** @hidden */
  107041. _lodGenerationOffset: number;
  107042. /** @hidden */
  107043. _depthStencilTexture: Nullable<InternalTexture>;
  107044. /** @hidden */
  107045. _colorTextureArray: Nullable<WebGLTexture>;
  107046. /** @hidden */
  107047. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107048. /** @hidden */
  107049. _lodTextureHigh: Nullable<BaseTexture>;
  107050. /** @hidden */
  107051. _lodTextureMid: Nullable<BaseTexture>;
  107052. /** @hidden */
  107053. _lodTextureLow: Nullable<BaseTexture>;
  107054. /** @hidden */
  107055. _isRGBD: boolean;
  107056. /** @hidden */
  107057. _linearSpecularLOD: boolean;
  107058. /** @hidden */
  107059. _irradianceTexture: Nullable<BaseTexture>;
  107060. /** @hidden */
  107061. _webGLTexture: Nullable<WebGLTexture>;
  107062. /** @hidden */
  107063. _references: number;
  107064. private _engine;
  107065. /**
  107066. * Gets the Engine the texture belongs to.
  107067. * @returns The babylon engine
  107068. */
  107069. getEngine(): ThinEngine;
  107070. /**
  107071. * Gets the data source type of the texture
  107072. */
  107073. get source(): InternalTextureSource;
  107074. /**
  107075. * Creates a new InternalTexture
  107076. * @param engine defines the engine to use
  107077. * @param source defines the type of data that will be used
  107078. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107079. */
  107080. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107081. /**
  107082. * Increments the number of references (ie. the number of Texture that point to it)
  107083. */
  107084. incrementReferences(): void;
  107085. /**
  107086. * Change the size of the texture (not the size of the content)
  107087. * @param width defines the new width
  107088. * @param height defines the new height
  107089. * @param depth defines the new depth (1 by default)
  107090. */
  107091. updateSize(width: int, height: int, depth?: int): void;
  107092. /** @hidden */
  107093. _rebuild(): void;
  107094. /** @hidden */
  107095. _swapAndDie(target: InternalTexture): void;
  107096. /**
  107097. * Dispose the current allocated resources
  107098. */
  107099. dispose(): void;
  107100. }
  107101. }
  107102. declare module BABYLON {
  107103. /**
  107104. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107106. */
  107107. export class Analyser {
  107108. /**
  107109. * Gets or sets the smoothing
  107110. * @ignorenaming
  107111. */
  107112. SMOOTHING: number;
  107113. /**
  107114. * Gets or sets the FFT table size
  107115. * @ignorenaming
  107116. */
  107117. FFT_SIZE: number;
  107118. /**
  107119. * Gets or sets the bar graph amplitude
  107120. * @ignorenaming
  107121. */
  107122. BARGRAPHAMPLITUDE: number;
  107123. /**
  107124. * Gets or sets the position of the debug canvas
  107125. * @ignorenaming
  107126. */
  107127. DEBUGCANVASPOS: {
  107128. x: number;
  107129. y: number;
  107130. };
  107131. /**
  107132. * Gets or sets the debug canvas size
  107133. * @ignorenaming
  107134. */
  107135. DEBUGCANVASSIZE: {
  107136. width: number;
  107137. height: number;
  107138. };
  107139. private _byteFreqs;
  107140. private _byteTime;
  107141. private _floatFreqs;
  107142. private _webAudioAnalyser;
  107143. private _debugCanvas;
  107144. private _debugCanvasContext;
  107145. private _scene;
  107146. private _registerFunc;
  107147. private _audioEngine;
  107148. /**
  107149. * Creates a new analyser
  107150. * @param scene defines hosting scene
  107151. */
  107152. constructor(scene: Scene);
  107153. /**
  107154. * Get the number of data values you will have to play with for the visualization
  107155. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107156. * @returns a number
  107157. */
  107158. getFrequencyBinCount(): number;
  107159. /**
  107160. * Gets the current frequency data as a byte array
  107161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107162. * @returns a Uint8Array
  107163. */
  107164. getByteFrequencyData(): Uint8Array;
  107165. /**
  107166. * Gets the current waveform as a byte array
  107167. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107168. * @returns a Uint8Array
  107169. */
  107170. getByteTimeDomainData(): Uint8Array;
  107171. /**
  107172. * Gets the current frequency data as a float array
  107173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107174. * @returns a Float32Array
  107175. */
  107176. getFloatFrequencyData(): Float32Array;
  107177. /**
  107178. * Renders the debug canvas
  107179. */
  107180. drawDebugCanvas(): void;
  107181. /**
  107182. * Stops rendering the debug canvas and removes it
  107183. */
  107184. stopDebugCanvas(): void;
  107185. /**
  107186. * Connects two audio nodes
  107187. * @param inputAudioNode defines first node to connect
  107188. * @param outputAudioNode defines second node to connect
  107189. */
  107190. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107191. /**
  107192. * Releases all associated resources
  107193. */
  107194. dispose(): void;
  107195. }
  107196. }
  107197. declare module BABYLON {
  107198. /**
  107199. * This represents an audio engine and it is responsible
  107200. * to play, synchronize and analyse sounds throughout the application.
  107201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107202. */
  107203. export interface IAudioEngine extends IDisposable {
  107204. /**
  107205. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107206. */
  107207. readonly canUseWebAudio: boolean;
  107208. /**
  107209. * Gets the current AudioContext if available.
  107210. */
  107211. readonly audioContext: Nullable<AudioContext>;
  107212. /**
  107213. * The master gain node defines the global audio volume of your audio engine.
  107214. */
  107215. readonly masterGain: GainNode;
  107216. /**
  107217. * Gets whether or not mp3 are supported by your browser.
  107218. */
  107219. readonly isMP3supported: boolean;
  107220. /**
  107221. * Gets whether or not ogg are supported by your browser.
  107222. */
  107223. readonly isOGGsupported: boolean;
  107224. /**
  107225. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107226. * @ignoreNaming
  107227. */
  107228. WarnedWebAudioUnsupported: boolean;
  107229. /**
  107230. * Defines if the audio engine relies on a custom unlocked button.
  107231. * In this case, the embedded button will not be displayed.
  107232. */
  107233. useCustomUnlockedButton: boolean;
  107234. /**
  107235. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107236. */
  107237. readonly unlocked: boolean;
  107238. /**
  107239. * Event raised when audio has been unlocked on the browser.
  107240. */
  107241. onAudioUnlockedObservable: Observable<AudioEngine>;
  107242. /**
  107243. * Event raised when audio has been locked on the browser.
  107244. */
  107245. onAudioLockedObservable: Observable<AudioEngine>;
  107246. /**
  107247. * Flags the audio engine in Locked state.
  107248. * This happens due to new browser policies preventing audio to autoplay.
  107249. */
  107250. lock(): void;
  107251. /**
  107252. * Unlocks the audio engine once a user action has been done on the dom.
  107253. * This is helpful to resume play once browser policies have been satisfied.
  107254. */
  107255. unlock(): void;
  107256. /**
  107257. * Gets the global volume sets on the master gain.
  107258. * @returns the global volume if set or -1 otherwise
  107259. */
  107260. getGlobalVolume(): number;
  107261. /**
  107262. * Sets the global volume of your experience (sets on the master gain).
  107263. * @param newVolume Defines the new global volume of the application
  107264. */
  107265. setGlobalVolume(newVolume: number): void;
  107266. /**
  107267. * Connect the audio engine to an audio analyser allowing some amazing
  107268. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107270. * @param analyser The analyser to connect to the engine
  107271. */
  107272. connectToAnalyser(analyser: Analyser): void;
  107273. }
  107274. /**
  107275. * This represents the default audio engine used in babylon.
  107276. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107278. */
  107279. export class AudioEngine implements IAudioEngine {
  107280. private _audioContext;
  107281. private _audioContextInitialized;
  107282. private _muteButton;
  107283. private _hostElement;
  107284. /**
  107285. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107286. */
  107287. canUseWebAudio: boolean;
  107288. /**
  107289. * The master gain node defines the global audio volume of your audio engine.
  107290. */
  107291. masterGain: GainNode;
  107292. /**
  107293. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107294. * @ignoreNaming
  107295. */
  107296. WarnedWebAudioUnsupported: boolean;
  107297. /**
  107298. * Gets whether or not mp3 are supported by your browser.
  107299. */
  107300. isMP3supported: boolean;
  107301. /**
  107302. * Gets whether or not ogg are supported by your browser.
  107303. */
  107304. isOGGsupported: boolean;
  107305. /**
  107306. * Gets whether audio has been unlocked on the device.
  107307. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107308. * a user interaction has happened.
  107309. */
  107310. unlocked: boolean;
  107311. /**
  107312. * Defines if the audio engine relies on a custom unlocked button.
  107313. * In this case, the embedded button will not be displayed.
  107314. */
  107315. useCustomUnlockedButton: boolean;
  107316. /**
  107317. * Event raised when audio has been unlocked on the browser.
  107318. */
  107319. onAudioUnlockedObservable: Observable<AudioEngine>;
  107320. /**
  107321. * Event raised when audio has been locked on the browser.
  107322. */
  107323. onAudioLockedObservable: Observable<AudioEngine>;
  107324. /**
  107325. * Gets the current AudioContext if available.
  107326. */
  107327. get audioContext(): Nullable<AudioContext>;
  107328. private _connectedAnalyser;
  107329. /**
  107330. * Instantiates a new audio engine.
  107331. *
  107332. * There should be only one per page as some browsers restrict the number
  107333. * of audio contexts you can create.
  107334. * @param hostElement defines the host element where to display the mute icon if necessary
  107335. */
  107336. constructor(hostElement?: Nullable<HTMLElement>);
  107337. /**
  107338. * Flags the audio engine in Locked state.
  107339. * This happens due to new browser policies preventing audio to autoplay.
  107340. */
  107341. lock(): void;
  107342. /**
  107343. * Unlocks the audio engine once a user action has been done on the dom.
  107344. * This is helpful to resume play once browser policies have been satisfied.
  107345. */
  107346. unlock(): void;
  107347. private _resumeAudioContext;
  107348. private _initializeAudioContext;
  107349. private _tryToRun;
  107350. private _triggerRunningState;
  107351. private _triggerSuspendedState;
  107352. private _displayMuteButton;
  107353. private _moveButtonToTopLeft;
  107354. private _onResize;
  107355. private _hideMuteButton;
  107356. /**
  107357. * Destroy and release the resources associated with the audio ccontext.
  107358. */
  107359. dispose(): void;
  107360. /**
  107361. * Gets the global volume sets on the master gain.
  107362. * @returns the global volume if set or -1 otherwise
  107363. */
  107364. getGlobalVolume(): number;
  107365. /**
  107366. * Sets the global volume of your experience (sets on the master gain).
  107367. * @param newVolume Defines the new global volume of the application
  107368. */
  107369. setGlobalVolume(newVolume: number): void;
  107370. /**
  107371. * Connect the audio engine to an audio analyser allowing some amazing
  107372. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107374. * @param analyser The analyser to connect to the engine
  107375. */
  107376. connectToAnalyser(analyser: Analyser): void;
  107377. }
  107378. }
  107379. declare module BABYLON {
  107380. /**
  107381. * Interface used to present a loading screen while loading a scene
  107382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107383. */
  107384. export interface ILoadingScreen {
  107385. /**
  107386. * Function called to display the loading screen
  107387. */
  107388. displayLoadingUI: () => void;
  107389. /**
  107390. * Function called to hide the loading screen
  107391. */
  107392. hideLoadingUI: () => void;
  107393. /**
  107394. * Gets or sets the color to use for the background
  107395. */
  107396. loadingUIBackgroundColor: string;
  107397. /**
  107398. * Gets or sets the text to display while loading
  107399. */
  107400. loadingUIText: string;
  107401. }
  107402. /**
  107403. * Class used for the default loading screen
  107404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107405. */
  107406. export class DefaultLoadingScreen implements ILoadingScreen {
  107407. private _renderingCanvas;
  107408. private _loadingText;
  107409. private _loadingDivBackgroundColor;
  107410. private _loadingDiv;
  107411. private _loadingTextDiv;
  107412. /** Gets or sets the logo url to use for the default loading screen */
  107413. static DefaultLogoUrl: string;
  107414. /** Gets or sets the spinner url to use for the default loading screen */
  107415. static DefaultSpinnerUrl: string;
  107416. /**
  107417. * Creates a new default loading screen
  107418. * @param _renderingCanvas defines the canvas used to render the scene
  107419. * @param _loadingText defines the default text to display
  107420. * @param _loadingDivBackgroundColor defines the default background color
  107421. */
  107422. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107423. /**
  107424. * Function called to display the loading screen
  107425. */
  107426. displayLoadingUI(): void;
  107427. /**
  107428. * Function called to hide the loading screen
  107429. */
  107430. hideLoadingUI(): void;
  107431. /**
  107432. * Gets or sets the text to display while loading
  107433. */
  107434. set loadingUIText(text: string);
  107435. get loadingUIText(): string;
  107436. /**
  107437. * Gets or sets the color to use for the background
  107438. */
  107439. get loadingUIBackgroundColor(): string;
  107440. set loadingUIBackgroundColor(color: string);
  107441. private _resizeLoadingUI;
  107442. }
  107443. }
  107444. declare module BABYLON {
  107445. /**
  107446. * Interface for any object that can request an animation frame
  107447. */
  107448. export interface ICustomAnimationFrameRequester {
  107449. /**
  107450. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107451. */
  107452. renderFunction?: Function;
  107453. /**
  107454. * Called to request the next frame to render to
  107455. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107456. */
  107457. requestAnimationFrame: Function;
  107458. /**
  107459. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107460. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107461. */
  107462. requestID?: number;
  107463. }
  107464. }
  107465. declare module BABYLON {
  107466. /**
  107467. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107468. */
  107469. export class PerformanceMonitor {
  107470. private _enabled;
  107471. private _rollingFrameTime;
  107472. private _lastFrameTimeMs;
  107473. /**
  107474. * constructor
  107475. * @param frameSampleSize The number of samples required to saturate the sliding window
  107476. */
  107477. constructor(frameSampleSize?: number);
  107478. /**
  107479. * Samples current frame
  107480. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107481. */
  107482. sampleFrame(timeMs?: number): void;
  107483. /**
  107484. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107485. */
  107486. get averageFrameTime(): number;
  107487. /**
  107488. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107489. */
  107490. get averageFrameTimeVariance(): number;
  107491. /**
  107492. * Returns the frame time of the most recent frame
  107493. */
  107494. get instantaneousFrameTime(): number;
  107495. /**
  107496. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107497. */
  107498. get averageFPS(): number;
  107499. /**
  107500. * Returns the average framerate in frames per second using the most recent frame time
  107501. */
  107502. get instantaneousFPS(): number;
  107503. /**
  107504. * Returns true if enough samples have been taken to completely fill the sliding window
  107505. */
  107506. get isSaturated(): boolean;
  107507. /**
  107508. * Enables contributions to the sliding window sample set
  107509. */
  107510. enable(): void;
  107511. /**
  107512. * Disables contributions to the sliding window sample set
  107513. * Samples will not be interpolated over the disabled period
  107514. */
  107515. disable(): void;
  107516. /**
  107517. * Returns true if sampling is enabled
  107518. */
  107519. get isEnabled(): boolean;
  107520. /**
  107521. * Resets performance monitor
  107522. */
  107523. reset(): void;
  107524. }
  107525. /**
  107526. * RollingAverage
  107527. *
  107528. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107529. */
  107530. export class RollingAverage {
  107531. /**
  107532. * Current average
  107533. */
  107534. average: number;
  107535. /**
  107536. * Current variance
  107537. */
  107538. variance: number;
  107539. protected _samples: Array<number>;
  107540. protected _sampleCount: number;
  107541. protected _pos: number;
  107542. protected _m2: number;
  107543. /**
  107544. * constructor
  107545. * @param length The number of samples required to saturate the sliding window
  107546. */
  107547. constructor(length: number);
  107548. /**
  107549. * Adds a sample to the sample set
  107550. * @param v The sample value
  107551. */
  107552. add(v: number): void;
  107553. /**
  107554. * Returns previously added values or null if outside of history or outside the sliding window domain
  107555. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107556. * @return Value previously recorded with add() or null if outside of range
  107557. */
  107558. history(i: number): number;
  107559. /**
  107560. * Returns true if enough samples have been taken to completely fill the sliding window
  107561. * @return true if sample-set saturated
  107562. */
  107563. isSaturated(): boolean;
  107564. /**
  107565. * Resets the rolling average (equivalent to 0 samples taken so far)
  107566. */
  107567. reset(): void;
  107568. /**
  107569. * Wraps a value around the sample range boundaries
  107570. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107571. * @return Wrapped position in sample range
  107572. */
  107573. protected _wrapPosition(i: number): number;
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * This class is used to track a performance counter which is number based.
  107579. * The user has access to many properties which give statistics of different nature.
  107580. *
  107581. * The implementer can track two kinds of Performance Counter: time and count.
  107582. * 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.
  107583. * 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.
  107584. */
  107585. export class PerfCounter {
  107586. /**
  107587. * Gets or sets a global boolean to turn on and off all the counters
  107588. */
  107589. static Enabled: boolean;
  107590. /**
  107591. * Returns the smallest value ever
  107592. */
  107593. get min(): number;
  107594. /**
  107595. * Returns the biggest value ever
  107596. */
  107597. get max(): number;
  107598. /**
  107599. * Returns the average value since the performance counter is running
  107600. */
  107601. get average(): number;
  107602. /**
  107603. * Returns the average value of the last second the counter was monitored
  107604. */
  107605. get lastSecAverage(): number;
  107606. /**
  107607. * Returns the current value
  107608. */
  107609. get current(): number;
  107610. /**
  107611. * Gets the accumulated total
  107612. */
  107613. get total(): number;
  107614. /**
  107615. * Gets the total value count
  107616. */
  107617. get count(): number;
  107618. /**
  107619. * Creates a new counter
  107620. */
  107621. constructor();
  107622. /**
  107623. * Call this method to start monitoring a new frame.
  107624. * 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.
  107625. */
  107626. fetchNewFrame(): void;
  107627. /**
  107628. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107629. * @param newCount the count value to add to the monitored count
  107630. * @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.
  107631. */
  107632. addCount(newCount: number, fetchResult: boolean): void;
  107633. /**
  107634. * Start monitoring this performance counter
  107635. */
  107636. beginMonitoring(): void;
  107637. /**
  107638. * Compute the time lapsed since the previous beginMonitoring() call.
  107639. * @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
  107640. */
  107641. endMonitoring(newFrame?: boolean): void;
  107642. private _fetchResult;
  107643. private _startMonitoringTime;
  107644. private _min;
  107645. private _max;
  107646. private _average;
  107647. private _current;
  107648. private _totalValueCount;
  107649. private _totalAccumulated;
  107650. private _lastSecAverage;
  107651. private _lastSecAccumulated;
  107652. private _lastSecTime;
  107653. private _lastSecValueCount;
  107654. }
  107655. }
  107656. declare module BABYLON {
  107657. interface ThinEngine {
  107658. /**
  107659. * Sets alpha constants used by some alpha blending modes
  107660. * @param r defines the red component
  107661. * @param g defines the green component
  107662. * @param b defines the blue component
  107663. * @param a defines the alpha component
  107664. */
  107665. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107666. /**
  107667. * Sets the current alpha mode
  107668. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107669. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107670. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107671. */
  107672. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107673. /**
  107674. * Gets the current alpha mode
  107675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107676. * @returns the current alpha mode
  107677. */
  107678. getAlphaMode(): number;
  107679. /**
  107680. * Sets the current alpha equation
  107681. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107682. */
  107683. setAlphaEquation(equation: number): void;
  107684. /**
  107685. * Gets the current alpha equation.
  107686. * @returns the current alpha equation
  107687. */
  107688. getAlphaEquation(): number;
  107689. }
  107690. }
  107691. declare module BABYLON {
  107692. /**
  107693. * Defines the interface used by display changed events
  107694. */
  107695. export interface IDisplayChangedEventArgs {
  107696. /** Gets the vrDisplay object (if any) */
  107697. vrDisplay: Nullable<any>;
  107698. /** Gets a boolean indicating if webVR is supported */
  107699. vrSupported: boolean;
  107700. }
  107701. /**
  107702. * Defines the interface used by objects containing a viewport (like a camera)
  107703. */
  107704. interface IViewportOwnerLike {
  107705. /**
  107706. * Gets or sets the viewport
  107707. */
  107708. viewport: IViewportLike;
  107709. }
  107710. /**
  107711. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107712. */
  107713. export class Engine extends ThinEngine {
  107714. /** Defines that alpha blending is disabled */
  107715. static readonly ALPHA_DISABLE: number;
  107716. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107717. static readonly ALPHA_ADD: number;
  107718. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107719. static readonly ALPHA_COMBINE: number;
  107720. /** Defines that alpha blending to DEST - SRC * DEST */
  107721. static readonly ALPHA_SUBTRACT: number;
  107722. /** Defines that alpha blending to SRC * DEST */
  107723. static readonly ALPHA_MULTIPLY: number;
  107724. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107725. static readonly ALPHA_MAXIMIZED: number;
  107726. /** Defines that alpha blending to SRC + DEST */
  107727. static readonly ALPHA_ONEONE: number;
  107728. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107729. static readonly ALPHA_PREMULTIPLIED: number;
  107730. /**
  107731. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107732. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107733. */
  107734. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107735. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107736. static readonly ALPHA_INTERPOLATE: number;
  107737. /**
  107738. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107739. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107740. */
  107741. static readonly ALPHA_SCREENMODE: number;
  107742. /** Defines that the ressource is not delayed*/
  107743. static readonly DELAYLOADSTATE_NONE: number;
  107744. /** Defines that the ressource was successfully delay loaded */
  107745. static readonly DELAYLOADSTATE_LOADED: number;
  107746. /** Defines that the ressource is currently delay loading */
  107747. static readonly DELAYLOADSTATE_LOADING: number;
  107748. /** Defines that the ressource is delayed and has not started loading */
  107749. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107751. static readonly NEVER: number;
  107752. /** 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 */
  107753. static readonly ALWAYS: number;
  107754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107755. static readonly LESS: number;
  107756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107757. static readonly EQUAL: number;
  107758. /** 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 */
  107759. static readonly LEQUAL: number;
  107760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107761. static readonly GREATER: number;
  107762. /** 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 */
  107763. static readonly GEQUAL: number;
  107764. /** 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 */
  107765. static readonly NOTEQUAL: number;
  107766. /** Passed to stencilOperation to specify that stencil value must be kept */
  107767. static readonly KEEP: number;
  107768. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107769. static readonly REPLACE: number;
  107770. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107771. static readonly INCR: number;
  107772. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107773. static readonly DECR: number;
  107774. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107775. static readonly INVERT: number;
  107776. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107777. static readonly INCR_WRAP: number;
  107778. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107779. static readonly DECR_WRAP: number;
  107780. /** Texture is not repeating outside of 0..1 UVs */
  107781. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107782. /** Texture is repeating outside of 0..1 UVs */
  107783. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107784. /** Texture is repeating and mirrored */
  107785. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107786. /** ALPHA */
  107787. static readonly TEXTUREFORMAT_ALPHA: number;
  107788. /** LUMINANCE */
  107789. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107790. /** LUMINANCE_ALPHA */
  107791. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107792. /** RGB */
  107793. static readonly TEXTUREFORMAT_RGB: number;
  107794. /** RGBA */
  107795. static readonly TEXTUREFORMAT_RGBA: number;
  107796. /** RED */
  107797. static readonly TEXTUREFORMAT_RED: number;
  107798. /** RED (2nd reference) */
  107799. static readonly TEXTUREFORMAT_R: number;
  107800. /** RG */
  107801. static readonly TEXTUREFORMAT_RG: number;
  107802. /** RED_INTEGER */
  107803. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107804. /** RED_INTEGER (2nd reference) */
  107805. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107806. /** RG_INTEGER */
  107807. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107808. /** RGB_INTEGER */
  107809. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107810. /** RGBA_INTEGER */
  107811. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107812. /** UNSIGNED_BYTE */
  107813. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107814. /** UNSIGNED_BYTE (2nd reference) */
  107815. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107816. /** FLOAT */
  107817. static readonly TEXTURETYPE_FLOAT: number;
  107818. /** HALF_FLOAT */
  107819. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107820. /** BYTE */
  107821. static readonly TEXTURETYPE_BYTE: number;
  107822. /** SHORT */
  107823. static readonly TEXTURETYPE_SHORT: number;
  107824. /** UNSIGNED_SHORT */
  107825. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107826. /** INT */
  107827. static readonly TEXTURETYPE_INT: number;
  107828. /** UNSIGNED_INT */
  107829. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107830. /** UNSIGNED_SHORT_4_4_4_4 */
  107831. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107832. /** UNSIGNED_SHORT_5_5_5_1 */
  107833. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107834. /** UNSIGNED_SHORT_5_6_5 */
  107835. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107836. /** UNSIGNED_INT_2_10_10_10_REV */
  107837. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107838. /** UNSIGNED_INT_24_8 */
  107839. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107840. /** UNSIGNED_INT_10F_11F_11F_REV */
  107841. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107842. /** UNSIGNED_INT_5_9_9_9_REV */
  107843. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107844. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107845. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107846. /** nearest is mag = nearest and min = nearest and mip = linear */
  107847. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107849. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107850. /** Trilinear is mag = linear and min = linear and mip = linear */
  107851. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107852. /** nearest is mag = nearest and min = nearest and mip = linear */
  107853. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107855. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107856. /** Trilinear is mag = linear and min = linear and mip = linear */
  107857. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107858. /** mag = nearest and min = nearest and mip = nearest */
  107859. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107860. /** mag = nearest and min = linear and mip = nearest */
  107861. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107862. /** mag = nearest and min = linear and mip = linear */
  107863. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107864. /** mag = nearest and min = linear and mip = none */
  107865. static readonly TEXTURE_NEAREST_LINEAR: number;
  107866. /** mag = nearest and min = nearest and mip = none */
  107867. static readonly TEXTURE_NEAREST_NEAREST: number;
  107868. /** mag = linear and min = nearest and mip = nearest */
  107869. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107870. /** mag = linear and min = nearest and mip = linear */
  107871. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107872. /** mag = linear and min = linear and mip = none */
  107873. static readonly TEXTURE_LINEAR_LINEAR: number;
  107874. /** mag = linear and min = nearest and mip = none */
  107875. static readonly TEXTURE_LINEAR_NEAREST: number;
  107876. /** Explicit coordinates mode */
  107877. static readonly TEXTURE_EXPLICIT_MODE: number;
  107878. /** Spherical coordinates mode */
  107879. static readonly TEXTURE_SPHERICAL_MODE: number;
  107880. /** Planar coordinates mode */
  107881. static readonly TEXTURE_PLANAR_MODE: number;
  107882. /** Cubic coordinates mode */
  107883. static readonly TEXTURE_CUBIC_MODE: number;
  107884. /** Projection coordinates mode */
  107885. static readonly TEXTURE_PROJECTION_MODE: number;
  107886. /** Skybox coordinates mode */
  107887. static readonly TEXTURE_SKYBOX_MODE: number;
  107888. /** Inverse Cubic coordinates mode */
  107889. static readonly TEXTURE_INVCUBIC_MODE: number;
  107890. /** Equirectangular coordinates mode */
  107891. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107892. /** Equirectangular Fixed coordinates mode */
  107893. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107894. /** Equirectangular Fixed Mirrored coordinates mode */
  107895. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107896. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107897. static readonly SCALEMODE_FLOOR: number;
  107898. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107899. static readonly SCALEMODE_NEAREST: number;
  107900. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107901. static readonly SCALEMODE_CEILING: number;
  107902. /**
  107903. * Returns the current npm package of the sdk
  107904. */
  107905. static get NpmPackage(): string;
  107906. /**
  107907. * Returns the current version of the framework
  107908. */
  107909. static get Version(): string;
  107910. /** Gets the list of created engines */
  107911. static get Instances(): Engine[];
  107912. /**
  107913. * Gets the latest created engine
  107914. */
  107915. static get LastCreatedEngine(): Nullable<Engine>;
  107916. /**
  107917. * Gets the latest created scene
  107918. */
  107919. static get LastCreatedScene(): Nullable<Scene>;
  107920. /**
  107921. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107922. * @param flag defines which part of the materials must be marked as dirty
  107923. * @param predicate defines a predicate used to filter which materials should be affected
  107924. */
  107925. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107926. /**
  107927. * Method called to create the default loading screen.
  107928. * This can be overriden in your own app.
  107929. * @param canvas The rendering canvas element
  107930. * @returns The loading screen
  107931. */
  107932. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107933. /**
  107934. * Method called to create the default rescale post process on each engine.
  107935. */
  107936. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107937. /**
  107938. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107939. **/
  107940. enableOfflineSupport: boolean;
  107941. /**
  107942. * 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)
  107943. **/
  107944. disableManifestCheck: boolean;
  107945. /**
  107946. * Gets the list of created scenes
  107947. */
  107948. scenes: Scene[];
  107949. /**
  107950. * Event raised when a new scene is created
  107951. */
  107952. onNewSceneAddedObservable: Observable<Scene>;
  107953. /**
  107954. * Gets the list of created postprocesses
  107955. */
  107956. postProcesses: PostProcess[];
  107957. /**
  107958. * Gets a boolean indicating if the pointer is currently locked
  107959. */
  107960. isPointerLock: boolean;
  107961. /**
  107962. * Observable event triggered each time the rendering canvas is resized
  107963. */
  107964. onResizeObservable: Observable<Engine>;
  107965. /**
  107966. * Observable event triggered each time the canvas loses focus
  107967. */
  107968. onCanvasBlurObservable: Observable<Engine>;
  107969. /**
  107970. * Observable event triggered each time the canvas gains focus
  107971. */
  107972. onCanvasFocusObservable: Observable<Engine>;
  107973. /**
  107974. * Observable event triggered each time the canvas receives pointerout event
  107975. */
  107976. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107977. /**
  107978. * Observable raised when the engine begins a new frame
  107979. */
  107980. onBeginFrameObservable: Observable<Engine>;
  107981. /**
  107982. * If set, will be used to request the next animation frame for the render loop
  107983. */
  107984. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107985. /**
  107986. * Observable raised when the engine ends the current frame
  107987. */
  107988. onEndFrameObservable: Observable<Engine>;
  107989. /**
  107990. * Observable raised when the engine is about to compile a shader
  107991. */
  107992. onBeforeShaderCompilationObservable: Observable<Engine>;
  107993. /**
  107994. * Observable raised when the engine has jsut compiled a shader
  107995. */
  107996. onAfterShaderCompilationObservable: Observable<Engine>;
  107997. /**
  107998. * Gets the audio engine
  107999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108000. * @ignorenaming
  108001. */
  108002. static audioEngine: IAudioEngine;
  108003. /**
  108004. * Default AudioEngine factory responsible of creating the Audio Engine.
  108005. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  108006. */
  108007. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  108008. /**
  108009. * Default offline support factory responsible of creating a tool used to store data locally.
  108010. * By default, this will create a Database object if the workload has been embedded.
  108011. */
  108012. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  108013. private _loadingScreen;
  108014. private _pointerLockRequested;
  108015. private _dummyFramebuffer;
  108016. private _rescalePostProcess;
  108017. private _deterministicLockstep;
  108018. private _lockstepMaxSteps;
  108019. private _timeStep;
  108020. protected get _supportsHardwareTextureRescaling(): boolean;
  108021. private _fps;
  108022. private _deltaTime;
  108023. /** @hidden */
  108024. _drawCalls: PerfCounter;
  108025. /** 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 */
  108026. canvasTabIndex: number;
  108027. /**
  108028. * Turn this value on if you want to pause FPS computation when in background
  108029. */
  108030. disablePerformanceMonitorInBackground: boolean;
  108031. private _performanceMonitor;
  108032. /**
  108033. * Gets the performance monitor attached to this engine
  108034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108035. */
  108036. get performanceMonitor(): PerformanceMonitor;
  108037. private _onFocus;
  108038. private _onBlur;
  108039. private _onCanvasPointerOut;
  108040. private _onCanvasBlur;
  108041. private _onCanvasFocus;
  108042. private _onFullscreenChange;
  108043. private _onPointerLockChange;
  108044. /**
  108045. * Gets the HTML element used to attach event listeners
  108046. * @returns a HTML element
  108047. */
  108048. getInputElement(): Nullable<HTMLElement>;
  108049. /**
  108050. * Creates a new engine
  108051. * @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
  108052. * @param antialias defines enable antialiasing (default: false)
  108053. * @param options defines further options to be sent to the getContext() function
  108054. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108055. */
  108056. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108057. /**
  108058. * Gets current aspect ratio
  108059. * @param viewportOwner defines the camera to use to get the aspect ratio
  108060. * @param useScreen defines if screen size must be used (or the current render target if any)
  108061. * @returns a number defining the aspect ratio
  108062. */
  108063. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108064. /**
  108065. * Gets current screen aspect ratio
  108066. * @returns a number defining the aspect ratio
  108067. */
  108068. getScreenAspectRatio(): number;
  108069. /**
  108070. * Gets the client rect of the HTML canvas attached with the current webGL context
  108071. * @returns a client rectanglee
  108072. */
  108073. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108074. /**
  108075. * Gets the client rect of the HTML element used for events
  108076. * @returns a client rectanglee
  108077. */
  108078. getInputElementClientRect(): Nullable<ClientRect>;
  108079. /**
  108080. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108082. * @returns true if engine is in deterministic lock step mode
  108083. */
  108084. isDeterministicLockStep(): boolean;
  108085. /**
  108086. * Gets the max steps when engine is running in deterministic lock step
  108087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108088. * @returns the max steps
  108089. */
  108090. getLockstepMaxSteps(): number;
  108091. /**
  108092. * Returns the time in ms between steps when using deterministic lock step.
  108093. * @returns time step in (ms)
  108094. */
  108095. getTimeStep(): number;
  108096. /**
  108097. * Force the mipmap generation for the given render target texture
  108098. * @param texture defines the render target texture to use
  108099. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108100. */
  108101. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108102. /** States */
  108103. /**
  108104. * Set various states to the webGL context
  108105. * @param culling defines backface culling state
  108106. * @param zOffset defines the value to apply to zOffset (0 by default)
  108107. * @param force defines if states must be applied even if cache is up to date
  108108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108109. */
  108110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108111. /**
  108112. * Set the z offset to apply to current rendering
  108113. * @param value defines the offset to apply
  108114. */
  108115. setZOffset(value: number): void;
  108116. /**
  108117. * Gets the current value of the zOffset
  108118. * @returns the current zOffset state
  108119. */
  108120. getZOffset(): number;
  108121. /**
  108122. * Enable or disable depth buffering
  108123. * @param enable defines the state to set
  108124. */
  108125. setDepthBuffer(enable: boolean): void;
  108126. /**
  108127. * Gets a boolean indicating if depth writing is enabled
  108128. * @returns the current depth writing state
  108129. */
  108130. getDepthWrite(): boolean;
  108131. /**
  108132. * Enable or disable depth writing
  108133. * @param enable defines the state to set
  108134. */
  108135. setDepthWrite(enable: boolean): void;
  108136. /**
  108137. * Gets a boolean indicating if stencil buffer is enabled
  108138. * @returns the current stencil buffer state
  108139. */
  108140. getStencilBuffer(): boolean;
  108141. /**
  108142. * Enable or disable the stencil buffer
  108143. * @param enable defines if the stencil buffer must be enabled or disabled
  108144. */
  108145. setStencilBuffer(enable: boolean): void;
  108146. /**
  108147. * Gets the current stencil mask
  108148. * @returns a number defining the new stencil mask to use
  108149. */
  108150. getStencilMask(): number;
  108151. /**
  108152. * Sets the current stencil mask
  108153. * @param mask defines the new stencil mask to use
  108154. */
  108155. setStencilMask(mask: number): void;
  108156. /**
  108157. * Gets the current stencil function
  108158. * @returns a number defining the stencil function to use
  108159. */
  108160. getStencilFunction(): number;
  108161. /**
  108162. * Gets the current stencil reference value
  108163. * @returns a number defining the stencil reference value to use
  108164. */
  108165. getStencilFunctionReference(): number;
  108166. /**
  108167. * Gets the current stencil mask
  108168. * @returns a number defining the stencil mask to use
  108169. */
  108170. getStencilFunctionMask(): number;
  108171. /**
  108172. * Sets the current stencil function
  108173. * @param stencilFunc defines the new stencil function to use
  108174. */
  108175. setStencilFunction(stencilFunc: number): void;
  108176. /**
  108177. * Sets the current stencil reference
  108178. * @param reference defines the new stencil reference to use
  108179. */
  108180. setStencilFunctionReference(reference: number): void;
  108181. /**
  108182. * Sets the current stencil mask
  108183. * @param mask defines the new stencil mask to use
  108184. */
  108185. setStencilFunctionMask(mask: number): void;
  108186. /**
  108187. * Gets the current stencil operation when stencil fails
  108188. * @returns a number defining stencil operation to use when stencil fails
  108189. */
  108190. getStencilOperationFail(): number;
  108191. /**
  108192. * Gets the current stencil operation when depth fails
  108193. * @returns a number defining stencil operation to use when depth fails
  108194. */
  108195. getStencilOperationDepthFail(): number;
  108196. /**
  108197. * Gets the current stencil operation when stencil passes
  108198. * @returns a number defining stencil operation to use when stencil passes
  108199. */
  108200. getStencilOperationPass(): number;
  108201. /**
  108202. * Sets the stencil operation to use when stencil fails
  108203. * @param operation defines the stencil operation to use when stencil fails
  108204. */
  108205. setStencilOperationFail(operation: number): void;
  108206. /**
  108207. * Sets the stencil operation to use when depth fails
  108208. * @param operation defines the stencil operation to use when depth fails
  108209. */
  108210. setStencilOperationDepthFail(operation: number): void;
  108211. /**
  108212. * Sets the stencil operation to use when stencil passes
  108213. * @param operation defines the stencil operation to use when stencil passes
  108214. */
  108215. setStencilOperationPass(operation: number): void;
  108216. /**
  108217. * Sets a boolean indicating if the dithering state is enabled or disabled
  108218. * @param value defines the dithering state
  108219. */
  108220. setDitheringState(value: boolean): void;
  108221. /**
  108222. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108223. * @param value defines the rasterizer state
  108224. */
  108225. setRasterizerState(value: boolean): void;
  108226. /**
  108227. * Gets the current depth function
  108228. * @returns a number defining the depth function
  108229. */
  108230. getDepthFunction(): Nullable<number>;
  108231. /**
  108232. * Sets the current depth function
  108233. * @param depthFunc defines the function to use
  108234. */
  108235. setDepthFunction(depthFunc: number): void;
  108236. /**
  108237. * Sets the current depth function to GREATER
  108238. */
  108239. setDepthFunctionToGreater(): void;
  108240. /**
  108241. * Sets the current depth function to GEQUAL
  108242. */
  108243. setDepthFunctionToGreaterOrEqual(): void;
  108244. /**
  108245. * Sets the current depth function to LESS
  108246. */
  108247. setDepthFunctionToLess(): void;
  108248. /**
  108249. * Sets the current depth function to LEQUAL
  108250. */
  108251. setDepthFunctionToLessOrEqual(): void;
  108252. private _cachedStencilBuffer;
  108253. private _cachedStencilFunction;
  108254. private _cachedStencilMask;
  108255. private _cachedStencilOperationPass;
  108256. private _cachedStencilOperationFail;
  108257. private _cachedStencilOperationDepthFail;
  108258. private _cachedStencilReference;
  108259. /**
  108260. * Caches the the state of the stencil buffer
  108261. */
  108262. cacheStencilState(): void;
  108263. /**
  108264. * Restores the state of the stencil buffer
  108265. */
  108266. restoreStencilState(): void;
  108267. /**
  108268. * Directly set the WebGL Viewport
  108269. * @param x defines the x coordinate of the viewport (in screen space)
  108270. * @param y defines the y coordinate of the viewport (in screen space)
  108271. * @param width defines the width of the viewport (in screen space)
  108272. * @param height defines the height of the viewport (in screen space)
  108273. * @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
  108274. */
  108275. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108276. /**
  108277. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108278. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108279. * @param y defines the y-coordinate of the corner of the clear rectangle
  108280. * @param width defines the width of the clear rectangle
  108281. * @param height defines the height of the clear rectangle
  108282. * @param clearColor defines the clear color
  108283. */
  108284. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108285. /**
  108286. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108287. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108288. * @param y defines the y-coordinate of the corner of the clear rectangle
  108289. * @param width defines the width of the clear rectangle
  108290. * @param height defines the height of the clear rectangle
  108291. */
  108292. enableScissor(x: number, y: number, width: number, height: number): void;
  108293. /**
  108294. * Disable previously set scissor test rectangle
  108295. */
  108296. disableScissor(): void;
  108297. protected _reportDrawCall(): void;
  108298. /**
  108299. * Initializes a webVR display and starts listening to display change events
  108300. * The onVRDisplayChangedObservable will be notified upon these changes
  108301. * @returns The onVRDisplayChangedObservable
  108302. */
  108303. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108304. /** @hidden */
  108305. _prepareVRComponent(): void;
  108306. /** @hidden */
  108307. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108308. /** @hidden */
  108309. _submitVRFrame(): void;
  108310. /**
  108311. * Call this function to leave webVR mode
  108312. * Will do nothing if webVR is not supported or if there is no webVR device
  108313. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108314. */
  108315. disableVR(): void;
  108316. /**
  108317. * Gets a boolean indicating that the system is in VR mode and is presenting
  108318. * @returns true if VR mode is engaged
  108319. */
  108320. isVRPresenting(): boolean;
  108321. /** @hidden */
  108322. _requestVRFrame(): void;
  108323. /** @hidden */
  108324. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108325. /**
  108326. * Gets the source code of the vertex shader associated with a specific webGL program
  108327. * @param program defines the program to use
  108328. * @returns a string containing the source code of the vertex shader associated with the program
  108329. */
  108330. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108331. /**
  108332. * Gets the source code of the fragment shader associated with a specific webGL program
  108333. * @param program defines the program to use
  108334. * @returns a string containing the source code of the fragment shader associated with the program
  108335. */
  108336. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108337. /**
  108338. * Sets a depth stencil texture from a render target to the according uniform.
  108339. * @param channel The texture channel
  108340. * @param uniform The uniform to set
  108341. * @param texture The render target texture containing the depth stencil texture to apply
  108342. */
  108343. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108344. /**
  108345. * Sets a texture to the webGL context from a postprocess
  108346. * @param channel defines the channel to use
  108347. * @param postProcess defines the source postprocess
  108348. */
  108349. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108350. /**
  108351. * Binds the output of the passed in post process to the texture channel specified
  108352. * @param channel The channel the texture should be bound to
  108353. * @param postProcess The post process which's output should be bound
  108354. */
  108355. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108356. /** @hidden */
  108357. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108358. protected _rebuildBuffers(): void;
  108359. /** @hidden */
  108360. _renderFrame(): void;
  108361. _renderLoop(): void;
  108362. /** @hidden */
  108363. _renderViews(): boolean;
  108364. /**
  108365. * Toggle full screen mode
  108366. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108367. */
  108368. switchFullscreen(requestPointerLock: boolean): void;
  108369. /**
  108370. * Enters full screen mode
  108371. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108372. */
  108373. enterFullscreen(requestPointerLock: boolean): void;
  108374. /**
  108375. * Exits full screen mode
  108376. */
  108377. exitFullscreen(): void;
  108378. /**
  108379. * Enters Pointerlock mode
  108380. */
  108381. enterPointerlock(): void;
  108382. /**
  108383. * Exits Pointerlock mode
  108384. */
  108385. exitPointerlock(): void;
  108386. /**
  108387. * Begin a new frame
  108388. */
  108389. beginFrame(): void;
  108390. /**
  108391. * Enf the current frame
  108392. */
  108393. endFrame(): void;
  108394. resize(): void;
  108395. /**
  108396. * Force a specific size of the canvas
  108397. * @param width defines the new canvas' width
  108398. * @param height defines the new canvas' height
  108399. */
  108400. setSize(width: number, height: number): void;
  108401. /**
  108402. * Updates a dynamic vertex buffer.
  108403. * @param vertexBuffer the vertex buffer to update
  108404. * @param data the data used to update the vertex buffer
  108405. * @param byteOffset the byte offset of the data
  108406. * @param byteLength the byte length of the data
  108407. */
  108408. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108409. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108410. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108411. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108412. _releaseTexture(texture: InternalTexture): void;
  108413. /**
  108414. * @hidden
  108415. * Rescales a texture
  108416. * @param source input texutre
  108417. * @param destination destination texture
  108418. * @param scene scene to use to render the resize
  108419. * @param internalFormat format to use when resizing
  108420. * @param onComplete callback to be called when resize has completed
  108421. */
  108422. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108423. /**
  108424. * Gets the current framerate
  108425. * @returns a number representing the framerate
  108426. */
  108427. getFps(): number;
  108428. /**
  108429. * Gets the time spent between current and previous frame
  108430. * @returns a number representing the delta time in ms
  108431. */
  108432. getDeltaTime(): number;
  108433. private _measureFps;
  108434. /** @hidden */
  108435. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108436. /**
  108437. * Update a dynamic index buffer
  108438. * @param indexBuffer defines the target index buffer
  108439. * @param indices defines the data to update
  108440. * @param offset defines the offset in the target index buffer where update should start
  108441. */
  108442. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108443. /**
  108444. * Updates the sample count of a render target texture
  108445. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108446. * @param texture defines the texture to update
  108447. * @param samples defines the sample count to set
  108448. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108449. */
  108450. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108451. /**
  108452. * Updates a depth texture Comparison Mode and Function.
  108453. * If the comparison Function is equal to 0, the mode will be set to none.
  108454. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108455. * @param texture The texture to set the comparison function for
  108456. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108457. */
  108458. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108459. /**
  108460. * Creates a webGL buffer to use with instanciation
  108461. * @param capacity defines the size of the buffer
  108462. * @returns the webGL buffer
  108463. */
  108464. createInstancesBuffer(capacity: number): DataBuffer;
  108465. /**
  108466. * Delete a webGL buffer used with instanciation
  108467. * @param buffer defines the webGL buffer to delete
  108468. */
  108469. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108470. private _clientWaitAsync;
  108471. /** @hidden */
  108472. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108473. /** @hidden */
  108474. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108475. dispose(): void;
  108476. private _disableTouchAction;
  108477. /**
  108478. * Display the loading screen
  108479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108480. */
  108481. displayLoadingUI(): void;
  108482. /**
  108483. * Hide the loading screen
  108484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108485. */
  108486. hideLoadingUI(): void;
  108487. /**
  108488. * Gets the current loading screen object
  108489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108490. */
  108491. get loadingScreen(): ILoadingScreen;
  108492. /**
  108493. * Sets the current loading screen object
  108494. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108495. */
  108496. set loadingScreen(loadingScreen: ILoadingScreen);
  108497. /**
  108498. * Sets the current loading screen text
  108499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108500. */
  108501. set loadingUIText(text: string);
  108502. /**
  108503. * Sets the current loading screen background color
  108504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108505. */
  108506. set loadingUIBackgroundColor(color: string);
  108507. /** Pointerlock and fullscreen */
  108508. /**
  108509. * Ask the browser to promote the current element to pointerlock mode
  108510. * @param element defines the DOM element to promote
  108511. */
  108512. static _RequestPointerlock(element: HTMLElement): void;
  108513. /**
  108514. * Asks the browser to exit pointerlock mode
  108515. */
  108516. static _ExitPointerlock(): void;
  108517. /**
  108518. * Ask the browser to promote the current element to fullscreen rendering mode
  108519. * @param element defines the DOM element to promote
  108520. */
  108521. static _RequestFullscreen(element: HTMLElement): void;
  108522. /**
  108523. * Asks the browser to exit fullscreen mode
  108524. */
  108525. static _ExitFullscreen(): void;
  108526. }
  108527. }
  108528. declare module BABYLON {
  108529. /**
  108530. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108531. * during the life time of the application.
  108532. */
  108533. export class EngineStore {
  108534. /** Gets the list of created engines */
  108535. static Instances: Engine[];
  108536. /** @hidden */
  108537. static _LastCreatedScene: Nullable<Scene>;
  108538. /**
  108539. * Gets the latest created engine
  108540. */
  108541. static get LastCreatedEngine(): Nullable<Engine>;
  108542. /**
  108543. * Gets the latest created scene
  108544. */
  108545. static get LastCreatedScene(): Nullable<Scene>;
  108546. /**
  108547. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108548. * @ignorenaming
  108549. */
  108550. static UseFallbackTexture: boolean;
  108551. /**
  108552. * Texture content used if a texture cannot loaded
  108553. * @ignorenaming
  108554. */
  108555. static FallbackTexture: string;
  108556. }
  108557. }
  108558. declare module BABYLON {
  108559. /**
  108560. * Helper class that provides a small promise polyfill
  108561. */
  108562. export class PromisePolyfill {
  108563. /**
  108564. * Static function used to check if the polyfill is required
  108565. * If this is the case then the function will inject the polyfill to window.Promise
  108566. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108567. */
  108568. static Apply(force?: boolean): void;
  108569. }
  108570. }
  108571. declare module BABYLON {
  108572. /**
  108573. * Interface for screenshot methods with describe argument called `size` as object with options
  108574. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108575. */
  108576. export interface IScreenshotSize {
  108577. /**
  108578. * number in pixels for canvas height
  108579. */
  108580. height?: number;
  108581. /**
  108582. * multiplier allowing render at a higher or lower resolution
  108583. * If value is defined then height and width will be ignored and taken from camera
  108584. */
  108585. precision?: number;
  108586. /**
  108587. * number in pixels for canvas width
  108588. */
  108589. width?: number;
  108590. }
  108591. }
  108592. declare module BABYLON {
  108593. interface IColor4Like {
  108594. r: float;
  108595. g: float;
  108596. b: float;
  108597. a: float;
  108598. }
  108599. /**
  108600. * Class containing a set of static utilities functions
  108601. */
  108602. export class Tools {
  108603. /**
  108604. * Gets or sets the base URL to use to load assets
  108605. */
  108606. static get BaseUrl(): string;
  108607. static set BaseUrl(value: string);
  108608. /**
  108609. * Enable/Disable Custom HTTP Request Headers globally.
  108610. * default = false
  108611. * @see CustomRequestHeaders
  108612. */
  108613. static UseCustomRequestHeaders: boolean;
  108614. /**
  108615. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108616. * i.e. when loading files, where the server/service expects an Authorization header
  108617. */
  108618. static CustomRequestHeaders: {
  108619. [key: string]: string;
  108620. };
  108621. /**
  108622. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108623. */
  108624. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108625. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108626. /**
  108627. * Default behaviour for cors in the application.
  108628. * It can be a string if the expected behavior is identical in the entire app.
  108629. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108630. */
  108631. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108632. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108633. /**
  108634. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108635. * @ignorenaming
  108636. */
  108637. static get UseFallbackTexture(): boolean;
  108638. static set UseFallbackTexture(value: boolean);
  108639. /**
  108640. * Use this object to register external classes like custom textures or material
  108641. * to allow the laoders to instantiate them
  108642. */
  108643. static get RegisteredExternalClasses(): {
  108644. [key: string]: Object;
  108645. };
  108646. static set RegisteredExternalClasses(classes: {
  108647. [key: string]: Object;
  108648. });
  108649. /**
  108650. * Texture content used if a texture cannot loaded
  108651. * @ignorenaming
  108652. */
  108653. static get fallbackTexture(): string;
  108654. static set fallbackTexture(value: string);
  108655. /**
  108656. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108657. * @param u defines the coordinate on X axis
  108658. * @param v defines the coordinate on Y axis
  108659. * @param width defines the width of the source data
  108660. * @param height defines the height of the source data
  108661. * @param pixels defines the source byte array
  108662. * @param color defines the output color
  108663. */
  108664. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108665. /**
  108666. * Interpolates between a and b via alpha
  108667. * @param a The lower value (returned when alpha = 0)
  108668. * @param b The upper value (returned when alpha = 1)
  108669. * @param alpha The interpolation-factor
  108670. * @return The mixed value
  108671. */
  108672. static Mix(a: number, b: number, alpha: number): number;
  108673. /**
  108674. * Tries to instantiate a new object from a given class name
  108675. * @param className defines the class name to instantiate
  108676. * @returns the new object or null if the system was not able to do the instantiation
  108677. */
  108678. static Instantiate(className: string): any;
  108679. /**
  108680. * Provides a slice function that will work even on IE
  108681. * @param data defines the array to slice
  108682. * @param start defines the start of the data (optional)
  108683. * @param end defines the end of the data (optional)
  108684. * @returns the new sliced array
  108685. */
  108686. static Slice<T>(data: T, start?: number, end?: number): T;
  108687. /**
  108688. * Polyfill for setImmediate
  108689. * @param action defines the action to execute after the current execution block
  108690. */
  108691. static SetImmediate(action: () => void): void;
  108692. /**
  108693. * Function indicating if a number is an exponent of 2
  108694. * @param value defines the value to test
  108695. * @returns true if the value is an exponent of 2
  108696. */
  108697. static IsExponentOfTwo(value: number): boolean;
  108698. private static _tmpFloatArray;
  108699. /**
  108700. * Returns the nearest 32-bit single precision float representation of a Number
  108701. * @param value A Number. If the parameter is of a different type, it will get converted
  108702. * to a number or to NaN if it cannot be converted
  108703. * @returns number
  108704. */
  108705. static FloatRound(value: number): number;
  108706. /**
  108707. * Extracts the filename from a path
  108708. * @param path defines the path to use
  108709. * @returns the filename
  108710. */
  108711. static GetFilename(path: string): string;
  108712. /**
  108713. * Extracts the "folder" part of a path (everything before the filename).
  108714. * @param uri The URI to extract the info from
  108715. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108716. * @returns The "folder" part of the path
  108717. */
  108718. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108719. /**
  108720. * Extracts text content from a DOM element hierarchy
  108721. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108722. */
  108723. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108724. /**
  108725. * Convert an angle in radians to degrees
  108726. * @param angle defines the angle to convert
  108727. * @returns the angle in degrees
  108728. */
  108729. static ToDegrees(angle: number): number;
  108730. /**
  108731. * Convert an angle in degrees to radians
  108732. * @param angle defines the angle to convert
  108733. * @returns the angle in radians
  108734. */
  108735. static ToRadians(angle: number): number;
  108736. /**
  108737. * Returns an array if obj is not an array
  108738. * @param obj defines the object to evaluate as an array
  108739. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108740. * @returns either obj directly if obj is an array or a new array containing obj
  108741. */
  108742. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108743. /**
  108744. * Gets the pointer prefix to use
  108745. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108746. */
  108747. static GetPointerPrefix(): string;
  108748. /**
  108749. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108750. * @param url define the url we are trying
  108751. * @param element define the dom element where to configure the cors policy
  108752. */
  108753. static SetCorsBehavior(url: string | string[], element: {
  108754. crossOrigin: string | null;
  108755. }): void;
  108756. /**
  108757. * Removes unwanted characters from an url
  108758. * @param url defines the url to clean
  108759. * @returns the cleaned url
  108760. */
  108761. static CleanUrl(url: string): string;
  108762. /**
  108763. * Gets or sets a function used to pre-process url before using them to load assets
  108764. */
  108765. static get PreprocessUrl(): (url: string) => string;
  108766. static set PreprocessUrl(processor: (url: string) => string);
  108767. /**
  108768. * Loads an image as an HTMLImageElement.
  108769. * @param input url string, ArrayBuffer, or Blob to load
  108770. * @param onLoad callback called when the image successfully loads
  108771. * @param onError callback called when the image fails to load
  108772. * @param offlineProvider offline provider for caching
  108773. * @param mimeType optional mime type
  108774. * @returns the HTMLImageElement of the loaded image
  108775. */
  108776. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108777. /**
  108778. * Loads a file from a url
  108779. * @param url url string, ArrayBuffer, or Blob to load
  108780. * @param onSuccess callback called when the file successfully loads
  108781. * @param onProgress callback called while file is loading (if the server supports this mode)
  108782. * @param offlineProvider defines the offline provider for caching
  108783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108784. * @param onError callback called when the file fails to load
  108785. * @returns a file request object
  108786. */
  108787. 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;
  108788. /**
  108789. * Loads a file from a url
  108790. * @param url the file url to load
  108791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108792. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108793. */
  108794. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108795. /**
  108796. * Load a script (identified by an url). When the url returns, the
  108797. * content of this file is added into a new script element, attached to the DOM (body element)
  108798. * @param scriptUrl defines the url of the script to laod
  108799. * @param onSuccess defines the callback called when the script is loaded
  108800. * @param onError defines the callback to call if an error occurs
  108801. * @param scriptId defines the id of the script element
  108802. */
  108803. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108804. /**
  108805. * Load an asynchronous script (identified by an url). When the url returns, the
  108806. * content of this file is added into a new script element, attached to the DOM (body element)
  108807. * @param scriptUrl defines the url of the script to laod
  108808. * @param scriptId defines the id of the script element
  108809. * @returns a promise request object
  108810. */
  108811. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108812. /**
  108813. * Loads a file from a blob
  108814. * @param fileToLoad defines the blob to use
  108815. * @param callback defines the callback to call when data is loaded
  108816. * @param progressCallback defines the callback to call during loading process
  108817. * @returns a file request object
  108818. */
  108819. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108820. /**
  108821. * Reads a file from a File object
  108822. * @param file defines the file to load
  108823. * @param onSuccess defines the callback to call when data is loaded
  108824. * @param onProgress defines the callback to call during loading process
  108825. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108826. * @param onError defines the callback to call when an error occurs
  108827. * @returns a file request object
  108828. */
  108829. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108830. /**
  108831. * Creates a data url from a given string content
  108832. * @param content defines the content to convert
  108833. * @returns the new data url link
  108834. */
  108835. static FileAsURL(content: string): string;
  108836. /**
  108837. * Format the given number to a specific decimal format
  108838. * @param value defines the number to format
  108839. * @param decimals defines the number of decimals to use
  108840. * @returns the formatted string
  108841. */
  108842. static Format(value: number, decimals?: number): string;
  108843. /**
  108844. * Tries to copy an object by duplicating every property
  108845. * @param source defines the source object
  108846. * @param destination defines the target object
  108847. * @param doNotCopyList defines a list of properties to avoid
  108848. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108849. */
  108850. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108851. /**
  108852. * Gets a boolean indicating if the given object has no own property
  108853. * @param obj defines the object to test
  108854. * @returns true if object has no own property
  108855. */
  108856. static IsEmpty(obj: any): boolean;
  108857. /**
  108858. * Function used to register events at window level
  108859. * @param windowElement defines the Window object to use
  108860. * @param events defines the events to register
  108861. */
  108862. static RegisterTopRootEvents(windowElement: Window, events: {
  108863. name: string;
  108864. handler: Nullable<(e: FocusEvent) => any>;
  108865. }[]): void;
  108866. /**
  108867. * Function used to unregister events from window level
  108868. * @param windowElement defines the Window object to use
  108869. * @param events defines the events to unregister
  108870. */
  108871. static UnregisterTopRootEvents(windowElement: Window, events: {
  108872. name: string;
  108873. handler: Nullable<(e: FocusEvent) => any>;
  108874. }[]): void;
  108875. /**
  108876. * @ignore
  108877. */
  108878. static _ScreenshotCanvas: HTMLCanvasElement;
  108879. /**
  108880. * Dumps the current bound framebuffer
  108881. * @param width defines the rendering width
  108882. * @param height defines the rendering height
  108883. * @param engine defines the hosting engine
  108884. * @param successCallback defines the callback triggered once the data are available
  108885. * @param mimeType defines the mime type of the result
  108886. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108887. */
  108888. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108889. /**
  108890. * Converts the canvas data to blob.
  108891. * This acts as a polyfill for browsers not supporting the to blob function.
  108892. * @param canvas Defines the canvas to extract the data from
  108893. * @param successCallback Defines the callback triggered once the data are available
  108894. * @param mimeType Defines the mime type of the result
  108895. */
  108896. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108897. /**
  108898. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108899. * @param successCallback defines the callback triggered once the data are available
  108900. * @param mimeType defines the mime type of the result
  108901. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108902. */
  108903. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108904. /**
  108905. * Downloads a blob in the browser
  108906. * @param blob defines the blob to download
  108907. * @param fileName defines the name of the downloaded file
  108908. */
  108909. static Download(blob: Blob, fileName: string): void;
  108910. /**
  108911. * Captures a screenshot of the current rendering
  108912. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108913. * @param engine defines the rendering engine
  108914. * @param camera defines the source camera
  108915. * @param size This parameter can be set to a single number or to an object with the
  108916. * following (optional) properties: precision, width, height. If a single number is passed,
  108917. * it will be used for both width and height. If an object is passed, the screenshot size
  108918. * will be derived from the parameters. The precision property is a multiplier allowing
  108919. * rendering at a higher or lower resolution
  108920. * @param successCallback defines the callback receives a single parameter which contains the
  108921. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108922. * src parameter of an <img> to display it
  108923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108924. * Check your browser for supported MIME types
  108925. */
  108926. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108927. /**
  108928. * Captures a screenshot of the current rendering
  108929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108930. * @param engine defines the rendering engine
  108931. * @param camera defines the source camera
  108932. * @param size This parameter can be set to a single number or to an object with the
  108933. * following (optional) properties: precision, width, height. If a single number is passed,
  108934. * it will be used for both width and height. If an object is passed, the screenshot size
  108935. * will be derived from the parameters. The precision property is a multiplier allowing
  108936. * rendering at a higher or lower resolution
  108937. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108938. * Check your browser for supported MIME types
  108939. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108940. * to the src parameter of an <img> to display it
  108941. */
  108942. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108943. /**
  108944. * Generates an image screenshot from the specified camera.
  108945. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108946. * @param engine The engine to use for rendering
  108947. * @param camera The camera to use for rendering
  108948. * @param size This parameter can be set to a single number or to an object with the
  108949. * following (optional) properties: precision, width, height. If a single number is passed,
  108950. * it will be used for both width and height. If an object is passed, the screenshot size
  108951. * will be derived from the parameters. The precision property is a multiplier allowing
  108952. * rendering at a higher or lower resolution
  108953. * @param successCallback The callback receives a single parameter which contains the
  108954. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108955. * src parameter of an <img> to display it
  108956. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108957. * Check your browser for supported MIME types
  108958. * @param samples Texture samples (default: 1)
  108959. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108960. * @param fileName A name for for the downloaded file.
  108961. */
  108962. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108963. /**
  108964. * Generates an image screenshot from the specified camera.
  108965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108966. * @param engine The engine to use for rendering
  108967. * @param camera The camera to use for rendering
  108968. * @param size This parameter can be set to a single number or to an object with the
  108969. * following (optional) properties: precision, width, height. If a single number is passed,
  108970. * it will be used for both width and height. If an object is passed, the screenshot size
  108971. * will be derived from the parameters. The precision property is a multiplier allowing
  108972. * rendering at a higher or lower resolution
  108973. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108974. * Check your browser for supported MIME types
  108975. * @param samples Texture samples (default: 1)
  108976. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108977. * @param fileName A name for for the downloaded file.
  108978. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108979. * to the src parameter of an <img> to display it
  108980. */
  108981. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108982. /**
  108983. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108984. * Be aware Math.random() could cause collisions, but:
  108985. * "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"
  108986. * @returns a pseudo random id
  108987. */
  108988. static RandomId(): string;
  108989. /**
  108990. * Test if the given uri is a base64 string
  108991. * @param uri The uri to test
  108992. * @return True if the uri is a base64 string or false otherwise
  108993. */
  108994. static IsBase64(uri: string): boolean;
  108995. /**
  108996. * Decode the given base64 uri.
  108997. * @param uri The uri to decode
  108998. * @return The decoded base64 data.
  108999. */
  109000. static DecodeBase64(uri: string): ArrayBuffer;
  109001. /**
  109002. * Gets the absolute url.
  109003. * @param url the input url
  109004. * @return the absolute url
  109005. */
  109006. static GetAbsoluteUrl(url: string): string;
  109007. /**
  109008. * No log
  109009. */
  109010. static readonly NoneLogLevel: number;
  109011. /**
  109012. * Only message logs
  109013. */
  109014. static readonly MessageLogLevel: number;
  109015. /**
  109016. * Only warning logs
  109017. */
  109018. static readonly WarningLogLevel: number;
  109019. /**
  109020. * Only error logs
  109021. */
  109022. static readonly ErrorLogLevel: number;
  109023. /**
  109024. * All logs
  109025. */
  109026. static readonly AllLogLevel: number;
  109027. /**
  109028. * Gets a value indicating the number of loading errors
  109029. * @ignorenaming
  109030. */
  109031. static get errorsCount(): number;
  109032. /**
  109033. * Callback called when a new log is added
  109034. */
  109035. static OnNewCacheEntry: (entry: string) => void;
  109036. /**
  109037. * Log a message to the console
  109038. * @param message defines the message to log
  109039. */
  109040. static Log(message: string): void;
  109041. /**
  109042. * Write a warning message to the console
  109043. * @param message defines the message to log
  109044. */
  109045. static Warn(message: string): void;
  109046. /**
  109047. * Write an error message to the console
  109048. * @param message defines the message to log
  109049. */
  109050. static Error(message: string): void;
  109051. /**
  109052. * Gets current log cache (list of logs)
  109053. */
  109054. static get LogCache(): string;
  109055. /**
  109056. * Clears the log cache
  109057. */
  109058. static ClearLogCache(): void;
  109059. /**
  109060. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109061. */
  109062. static set LogLevels(level: number);
  109063. /**
  109064. * Checks if the window object exists
  109065. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109066. */
  109067. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109068. /**
  109069. * No performance log
  109070. */
  109071. static readonly PerformanceNoneLogLevel: number;
  109072. /**
  109073. * Use user marks to log performance
  109074. */
  109075. static readonly PerformanceUserMarkLogLevel: number;
  109076. /**
  109077. * Log performance to the console
  109078. */
  109079. static readonly PerformanceConsoleLogLevel: number;
  109080. private static _performance;
  109081. /**
  109082. * Sets the current performance log level
  109083. */
  109084. static set PerformanceLogLevel(level: number);
  109085. private static _StartPerformanceCounterDisabled;
  109086. private static _EndPerformanceCounterDisabled;
  109087. private static _StartUserMark;
  109088. private static _EndUserMark;
  109089. private static _StartPerformanceConsole;
  109090. private static _EndPerformanceConsole;
  109091. /**
  109092. * Starts a performance counter
  109093. */
  109094. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109095. /**
  109096. * Ends a specific performance coutner
  109097. */
  109098. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109099. /**
  109100. * Gets either window.performance.now() if supported or Date.now() else
  109101. */
  109102. static get Now(): number;
  109103. /**
  109104. * This method will return the name of the class used to create the instance of the given object.
  109105. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109106. * @param object the object to get the class name from
  109107. * @param isType defines if the object is actually a type
  109108. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109109. */
  109110. static GetClassName(object: any, isType?: boolean): string;
  109111. /**
  109112. * Gets the first element of an array satisfying a given predicate
  109113. * @param array defines the array to browse
  109114. * @param predicate defines the predicate to use
  109115. * @returns null if not found or the element
  109116. */
  109117. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109118. /**
  109119. * This method will return the name of the full name of the class, including its owning module (if any).
  109120. * 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).
  109121. * @param object the object to get the class name from
  109122. * @param isType defines if the object is actually a type
  109123. * @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.
  109124. * @ignorenaming
  109125. */
  109126. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109127. /**
  109128. * Returns a promise that resolves after the given amount of time.
  109129. * @param delay Number of milliseconds to delay
  109130. * @returns Promise that resolves after the given amount of time
  109131. */
  109132. static DelayAsync(delay: number): Promise<void>;
  109133. /**
  109134. * Utility function to detect if the current user agent is Safari
  109135. * @returns whether or not the current user agent is safari
  109136. */
  109137. static IsSafari(): boolean;
  109138. }
  109139. /**
  109140. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109141. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109142. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109143. * @param name The name of the class, case should be preserved
  109144. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109145. */
  109146. export function className(name: string, module?: string): (target: Object) => void;
  109147. /**
  109148. * An implementation of a loop for asynchronous functions.
  109149. */
  109150. export class AsyncLoop {
  109151. /**
  109152. * Defines the number of iterations for the loop
  109153. */
  109154. iterations: number;
  109155. /**
  109156. * Defines the current index of the loop.
  109157. */
  109158. index: number;
  109159. private _done;
  109160. private _fn;
  109161. private _successCallback;
  109162. /**
  109163. * Constructor.
  109164. * @param iterations the number of iterations.
  109165. * @param func the function to run each iteration
  109166. * @param successCallback the callback that will be called upon succesful execution
  109167. * @param offset starting offset.
  109168. */
  109169. constructor(
  109170. /**
  109171. * Defines the number of iterations for the loop
  109172. */
  109173. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109174. /**
  109175. * Execute the next iteration. Must be called after the last iteration was finished.
  109176. */
  109177. executeNext(): void;
  109178. /**
  109179. * Break the loop and run the success callback.
  109180. */
  109181. breakLoop(): void;
  109182. /**
  109183. * Create and run an async loop.
  109184. * @param iterations the number of iterations.
  109185. * @param fn the function to run each iteration
  109186. * @param successCallback the callback that will be called upon succesful execution
  109187. * @param offset starting offset.
  109188. * @returns the created async loop object
  109189. */
  109190. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109191. /**
  109192. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109193. * @param iterations total number of iterations
  109194. * @param syncedIterations number of synchronous iterations in each async iteration.
  109195. * @param fn the function to call each iteration.
  109196. * @param callback a success call back that will be called when iterating stops.
  109197. * @param breakFunction a break condition (optional)
  109198. * @param timeout timeout settings for the setTimeout function. default - 0.
  109199. * @returns the created async loop object
  109200. */
  109201. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109202. }
  109203. }
  109204. declare module BABYLON {
  109205. /**
  109206. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109207. * The underlying implementation relies on an associative array to ensure the best performances.
  109208. * The value can be anything including 'null' but except 'undefined'
  109209. */
  109210. export class StringDictionary<T> {
  109211. /**
  109212. * This will clear this dictionary and copy the content from the 'source' one.
  109213. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109214. * @param source the dictionary to take the content from and copy to this dictionary
  109215. */
  109216. copyFrom(source: StringDictionary<T>): void;
  109217. /**
  109218. * Get a value based from its key
  109219. * @param key the given key to get the matching value from
  109220. * @return the value if found, otherwise undefined is returned
  109221. */
  109222. get(key: string): T | undefined;
  109223. /**
  109224. * Get a value from its key or add it if it doesn't exist.
  109225. * This method will ensure you that a given key/data will be present in the dictionary.
  109226. * @param key the given key to get the matching value from
  109227. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109228. * The factory will only be invoked if there's no data for the given key.
  109229. * @return the value corresponding to the key.
  109230. */
  109231. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109232. /**
  109233. * Get a value from its key if present in the dictionary otherwise add it
  109234. * @param key the key to get the value from
  109235. * @param val if there's no such key/value pair in the dictionary add it with this value
  109236. * @return the value corresponding to the key
  109237. */
  109238. getOrAdd(key: string, val: T): T;
  109239. /**
  109240. * Check if there's a given key in the dictionary
  109241. * @param key the key to check for
  109242. * @return true if the key is present, false otherwise
  109243. */
  109244. contains(key: string): boolean;
  109245. /**
  109246. * Add a new key and its corresponding value
  109247. * @param key the key to add
  109248. * @param value the value corresponding to the key
  109249. * @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
  109250. */
  109251. add(key: string, value: T): boolean;
  109252. /**
  109253. * Update a specific value associated to a key
  109254. * @param key defines the key to use
  109255. * @param value defines the value to store
  109256. * @returns true if the value was updated (or false if the key was not found)
  109257. */
  109258. set(key: string, value: T): boolean;
  109259. /**
  109260. * Get the element of the given key and remove it from the dictionary
  109261. * @param key defines the key to search
  109262. * @returns the value associated with the key or null if not found
  109263. */
  109264. getAndRemove(key: string): Nullable<T>;
  109265. /**
  109266. * Remove a key/value from the dictionary.
  109267. * @param key the key to remove
  109268. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109269. */
  109270. remove(key: string): boolean;
  109271. /**
  109272. * Clear the whole content of the dictionary
  109273. */
  109274. clear(): void;
  109275. /**
  109276. * Gets the current count
  109277. */
  109278. get count(): number;
  109279. /**
  109280. * Execute a callback on each key/val of the dictionary.
  109281. * Note that you can remove any element in this dictionary in the callback implementation
  109282. * @param callback the callback to execute on a given key/value pair
  109283. */
  109284. forEach(callback: (key: string, val: T) => void): void;
  109285. /**
  109286. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109287. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109288. * Note that you can remove any element in this dictionary in the callback implementation
  109289. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109290. * @returns the first item
  109291. */
  109292. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109293. private _count;
  109294. private _data;
  109295. }
  109296. }
  109297. declare module BABYLON {
  109298. /** @hidden */
  109299. export interface ICollisionCoordinator {
  109300. createCollider(): Collider;
  109301. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109302. init(scene: Scene): void;
  109303. }
  109304. /** @hidden */
  109305. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109306. private _scene;
  109307. private _scaledPosition;
  109308. private _scaledVelocity;
  109309. private _finalPosition;
  109310. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109311. createCollider(): Collider;
  109312. init(scene: Scene): void;
  109313. private _collideWithWorld;
  109314. }
  109315. }
  109316. declare module BABYLON {
  109317. /**
  109318. * Class used to manage all inputs for the scene.
  109319. */
  109320. export class InputManager {
  109321. /** The distance in pixel that you have to move to prevent some events */
  109322. static DragMovementThreshold: number;
  109323. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109324. static LongPressDelay: number;
  109325. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109326. static DoubleClickDelay: number;
  109327. /** If you need to check double click without raising a single click at first click, enable this flag */
  109328. static ExclusiveDoubleClickMode: boolean;
  109329. private _wheelEventName;
  109330. private _onPointerMove;
  109331. private _onPointerDown;
  109332. private _onPointerUp;
  109333. private _initClickEvent;
  109334. private _initActionManager;
  109335. private _delayedSimpleClick;
  109336. private _delayedSimpleClickTimeout;
  109337. private _previousDelayedSimpleClickTimeout;
  109338. private _meshPickProceed;
  109339. private _previousButtonPressed;
  109340. private _currentPickResult;
  109341. private _previousPickResult;
  109342. private _totalPointersPressed;
  109343. private _doubleClickOccured;
  109344. private _pointerOverMesh;
  109345. private _pickedDownMesh;
  109346. private _pickedUpMesh;
  109347. private _pointerX;
  109348. private _pointerY;
  109349. private _unTranslatedPointerX;
  109350. private _unTranslatedPointerY;
  109351. private _startingPointerPosition;
  109352. private _previousStartingPointerPosition;
  109353. private _startingPointerTime;
  109354. private _previousStartingPointerTime;
  109355. private _pointerCaptures;
  109356. private _onKeyDown;
  109357. private _onKeyUp;
  109358. private _onCanvasFocusObserver;
  109359. private _onCanvasBlurObserver;
  109360. private _scene;
  109361. /**
  109362. * Creates a new InputManager
  109363. * @param scene defines the hosting scene
  109364. */
  109365. constructor(scene: Scene);
  109366. /**
  109367. * Gets the mesh that is currently under the pointer
  109368. */
  109369. get meshUnderPointer(): Nullable<AbstractMesh>;
  109370. /**
  109371. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109372. */
  109373. get unTranslatedPointer(): Vector2;
  109374. /**
  109375. * Gets or sets the current on-screen X position of the pointer
  109376. */
  109377. get pointerX(): number;
  109378. set pointerX(value: number);
  109379. /**
  109380. * Gets or sets the current on-screen Y position of the pointer
  109381. */
  109382. get pointerY(): number;
  109383. set pointerY(value: number);
  109384. private _updatePointerPosition;
  109385. private _processPointerMove;
  109386. private _setRayOnPointerInfo;
  109387. private _checkPrePointerObservable;
  109388. /**
  109389. * Use this method to simulate a pointer move on a mesh
  109390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109393. */
  109394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109395. /**
  109396. * Use this method to simulate a pointer down on a mesh
  109397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109400. */
  109401. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109402. private _processPointerDown;
  109403. /** @hidden */
  109404. _isPointerSwiping(): boolean;
  109405. /**
  109406. * Use this method to simulate a pointer up on a mesh
  109407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109410. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109411. */
  109412. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109413. private _processPointerUp;
  109414. /**
  109415. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109416. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109417. * @returns true if the pointer was captured
  109418. */
  109419. isPointerCaptured(pointerId?: number): boolean;
  109420. /**
  109421. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109422. * @param attachUp defines if you want to attach events to pointerup
  109423. * @param attachDown defines if you want to attach events to pointerdown
  109424. * @param attachMove defines if you want to attach events to pointermove
  109425. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109426. */
  109427. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109428. /**
  109429. * Detaches all event handlers
  109430. */
  109431. detachControl(): void;
  109432. /**
  109433. * Force the value of meshUnderPointer
  109434. * @param mesh defines the mesh to use
  109435. */
  109436. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109437. /**
  109438. * Gets the mesh under the pointer
  109439. * @returns a Mesh or null if no mesh is under the pointer
  109440. */
  109441. getPointerOverMesh(): Nullable<AbstractMesh>;
  109442. }
  109443. }
  109444. declare module BABYLON {
  109445. /**
  109446. * Helper class used to generate session unique ID
  109447. */
  109448. export class UniqueIdGenerator {
  109449. private static _UniqueIdCounter;
  109450. /**
  109451. * Gets an unique (relatively to the current scene) Id
  109452. */
  109453. static get UniqueId(): number;
  109454. }
  109455. }
  109456. declare module BABYLON {
  109457. /**
  109458. * This class defines the direct association between an animation and a target
  109459. */
  109460. export class TargetedAnimation {
  109461. /**
  109462. * Animation to perform
  109463. */
  109464. animation: Animation;
  109465. /**
  109466. * Target to animate
  109467. */
  109468. target: any;
  109469. /**
  109470. * Serialize the object
  109471. * @returns the JSON object representing the current entity
  109472. */
  109473. serialize(): any;
  109474. }
  109475. /**
  109476. * Use this class to create coordinated animations on multiple targets
  109477. */
  109478. export class AnimationGroup implements IDisposable {
  109479. /** The name of the animation group */
  109480. name: string;
  109481. private _scene;
  109482. private _targetedAnimations;
  109483. private _animatables;
  109484. private _from;
  109485. private _to;
  109486. private _isStarted;
  109487. private _isPaused;
  109488. private _speedRatio;
  109489. private _loopAnimation;
  109490. private _isAdditive;
  109491. /**
  109492. * Gets or sets the unique id of the node
  109493. */
  109494. uniqueId: number;
  109495. /**
  109496. * This observable will notify when one animation have ended
  109497. */
  109498. onAnimationEndObservable: Observable<TargetedAnimation>;
  109499. /**
  109500. * Observer raised when one animation loops
  109501. */
  109502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109503. /**
  109504. * Observer raised when all animations have looped
  109505. */
  109506. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109507. /**
  109508. * This observable will notify when all animations have ended.
  109509. */
  109510. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109511. /**
  109512. * This observable will notify when all animations have paused.
  109513. */
  109514. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109515. /**
  109516. * This observable will notify when all animations are playing.
  109517. */
  109518. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109519. /**
  109520. * Gets the first frame
  109521. */
  109522. get from(): number;
  109523. /**
  109524. * Gets the last frame
  109525. */
  109526. get to(): number;
  109527. /**
  109528. * Define if the animations are started
  109529. */
  109530. get isStarted(): boolean;
  109531. /**
  109532. * Gets a value indicating that the current group is playing
  109533. */
  109534. get isPlaying(): boolean;
  109535. /**
  109536. * Gets or sets the speed ratio to use for all animations
  109537. */
  109538. get speedRatio(): number;
  109539. /**
  109540. * Gets or sets the speed ratio to use for all animations
  109541. */
  109542. set speedRatio(value: number);
  109543. /**
  109544. * Gets or sets if all animations should loop or not
  109545. */
  109546. get loopAnimation(): boolean;
  109547. set loopAnimation(value: boolean);
  109548. /**
  109549. * Gets or sets if all animations should be evaluated additively
  109550. */
  109551. get isAdditive(): boolean;
  109552. set isAdditive(value: boolean);
  109553. /**
  109554. * Gets the targeted animations for this animation group
  109555. */
  109556. get targetedAnimations(): Array<TargetedAnimation>;
  109557. /**
  109558. * returning the list of animatables controlled by this animation group.
  109559. */
  109560. get animatables(): Array<Animatable>;
  109561. /**
  109562. * Instantiates a new Animation Group.
  109563. * This helps managing several animations at once.
  109564. * @see http://doc.babylonjs.com/how_to/group
  109565. * @param name Defines the name of the group
  109566. * @param scene Defines the scene the group belongs to
  109567. */
  109568. constructor(
  109569. /** The name of the animation group */
  109570. name: string, scene?: Nullable<Scene>);
  109571. /**
  109572. * Add an animation (with its target) in the group
  109573. * @param animation defines the animation we want to add
  109574. * @param target defines the target of the animation
  109575. * @returns the TargetedAnimation object
  109576. */
  109577. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109578. /**
  109579. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109580. * It can add constant keys at begin or end
  109581. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109582. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109583. * @returns the animation group
  109584. */
  109585. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109586. private _animationLoopCount;
  109587. private _animationLoopFlags;
  109588. private _processLoop;
  109589. /**
  109590. * Start all animations on given targets
  109591. * @param loop defines if animations must loop
  109592. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109593. * @param from defines the from key (optional)
  109594. * @param to defines the to key (optional)
  109595. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109596. * @returns the current animation group
  109597. */
  109598. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109599. /**
  109600. * Pause all animations
  109601. * @returns the animation group
  109602. */
  109603. pause(): AnimationGroup;
  109604. /**
  109605. * Play all animations to initial state
  109606. * This function will start() the animations if they were not started or will restart() them if they were paused
  109607. * @param loop defines if animations must loop
  109608. * @returns the animation group
  109609. */
  109610. play(loop?: boolean): AnimationGroup;
  109611. /**
  109612. * Reset all animations to initial state
  109613. * @returns the animation group
  109614. */
  109615. reset(): AnimationGroup;
  109616. /**
  109617. * Restart animations from key 0
  109618. * @returns the animation group
  109619. */
  109620. restart(): AnimationGroup;
  109621. /**
  109622. * Stop all animations
  109623. * @returns the animation group
  109624. */
  109625. stop(): AnimationGroup;
  109626. /**
  109627. * Set animation weight for all animatables
  109628. * @param weight defines the weight to use
  109629. * @return the animationGroup
  109630. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109631. */
  109632. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109633. /**
  109634. * Synchronize and normalize all animatables with a source animatable
  109635. * @param root defines the root animatable to synchronize with
  109636. * @return the animationGroup
  109637. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109638. */
  109639. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109640. /**
  109641. * Goes to a specific frame in this animation group
  109642. * @param frame the frame number to go to
  109643. * @return the animationGroup
  109644. */
  109645. goToFrame(frame: number): AnimationGroup;
  109646. /**
  109647. * Dispose all associated resources
  109648. */
  109649. dispose(): void;
  109650. private _checkAnimationGroupEnded;
  109651. /**
  109652. * Clone the current animation group and returns a copy
  109653. * @param newName defines the name of the new group
  109654. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109655. * @returns the new aniamtion group
  109656. */
  109657. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109658. /**
  109659. * Serializes the animationGroup to an object
  109660. * @returns Serialized object
  109661. */
  109662. serialize(): any;
  109663. /**
  109664. * Returns a new AnimationGroup object parsed from the source provided.
  109665. * @param parsedAnimationGroup defines the source
  109666. * @param scene defines the scene that will receive the animationGroup
  109667. * @returns a new AnimationGroup
  109668. */
  109669. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109670. /**
  109671. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109672. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109673. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109674. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109675. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109676. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109677. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109678. */
  109679. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109680. /**
  109681. * Returns the string "AnimationGroup"
  109682. * @returns "AnimationGroup"
  109683. */
  109684. getClassName(): string;
  109685. /**
  109686. * Creates a detailled string about the object
  109687. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109688. * @returns a string representing the object
  109689. */
  109690. toString(fullDetails?: boolean): string;
  109691. }
  109692. }
  109693. declare module BABYLON {
  109694. /**
  109695. * Define an interface for all classes that will hold resources
  109696. */
  109697. export interface IDisposable {
  109698. /**
  109699. * Releases all held resources
  109700. */
  109701. dispose(): void;
  109702. }
  109703. /** Interface defining initialization parameters for Scene class */
  109704. export interface SceneOptions {
  109705. /**
  109706. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109707. * It will improve performance when the number of geometries becomes important.
  109708. */
  109709. useGeometryUniqueIdsMap?: boolean;
  109710. /**
  109711. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109712. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109713. */
  109714. useMaterialMeshMap?: boolean;
  109715. /**
  109716. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109717. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109718. */
  109719. useClonedMeshMap?: boolean;
  109720. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109721. virtual?: boolean;
  109722. }
  109723. /**
  109724. * Represents a scene to be rendered by the engine.
  109725. * @see http://doc.babylonjs.com/features/scene
  109726. */
  109727. export class Scene extends AbstractScene implements IAnimatable {
  109728. /** The fog is deactivated */
  109729. static readonly FOGMODE_NONE: number;
  109730. /** The fog density is following an exponential function */
  109731. static readonly FOGMODE_EXP: number;
  109732. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109733. static readonly FOGMODE_EXP2: number;
  109734. /** The fog density is following a linear function. */
  109735. static readonly FOGMODE_LINEAR: number;
  109736. /**
  109737. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109739. */
  109740. static MinDeltaTime: number;
  109741. /**
  109742. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109743. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109744. */
  109745. static MaxDeltaTime: number;
  109746. /**
  109747. * Factory used to create the default material.
  109748. * @param name The name of the material to create
  109749. * @param scene The scene to create the material for
  109750. * @returns The default material
  109751. */
  109752. static DefaultMaterialFactory(scene: Scene): Material;
  109753. /**
  109754. * Factory used to create the a collision coordinator.
  109755. * @returns The collision coordinator
  109756. */
  109757. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109758. /** @hidden */
  109759. _inputManager: InputManager;
  109760. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109761. cameraToUseForPointers: Nullable<Camera>;
  109762. /** @hidden */
  109763. readonly _isScene: boolean;
  109764. /** @hidden */
  109765. _blockEntityCollection: boolean;
  109766. /**
  109767. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109768. */
  109769. autoClear: boolean;
  109770. /**
  109771. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109772. */
  109773. autoClearDepthAndStencil: boolean;
  109774. /**
  109775. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109776. */
  109777. clearColor: Color4;
  109778. /**
  109779. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109780. */
  109781. ambientColor: Color3;
  109782. /**
  109783. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109784. * It should only be one of the following (if not the default embedded one):
  109785. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109786. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109787. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109788. * The material properties need to be setup according to the type of texture in use.
  109789. */
  109790. environmentBRDFTexture: BaseTexture;
  109791. /** @hidden */
  109792. protected _environmentTexture: Nullable<BaseTexture>;
  109793. /**
  109794. * Texture used in all pbr material as the reflection texture.
  109795. * As in the majority of the scene they are the same (exception for multi room and so on),
  109796. * this is easier to reference from here than from all the materials.
  109797. */
  109798. get environmentTexture(): Nullable<BaseTexture>;
  109799. /**
  109800. * Texture used in all pbr material as the reflection texture.
  109801. * As in the majority of the scene they are the same (exception for multi room and so on),
  109802. * this is easier to set here than in all the materials.
  109803. */
  109804. set environmentTexture(value: Nullable<BaseTexture>);
  109805. /** @hidden */
  109806. protected _environmentIntensity: number;
  109807. /**
  109808. * Intensity of the environment in all pbr material.
  109809. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109810. * As in the majority of the scene they are the same (exception for multi room and so on),
  109811. * this is easier to reference from here than from all the materials.
  109812. */
  109813. get environmentIntensity(): number;
  109814. /**
  109815. * Intensity of the environment in all pbr material.
  109816. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109817. * As in the majority of the scene they are the same (exception for multi room and so on),
  109818. * this is easier to set here than in all the materials.
  109819. */
  109820. set environmentIntensity(value: number);
  109821. /** @hidden */
  109822. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109823. /**
  109824. * Default image processing configuration used either in the rendering
  109825. * Forward main pass or through the imageProcessingPostProcess if present.
  109826. * As in the majority of the scene they are the same (exception for multi camera),
  109827. * this is easier to reference from here than from all the materials and post process.
  109828. *
  109829. * No setter as we it is a shared configuration, you can set the values instead.
  109830. */
  109831. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109832. private _forceWireframe;
  109833. /**
  109834. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109835. */
  109836. set forceWireframe(value: boolean);
  109837. get forceWireframe(): boolean;
  109838. private _skipFrustumClipping;
  109839. /**
  109840. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109841. */
  109842. set skipFrustumClipping(value: boolean);
  109843. get skipFrustumClipping(): boolean;
  109844. private _forcePointsCloud;
  109845. /**
  109846. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109847. */
  109848. set forcePointsCloud(value: boolean);
  109849. get forcePointsCloud(): boolean;
  109850. /**
  109851. * Gets or sets the active clipplane 1
  109852. */
  109853. clipPlane: Nullable<Plane>;
  109854. /**
  109855. * Gets or sets the active clipplane 2
  109856. */
  109857. clipPlane2: Nullable<Plane>;
  109858. /**
  109859. * Gets or sets the active clipplane 3
  109860. */
  109861. clipPlane3: Nullable<Plane>;
  109862. /**
  109863. * Gets or sets the active clipplane 4
  109864. */
  109865. clipPlane4: Nullable<Plane>;
  109866. /**
  109867. * Gets or sets the active clipplane 5
  109868. */
  109869. clipPlane5: Nullable<Plane>;
  109870. /**
  109871. * Gets or sets the active clipplane 6
  109872. */
  109873. clipPlane6: Nullable<Plane>;
  109874. /**
  109875. * Gets or sets a boolean indicating if animations are enabled
  109876. */
  109877. animationsEnabled: boolean;
  109878. private _animationPropertiesOverride;
  109879. /**
  109880. * Gets or sets the animation properties override
  109881. */
  109882. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109883. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109884. /**
  109885. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109886. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109887. */
  109888. useConstantAnimationDeltaTime: boolean;
  109889. /**
  109890. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109891. * Please note that it requires to run a ray cast through the scene on every frame
  109892. */
  109893. constantlyUpdateMeshUnderPointer: boolean;
  109894. /**
  109895. * Defines the HTML cursor to use when hovering over interactive elements
  109896. */
  109897. hoverCursor: string;
  109898. /**
  109899. * Defines the HTML default cursor to use (empty by default)
  109900. */
  109901. defaultCursor: string;
  109902. /**
  109903. * Defines whether cursors are handled by the scene.
  109904. */
  109905. doNotHandleCursors: boolean;
  109906. /**
  109907. * This is used to call preventDefault() on pointer down
  109908. * in order to block unwanted artifacts like system double clicks
  109909. */
  109910. preventDefaultOnPointerDown: boolean;
  109911. /**
  109912. * This is used to call preventDefault() on pointer up
  109913. * in order to block unwanted artifacts like system double clicks
  109914. */
  109915. preventDefaultOnPointerUp: boolean;
  109916. /**
  109917. * Gets or sets user defined metadata
  109918. */
  109919. metadata: any;
  109920. /**
  109921. * For internal use only. Please do not use.
  109922. */
  109923. reservedDataStore: any;
  109924. /**
  109925. * Gets the name of the plugin used to load this scene (null by default)
  109926. */
  109927. loadingPluginName: string;
  109928. /**
  109929. * Use this array to add regular expressions used to disable offline support for specific urls
  109930. */
  109931. disableOfflineSupportExceptionRules: RegExp[];
  109932. /**
  109933. * An event triggered when the scene is disposed.
  109934. */
  109935. onDisposeObservable: Observable<Scene>;
  109936. private _onDisposeObserver;
  109937. /** Sets a function to be executed when this scene is disposed. */
  109938. set onDispose(callback: () => void);
  109939. /**
  109940. * An event triggered before rendering the scene (right after animations and physics)
  109941. */
  109942. onBeforeRenderObservable: Observable<Scene>;
  109943. private _onBeforeRenderObserver;
  109944. /** Sets a function to be executed before rendering this scene */
  109945. set beforeRender(callback: Nullable<() => void>);
  109946. /**
  109947. * An event triggered after rendering the scene
  109948. */
  109949. onAfterRenderObservable: Observable<Scene>;
  109950. /**
  109951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109952. */
  109953. onAfterRenderCameraObservable: Observable<Camera>;
  109954. private _onAfterRenderObserver;
  109955. /** Sets a function to be executed after rendering this scene */
  109956. set afterRender(callback: Nullable<() => void>);
  109957. /**
  109958. * An event triggered before animating the scene
  109959. */
  109960. onBeforeAnimationsObservable: Observable<Scene>;
  109961. /**
  109962. * An event triggered after animations processing
  109963. */
  109964. onAfterAnimationsObservable: Observable<Scene>;
  109965. /**
  109966. * An event triggered before draw calls are ready to be sent
  109967. */
  109968. onBeforeDrawPhaseObservable: Observable<Scene>;
  109969. /**
  109970. * An event triggered after draw calls have been sent
  109971. */
  109972. onAfterDrawPhaseObservable: Observable<Scene>;
  109973. /**
  109974. * An event triggered when the scene is ready
  109975. */
  109976. onReadyObservable: Observable<Scene>;
  109977. /**
  109978. * An event triggered before rendering a camera
  109979. */
  109980. onBeforeCameraRenderObservable: Observable<Camera>;
  109981. private _onBeforeCameraRenderObserver;
  109982. /** Sets a function to be executed before rendering a camera*/
  109983. set beforeCameraRender(callback: () => void);
  109984. /**
  109985. * An event triggered after rendering a camera
  109986. */
  109987. onAfterCameraRenderObservable: Observable<Camera>;
  109988. private _onAfterCameraRenderObserver;
  109989. /** Sets a function to be executed after rendering a camera*/
  109990. set afterCameraRender(callback: () => void);
  109991. /**
  109992. * An event triggered when active meshes evaluation is about to start
  109993. */
  109994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109995. /**
  109996. * An event triggered when active meshes evaluation is done
  109997. */
  109998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109999. /**
  110000. * An event triggered when particles rendering is about to start
  110001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110002. */
  110003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  110004. /**
  110005. * An event triggered when particles rendering is done
  110006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110007. */
  110008. onAfterParticlesRenderingObservable: Observable<Scene>;
  110009. /**
  110010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  110011. */
  110012. onDataLoadedObservable: Observable<Scene>;
  110013. /**
  110014. * An event triggered when a camera is created
  110015. */
  110016. onNewCameraAddedObservable: Observable<Camera>;
  110017. /**
  110018. * An event triggered when a camera is removed
  110019. */
  110020. onCameraRemovedObservable: Observable<Camera>;
  110021. /**
  110022. * An event triggered when a light is created
  110023. */
  110024. onNewLightAddedObservable: Observable<Light>;
  110025. /**
  110026. * An event triggered when a light is removed
  110027. */
  110028. onLightRemovedObservable: Observable<Light>;
  110029. /**
  110030. * An event triggered when a geometry is created
  110031. */
  110032. onNewGeometryAddedObservable: Observable<Geometry>;
  110033. /**
  110034. * An event triggered when a geometry is removed
  110035. */
  110036. onGeometryRemovedObservable: Observable<Geometry>;
  110037. /**
  110038. * An event triggered when a transform node is created
  110039. */
  110040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110041. /**
  110042. * An event triggered when a transform node is removed
  110043. */
  110044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110045. /**
  110046. * An event triggered when a mesh is created
  110047. */
  110048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110049. /**
  110050. * An event triggered when a mesh is removed
  110051. */
  110052. onMeshRemovedObservable: Observable<AbstractMesh>;
  110053. /**
  110054. * An event triggered when a skeleton is created
  110055. */
  110056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110057. /**
  110058. * An event triggered when a skeleton is removed
  110059. */
  110060. onSkeletonRemovedObservable: Observable<Skeleton>;
  110061. /**
  110062. * An event triggered when a material is created
  110063. */
  110064. onNewMaterialAddedObservable: Observable<Material>;
  110065. /**
  110066. * An event triggered when a material is removed
  110067. */
  110068. onMaterialRemovedObservable: Observable<Material>;
  110069. /**
  110070. * An event triggered when a texture is created
  110071. */
  110072. onNewTextureAddedObservable: Observable<BaseTexture>;
  110073. /**
  110074. * An event triggered when a texture is removed
  110075. */
  110076. onTextureRemovedObservable: Observable<BaseTexture>;
  110077. /**
  110078. * An event triggered when render targets are about to be rendered
  110079. * Can happen multiple times per frame.
  110080. */
  110081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110082. /**
  110083. * An event triggered when render targets were rendered.
  110084. * Can happen multiple times per frame.
  110085. */
  110086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110087. /**
  110088. * An event triggered before calculating deterministic simulation step
  110089. */
  110090. onBeforeStepObservable: Observable<Scene>;
  110091. /**
  110092. * An event triggered after calculating deterministic simulation step
  110093. */
  110094. onAfterStepObservable: Observable<Scene>;
  110095. /**
  110096. * An event triggered when the activeCamera property is updated
  110097. */
  110098. onActiveCameraChanged: Observable<Scene>;
  110099. /**
  110100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110102. * 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)
  110103. */
  110104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110105. /**
  110106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110108. * 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)
  110109. */
  110110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110111. /**
  110112. * This Observable will when a mesh has been imported into the scene.
  110113. */
  110114. onMeshImportedObservable: Observable<AbstractMesh>;
  110115. /**
  110116. * This Observable will when an animation file has been imported into the scene.
  110117. */
  110118. onAnimationFileImportedObservable: Observable<Scene>;
  110119. /**
  110120. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110121. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110122. */
  110123. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110124. /** @hidden */
  110125. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110126. /**
  110127. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110128. */
  110129. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110130. /**
  110131. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110132. */
  110133. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110134. /**
  110135. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110136. */
  110137. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110138. /** Callback called when a pointer move is detected */
  110139. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110140. /** Callback called when a pointer down is detected */
  110141. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110142. /** Callback called when a pointer up is detected */
  110143. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110144. /** Callback called when a pointer pick is detected */
  110145. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110146. /**
  110147. * 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).
  110148. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110149. */
  110150. onPrePointerObservable: Observable<PointerInfoPre>;
  110151. /**
  110152. * Observable event triggered each time an input event is received from the rendering canvas
  110153. */
  110154. onPointerObservable: Observable<PointerInfo>;
  110155. /**
  110156. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110157. */
  110158. get unTranslatedPointer(): Vector2;
  110159. /**
  110160. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110161. */
  110162. static get DragMovementThreshold(): number;
  110163. static set DragMovementThreshold(value: number);
  110164. /**
  110165. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110166. */
  110167. static get LongPressDelay(): number;
  110168. static set LongPressDelay(value: number);
  110169. /**
  110170. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110171. */
  110172. static get DoubleClickDelay(): number;
  110173. static set DoubleClickDelay(value: number);
  110174. /** If you need to check double click without raising a single click at first click, enable this flag */
  110175. static get ExclusiveDoubleClickMode(): boolean;
  110176. static set ExclusiveDoubleClickMode(value: boolean);
  110177. /** @hidden */
  110178. _mirroredCameraPosition: Nullable<Vector3>;
  110179. /**
  110180. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110181. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110182. */
  110183. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110184. /**
  110185. * Observable event triggered each time an keyboard event is received from the hosting window
  110186. */
  110187. onKeyboardObservable: Observable<KeyboardInfo>;
  110188. private _useRightHandedSystem;
  110189. /**
  110190. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110191. */
  110192. set useRightHandedSystem(value: boolean);
  110193. get useRightHandedSystem(): boolean;
  110194. private _timeAccumulator;
  110195. private _currentStepId;
  110196. private _currentInternalStep;
  110197. /**
  110198. * Sets the step Id used by deterministic lock step
  110199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110200. * @param newStepId defines the step Id
  110201. */
  110202. setStepId(newStepId: number): void;
  110203. /**
  110204. * Gets the step Id used by deterministic lock step
  110205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110206. * @returns the step Id
  110207. */
  110208. getStepId(): number;
  110209. /**
  110210. * Gets the internal step used by deterministic lock step
  110211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110212. * @returns the internal step
  110213. */
  110214. getInternalStep(): number;
  110215. private _fogEnabled;
  110216. /**
  110217. * Gets or sets a boolean indicating if fog is enabled on this scene
  110218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110219. * (Default is true)
  110220. */
  110221. set fogEnabled(value: boolean);
  110222. get fogEnabled(): boolean;
  110223. private _fogMode;
  110224. /**
  110225. * Gets or sets the fog mode to use
  110226. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110227. * | mode | value |
  110228. * | --- | --- |
  110229. * | FOGMODE_NONE | 0 |
  110230. * | FOGMODE_EXP | 1 |
  110231. * | FOGMODE_EXP2 | 2 |
  110232. * | FOGMODE_LINEAR | 3 |
  110233. */
  110234. set fogMode(value: number);
  110235. get fogMode(): number;
  110236. /**
  110237. * Gets or sets the fog color to use
  110238. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110239. * (Default is Color3(0.2, 0.2, 0.3))
  110240. */
  110241. fogColor: Color3;
  110242. /**
  110243. * Gets or sets the fog density to use
  110244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110245. * (Default is 0.1)
  110246. */
  110247. fogDensity: number;
  110248. /**
  110249. * Gets or sets the fog start distance to use
  110250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110251. * (Default is 0)
  110252. */
  110253. fogStart: number;
  110254. /**
  110255. * Gets or sets the fog end distance to use
  110256. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110257. * (Default is 1000)
  110258. */
  110259. fogEnd: number;
  110260. private _shadowsEnabled;
  110261. /**
  110262. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110263. */
  110264. set shadowsEnabled(value: boolean);
  110265. get shadowsEnabled(): boolean;
  110266. private _lightsEnabled;
  110267. /**
  110268. * Gets or sets a boolean indicating if lights are enabled on this scene
  110269. */
  110270. set lightsEnabled(value: boolean);
  110271. get lightsEnabled(): boolean;
  110272. /** All of the active cameras added to this scene. */
  110273. activeCameras: Camera[];
  110274. /** @hidden */
  110275. _activeCamera: Nullable<Camera>;
  110276. /** Gets or sets the current active camera */
  110277. get activeCamera(): Nullable<Camera>;
  110278. set activeCamera(value: Nullable<Camera>);
  110279. private _defaultMaterial;
  110280. /** The default material used on meshes when no material is affected */
  110281. get defaultMaterial(): Material;
  110282. /** The default material used on meshes when no material is affected */
  110283. set defaultMaterial(value: Material);
  110284. private _texturesEnabled;
  110285. /**
  110286. * Gets or sets a boolean indicating if textures are enabled on this scene
  110287. */
  110288. set texturesEnabled(value: boolean);
  110289. get texturesEnabled(): boolean;
  110290. /**
  110291. * Gets or sets a boolean indicating if particles are enabled on this scene
  110292. */
  110293. particlesEnabled: boolean;
  110294. /**
  110295. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110296. */
  110297. spritesEnabled: boolean;
  110298. private _skeletonsEnabled;
  110299. /**
  110300. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110301. */
  110302. set skeletonsEnabled(value: boolean);
  110303. get skeletonsEnabled(): boolean;
  110304. /**
  110305. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110306. */
  110307. lensFlaresEnabled: boolean;
  110308. /**
  110309. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110311. */
  110312. collisionsEnabled: boolean;
  110313. private _collisionCoordinator;
  110314. /** @hidden */
  110315. get collisionCoordinator(): ICollisionCoordinator;
  110316. /**
  110317. * Defines the gravity applied to this scene (used only for collisions)
  110318. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110319. */
  110320. gravity: Vector3;
  110321. /**
  110322. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110323. */
  110324. postProcessesEnabled: boolean;
  110325. /**
  110326. * The list of postprocesses added to the scene
  110327. */
  110328. postProcesses: PostProcess[];
  110329. /**
  110330. * Gets the current postprocess manager
  110331. */
  110332. postProcessManager: PostProcessManager;
  110333. /**
  110334. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110335. */
  110336. renderTargetsEnabled: boolean;
  110337. /**
  110338. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110339. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110340. */
  110341. dumpNextRenderTargets: boolean;
  110342. /**
  110343. * The list of user defined render targets added to the scene
  110344. */
  110345. customRenderTargets: RenderTargetTexture[];
  110346. /**
  110347. * Defines if texture loading must be delayed
  110348. * If true, textures will only be loaded when they need to be rendered
  110349. */
  110350. useDelayedTextureLoading: boolean;
  110351. /**
  110352. * Gets the list of meshes imported to the scene through SceneLoader
  110353. */
  110354. importedMeshesFiles: String[];
  110355. /**
  110356. * Gets or sets a boolean indicating if probes are enabled on this scene
  110357. */
  110358. probesEnabled: boolean;
  110359. /**
  110360. * Gets or sets the current offline provider to use to store scene data
  110361. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110362. */
  110363. offlineProvider: IOfflineProvider;
  110364. /**
  110365. * Gets or sets the action manager associated with the scene
  110366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110367. */
  110368. actionManager: AbstractActionManager;
  110369. private _meshesForIntersections;
  110370. /**
  110371. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110372. */
  110373. proceduralTexturesEnabled: boolean;
  110374. private _engine;
  110375. private _totalVertices;
  110376. /** @hidden */
  110377. _activeIndices: PerfCounter;
  110378. /** @hidden */
  110379. _activeParticles: PerfCounter;
  110380. /** @hidden */
  110381. _activeBones: PerfCounter;
  110382. private _animationRatio;
  110383. /** @hidden */
  110384. _animationTimeLast: number;
  110385. /** @hidden */
  110386. _animationTime: number;
  110387. /**
  110388. * Gets or sets a general scale for animation speed
  110389. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110390. */
  110391. animationTimeScale: number;
  110392. /** @hidden */
  110393. _cachedMaterial: Nullable<Material>;
  110394. /** @hidden */
  110395. _cachedEffect: Nullable<Effect>;
  110396. /** @hidden */
  110397. _cachedVisibility: Nullable<number>;
  110398. private _renderId;
  110399. private _frameId;
  110400. private _executeWhenReadyTimeoutId;
  110401. private _intermediateRendering;
  110402. private _viewUpdateFlag;
  110403. private _projectionUpdateFlag;
  110404. /** @hidden */
  110405. _toBeDisposed: Nullable<IDisposable>[];
  110406. private _activeRequests;
  110407. /** @hidden */
  110408. _pendingData: any[];
  110409. private _isDisposed;
  110410. /**
  110411. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110412. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110413. */
  110414. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110415. private _activeMeshes;
  110416. private _processedMaterials;
  110417. private _renderTargets;
  110418. /** @hidden */
  110419. _activeParticleSystems: SmartArray<IParticleSystem>;
  110420. private _activeSkeletons;
  110421. private _softwareSkinnedMeshes;
  110422. private _renderingManager;
  110423. /** @hidden */
  110424. _activeAnimatables: Animatable[];
  110425. private _transformMatrix;
  110426. private _sceneUbo;
  110427. /** @hidden */
  110428. _viewMatrix: Matrix;
  110429. private _projectionMatrix;
  110430. /** @hidden */
  110431. _forcedViewPosition: Nullable<Vector3>;
  110432. /** @hidden */
  110433. _frustumPlanes: Plane[];
  110434. /**
  110435. * Gets the list of frustum planes (built from the active camera)
  110436. */
  110437. get frustumPlanes(): Plane[];
  110438. /**
  110439. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110440. * This is useful if there are more lights that the maximum simulteanous authorized
  110441. */
  110442. requireLightSorting: boolean;
  110443. /** @hidden */
  110444. readonly useMaterialMeshMap: boolean;
  110445. /** @hidden */
  110446. readonly useClonedMeshMap: boolean;
  110447. private _externalData;
  110448. private _uid;
  110449. /**
  110450. * @hidden
  110451. * Backing store of defined scene components.
  110452. */
  110453. _components: ISceneComponent[];
  110454. /**
  110455. * @hidden
  110456. * Backing store of defined scene components.
  110457. */
  110458. _serializableComponents: ISceneSerializableComponent[];
  110459. /**
  110460. * List of components to register on the next registration step.
  110461. */
  110462. private _transientComponents;
  110463. /**
  110464. * Registers the transient components if needed.
  110465. */
  110466. private _registerTransientComponents;
  110467. /**
  110468. * @hidden
  110469. * Add a component to the scene.
  110470. * Note that the ccomponent could be registered on th next frame if this is called after
  110471. * the register component stage.
  110472. * @param component Defines the component to add to the scene
  110473. */
  110474. _addComponent(component: ISceneComponent): void;
  110475. /**
  110476. * @hidden
  110477. * Gets a component from the scene.
  110478. * @param name defines the name of the component to retrieve
  110479. * @returns the component or null if not present
  110480. */
  110481. _getComponent(name: string): Nullable<ISceneComponent>;
  110482. /**
  110483. * @hidden
  110484. * Defines the actions happening before camera updates.
  110485. */
  110486. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110487. /**
  110488. * @hidden
  110489. * Defines the actions happening before clear the canvas.
  110490. */
  110491. _beforeClearStage: Stage<SimpleStageAction>;
  110492. /**
  110493. * @hidden
  110494. * Defines the actions when collecting render targets for the frame.
  110495. */
  110496. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110497. /**
  110498. * @hidden
  110499. * Defines the actions happening for one camera in the frame.
  110500. */
  110501. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110502. /**
  110503. * @hidden
  110504. * Defines the actions happening during the per mesh ready checks.
  110505. */
  110506. _isReadyForMeshStage: Stage<MeshStageAction>;
  110507. /**
  110508. * @hidden
  110509. * Defines the actions happening before evaluate active mesh checks.
  110510. */
  110511. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110512. /**
  110513. * @hidden
  110514. * Defines the actions happening during the evaluate sub mesh checks.
  110515. */
  110516. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110517. /**
  110518. * @hidden
  110519. * Defines the actions happening during the active mesh stage.
  110520. */
  110521. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110522. /**
  110523. * @hidden
  110524. * Defines the actions happening during the per camera render target step.
  110525. */
  110526. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110527. /**
  110528. * @hidden
  110529. * Defines the actions happening just before the active camera is drawing.
  110530. */
  110531. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110532. /**
  110533. * @hidden
  110534. * Defines the actions happening just before a render target is drawing.
  110535. */
  110536. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110537. /**
  110538. * @hidden
  110539. * Defines the actions happening just before a rendering group is drawing.
  110540. */
  110541. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110542. /**
  110543. * @hidden
  110544. * Defines the actions happening just before a mesh is drawing.
  110545. */
  110546. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110547. /**
  110548. * @hidden
  110549. * Defines the actions happening just after a mesh has been drawn.
  110550. */
  110551. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110552. /**
  110553. * @hidden
  110554. * Defines the actions happening just after a rendering group has been drawn.
  110555. */
  110556. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110557. /**
  110558. * @hidden
  110559. * Defines the actions happening just after the active camera has been drawn.
  110560. */
  110561. _afterCameraDrawStage: Stage<CameraStageAction>;
  110562. /**
  110563. * @hidden
  110564. * Defines the actions happening just after a render target has been drawn.
  110565. */
  110566. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110567. /**
  110568. * @hidden
  110569. * Defines the actions happening just after rendering all cameras and computing intersections.
  110570. */
  110571. _afterRenderStage: Stage<SimpleStageAction>;
  110572. /**
  110573. * @hidden
  110574. * Defines the actions happening when a pointer move event happens.
  110575. */
  110576. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110577. /**
  110578. * @hidden
  110579. * Defines the actions happening when a pointer down event happens.
  110580. */
  110581. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110582. /**
  110583. * @hidden
  110584. * Defines the actions happening when a pointer up event happens.
  110585. */
  110586. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110587. /**
  110588. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110589. */
  110590. private geometriesByUniqueId;
  110591. /**
  110592. * Creates a new Scene
  110593. * @param engine defines the engine to use to render this scene
  110594. * @param options defines the scene options
  110595. */
  110596. constructor(engine: Engine, options?: SceneOptions);
  110597. /**
  110598. * Gets a string idenfifying the name of the class
  110599. * @returns "Scene" string
  110600. */
  110601. getClassName(): string;
  110602. private _defaultMeshCandidates;
  110603. /**
  110604. * @hidden
  110605. */
  110606. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110607. private _defaultSubMeshCandidates;
  110608. /**
  110609. * @hidden
  110610. */
  110611. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110612. /**
  110613. * Sets the default candidate providers for the scene.
  110614. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110615. * and getCollidingSubMeshCandidates to their default function
  110616. */
  110617. setDefaultCandidateProviders(): void;
  110618. /**
  110619. * Gets the mesh that is currently under the pointer
  110620. */
  110621. get meshUnderPointer(): Nullable<AbstractMesh>;
  110622. /**
  110623. * Gets or sets the current on-screen X position of the pointer
  110624. */
  110625. get pointerX(): number;
  110626. set pointerX(value: number);
  110627. /**
  110628. * Gets or sets the current on-screen Y position of the pointer
  110629. */
  110630. get pointerY(): number;
  110631. set pointerY(value: number);
  110632. /**
  110633. * Gets the cached material (ie. the latest rendered one)
  110634. * @returns the cached material
  110635. */
  110636. getCachedMaterial(): Nullable<Material>;
  110637. /**
  110638. * Gets the cached effect (ie. the latest rendered one)
  110639. * @returns the cached effect
  110640. */
  110641. getCachedEffect(): Nullable<Effect>;
  110642. /**
  110643. * Gets the cached visibility state (ie. the latest rendered one)
  110644. * @returns the cached visibility state
  110645. */
  110646. getCachedVisibility(): Nullable<number>;
  110647. /**
  110648. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110649. * @param material defines the current material
  110650. * @param effect defines the current effect
  110651. * @param visibility defines the current visibility state
  110652. * @returns true if one parameter is not cached
  110653. */
  110654. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110655. /**
  110656. * Gets the engine associated with the scene
  110657. * @returns an Engine
  110658. */
  110659. getEngine(): Engine;
  110660. /**
  110661. * Gets the total number of vertices rendered per frame
  110662. * @returns the total number of vertices rendered per frame
  110663. */
  110664. getTotalVertices(): number;
  110665. /**
  110666. * Gets the performance counter for total vertices
  110667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110668. */
  110669. get totalVerticesPerfCounter(): PerfCounter;
  110670. /**
  110671. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110672. * @returns the total number of active indices rendered per frame
  110673. */
  110674. getActiveIndices(): number;
  110675. /**
  110676. * Gets the performance counter for active indices
  110677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110678. */
  110679. get totalActiveIndicesPerfCounter(): PerfCounter;
  110680. /**
  110681. * Gets the total number of active particles rendered per frame
  110682. * @returns the total number of active particles rendered per frame
  110683. */
  110684. getActiveParticles(): number;
  110685. /**
  110686. * Gets the performance counter for active particles
  110687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110688. */
  110689. get activeParticlesPerfCounter(): PerfCounter;
  110690. /**
  110691. * Gets the total number of active bones rendered per frame
  110692. * @returns the total number of active bones rendered per frame
  110693. */
  110694. getActiveBones(): number;
  110695. /**
  110696. * Gets the performance counter for active bones
  110697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110698. */
  110699. get activeBonesPerfCounter(): PerfCounter;
  110700. /**
  110701. * Gets the array of active meshes
  110702. * @returns an array of AbstractMesh
  110703. */
  110704. getActiveMeshes(): SmartArray<AbstractMesh>;
  110705. /**
  110706. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110707. * @returns a number
  110708. */
  110709. getAnimationRatio(): number;
  110710. /**
  110711. * Gets an unique Id for the current render phase
  110712. * @returns a number
  110713. */
  110714. getRenderId(): number;
  110715. /**
  110716. * Gets an unique Id for the current frame
  110717. * @returns a number
  110718. */
  110719. getFrameId(): number;
  110720. /** Call this function if you want to manually increment the render Id*/
  110721. incrementRenderId(): void;
  110722. private _createUbo;
  110723. /**
  110724. * Use this method to simulate a pointer move on a mesh
  110725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110728. * @returns the current scene
  110729. */
  110730. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110731. /**
  110732. * Use this method to simulate a pointer down on a mesh
  110733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110736. * @returns the current scene
  110737. */
  110738. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110739. /**
  110740. * Use this method to simulate a pointer up on a mesh
  110741. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110742. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110743. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110744. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110745. * @returns the current scene
  110746. */
  110747. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110748. /**
  110749. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110750. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110751. * @returns true if the pointer was captured
  110752. */
  110753. isPointerCaptured(pointerId?: number): boolean;
  110754. /**
  110755. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110756. * @param attachUp defines if you want to attach events to pointerup
  110757. * @param attachDown defines if you want to attach events to pointerdown
  110758. * @param attachMove defines if you want to attach events to pointermove
  110759. */
  110760. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110761. /** Detaches all event handlers*/
  110762. detachControl(): void;
  110763. /**
  110764. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110765. * Delay loaded resources are not taking in account
  110766. * @return true if all required resources are ready
  110767. */
  110768. isReady(): boolean;
  110769. /** Resets all cached information relative to material (including effect and visibility) */
  110770. resetCachedMaterial(): void;
  110771. /**
  110772. * Registers a function to be called before every frame render
  110773. * @param func defines the function to register
  110774. */
  110775. registerBeforeRender(func: () => void): void;
  110776. /**
  110777. * Unregisters a function called before every frame render
  110778. * @param func defines the function to unregister
  110779. */
  110780. unregisterBeforeRender(func: () => void): void;
  110781. /**
  110782. * Registers a function to be called after every frame render
  110783. * @param func defines the function to register
  110784. */
  110785. registerAfterRender(func: () => void): void;
  110786. /**
  110787. * Unregisters a function called after every frame render
  110788. * @param func defines the function to unregister
  110789. */
  110790. unregisterAfterRender(func: () => void): void;
  110791. private _executeOnceBeforeRender;
  110792. /**
  110793. * The provided function will run before render once and will be disposed afterwards.
  110794. * A timeout delay can be provided so that the function will be executed in N ms.
  110795. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110796. * @param func The function to be executed.
  110797. * @param timeout optional delay in ms
  110798. */
  110799. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110800. /** @hidden */
  110801. _addPendingData(data: any): void;
  110802. /** @hidden */
  110803. _removePendingData(data: any): void;
  110804. /**
  110805. * Returns the number of items waiting to be loaded
  110806. * @returns the number of items waiting to be loaded
  110807. */
  110808. getWaitingItemsCount(): number;
  110809. /**
  110810. * Returns a boolean indicating if the scene is still loading data
  110811. */
  110812. get isLoading(): boolean;
  110813. /**
  110814. * Registers a function to be executed when the scene is ready
  110815. * @param {Function} func - the function to be executed
  110816. */
  110817. executeWhenReady(func: () => void): void;
  110818. /**
  110819. * Returns a promise that resolves when the scene is ready
  110820. * @returns A promise that resolves when the scene is ready
  110821. */
  110822. whenReadyAsync(): Promise<void>;
  110823. /** @hidden */
  110824. _checkIsReady(): void;
  110825. /**
  110826. * Gets all animatable attached to the scene
  110827. */
  110828. get animatables(): Animatable[];
  110829. /**
  110830. * Resets the last animation time frame.
  110831. * Useful to override when animations start running when loading a scene for the first time.
  110832. */
  110833. resetLastAnimationTimeFrame(): void;
  110834. /**
  110835. * Gets the current view matrix
  110836. * @returns a Matrix
  110837. */
  110838. getViewMatrix(): Matrix;
  110839. /**
  110840. * Gets the current projection matrix
  110841. * @returns a Matrix
  110842. */
  110843. getProjectionMatrix(): Matrix;
  110844. /**
  110845. * Gets the current transform matrix
  110846. * @returns a Matrix made of View * Projection
  110847. */
  110848. getTransformMatrix(): Matrix;
  110849. /**
  110850. * Sets the current transform matrix
  110851. * @param viewL defines the View matrix to use
  110852. * @param projectionL defines the Projection matrix to use
  110853. * @param viewR defines the right View matrix to use (if provided)
  110854. * @param projectionR defines the right Projection matrix to use (if provided)
  110855. */
  110856. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110857. /**
  110858. * Gets the uniform buffer used to store scene data
  110859. * @returns a UniformBuffer
  110860. */
  110861. getSceneUniformBuffer(): UniformBuffer;
  110862. /**
  110863. * Gets an unique (relatively to the current scene) Id
  110864. * @returns an unique number for the scene
  110865. */
  110866. getUniqueId(): number;
  110867. /**
  110868. * Add a mesh to the list of scene's meshes
  110869. * @param newMesh defines the mesh to add
  110870. * @param recursive if all child meshes should also be added to the scene
  110871. */
  110872. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110873. /**
  110874. * Remove a mesh for the list of scene's meshes
  110875. * @param toRemove defines the mesh to remove
  110876. * @param recursive if all child meshes should also be removed from the scene
  110877. * @returns the index where the mesh was in the mesh list
  110878. */
  110879. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110880. /**
  110881. * Add a transform node to the list of scene's transform nodes
  110882. * @param newTransformNode defines the transform node to add
  110883. */
  110884. addTransformNode(newTransformNode: TransformNode): void;
  110885. /**
  110886. * Remove a transform node for the list of scene's transform nodes
  110887. * @param toRemove defines the transform node to remove
  110888. * @returns the index where the transform node was in the transform node list
  110889. */
  110890. removeTransformNode(toRemove: TransformNode): number;
  110891. /**
  110892. * Remove a skeleton for the list of scene's skeletons
  110893. * @param toRemove defines the skeleton to remove
  110894. * @returns the index where the skeleton was in the skeleton list
  110895. */
  110896. removeSkeleton(toRemove: Skeleton): number;
  110897. /**
  110898. * Remove a morph target for the list of scene's morph targets
  110899. * @param toRemove defines the morph target to remove
  110900. * @returns the index where the morph target was in the morph target list
  110901. */
  110902. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110903. /**
  110904. * Remove a light for the list of scene's lights
  110905. * @param toRemove defines the light to remove
  110906. * @returns the index where the light was in the light list
  110907. */
  110908. removeLight(toRemove: Light): number;
  110909. /**
  110910. * Remove a camera for the list of scene's cameras
  110911. * @param toRemove defines the camera to remove
  110912. * @returns the index where the camera was in the camera list
  110913. */
  110914. removeCamera(toRemove: Camera): number;
  110915. /**
  110916. * Remove a particle system for the list of scene's particle systems
  110917. * @param toRemove defines the particle system to remove
  110918. * @returns the index where the particle system was in the particle system list
  110919. */
  110920. removeParticleSystem(toRemove: IParticleSystem): number;
  110921. /**
  110922. * Remove a animation for the list of scene's animations
  110923. * @param toRemove defines the animation to remove
  110924. * @returns the index where the animation was in the animation list
  110925. */
  110926. removeAnimation(toRemove: Animation): number;
  110927. /**
  110928. * Will stop the animation of the given target
  110929. * @param target - the target
  110930. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110931. * @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)
  110932. */
  110933. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110934. /**
  110935. * Removes the given animation group from this scene.
  110936. * @param toRemove The animation group to remove
  110937. * @returns The index of the removed animation group
  110938. */
  110939. removeAnimationGroup(toRemove: AnimationGroup): number;
  110940. /**
  110941. * Removes the given multi-material from this scene.
  110942. * @param toRemove The multi-material to remove
  110943. * @returns The index of the removed multi-material
  110944. */
  110945. removeMultiMaterial(toRemove: MultiMaterial): number;
  110946. /**
  110947. * Removes the given material from this scene.
  110948. * @param toRemove The material to remove
  110949. * @returns The index of the removed material
  110950. */
  110951. removeMaterial(toRemove: Material): number;
  110952. /**
  110953. * Removes the given action manager from this scene.
  110954. * @param toRemove The action manager to remove
  110955. * @returns The index of the removed action manager
  110956. */
  110957. removeActionManager(toRemove: AbstractActionManager): number;
  110958. /**
  110959. * Removes the given texture from this scene.
  110960. * @param toRemove The texture to remove
  110961. * @returns The index of the removed texture
  110962. */
  110963. removeTexture(toRemove: BaseTexture): number;
  110964. /**
  110965. * Adds the given light to this scene
  110966. * @param newLight The light to add
  110967. */
  110968. addLight(newLight: Light): void;
  110969. /**
  110970. * Sorts the list list based on light priorities
  110971. */
  110972. sortLightsByPriority(): void;
  110973. /**
  110974. * Adds the given camera to this scene
  110975. * @param newCamera The camera to add
  110976. */
  110977. addCamera(newCamera: Camera): void;
  110978. /**
  110979. * Adds the given skeleton to this scene
  110980. * @param newSkeleton The skeleton to add
  110981. */
  110982. addSkeleton(newSkeleton: Skeleton): void;
  110983. /**
  110984. * Adds the given particle system to this scene
  110985. * @param newParticleSystem The particle system to add
  110986. */
  110987. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110988. /**
  110989. * Adds the given animation to this scene
  110990. * @param newAnimation The animation to add
  110991. */
  110992. addAnimation(newAnimation: Animation): void;
  110993. /**
  110994. * Adds the given animation group to this scene.
  110995. * @param newAnimationGroup The animation group to add
  110996. */
  110997. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110998. /**
  110999. * Adds the given multi-material to this scene
  111000. * @param newMultiMaterial The multi-material to add
  111001. */
  111002. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  111003. /**
  111004. * Adds the given material to this scene
  111005. * @param newMaterial The material to add
  111006. */
  111007. addMaterial(newMaterial: Material): void;
  111008. /**
  111009. * Adds the given morph target to this scene
  111010. * @param newMorphTargetManager The morph target to add
  111011. */
  111012. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  111013. /**
  111014. * Adds the given geometry to this scene
  111015. * @param newGeometry The geometry to add
  111016. */
  111017. addGeometry(newGeometry: Geometry): void;
  111018. /**
  111019. * Adds the given action manager to this scene
  111020. * @param newActionManager The action manager to add
  111021. */
  111022. addActionManager(newActionManager: AbstractActionManager): void;
  111023. /**
  111024. * Adds the given texture to this scene.
  111025. * @param newTexture The texture to add
  111026. */
  111027. addTexture(newTexture: BaseTexture): void;
  111028. /**
  111029. * Switch active camera
  111030. * @param newCamera defines the new active camera
  111031. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111032. */
  111033. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111034. /**
  111035. * sets the active camera of the scene using its ID
  111036. * @param id defines the camera's ID
  111037. * @return the new active camera or null if none found.
  111038. */
  111039. setActiveCameraByID(id: string): Nullable<Camera>;
  111040. /**
  111041. * sets the active camera of the scene using its name
  111042. * @param name defines the camera's name
  111043. * @returns the new active camera or null if none found.
  111044. */
  111045. setActiveCameraByName(name: string): Nullable<Camera>;
  111046. /**
  111047. * get an animation group using its name
  111048. * @param name defines the material's name
  111049. * @return the animation group or null if none found.
  111050. */
  111051. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111052. /**
  111053. * Get a material using its unique id
  111054. * @param uniqueId defines the material's unique id
  111055. * @return the material or null if none found.
  111056. */
  111057. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111058. /**
  111059. * get a material using its id
  111060. * @param id defines the material's ID
  111061. * @return the material or null if none found.
  111062. */
  111063. getMaterialByID(id: string): Nullable<Material>;
  111064. /**
  111065. * Gets a the last added material using a given id
  111066. * @param id defines the material's ID
  111067. * @return the last material with the given id or null if none found.
  111068. */
  111069. getLastMaterialByID(id: string): Nullable<Material>;
  111070. /**
  111071. * Gets a material using its name
  111072. * @param name defines the material's name
  111073. * @return the material or null if none found.
  111074. */
  111075. getMaterialByName(name: string): Nullable<Material>;
  111076. /**
  111077. * Get a texture using its unique id
  111078. * @param uniqueId defines the texture's unique id
  111079. * @return the texture or null if none found.
  111080. */
  111081. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111082. /**
  111083. * Gets a camera using its id
  111084. * @param id defines the id to look for
  111085. * @returns the camera or null if not found
  111086. */
  111087. getCameraByID(id: string): Nullable<Camera>;
  111088. /**
  111089. * Gets a camera using its unique id
  111090. * @param uniqueId defines the unique id to look for
  111091. * @returns the camera or null if not found
  111092. */
  111093. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111094. /**
  111095. * Gets a camera using its name
  111096. * @param name defines the camera's name
  111097. * @return the camera or null if none found.
  111098. */
  111099. getCameraByName(name: string): Nullable<Camera>;
  111100. /**
  111101. * Gets a bone using its id
  111102. * @param id defines the bone's id
  111103. * @return the bone or null if not found
  111104. */
  111105. getBoneByID(id: string): Nullable<Bone>;
  111106. /**
  111107. * Gets a bone using its id
  111108. * @param name defines the bone's name
  111109. * @return the bone or null if not found
  111110. */
  111111. getBoneByName(name: string): Nullable<Bone>;
  111112. /**
  111113. * Gets a light node using its name
  111114. * @param name defines the the light's name
  111115. * @return the light or null if none found.
  111116. */
  111117. getLightByName(name: string): Nullable<Light>;
  111118. /**
  111119. * Gets a light node using its id
  111120. * @param id defines the light's id
  111121. * @return the light or null if none found.
  111122. */
  111123. getLightByID(id: string): Nullable<Light>;
  111124. /**
  111125. * Gets a light node using its scene-generated unique ID
  111126. * @param uniqueId defines the light's unique id
  111127. * @return the light or null if none found.
  111128. */
  111129. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111130. /**
  111131. * Gets a particle system by id
  111132. * @param id defines the particle system id
  111133. * @return the corresponding system or null if none found
  111134. */
  111135. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111136. /**
  111137. * Gets a geometry using its ID
  111138. * @param id defines the geometry's id
  111139. * @return the geometry or null if none found.
  111140. */
  111141. getGeometryByID(id: string): Nullable<Geometry>;
  111142. private _getGeometryByUniqueID;
  111143. /**
  111144. * Add a new geometry to this scene
  111145. * @param geometry defines the geometry to be added to the scene.
  111146. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111147. * @return a boolean defining if the geometry was added or not
  111148. */
  111149. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111150. /**
  111151. * Removes an existing geometry
  111152. * @param geometry defines the geometry to be removed from the scene
  111153. * @return a boolean defining if the geometry was removed or not
  111154. */
  111155. removeGeometry(geometry: Geometry): boolean;
  111156. /**
  111157. * Gets the list of geometries attached to the scene
  111158. * @returns an array of Geometry
  111159. */
  111160. getGeometries(): Geometry[];
  111161. /**
  111162. * Gets the first added mesh found of a given ID
  111163. * @param id defines the id to search for
  111164. * @return the mesh found or null if not found at all
  111165. */
  111166. getMeshByID(id: string): Nullable<AbstractMesh>;
  111167. /**
  111168. * Gets a list of meshes using their id
  111169. * @param id defines the id to search for
  111170. * @returns a list of meshes
  111171. */
  111172. getMeshesByID(id: string): Array<AbstractMesh>;
  111173. /**
  111174. * Gets the first added transform node found of a given ID
  111175. * @param id defines the id to search for
  111176. * @return the found transform node or null if not found at all.
  111177. */
  111178. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111179. /**
  111180. * Gets a transform node with its auto-generated unique id
  111181. * @param uniqueId efines the unique id to search for
  111182. * @return the found transform node or null if not found at all.
  111183. */
  111184. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111185. /**
  111186. * Gets a list of transform nodes using their id
  111187. * @param id defines the id to search for
  111188. * @returns a list of transform nodes
  111189. */
  111190. getTransformNodesByID(id: string): Array<TransformNode>;
  111191. /**
  111192. * Gets a mesh with its auto-generated unique id
  111193. * @param uniqueId defines the unique id to search for
  111194. * @return the found mesh or null if not found at all.
  111195. */
  111196. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111197. /**
  111198. * Gets a the last added mesh using a given id
  111199. * @param id defines the id to search for
  111200. * @return the found mesh or null if not found at all.
  111201. */
  111202. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111203. /**
  111204. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111205. * @param id defines the id to search for
  111206. * @return the found node or null if not found at all
  111207. */
  111208. getLastEntryByID(id: string): Nullable<Node>;
  111209. /**
  111210. * Gets a node (Mesh, Camera, Light) using a given id
  111211. * @param id defines the id to search for
  111212. * @return the found node or null if not found at all
  111213. */
  111214. getNodeByID(id: string): Nullable<Node>;
  111215. /**
  111216. * Gets a node (Mesh, Camera, Light) using a given name
  111217. * @param name defines the name to search for
  111218. * @return the found node or null if not found at all.
  111219. */
  111220. getNodeByName(name: string): Nullable<Node>;
  111221. /**
  111222. * Gets a mesh using a given name
  111223. * @param name defines the name to search for
  111224. * @return the found mesh or null if not found at all.
  111225. */
  111226. getMeshByName(name: string): Nullable<AbstractMesh>;
  111227. /**
  111228. * Gets a transform node using a given name
  111229. * @param name defines the name to search for
  111230. * @return the found transform node or null if not found at all.
  111231. */
  111232. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111233. /**
  111234. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111235. * @param id defines the id to search for
  111236. * @return the found skeleton or null if not found at all.
  111237. */
  111238. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111239. /**
  111240. * Gets a skeleton using a given auto generated unique id
  111241. * @param uniqueId defines the unique id to search for
  111242. * @return the found skeleton or null if not found at all.
  111243. */
  111244. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111245. /**
  111246. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111247. * @param id defines the id to search for
  111248. * @return the found skeleton or null if not found at all.
  111249. */
  111250. getSkeletonById(id: string): Nullable<Skeleton>;
  111251. /**
  111252. * Gets a skeleton using a given name
  111253. * @param name defines the name to search for
  111254. * @return the found skeleton or null if not found at all.
  111255. */
  111256. getSkeletonByName(name: string): Nullable<Skeleton>;
  111257. /**
  111258. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111259. * @param id defines the id to search for
  111260. * @return the found morph target manager or null if not found at all.
  111261. */
  111262. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111263. /**
  111264. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111265. * @param id defines the id to search for
  111266. * @return the found morph target or null if not found at all.
  111267. */
  111268. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111269. /**
  111270. * Gets a boolean indicating if the given mesh is active
  111271. * @param mesh defines the mesh to look for
  111272. * @returns true if the mesh is in the active list
  111273. */
  111274. isActiveMesh(mesh: AbstractMesh): boolean;
  111275. /**
  111276. * Return a unique id as a string which can serve as an identifier for the scene
  111277. */
  111278. get uid(): string;
  111279. /**
  111280. * Add an externaly attached data from its key.
  111281. * This method call will fail and return false, if such key already exists.
  111282. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111283. * @param key the unique key that identifies the data
  111284. * @param data the data object to associate to the key for this Engine instance
  111285. * @return true if no such key were already present and the data was added successfully, false otherwise
  111286. */
  111287. addExternalData<T>(key: string, data: T): boolean;
  111288. /**
  111289. * Get an externaly attached data from its key
  111290. * @param key the unique key that identifies the data
  111291. * @return the associated data, if present (can be null), or undefined if not present
  111292. */
  111293. getExternalData<T>(key: string): Nullable<T>;
  111294. /**
  111295. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111296. * @param key the unique key that identifies the data
  111297. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111298. * @return the associated data, can be null if the factory returned null.
  111299. */
  111300. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111301. /**
  111302. * Remove an externaly attached data from the Engine instance
  111303. * @param key the unique key that identifies the data
  111304. * @return true if the data was successfully removed, false if it doesn't exist
  111305. */
  111306. removeExternalData(key: string): boolean;
  111307. private _evaluateSubMesh;
  111308. /**
  111309. * Clear the processed materials smart array preventing retention point in material dispose.
  111310. */
  111311. freeProcessedMaterials(): void;
  111312. private _preventFreeActiveMeshesAndRenderingGroups;
  111313. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111314. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111315. * when disposing several meshes in a row or a hierarchy of meshes.
  111316. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111317. */
  111318. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111319. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111320. /**
  111321. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111322. */
  111323. freeActiveMeshes(): void;
  111324. /**
  111325. * Clear the info related to rendering groups preventing retention points during dispose.
  111326. */
  111327. freeRenderingGroups(): void;
  111328. /** @hidden */
  111329. _isInIntermediateRendering(): boolean;
  111330. /**
  111331. * Lambda returning the list of potentially active meshes.
  111332. */
  111333. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111334. /**
  111335. * Lambda returning the list of potentially active sub meshes.
  111336. */
  111337. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111338. /**
  111339. * Lambda returning the list of potentially intersecting sub meshes.
  111340. */
  111341. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111342. /**
  111343. * Lambda returning the list of potentially colliding sub meshes.
  111344. */
  111345. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111346. private _activeMeshesFrozen;
  111347. private _skipEvaluateActiveMeshesCompletely;
  111348. /**
  111349. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111350. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111351. * @returns the current scene
  111352. */
  111353. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111354. /**
  111355. * Use this function to restart evaluating active meshes on every frame
  111356. * @returns the current scene
  111357. */
  111358. unfreezeActiveMeshes(): Scene;
  111359. private _evaluateActiveMeshes;
  111360. private _activeMesh;
  111361. /**
  111362. * Update the transform matrix to update from the current active camera
  111363. * @param force defines a boolean used to force the update even if cache is up to date
  111364. */
  111365. updateTransformMatrix(force?: boolean): void;
  111366. private _bindFrameBuffer;
  111367. /** @hidden */
  111368. _allowPostProcessClearColor: boolean;
  111369. /** @hidden */
  111370. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111371. private _processSubCameras;
  111372. private _checkIntersections;
  111373. /** @hidden */
  111374. _advancePhysicsEngineStep(step: number): void;
  111375. /**
  111376. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111377. */
  111378. getDeterministicFrameTime: () => number;
  111379. /** @hidden */
  111380. _animate(): void;
  111381. /** Execute all animations (for a frame) */
  111382. animate(): void;
  111383. /**
  111384. * Render the scene
  111385. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111386. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111387. */
  111388. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111389. /**
  111390. * Freeze all materials
  111391. * A frozen material will not be updatable but should be faster to render
  111392. */
  111393. freezeMaterials(): void;
  111394. /**
  111395. * Unfreeze all materials
  111396. * A frozen material will not be updatable but should be faster to render
  111397. */
  111398. unfreezeMaterials(): void;
  111399. /**
  111400. * Releases all held ressources
  111401. */
  111402. dispose(): void;
  111403. /**
  111404. * Gets if the scene is already disposed
  111405. */
  111406. get isDisposed(): boolean;
  111407. /**
  111408. * Call this function to reduce memory footprint of the scene.
  111409. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111410. */
  111411. clearCachedVertexData(): void;
  111412. /**
  111413. * This function will remove the local cached buffer data from texture.
  111414. * It will save memory but will prevent the texture from being rebuilt
  111415. */
  111416. cleanCachedTextureBuffer(): void;
  111417. /**
  111418. * Get the world extend vectors with an optional filter
  111419. *
  111420. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111421. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111422. */
  111423. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111424. min: Vector3;
  111425. max: Vector3;
  111426. };
  111427. /**
  111428. * Creates a ray that can be used to pick in the scene
  111429. * @param x defines the x coordinate of the origin (on-screen)
  111430. * @param y defines the y coordinate of the origin (on-screen)
  111431. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111432. * @param camera defines the camera to use for the picking
  111433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111434. * @returns a Ray
  111435. */
  111436. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111437. /**
  111438. * Creates a ray that can be used to pick in the scene
  111439. * @param x defines the x coordinate of the origin (on-screen)
  111440. * @param y defines the y coordinate of the origin (on-screen)
  111441. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111442. * @param result defines the ray where to store the picking ray
  111443. * @param camera defines the camera to use for the picking
  111444. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111445. * @returns the current scene
  111446. */
  111447. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111448. /**
  111449. * Creates a ray that can be used to pick in the scene
  111450. * @param x defines the x coordinate of the origin (on-screen)
  111451. * @param y defines the y coordinate of the origin (on-screen)
  111452. * @param camera defines the camera to use for the picking
  111453. * @returns a Ray
  111454. */
  111455. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111456. /**
  111457. * Creates a ray that can be used to pick in the scene
  111458. * @param x defines the x coordinate of the origin (on-screen)
  111459. * @param y defines the y coordinate of the origin (on-screen)
  111460. * @param result defines the ray where to store the picking ray
  111461. * @param camera defines the camera to use for the picking
  111462. * @returns the current scene
  111463. */
  111464. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111465. /** Launch a ray to try to pick a mesh in the scene
  111466. * @param x position on screen
  111467. * @param y position on screen
  111468. * @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
  111469. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111470. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111471. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111472. * @returns a PickingInfo
  111473. */
  111474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111475. /** Use the given ray to pick a mesh in the scene
  111476. * @param ray The ray to use to pick meshes
  111477. * @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
  111478. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111480. * @returns a PickingInfo
  111481. */
  111482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111483. /**
  111484. * Launch a ray to try to pick a mesh in the scene
  111485. * @param x X position on screen
  111486. * @param y Y position on screen
  111487. * @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
  111488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111489. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111490. * @returns an array of PickingInfo
  111491. */
  111492. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111493. /**
  111494. * Launch a ray to try to pick a mesh in the scene
  111495. * @param ray Ray to use
  111496. * @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
  111497. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111498. * @returns an array of PickingInfo
  111499. */
  111500. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111501. /**
  111502. * Force the value of meshUnderPointer
  111503. * @param mesh defines the mesh to use
  111504. */
  111505. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111506. /**
  111507. * Gets the mesh under the pointer
  111508. * @returns a Mesh or null if no mesh is under the pointer
  111509. */
  111510. getPointerOverMesh(): Nullable<AbstractMesh>;
  111511. /** @hidden */
  111512. _rebuildGeometries(): void;
  111513. /** @hidden */
  111514. _rebuildTextures(): void;
  111515. private _getByTags;
  111516. /**
  111517. * Get a list of meshes by tags
  111518. * @param tagsQuery defines the tags query to use
  111519. * @param forEach defines a predicate used to filter results
  111520. * @returns an array of Mesh
  111521. */
  111522. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111523. /**
  111524. * Get a list of cameras by tags
  111525. * @param tagsQuery defines the tags query to use
  111526. * @param forEach defines a predicate used to filter results
  111527. * @returns an array of Camera
  111528. */
  111529. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111530. /**
  111531. * Get a list of lights by tags
  111532. * @param tagsQuery defines the tags query to use
  111533. * @param forEach defines a predicate used to filter results
  111534. * @returns an array of Light
  111535. */
  111536. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111537. /**
  111538. * Get a list of materials by tags
  111539. * @param tagsQuery defines the tags query to use
  111540. * @param forEach defines a predicate used to filter results
  111541. * @returns an array of Material
  111542. */
  111543. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111544. /**
  111545. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111546. * This allowed control for front to back rendering or reversly depending of the special needs.
  111547. *
  111548. * @param renderingGroupId The rendering group id corresponding to its index
  111549. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111550. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111551. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111552. */
  111553. 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;
  111554. /**
  111555. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111556. *
  111557. * @param renderingGroupId The rendering group id corresponding to its index
  111558. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111559. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111560. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111561. */
  111562. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111563. /**
  111564. * Gets the current auto clear configuration for one rendering group of the rendering
  111565. * manager.
  111566. * @param index the rendering group index to get the information for
  111567. * @returns The auto clear setup for the requested rendering group
  111568. */
  111569. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111570. private _blockMaterialDirtyMechanism;
  111571. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111572. get blockMaterialDirtyMechanism(): boolean;
  111573. set blockMaterialDirtyMechanism(value: boolean);
  111574. /**
  111575. * Will flag all materials as dirty to trigger new shader compilation
  111576. * @param flag defines the flag used to specify which material part must be marked as dirty
  111577. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111578. */
  111579. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111580. /** @hidden */
  111581. _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;
  111582. /** @hidden */
  111583. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111584. /** @hidden */
  111585. _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;
  111586. /** @hidden */
  111587. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111588. /** @hidden */
  111589. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111590. /** @hidden */
  111591. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111592. }
  111593. }
  111594. declare module BABYLON {
  111595. /**
  111596. * Set of assets to keep when moving a scene into an asset container.
  111597. */
  111598. export class KeepAssets extends AbstractScene {
  111599. }
  111600. /**
  111601. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111602. */
  111603. export class InstantiatedEntries {
  111604. /**
  111605. * List of new root nodes (eg. nodes with no parent)
  111606. */
  111607. rootNodes: TransformNode[];
  111608. /**
  111609. * List of new skeletons
  111610. */
  111611. skeletons: Skeleton[];
  111612. /**
  111613. * List of new animation groups
  111614. */
  111615. animationGroups: AnimationGroup[];
  111616. }
  111617. /**
  111618. * Container with a set of assets that can be added or removed from a scene.
  111619. */
  111620. export class AssetContainer extends AbstractScene {
  111621. private _wasAddedToScene;
  111622. /**
  111623. * The scene the AssetContainer belongs to.
  111624. */
  111625. scene: Scene;
  111626. /**
  111627. * Instantiates an AssetContainer.
  111628. * @param scene The scene the AssetContainer belongs to.
  111629. */
  111630. constructor(scene: Scene);
  111631. /**
  111632. * Instantiate or clone all meshes and add the new ones to the scene.
  111633. * Skeletons and animation groups will all be cloned
  111634. * @param nameFunction defines an optional function used to get new names for clones
  111635. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111636. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111637. */
  111638. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111639. /**
  111640. * Adds all the assets from the container to the scene.
  111641. */
  111642. addAllToScene(): void;
  111643. /**
  111644. * Removes all the assets in the container from the scene
  111645. */
  111646. removeAllFromScene(): void;
  111647. /**
  111648. * Disposes all the assets in the container
  111649. */
  111650. dispose(): void;
  111651. private _moveAssets;
  111652. /**
  111653. * Removes all the assets contained in the scene and adds them to the container.
  111654. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111655. */
  111656. moveAllFromScene(keepAssets?: KeepAssets): void;
  111657. /**
  111658. * 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.
  111659. * @returns the root mesh
  111660. */
  111661. createRootMesh(): Mesh;
  111662. /**
  111663. * Merge animations from this asset container into a scene
  111664. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111665. * @param animatables set of animatables to retarget to a node from the scene
  111666. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111667. */
  111668. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111669. }
  111670. }
  111671. declare module BABYLON {
  111672. /**
  111673. * Defines how the parser contract is defined.
  111674. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111675. */
  111676. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111677. /**
  111678. * Defines how the individual parser contract is defined.
  111679. * These parser can parse an individual asset
  111680. */
  111681. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111682. /**
  111683. * Base class of the scene acting as a container for the different elements composing a scene.
  111684. * This class is dynamically extended by the different components of the scene increasing
  111685. * flexibility and reducing coupling
  111686. */
  111687. export abstract class AbstractScene {
  111688. /**
  111689. * Stores the list of available parsers in the application.
  111690. */
  111691. private static _BabylonFileParsers;
  111692. /**
  111693. * Stores the list of available individual parsers in the application.
  111694. */
  111695. private static _IndividualBabylonFileParsers;
  111696. /**
  111697. * Adds a parser in the list of available ones
  111698. * @param name Defines the name of the parser
  111699. * @param parser Defines the parser to add
  111700. */
  111701. static AddParser(name: string, parser: BabylonFileParser): void;
  111702. /**
  111703. * Gets a general parser from the list of avaialble ones
  111704. * @param name Defines the name of the parser
  111705. * @returns the requested parser or null
  111706. */
  111707. static GetParser(name: string): Nullable<BabylonFileParser>;
  111708. /**
  111709. * Adds n individual parser in the list of available ones
  111710. * @param name Defines the name of the parser
  111711. * @param parser Defines the parser to add
  111712. */
  111713. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111714. /**
  111715. * Gets an individual parser from the list of avaialble ones
  111716. * @param name Defines the name of the parser
  111717. * @returns the requested parser or null
  111718. */
  111719. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111720. /**
  111721. * Parser json data and populate both a scene and its associated container object
  111722. * @param jsonData Defines the data to parse
  111723. * @param scene Defines the scene to parse the data for
  111724. * @param container Defines the container attached to the parsing sequence
  111725. * @param rootUrl Defines the root url of the data
  111726. */
  111727. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111728. /**
  111729. * Gets the list of root nodes (ie. nodes with no parent)
  111730. */
  111731. rootNodes: Node[];
  111732. /** All of the cameras added to this scene
  111733. * @see http://doc.babylonjs.com/babylon101/cameras
  111734. */
  111735. cameras: Camera[];
  111736. /**
  111737. * All of the lights added to this scene
  111738. * @see http://doc.babylonjs.com/babylon101/lights
  111739. */
  111740. lights: Light[];
  111741. /**
  111742. * All of the (abstract) meshes added to this scene
  111743. */
  111744. meshes: AbstractMesh[];
  111745. /**
  111746. * The list of skeletons added to the scene
  111747. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111748. */
  111749. skeletons: Skeleton[];
  111750. /**
  111751. * All of the particle systems added to this scene
  111752. * @see http://doc.babylonjs.com/babylon101/particles
  111753. */
  111754. particleSystems: IParticleSystem[];
  111755. /**
  111756. * Gets a list of Animations associated with the scene
  111757. */
  111758. animations: Animation[];
  111759. /**
  111760. * All of the animation groups added to this scene
  111761. * @see http://doc.babylonjs.com/how_to/group
  111762. */
  111763. animationGroups: AnimationGroup[];
  111764. /**
  111765. * All of the multi-materials added to this scene
  111766. * @see http://doc.babylonjs.com/how_to/multi_materials
  111767. */
  111768. multiMaterials: MultiMaterial[];
  111769. /**
  111770. * All of the materials added to this scene
  111771. * In the context of a Scene, it is not supposed to be modified manually.
  111772. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111773. * Note also that the order of the Material within the array is not significant and might change.
  111774. * @see http://doc.babylonjs.com/babylon101/materials
  111775. */
  111776. materials: Material[];
  111777. /**
  111778. * The list of morph target managers added to the scene
  111779. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111780. */
  111781. morphTargetManagers: MorphTargetManager[];
  111782. /**
  111783. * The list of geometries used in the scene.
  111784. */
  111785. geometries: Geometry[];
  111786. /**
  111787. * All of the tranform nodes added to this scene
  111788. * In the context of a Scene, it is not supposed to be modified manually.
  111789. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111790. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111791. * @see http://doc.babylonjs.com/how_to/transformnode
  111792. */
  111793. transformNodes: TransformNode[];
  111794. /**
  111795. * ActionManagers available on the scene.
  111796. */
  111797. actionManagers: AbstractActionManager[];
  111798. /**
  111799. * Textures to keep.
  111800. */
  111801. textures: BaseTexture[];
  111802. /**
  111803. * Environment texture for the scene
  111804. */
  111805. environmentTexture: Nullable<BaseTexture>;
  111806. /**
  111807. * @returns all meshes, lights, cameras, transformNodes and bones
  111808. */
  111809. getNodes(): Array<Node>;
  111810. }
  111811. }
  111812. declare module BABYLON {
  111813. /**
  111814. * Interface used to define options for Sound class
  111815. */
  111816. export interface ISoundOptions {
  111817. /**
  111818. * Does the sound autoplay once loaded.
  111819. */
  111820. autoplay?: boolean;
  111821. /**
  111822. * Does the sound loop after it finishes playing once.
  111823. */
  111824. loop?: boolean;
  111825. /**
  111826. * Sound's volume
  111827. */
  111828. volume?: number;
  111829. /**
  111830. * Is it a spatial sound?
  111831. */
  111832. spatialSound?: boolean;
  111833. /**
  111834. * Maximum distance to hear that sound
  111835. */
  111836. maxDistance?: number;
  111837. /**
  111838. * Uses user defined attenuation function
  111839. */
  111840. useCustomAttenuation?: boolean;
  111841. /**
  111842. * Define the roll off factor of spatial sounds.
  111843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111844. */
  111845. rolloffFactor?: number;
  111846. /**
  111847. * Define the reference distance the sound should be heard perfectly.
  111848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111849. */
  111850. refDistance?: number;
  111851. /**
  111852. * Define the distance attenuation model the sound will follow.
  111853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111854. */
  111855. distanceModel?: string;
  111856. /**
  111857. * Defines the playback speed (1 by default)
  111858. */
  111859. playbackRate?: number;
  111860. /**
  111861. * Defines if the sound is from a streaming source
  111862. */
  111863. streaming?: boolean;
  111864. /**
  111865. * Defines an optional length (in seconds) inside the sound file
  111866. */
  111867. length?: number;
  111868. /**
  111869. * Defines an optional offset (in seconds) inside the sound file
  111870. */
  111871. offset?: number;
  111872. /**
  111873. * If true, URLs will not be required to state the audio file codec to use.
  111874. */
  111875. skipCodecCheck?: boolean;
  111876. }
  111877. /**
  111878. * Defines a sound that can be played in the application.
  111879. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111881. */
  111882. export class Sound {
  111883. /**
  111884. * The name of the sound in the scene.
  111885. */
  111886. name: string;
  111887. /**
  111888. * Does the sound autoplay once loaded.
  111889. */
  111890. autoplay: boolean;
  111891. /**
  111892. * Does the sound loop after it finishes playing once.
  111893. */
  111894. loop: boolean;
  111895. /**
  111896. * Does the sound use a custom attenuation curve to simulate the falloff
  111897. * happening when the source gets further away from the camera.
  111898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111899. */
  111900. useCustomAttenuation: boolean;
  111901. /**
  111902. * The sound track id this sound belongs to.
  111903. */
  111904. soundTrackId: number;
  111905. /**
  111906. * Is this sound currently played.
  111907. */
  111908. isPlaying: boolean;
  111909. /**
  111910. * Is this sound currently paused.
  111911. */
  111912. isPaused: boolean;
  111913. /**
  111914. * Does this sound enables spatial sound.
  111915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111916. */
  111917. spatialSound: boolean;
  111918. /**
  111919. * Define the reference distance the sound should be heard perfectly.
  111920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111921. */
  111922. refDistance: number;
  111923. /**
  111924. * Define the roll off factor of spatial sounds.
  111925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111926. */
  111927. rolloffFactor: number;
  111928. /**
  111929. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111931. */
  111932. maxDistance: number;
  111933. /**
  111934. * Define the distance attenuation model the sound will follow.
  111935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111936. */
  111937. distanceModel: string;
  111938. /**
  111939. * @hidden
  111940. * Back Compat
  111941. **/
  111942. onended: () => any;
  111943. /**
  111944. * Observable event when the current playing sound finishes.
  111945. */
  111946. onEndedObservable: Observable<Sound>;
  111947. private _panningModel;
  111948. private _playbackRate;
  111949. private _streaming;
  111950. private _startTime;
  111951. private _startOffset;
  111952. private _position;
  111953. /** @hidden */
  111954. _positionInEmitterSpace: boolean;
  111955. private _localDirection;
  111956. private _volume;
  111957. private _isReadyToPlay;
  111958. private _isDirectional;
  111959. private _readyToPlayCallback;
  111960. private _audioBuffer;
  111961. private _soundSource;
  111962. private _streamingSource;
  111963. private _soundPanner;
  111964. private _soundGain;
  111965. private _inputAudioNode;
  111966. private _outputAudioNode;
  111967. private _coneInnerAngle;
  111968. private _coneOuterAngle;
  111969. private _coneOuterGain;
  111970. private _scene;
  111971. private _connectedTransformNode;
  111972. private _customAttenuationFunction;
  111973. private _registerFunc;
  111974. private _isOutputConnected;
  111975. private _htmlAudioElement;
  111976. private _urlType;
  111977. private _length?;
  111978. private _offset?;
  111979. /** @hidden */
  111980. static _SceneComponentInitialization: (scene: Scene) => void;
  111981. /**
  111982. * Create a sound and attach it to a scene
  111983. * @param name Name of your sound
  111984. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111985. * @param scene defines the scene the sound belongs to
  111986. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111987. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111988. */
  111989. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111990. /**
  111991. * Release the sound and its associated resources
  111992. */
  111993. dispose(): void;
  111994. /**
  111995. * Gets if the sounds is ready to be played or not.
  111996. * @returns true if ready, otherwise false
  111997. */
  111998. isReady(): boolean;
  111999. private _soundLoaded;
  112000. /**
  112001. * Sets the data of the sound from an audiobuffer
  112002. * @param audioBuffer The audioBuffer containing the data
  112003. */
  112004. setAudioBuffer(audioBuffer: AudioBuffer): void;
  112005. /**
  112006. * Updates the current sounds options such as maxdistance, loop...
  112007. * @param options A JSON object containing values named as the object properties
  112008. */
  112009. updateOptions(options: ISoundOptions): void;
  112010. private _createSpatialParameters;
  112011. private _updateSpatialParameters;
  112012. /**
  112013. * Switch the panning model to HRTF:
  112014. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112016. */
  112017. switchPanningModelToHRTF(): void;
  112018. /**
  112019. * Switch the panning model to Equal Power:
  112020. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112022. */
  112023. switchPanningModelToEqualPower(): void;
  112024. private _switchPanningModel;
  112025. /**
  112026. * Connect this sound to a sound track audio node like gain...
  112027. * @param soundTrackAudioNode the sound track audio node to connect to
  112028. */
  112029. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112030. /**
  112031. * Transform this sound into a directional source
  112032. * @param coneInnerAngle Size of the inner cone in degree
  112033. * @param coneOuterAngle Size of the outer cone in degree
  112034. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112035. */
  112036. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112037. /**
  112038. * Gets or sets the inner angle for the directional cone.
  112039. */
  112040. get directionalConeInnerAngle(): number;
  112041. /**
  112042. * Gets or sets the inner angle for the directional cone.
  112043. */
  112044. set directionalConeInnerAngle(value: number);
  112045. /**
  112046. * Gets or sets the outer angle for the directional cone.
  112047. */
  112048. get directionalConeOuterAngle(): number;
  112049. /**
  112050. * Gets or sets the outer angle for the directional cone.
  112051. */
  112052. set directionalConeOuterAngle(value: number);
  112053. /**
  112054. * Sets the position of the emitter if spatial sound is enabled
  112055. * @param newPosition Defines the new posisiton
  112056. */
  112057. setPosition(newPosition: Vector3): void;
  112058. /**
  112059. * Sets the local direction of the emitter if spatial sound is enabled
  112060. * @param newLocalDirection Defines the new local direction
  112061. */
  112062. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112063. private _updateDirection;
  112064. /** @hidden */
  112065. updateDistanceFromListener(): void;
  112066. /**
  112067. * Sets a new custom attenuation function for the sound.
  112068. * @param callback Defines the function used for the attenuation
  112069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112070. */
  112071. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112072. /**
  112073. * Play the sound
  112074. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112075. * @param offset (optional) Start the sound at a specific time in seconds
  112076. * @param length (optional) Sound duration (in seconds)
  112077. */
  112078. play(time?: number, offset?: number, length?: number): void;
  112079. private _onended;
  112080. /**
  112081. * Stop the sound
  112082. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112083. */
  112084. stop(time?: number): void;
  112085. /**
  112086. * Put the sound in pause
  112087. */
  112088. pause(): void;
  112089. /**
  112090. * Sets a dedicated volume for this sounds
  112091. * @param newVolume Define the new volume of the sound
  112092. * @param time Define time for gradual change to new volume
  112093. */
  112094. setVolume(newVolume: number, time?: number): void;
  112095. /**
  112096. * Set the sound play back rate
  112097. * @param newPlaybackRate Define the playback rate the sound should be played at
  112098. */
  112099. setPlaybackRate(newPlaybackRate: number): void;
  112100. /**
  112101. * Gets the volume of the sound.
  112102. * @returns the volume of the sound
  112103. */
  112104. getVolume(): number;
  112105. /**
  112106. * Attach the sound to a dedicated mesh
  112107. * @param transformNode The transform node to connect the sound with
  112108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112109. */
  112110. attachToMesh(transformNode: TransformNode): void;
  112111. /**
  112112. * Detach the sound from the previously attached mesh
  112113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112114. */
  112115. detachFromMesh(): void;
  112116. private _onRegisterAfterWorldMatrixUpdate;
  112117. /**
  112118. * Clone the current sound in the scene.
  112119. * @returns the new sound clone
  112120. */
  112121. clone(): Nullable<Sound>;
  112122. /**
  112123. * Gets the current underlying audio buffer containing the data
  112124. * @returns the audio buffer
  112125. */
  112126. getAudioBuffer(): Nullable<AudioBuffer>;
  112127. /**
  112128. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112129. * @returns the source node
  112130. */
  112131. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112132. /**
  112133. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112134. * @returns the gain node
  112135. */
  112136. getSoundGain(): Nullable<GainNode>;
  112137. /**
  112138. * Serializes the Sound in a JSON representation
  112139. * @returns the JSON representation of the sound
  112140. */
  112141. serialize(): any;
  112142. /**
  112143. * Parse a JSON representation of a sound to innstantiate in a given scene
  112144. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112145. * @param scene Define the scene the new parsed sound should be created in
  112146. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112147. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112148. * @returns the newly parsed sound
  112149. */
  112150. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112151. }
  112152. }
  112153. declare module BABYLON {
  112154. /**
  112155. * This defines an action helpful to play a defined sound on a triggered action.
  112156. */
  112157. export class PlaySoundAction extends Action {
  112158. private _sound;
  112159. /**
  112160. * Instantiate the action
  112161. * @param triggerOptions defines the trigger options
  112162. * @param sound defines the sound to play
  112163. * @param condition defines the trigger related conditions
  112164. */
  112165. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112166. /** @hidden */
  112167. _prepare(): void;
  112168. /**
  112169. * Execute the action and play the sound.
  112170. */
  112171. execute(): void;
  112172. /**
  112173. * Serializes the actions and its related information.
  112174. * @param parent defines the object to serialize in
  112175. * @returns the serialized object
  112176. */
  112177. serialize(parent: any): any;
  112178. }
  112179. /**
  112180. * This defines an action helpful to stop a defined sound on a triggered action.
  112181. */
  112182. export class StopSoundAction extends Action {
  112183. private _sound;
  112184. /**
  112185. * Instantiate the action
  112186. * @param triggerOptions defines the trigger options
  112187. * @param sound defines the sound to stop
  112188. * @param condition defines the trigger related conditions
  112189. */
  112190. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112191. /** @hidden */
  112192. _prepare(): void;
  112193. /**
  112194. * Execute the action and stop the sound.
  112195. */
  112196. execute(): void;
  112197. /**
  112198. * Serializes the actions and its related information.
  112199. * @param parent defines the object to serialize in
  112200. * @returns the serialized object
  112201. */
  112202. serialize(parent: any): any;
  112203. }
  112204. }
  112205. declare module BABYLON {
  112206. /**
  112207. * This defines an action responsible to change the value of a property
  112208. * by interpolating between its current value and the newly set one once triggered.
  112209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112210. */
  112211. export class InterpolateValueAction extends Action {
  112212. /**
  112213. * Defines the path of the property where the value should be interpolated
  112214. */
  112215. propertyPath: string;
  112216. /**
  112217. * Defines the target value at the end of the interpolation.
  112218. */
  112219. value: any;
  112220. /**
  112221. * Defines the time it will take for the property to interpolate to the value.
  112222. */
  112223. duration: number;
  112224. /**
  112225. * Defines if the other scene animations should be stopped when the action has been triggered
  112226. */
  112227. stopOtherAnimations?: boolean;
  112228. /**
  112229. * Defines a callback raised once the interpolation animation has been done.
  112230. */
  112231. onInterpolationDone?: () => void;
  112232. /**
  112233. * Observable triggered once the interpolation animation has been done.
  112234. */
  112235. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112236. private _target;
  112237. private _effectiveTarget;
  112238. private _property;
  112239. /**
  112240. * Instantiate the action
  112241. * @param triggerOptions defines the trigger options
  112242. * @param target defines the object containing the value to interpolate
  112243. * @param propertyPath defines the path to the property in the target object
  112244. * @param value defines the target value at the end of the interpolation
  112245. * @param duration deines the time it will take for the property to interpolate to the value.
  112246. * @param condition defines the trigger related conditions
  112247. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112248. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112249. */
  112250. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112251. /** @hidden */
  112252. _prepare(): void;
  112253. /**
  112254. * Execute the action starts the value interpolation.
  112255. */
  112256. execute(): void;
  112257. /**
  112258. * Serializes the actions and its related information.
  112259. * @param parent defines the object to serialize in
  112260. * @returns the serialized object
  112261. */
  112262. serialize(parent: any): any;
  112263. }
  112264. }
  112265. declare module BABYLON {
  112266. /**
  112267. * Options allowed during the creation of a sound track.
  112268. */
  112269. export interface ISoundTrackOptions {
  112270. /**
  112271. * The volume the sound track should take during creation
  112272. */
  112273. volume?: number;
  112274. /**
  112275. * Define if the sound track is the main sound track of the scene
  112276. */
  112277. mainTrack?: boolean;
  112278. }
  112279. /**
  112280. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112281. * It will be also used in a future release to apply effects on a specific track.
  112282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112283. */
  112284. export class SoundTrack {
  112285. /**
  112286. * The unique identifier of the sound track in the scene.
  112287. */
  112288. id: number;
  112289. /**
  112290. * The list of sounds included in the sound track.
  112291. */
  112292. soundCollection: Array<Sound>;
  112293. private _outputAudioNode;
  112294. private _scene;
  112295. private _connectedAnalyser;
  112296. private _options;
  112297. private _isInitialized;
  112298. /**
  112299. * Creates a new sound track.
  112300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112301. * @param scene Define the scene the sound track belongs to
  112302. * @param options
  112303. */
  112304. constructor(scene: Scene, options?: ISoundTrackOptions);
  112305. private _initializeSoundTrackAudioGraph;
  112306. /**
  112307. * Release the sound track and its associated resources
  112308. */
  112309. dispose(): void;
  112310. /**
  112311. * Adds a sound to this sound track
  112312. * @param sound define the cound to add
  112313. * @ignoreNaming
  112314. */
  112315. AddSound(sound: Sound): void;
  112316. /**
  112317. * Removes a sound to this sound track
  112318. * @param sound define the cound to remove
  112319. * @ignoreNaming
  112320. */
  112321. RemoveSound(sound: Sound): void;
  112322. /**
  112323. * Set a global volume for the full sound track.
  112324. * @param newVolume Define the new volume of the sound track
  112325. */
  112326. setVolume(newVolume: number): void;
  112327. /**
  112328. * Switch the panning model to HRTF:
  112329. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112331. */
  112332. switchPanningModelToHRTF(): void;
  112333. /**
  112334. * Switch the panning model to Equal Power:
  112335. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112337. */
  112338. switchPanningModelToEqualPower(): void;
  112339. /**
  112340. * Connect the sound track to an audio analyser allowing some amazing
  112341. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112343. * @param analyser The analyser to connect to the engine
  112344. */
  112345. connectToAnalyser(analyser: Analyser): void;
  112346. }
  112347. }
  112348. declare module BABYLON {
  112349. interface AbstractScene {
  112350. /**
  112351. * The list of sounds used in the scene.
  112352. */
  112353. sounds: Nullable<Array<Sound>>;
  112354. }
  112355. interface Scene {
  112356. /**
  112357. * @hidden
  112358. * Backing field
  112359. */
  112360. _mainSoundTrack: SoundTrack;
  112361. /**
  112362. * The main sound track played by the scene.
  112363. * It cotains your primary collection of sounds.
  112364. */
  112365. mainSoundTrack: SoundTrack;
  112366. /**
  112367. * The list of sound tracks added to the scene
  112368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112369. */
  112370. soundTracks: Nullable<Array<SoundTrack>>;
  112371. /**
  112372. * Gets a sound using a given name
  112373. * @param name defines the name to search for
  112374. * @return the found sound or null if not found at all.
  112375. */
  112376. getSoundByName(name: string): Nullable<Sound>;
  112377. /**
  112378. * Gets or sets if audio support is enabled
  112379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112380. */
  112381. audioEnabled: boolean;
  112382. /**
  112383. * Gets or sets if audio will be output to headphones
  112384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112385. */
  112386. headphone: boolean;
  112387. /**
  112388. * Gets or sets custom audio listener position provider
  112389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112390. */
  112391. audioListenerPositionProvider: Nullable<() => Vector3>;
  112392. /**
  112393. * Gets or sets a refresh rate when using 3D audio positioning
  112394. */
  112395. audioPositioningRefreshRate: number;
  112396. }
  112397. /**
  112398. * Defines the sound scene component responsible to manage any sounds
  112399. * in a given scene.
  112400. */
  112401. export class AudioSceneComponent implements ISceneSerializableComponent {
  112402. /**
  112403. * The component name helpfull to identify the component in the list of scene components.
  112404. */
  112405. readonly name: string;
  112406. /**
  112407. * The scene the component belongs to.
  112408. */
  112409. scene: Scene;
  112410. private _audioEnabled;
  112411. /**
  112412. * Gets whether audio is enabled or not.
  112413. * Please use related enable/disable method to switch state.
  112414. */
  112415. get audioEnabled(): boolean;
  112416. private _headphone;
  112417. /**
  112418. * Gets whether audio is outputing to headphone or not.
  112419. * Please use the according Switch methods to change output.
  112420. */
  112421. get headphone(): boolean;
  112422. /**
  112423. * Gets or sets a refresh rate when using 3D audio positioning
  112424. */
  112425. audioPositioningRefreshRate: number;
  112426. private _audioListenerPositionProvider;
  112427. /**
  112428. * Gets the current audio listener position provider
  112429. */
  112430. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112431. /**
  112432. * Sets a custom listener position for all sounds in the scene
  112433. * By default, this is the position of the first active camera
  112434. */
  112435. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112436. /**
  112437. * Creates a new instance of the component for the given scene
  112438. * @param scene Defines the scene to register the component in
  112439. */
  112440. constructor(scene: Scene);
  112441. /**
  112442. * Registers the component in a given scene
  112443. */
  112444. register(): void;
  112445. /**
  112446. * Rebuilds the elements related to this component in case of
  112447. * context lost for instance.
  112448. */
  112449. rebuild(): void;
  112450. /**
  112451. * Serializes the component data to the specified json object
  112452. * @param serializationObject The object to serialize to
  112453. */
  112454. serialize(serializationObject: any): void;
  112455. /**
  112456. * Adds all the elements from the container to the scene
  112457. * @param container the container holding the elements
  112458. */
  112459. addFromContainer(container: AbstractScene): void;
  112460. /**
  112461. * Removes all the elements in the container from the scene
  112462. * @param container contains the elements to remove
  112463. * @param dispose if the removed element should be disposed (default: false)
  112464. */
  112465. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112466. /**
  112467. * Disposes the component and the associated ressources.
  112468. */
  112469. dispose(): void;
  112470. /**
  112471. * Disables audio in the associated scene.
  112472. */
  112473. disableAudio(): void;
  112474. /**
  112475. * Enables audio in the associated scene.
  112476. */
  112477. enableAudio(): void;
  112478. /**
  112479. * Switch audio to headphone output.
  112480. */
  112481. switchAudioModeForHeadphones(): void;
  112482. /**
  112483. * Switch audio to normal speakers.
  112484. */
  112485. switchAudioModeForNormalSpeakers(): void;
  112486. private _cachedCameraDirection;
  112487. private _cachedCameraPosition;
  112488. private _lastCheck;
  112489. private _afterRender;
  112490. }
  112491. }
  112492. declare module BABYLON {
  112493. /**
  112494. * Wraps one or more Sound objects and selects one with random weight for playback.
  112495. */
  112496. export class WeightedSound {
  112497. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112498. loop: boolean;
  112499. private _coneInnerAngle;
  112500. private _coneOuterAngle;
  112501. private _volume;
  112502. /** A Sound is currently playing. */
  112503. isPlaying: boolean;
  112504. /** A Sound is currently paused. */
  112505. isPaused: boolean;
  112506. private _sounds;
  112507. private _weights;
  112508. private _currentIndex?;
  112509. /**
  112510. * Creates a new WeightedSound from the list of sounds given.
  112511. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112512. * @param sounds Array of Sounds that will be selected from.
  112513. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112514. */
  112515. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112516. /**
  112517. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112518. */
  112519. get directionalConeInnerAngle(): number;
  112520. /**
  112521. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112522. */
  112523. set directionalConeInnerAngle(value: number);
  112524. /**
  112525. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112526. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112527. */
  112528. get directionalConeOuterAngle(): number;
  112529. /**
  112530. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112531. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112532. */
  112533. set directionalConeOuterAngle(value: number);
  112534. /**
  112535. * Playback volume.
  112536. */
  112537. get volume(): number;
  112538. /**
  112539. * Playback volume.
  112540. */
  112541. set volume(value: number);
  112542. private _onended;
  112543. /**
  112544. * Suspend playback
  112545. */
  112546. pause(): void;
  112547. /**
  112548. * Stop playback
  112549. */
  112550. stop(): void;
  112551. /**
  112552. * Start playback.
  112553. * @param startOffset Position the clip head at a specific time in seconds.
  112554. */
  112555. play(startOffset?: number): void;
  112556. }
  112557. }
  112558. declare module BABYLON {
  112559. /**
  112560. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112562. */
  112563. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112564. /**
  112565. * Gets the name of the behavior.
  112566. */
  112567. get name(): string;
  112568. /**
  112569. * The easing function used by animations
  112570. */
  112571. static EasingFunction: BackEase;
  112572. /**
  112573. * The easing mode used by animations
  112574. */
  112575. static EasingMode: number;
  112576. /**
  112577. * The duration of the animation, in milliseconds
  112578. */
  112579. transitionDuration: number;
  112580. /**
  112581. * Length of the distance animated by the transition when lower radius is reached
  112582. */
  112583. lowerRadiusTransitionRange: number;
  112584. /**
  112585. * Length of the distance animated by the transition when upper radius is reached
  112586. */
  112587. upperRadiusTransitionRange: number;
  112588. private _autoTransitionRange;
  112589. /**
  112590. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112591. */
  112592. get autoTransitionRange(): boolean;
  112593. /**
  112594. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112595. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112596. */
  112597. set autoTransitionRange(value: boolean);
  112598. private _attachedCamera;
  112599. private _onAfterCheckInputsObserver;
  112600. private _onMeshTargetChangedObserver;
  112601. /**
  112602. * Initializes the behavior.
  112603. */
  112604. init(): void;
  112605. /**
  112606. * Attaches the behavior to its arc rotate camera.
  112607. * @param camera Defines the camera to attach the behavior to
  112608. */
  112609. attach(camera: ArcRotateCamera): void;
  112610. /**
  112611. * Detaches the behavior from its current arc rotate camera.
  112612. */
  112613. detach(): void;
  112614. private _radiusIsAnimating;
  112615. private _radiusBounceTransition;
  112616. private _animatables;
  112617. private _cachedWheelPrecision;
  112618. /**
  112619. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112620. * @param radiusLimit The limit to check against.
  112621. * @return Bool to indicate if at limit.
  112622. */
  112623. private _isRadiusAtLimit;
  112624. /**
  112625. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112626. * @param radiusDelta The delta by which to animate to. Can be negative.
  112627. */
  112628. private _applyBoundRadiusAnimation;
  112629. /**
  112630. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112631. */
  112632. protected _clearAnimationLocks(): void;
  112633. /**
  112634. * Stops and removes all animations that have been applied to the camera
  112635. */
  112636. stopAllAnimations(): void;
  112637. }
  112638. }
  112639. declare module BABYLON {
  112640. /**
  112641. * 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.
  112642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112643. */
  112644. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112645. /**
  112646. * Gets the name of the behavior.
  112647. */
  112648. get name(): string;
  112649. private _mode;
  112650. private _radiusScale;
  112651. private _positionScale;
  112652. private _defaultElevation;
  112653. private _elevationReturnTime;
  112654. private _elevationReturnWaitTime;
  112655. private _zoomStopsAnimation;
  112656. private _framingTime;
  112657. /**
  112658. * The easing function used by animations
  112659. */
  112660. static EasingFunction: ExponentialEase;
  112661. /**
  112662. * The easing mode used by animations
  112663. */
  112664. static EasingMode: number;
  112665. /**
  112666. * Sets the current mode used by the behavior
  112667. */
  112668. set mode(mode: number);
  112669. /**
  112670. * Gets current mode used by the behavior.
  112671. */
  112672. get mode(): number;
  112673. /**
  112674. * Sets the scale applied to the radius (1 by default)
  112675. */
  112676. set radiusScale(radius: number);
  112677. /**
  112678. * Gets the scale applied to the radius
  112679. */
  112680. get radiusScale(): number;
  112681. /**
  112682. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112683. */
  112684. set positionScale(scale: number);
  112685. /**
  112686. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112687. */
  112688. get positionScale(): number;
  112689. /**
  112690. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112691. * behaviour is triggered, in radians.
  112692. */
  112693. set defaultElevation(elevation: number);
  112694. /**
  112695. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112696. * behaviour is triggered, in radians.
  112697. */
  112698. get defaultElevation(): number;
  112699. /**
  112700. * Sets the time (in milliseconds) taken to return to the default beta position.
  112701. * Negative value indicates camera should not return to default.
  112702. */
  112703. set elevationReturnTime(speed: number);
  112704. /**
  112705. * Gets the time (in milliseconds) taken to return to the default beta position.
  112706. * Negative value indicates camera should not return to default.
  112707. */
  112708. get elevationReturnTime(): number;
  112709. /**
  112710. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112711. */
  112712. set elevationReturnWaitTime(time: number);
  112713. /**
  112714. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112715. */
  112716. get elevationReturnWaitTime(): number;
  112717. /**
  112718. * Sets the flag that indicates if user zooming should stop animation.
  112719. */
  112720. set zoomStopsAnimation(flag: boolean);
  112721. /**
  112722. * Gets the flag that indicates if user zooming should stop animation.
  112723. */
  112724. get zoomStopsAnimation(): boolean;
  112725. /**
  112726. * Sets the transition time when framing the mesh, in milliseconds
  112727. */
  112728. set framingTime(time: number);
  112729. /**
  112730. * Gets the transition time when framing the mesh, in milliseconds
  112731. */
  112732. get framingTime(): number;
  112733. /**
  112734. * Define if the behavior should automatically change the configured
  112735. * camera limits and sensibilities.
  112736. */
  112737. autoCorrectCameraLimitsAndSensibility: boolean;
  112738. private _onPrePointerObservableObserver;
  112739. private _onAfterCheckInputsObserver;
  112740. private _onMeshTargetChangedObserver;
  112741. private _attachedCamera;
  112742. private _isPointerDown;
  112743. private _lastInteractionTime;
  112744. /**
  112745. * Initializes the behavior.
  112746. */
  112747. init(): void;
  112748. /**
  112749. * Attaches the behavior to its arc rotate camera.
  112750. * @param camera Defines the camera to attach the behavior to
  112751. */
  112752. attach(camera: ArcRotateCamera): void;
  112753. /**
  112754. * Detaches the behavior from its current arc rotate camera.
  112755. */
  112756. detach(): void;
  112757. private _animatables;
  112758. private _betaIsAnimating;
  112759. private _betaTransition;
  112760. private _radiusTransition;
  112761. private _vectorTransition;
  112762. /**
  112763. * Targets the given mesh and updates zoom level accordingly.
  112764. * @param mesh The mesh to target.
  112765. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112766. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112767. */
  112768. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112769. /**
  112770. * Targets the given mesh with its children and updates zoom level accordingly.
  112771. * @param mesh The mesh to target.
  112772. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112773. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112774. */
  112775. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112776. /**
  112777. * Targets the given meshes with their children and updates zoom level accordingly.
  112778. * @param meshes The mesh to target.
  112779. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112780. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112781. */
  112782. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112783. /**
  112784. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112785. * @param minimumWorld Determines the smaller position of the bounding box extend
  112786. * @param maximumWorld Determines the bigger position of the bounding box extend
  112787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112789. */
  112790. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112791. /**
  112792. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112793. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112794. * frustum width.
  112795. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112796. * to fully enclose the mesh in the viewing frustum.
  112797. */
  112798. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112799. /**
  112800. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112801. * is automatically returned to its default position (expected to be above ground plane).
  112802. */
  112803. private _maintainCameraAboveGround;
  112804. /**
  112805. * Returns the frustum slope based on the canvas ratio and camera FOV
  112806. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112807. */
  112808. private _getFrustumSlope;
  112809. /**
  112810. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112811. */
  112812. private _clearAnimationLocks;
  112813. /**
  112814. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112815. */
  112816. private _applyUserInteraction;
  112817. /**
  112818. * Stops and removes all animations that have been applied to the camera
  112819. */
  112820. stopAllAnimations(): void;
  112821. /**
  112822. * Gets a value indicating if the user is moving the camera
  112823. */
  112824. get isUserIsMoving(): boolean;
  112825. /**
  112826. * The camera can move all the way towards the mesh.
  112827. */
  112828. static IgnoreBoundsSizeMode: number;
  112829. /**
  112830. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112831. */
  112832. static FitFrustumSidesMode: number;
  112833. }
  112834. }
  112835. declare module BABYLON {
  112836. /**
  112837. * Base class for Camera Pointer Inputs.
  112838. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112839. * for example usage.
  112840. */
  112841. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112842. /**
  112843. * Defines the camera the input is attached to.
  112844. */
  112845. abstract camera: Camera;
  112846. /**
  112847. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112848. */
  112849. protected _altKey: boolean;
  112850. protected _ctrlKey: boolean;
  112851. protected _metaKey: boolean;
  112852. protected _shiftKey: boolean;
  112853. /**
  112854. * Which mouse buttons were pressed at time of last mouse event.
  112855. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112856. */
  112857. protected _buttonsPressed: number;
  112858. /**
  112859. * Defines the buttons associated with the input to handle camera move.
  112860. */
  112861. buttons: number[];
  112862. /**
  112863. * Attach the input controls to a specific dom element to get the input from.
  112864. * @param element Defines the element the controls should be listened from
  112865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112866. */
  112867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112868. /**
  112869. * Detach the current controls from the specified dom element.
  112870. * @param element Defines the element to stop listening the inputs from
  112871. */
  112872. detachControl(element: Nullable<HTMLElement>): void;
  112873. /**
  112874. * Gets the class name of the current input.
  112875. * @returns the class name
  112876. */
  112877. getClassName(): string;
  112878. /**
  112879. * Get the friendly name associated with the input class.
  112880. * @returns the input friendly name
  112881. */
  112882. getSimpleName(): string;
  112883. /**
  112884. * Called on pointer POINTERDOUBLETAP event.
  112885. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112886. */
  112887. protected onDoubleTap(type: string): void;
  112888. /**
  112889. * Called on pointer POINTERMOVE event if only a single touch is active.
  112890. * Override this method to provide functionality.
  112891. */
  112892. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112893. /**
  112894. * Called on pointer POINTERMOVE event if multiple touches are active.
  112895. * Override this method to provide functionality.
  112896. */
  112897. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112898. /**
  112899. * Called on JS contextmenu event.
  112900. * Override this method to provide functionality.
  112901. */
  112902. protected onContextMenu(evt: PointerEvent): void;
  112903. /**
  112904. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112905. * press.
  112906. * Override this method to provide functionality.
  112907. */
  112908. protected onButtonDown(evt: PointerEvent): void;
  112909. /**
  112910. * Called each time a new POINTERUP event occurs. Ie, for each button
  112911. * release.
  112912. * Override this method to provide functionality.
  112913. */
  112914. protected onButtonUp(evt: PointerEvent): void;
  112915. /**
  112916. * Called when window becomes inactive.
  112917. * Override this method to provide functionality.
  112918. */
  112919. protected onLostFocus(): void;
  112920. private _pointerInput;
  112921. private _observer;
  112922. private _onLostFocus;
  112923. private pointA;
  112924. private pointB;
  112925. }
  112926. }
  112927. declare module BABYLON {
  112928. /**
  112929. * Manage the pointers inputs to control an arc rotate camera.
  112930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112931. */
  112932. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112933. /**
  112934. * Defines the camera the input is attached to.
  112935. */
  112936. camera: ArcRotateCamera;
  112937. /**
  112938. * Gets the class name of the current input.
  112939. * @returns the class name
  112940. */
  112941. getClassName(): string;
  112942. /**
  112943. * Defines the buttons associated with the input to handle camera move.
  112944. */
  112945. buttons: number[];
  112946. /**
  112947. * Defines the pointer angular sensibility along the X axis or how fast is
  112948. * the camera rotating.
  112949. */
  112950. angularSensibilityX: number;
  112951. /**
  112952. * Defines the pointer angular sensibility along the Y axis or how fast is
  112953. * the camera rotating.
  112954. */
  112955. angularSensibilityY: number;
  112956. /**
  112957. * Defines the pointer pinch precision or how fast is the camera zooming.
  112958. */
  112959. pinchPrecision: number;
  112960. /**
  112961. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112962. * from 0.
  112963. * It defines the percentage of current camera.radius to use as delta when
  112964. * pinch zoom is used.
  112965. */
  112966. pinchDeltaPercentage: number;
  112967. /**
  112968. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112969. * that any object in the plane at the camera's target point will scale
  112970. * perfectly with finger motion.
  112971. * Overrides pinchDeltaPercentage and pinchPrecision.
  112972. */
  112973. useNaturalPinchZoom: boolean;
  112974. /**
  112975. * Defines the pointer panning sensibility or how fast is the camera moving.
  112976. */
  112977. panningSensibility: number;
  112978. /**
  112979. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112980. */
  112981. multiTouchPanning: boolean;
  112982. /**
  112983. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112984. * zoom (pinch) through multitouch.
  112985. */
  112986. multiTouchPanAndZoom: boolean;
  112987. /**
  112988. * Revers pinch action direction.
  112989. */
  112990. pinchInwards: boolean;
  112991. private _isPanClick;
  112992. private _twoFingerActivityCount;
  112993. private _isPinching;
  112994. /**
  112995. * Called on pointer POINTERMOVE event if only a single touch is active.
  112996. */
  112997. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112998. /**
  112999. * Called on pointer POINTERDOUBLETAP event.
  113000. */
  113001. protected onDoubleTap(type: string): void;
  113002. /**
  113003. * Called on pointer POINTERMOVE event if multiple touches are active.
  113004. */
  113005. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113006. /**
  113007. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113008. * press.
  113009. */
  113010. protected onButtonDown(evt: PointerEvent): void;
  113011. /**
  113012. * Called each time a new POINTERUP event occurs. Ie, for each button
  113013. * release.
  113014. */
  113015. protected onButtonUp(evt: PointerEvent): void;
  113016. /**
  113017. * Called when window becomes inactive.
  113018. */
  113019. protected onLostFocus(): void;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. /**
  113024. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113026. */
  113027. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113028. /**
  113029. * Defines the camera the input is attached to.
  113030. */
  113031. camera: ArcRotateCamera;
  113032. /**
  113033. * Defines the list of key codes associated with the up action (increase alpha)
  113034. */
  113035. keysUp: number[];
  113036. /**
  113037. * Defines the list of key codes associated with the down action (decrease alpha)
  113038. */
  113039. keysDown: number[];
  113040. /**
  113041. * Defines the list of key codes associated with the left action (increase beta)
  113042. */
  113043. keysLeft: number[];
  113044. /**
  113045. * Defines the list of key codes associated with the right action (decrease beta)
  113046. */
  113047. keysRight: number[];
  113048. /**
  113049. * Defines the list of key codes associated with the reset action.
  113050. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113051. */
  113052. keysReset: number[];
  113053. /**
  113054. * Defines the panning sensibility of the inputs.
  113055. * (How fast is the camera panning)
  113056. */
  113057. panningSensibility: number;
  113058. /**
  113059. * Defines the zooming sensibility of the inputs.
  113060. * (How fast is the camera zooming)
  113061. */
  113062. zoomingSensibility: number;
  113063. /**
  113064. * Defines whether maintaining the alt key down switch the movement mode from
  113065. * orientation to zoom.
  113066. */
  113067. useAltToZoom: boolean;
  113068. /**
  113069. * Rotation speed of the camera
  113070. */
  113071. angularSpeed: number;
  113072. private _keys;
  113073. private _ctrlPressed;
  113074. private _altPressed;
  113075. private _onCanvasBlurObserver;
  113076. private _onKeyboardObserver;
  113077. private _engine;
  113078. private _scene;
  113079. /**
  113080. * Attach the input controls to a specific dom element to get the input from.
  113081. * @param element Defines the element the controls should be listened from
  113082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113083. */
  113084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113085. /**
  113086. * Detach the current controls from the specified dom element.
  113087. * @param element Defines the element to stop listening the inputs from
  113088. */
  113089. detachControl(element: Nullable<HTMLElement>): void;
  113090. /**
  113091. * Update the current camera state depending on the inputs that have been used this frame.
  113092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113093. */
  113094. checkInputs(): void;
  113095. /**
  113096. * Gets the class name of the current intput.
  113097. * @returns the class name
  113098. */
  113099. getClassName(): string;
  113100. /**
  113101. * Get the friendly name associated with the input class.
  113102. * @returns the input friendly name
  113103. */
  113104. getSimpleName(): string;
  113105. }
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * Manage the mouse wheel inputs to control an arc rotate camera.
  113110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113111. */
  113112. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113113. /**
  113114. * Defines the camera the input is attached to.
  113115. */
  113116. camera: ArcRotateCamera;
  113117. /**
  113118. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113119. */
  113120. wheelPrecision: number;
  113121. /**
  113122. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113123. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113124. */
  113125. wheelDeltaPercentage: number;
  113126. private _wheel;
  113127. private _observer;
  113128. private computeDeltaFromMouseWheelLegacyEvent;
  113129. /**
  113130. * Attach the input controls to a specific dom element to get the input from.
  113131. * @param element Defines the element the controls should be listened from
  113132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113133. */
  113134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113135. /**
  113136. * Detach the current controls from the specified dom element.
  113137. * @param element Defines the element to stop listening the inputs from
  113138. */
  113139. detachControl(element: Nullable<HTMLElement>): void;
  113140. /**
  113141. * Gets the class name of the current intput.
  113142. * @returns the class name
  113143. */
  113144. getClassName(): string;
  113145. /**
  113146. * Get the friendly name associated with the input class.
  113147. * @returns the input friendly name
  113148. */
  113149. getSimpleName(): string;
  113150. }
  113151. }
  113152. declare module BABYLON {
  113153. /**
  113154. * Default Inputs manager for the ArcRotateCamera.
  113155. * It groups all the default supported inputs for ease of use.
  113156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113157. */
  113158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113159. /**
  113160. * Instantiates a new ArcRotateCameraInputsManager.
  113161. * @param camera Defines the camera the inputs belong to
  113162. */
  113163. constructor(camera: ArcRotateCamera);
  113164. /**
  113165. * Add mouse wheel input support to the input manager.
  113166. * @returns the current input manager
  113167. */
  113168. addMouseWheel(): ArcRotateCameraInputsManager;
  113169. /**
  113170. * Add pointers input support to the input manager.
  113171. * @returns the current input manager
  113172. */
  113173. addPointers(): ArcRotateCameraInputsManager;
  113174. /**
  113175. * Add keyboard input support to the input manager.
  113176. * @returns the current input manager
  113177. */
  113178. addKeyboard(): ArcRotateCameraInputsManager;
  113179. }
  113180. }
  113181. declare module BABYLON {
  113182. /**
  113183. * This represents an orbital type of camera.
  113184. *
  113185. * 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.
  113186. * 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.
  113187. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113188. */
  113189. export class ArcRotateCamera extends TargetCamera {
  113190. /**
  113191. * Defines the rotation angle of the camera along the longitudinal axis.
  113192. */
  113193. alpha: number;
  113194. /**
  113195. * Defines the rotation angle of the camera along the latitudinal axis.
  113196. */
  113197. beta: number;
  113198. /**
  113199. * Defines the radius of the camera from it s target point.
  113200. */
  113201. radius: number;
  113202. protected _target: Vector3;
  113203. protected _targetHost: Nullable<AbstractMesh>;
  113204. /**
  113205. * Defines the target point of the camera.
  113206. * The camera looks towards it form the radius distance.
  113207. */
  113208. get target(): Vector3;
  113209. set target(value: Vector3);
  113210. /**
  113211. * Define the current local position of the camera in the scene
  113212. */
  113213. get position(): Vector3;
  113214. set position(newPosition: Vector3);
  113215. protected _upVector: Vector3;
  113216. protected _upToYMatrix: Matrix;
  113217. protected _YToUpMatrix: Matrix;
  113218. /**
  113219. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113220. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113221. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113222. */
  113223. set upVector(vec: Vector3);
  113224. get upVector(): Vector3;
  113225. /**
  113226. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113227. */
  113228. setMatUp(): void;
  113229. /**
  113230. * Current inertia value on the longitudinal axis.
  113231. * The bigger this number the longer it will take for the camera to stop.
  113232. */
  113233. inertialAlphaOffset: number;
  113234. /**
  113235. * Current inertia value on the latitudinal axis.
  113236. * The bigger this number the longer it will take for the camera to stop.
  113237. */
  113238. inertialBetaOffset: number;
  113239. /**
  113240. * Current inertia value on the radius axis.
  113241. * The bigger this number the longer it will take for the camera to stop.
  113242. */
  113243. inertialRadiusOffset: number;
  113244. /**
  113245. * Minimum allowed angle on the longitudinal axis.
  113246. * This can help limiting how the Camera is able to move in the scene.
  113247. */
  113248. lowerAlphaLimit: Nullable<number>;
  113249. /**
  113250. * Maximum allowed angle on the longitudinal axis.
  113251. * This can help limiting how the Camera is able to move in the scene.
  113252. */
  113253. upperAlphaLimit: Nullable<number>;
  113254. /**
  113255. * Minimum allowed angle on the latitudinal axis.
  113256. * This can help limiting how the Camera is able to move in the scene.
  113257. */
  113258. lowerBetaLimit: number;
  113259. /**
  113260. * Maximum allowed angle on the latitudinal axis.
  113261. * This can help limiting how the Camera is able to move in the scene.
  113262. */
  113263. upperBetaLimit: number;
  113264. /**
  113265. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113266. * This can help limiting how the Camera is able to move in the scene.
  113267. */
  113268. lowerRadiusLimit: Nullable<number>;
  113269. /**
  113270. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113271. * This can help limiting how the Camera is able to move in the scene.
  113272. */
  113273. upperRadiusLimit: Nullable<number>;
  113274. /**
  113275. * Defines the current inertia value used during panning of the camera along the X axis.
  113276. */
  113277. inertialPanningX: number;
  113278. /**
  113279. * Defines the current inertia value used during panning of the camera along the Y axis.
  113280. */
  113281. inertialPanningY: number;
  113282. /**
  113283. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113284. * Basically if your fingers moves away from more than this distance you will be considered
  113285. * in pinch mode.
  113286. */
  113287. pinchToPanMaxDistance: number;
  113288. /**
  113289. * Defines the maximum distance the camera can pan.
  113290. * This could help keeping the cammera always in your scene.
  113291. */
  113292. panningDistanceLimit: Nullable<number>;
  113293. /**
  113294. * Defines the target of the camera before paning.
  113295. */
  113296. panningOriginTarget: Vector3;
  113297. /**
  113298. * Defines the value of the inertia used during panning.
  113299. * 0 would mean stop inertia and one would mean no decelleration at all.
  113300. */
  113301. panningInertia: number;
  113302. /**
  113303. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113304. */
  113305. get angularSensibilityX(): number;
  113306. set angularSensibilityX(value: number);
  113307. /**
  113308. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113309. */
  113310. get angularSensibilityY(): number;
  113311. set angularSensibilityY(value: number);
  113312. /**
  113313. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113314. */
  113315. get pinchPrecision(): number;
  113316. set pinchPrecision(value: number);
  113317. /**
  113318. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113319. * It will be used instead of pinchDeltaPrecision if different from 0.
  113320. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113321. */
  113322. get pinchDeltaPercentage(): number;
  113323. set pinchDeltaPercentage(value: number);
  113324. /**
  113325. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113326. * and pinch delta percentage.
  113327. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113328. * that any object in the plane at the camera's target point will scale
  113329. * perfectly with finger motion.
  113330. */
  113331. get useNaturalPinchZoom(): boolean;
  113332. set useNaturalPinchZoom(value: boolean);
  113333. /**
  113334. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113335. */
  113336. get panningSensibility(): number;
  113337. set panningSensibility(value: number);
  113338. /**
  113339. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113340. */
  113341. get keysUp(): number[];
  113342. set keysUp(value: number[]);
  113343. /**
  113344. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113345. */
  113346. get keysDown(): number[];
  113347. set keysDown(value: number[]);
  113348. /**
  113349. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113350. */
  113351. get keysLeft(): number[];
  113352. set keysLeft(value: number[]);
  113353. /**
  113354. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113355. */
  113356. get keysRight(): number[];
  113357. set keysRight(value: number[]);
  113358. /**
  113359. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113360. */
  113361. get wheelPrecision(): number;
  113362. set wheelPrecision(value: number);
  113363. /**
  113364. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113365. * It will be used instead of pinchDeltaPrecision if different from 0.
  113366. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113367. */
  113368. get wheelDeltaPercentage(): number;
  113369. set wheelDeltaPercentage(value: number);
  113370. /**
  113371. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113372. */
  113373. zoomOnFactor: number;
  113374. /**
  113375. * Defines a screen offset for the camera position.
  113376. */
  113377. targetScreenOffset: Vector2;
  113378. /**
  113379. * Allows the camera to be completely reversed.
  113380. * If false the camera can not arrive upside down.
  113381. */
  113382. allowUpsideDown: boolean;
  113383. /**
  113384. * Define if double tap/click is used to restore the previously saved state of the camera.
  113385. */
  113386. useInputToRestoreState: boolean;
  113387. /** @hidden */
  113388. _viewMatrix: Matrix;
  113389. /** @hidden */
  113390. _useCtrlForPanning: boolean;
  113391. /** @hidden */
  113392. _panningMouseButton: number;
  113393. /**
  113394. * Defines the input associated to the camera.
  113395. */
  113396. inputs: ArcRotateCameraInputsManager;
  113397. /** @hidden */
  113398. _reset: () => void;
  113399. /**
  113400. * Defines the allowed panning axis.
  113401. */
  113402. panningAxis: Vector3;
  113403. protected _localDirection: Vector3;
  113404. protected _transformedDirection: Vector3;
  113405. private _bouncingBehavior;
  113406. /**
  113407. * Gets the bouncing behavior of the camera if it has been enabled.
  113408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113409. */
  113410. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113411. /**
  113412. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113414. */
  113415. get useBouncingBehavior(): boolean;
  113416. set useBouncingBehavior(value: boolean);
  113417. private _framingBehavior;
  113418. /**
  113419. * Gets the framing behavior of the camera if it has been enabled.
  113420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113421. */
  113422. get framingBehavior(): Nullable<FramingBehavior>;
  113423. /**
  113424. * Defines if the framing behavior of the camera is enabled on the camera.
  113425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113426. */
  113427. get useFramingBehavior(): boolean;
  113428. set useFramingBehavior(value: boolean);
  113429. private _autoRotationBehavior;
  113430. /**
  113431. * Gets the auto rotation behavior of the camera if it has been enabled.
  113432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113433. */
  113434. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113435. /**
  113436. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113437. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113438. */
  113439. get useAutoRotationBehavior(): boolean;
  113440. set useAutoRotationBehavior(value: boolean);
  113441. /**
  113442. * Observable triggered when the mesh target has been changed on the camera.
  113443. */
  113444. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113445. /**
  113446. * Event raised when the camera is colliding with a mesh.
  113447. */
  113448. onCollide: (collidedMesh: AbstractMesh) => void;
  113449. /**
  113450. * Defines whether the camera should check collision with the objects oh the scene.
  113451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113452. */
  113453. checkCollisions: boolean;
  113454. /**
  113455. * Defines the collision radius of the camera.
  113456. * This simulates a sphere around the camera.
  113457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113458. */
  113459. collisionRadius: Vector3;
  113460. protected _collider: Collider;
  113461. protected _previousPosition: Vector3;
  113462. protected _collisionVelocity: Vector3;
  113463. protected _newPosition: Vector3;
  113464. protected _previousAlpha: number;
  113465. protected _previousBeta: number;
  113466. protected _previousRadius: number;
  113467. protected _collisionTriggered: boolean;
  113468. protected _targetBoundingCenter: Nullable<Vector3>;
  113469. private _computationVector;
  113470. /**
  113471. * Instantiates a new ArcRotateCamera in a given scene
  113472. * @param name Defines the name of the camera
  113473. * @param alpha Defines the camera rotation along the logitudinal axis
  113474. * @param beta Defines the camera rotation along the latitudinal axis
  113475. * @param radius Defines the camera distance from its target
  113476. * @param target Defines the camera target
  113477. * @param scene Defines the scene the camera belongs to
  113478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113479. */
  113480. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113481. /** @hidden */
  113482. _initCache(): void;
  113483. /** @hidden */
  113484. _updateCache(ignoreParentClass?: boolean): void;
  113485. protected _getTargetPosition(): Vector3;
  113486. private _storedAlpha;
  113487. private _storedBeta;
  113488. private _storedRadius;
  113489. private _storedTarget;
  113490. private _storedTargetScreenOffset;
  113491. /**
  113492. * Stores the current state of the camera (alpha, beta, radius and target)
  113493. * @returns the camera itself
  113494. */
  113495. storeState(): Camera;
  113496. /**
  113497. * @hidden
  113498. * Restored camera state. You must call storeState() first
  113499. */
  113500. _restoreStateValues(): boolean;
  113501. /** @hidden */
  113502. _isSynchronizedViewMatrix(): boolean;
  113503. /**
  113504. * Attached controls to the current camera.
  113505. * @param element Defines the element the controls should be listened from
  113506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113507. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113508. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113509. */
  113510. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113511. /**
  113512. * Detach the current controls from the camera.
  113513. * The camera will stop reacting to inputs.
  113514. * @param element Defines the element to stop listening the inputs from
  113515. */
  113516. detachControl(element: HTMLElement): void;
  113517. /** @hidden */
  113518. _checkInputs(): void;
  113519. protected _checkLimits(): void;
  113520. /**
  113521. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113522. */
  113523. rebuildAnglesAndRadius(): void;
  113524. /**
  113525. * Use a position to define the current camera related information like alpha, beta and radius
  113526. * @param position Defines the position to set the camera at
  113527. */
  113528. setPosition(position: Vector3): void;
  113529. /**
  113530. * Defines the target the camera should look at.
  113531. * This will automatically adapt alpha beta and radius to fit within the new target.
  113532. * @param target Defines the new target as a Vector or a mesh
  113533. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113534. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113535. */
  113536. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113537. /** @hidden */
  113538. _getViewMatrix(): Matrix;
  113539. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113540. /**
  113541. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113542. * @param meshes Defines the mesh to zoom on
  113543. * @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)
  113544. */
  113545. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113546. /**
  113547. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113548. * The target will be changed but the radius
  113549. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113550. * @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)
  113551. */
  113552. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113553. min: Vector3;
  113554. max: Vector3;
  113555. distance: number;
  113556. }, doNotUpdateMaxZ?: boolean): void;
  113557. /**
  113558. * @override
  113559. * Override Camera.createRigCamera
  113560. */
  113561. createRigCamera(name: string, cameraIndex: number): Camera;
  113562. /**
  113563. * @hidden
  113564. * @override
  113565. * Override Camera._updateRigCameras
  113566. */
  113567. _updateRigCameras(): void;
  113568. /**
  113569. * Destroy the camera and release the current resources hold by it.
  113570. */
  113571. dispose(): void;
  113572. /**
  113573. * Gets the current object class name.
  113574. * @return the class name
  113575. */
  113576. getClassName(): string;
  113577. }
  113578. }
  113579. declare module BABYLON {
  113580. /**
  113581. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113583. */
  113584. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113585. /**
  113586. * Gets the name of the behavior.
  113587. */
  113588. get name(): string;
  113589. private _zoomStopsAnimation;
  113590. private _idleRotationSpeed;
  113591. private _idleRotationWaitTime;
  113592. private _idleRotationSpinupTime;
  113593. /**
  113594. * Sets the flag that indicates if user zooming should stop animation.
  113595. */
  113596. set zoomStopsAnimation(flag: boolean);
  113597. /**
  113598. * Gets the flag that indicates if user zooming should stop animation.
  113599. */
  113600. get zoomStopsAnimation(): boolean;
  113601. /**
  113602. * Sets the default speed at which the camera rotates around the model.
  113603. */
  113604. set idleRotationSpeed(speed: number);
  113605. /**
  113606. * Gets the default speed at which the camera rotates around the model.
  113607. */
  113608. get idleRotationSpeed(): number;
  113609. /**
  113610. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113611. */
  113612. set idleRotationWaitTime(time: number);
  113613. /**
  113614. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113615. */
  113616. get idleRotationWaitTime(): number;
  113617. /**
  113618. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113619. */
  113620. set idleRotationSpinupTime(time: number);
  113621. /**
  113622. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113623. */
  113624. get idleRotationSpinupTime(): number;
  113625. /**
  113626. * Gets a value indicating if the camera is currently rotating because of this behavior
  113627. */
  113628. get rotationInProgress(): boolean;
  113629. private _onPrePointerObservableObserver;
  113630. private _onAfterCheckInputsObserver;
  113631. private _attachedCamera;
  113632. private _isPointerDown;
  113633. private _lastFrameTime;
  113634. private _lastInteractionTime;
  113635. private _cameraRotationSpeed;
  113636. /**
  113637. * Initializes the behavior.
  113638. */
  113639. init(): void;
  113640. /**
  113641. * Attaches the behavior to its arc rotate camera.
  113642. * @param camera Defines the camera to attach the behavior to
  113643. */
  113644. attach(camera: ArcRotateCamera): void;
  113645. /**
  113646. * Detaches the behavior from its current arc rotate camera.
  113647. */
  113648. detach(): void;
  113649. /**
  113650. * Returns true if user is scrolling.
  113651. * @return true if user is scrolling.
  113652. */
  113653. private _userIsZooming;
  113654. private _lastFrameRadius;
  113655. private _shouldAnimationStopForInteraction;
  113656. /**
  113657. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113658. */
  113659. private _applyUserInteraction;
  113660. private _userIsMoving;
  113661. }
  113662. }
  113663. declare module BABYLON {
  113664. /**
  113665. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113666. */
  113667. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113668. private ui;
  113669. /**
  113670. * The name of the behavior
  113671. */
  113672. name: string;
  113673. /**
  113674. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113675. */
  113676. distanceAwayFromFace: number;
  113677. /**
  113678. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113679. */
  113680. distanceAwayFromBottomOfFace: number;
  113681. private _faceVectors;
  113682. private _target;
  113683. private _scene;
  113684. private _onRenderObserver;
  113685. private _tmpMatrix;
  113686. private _tmpVector;
  113687. /**
  113688. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113689. * @param ui The transform node that should be attched to the mesh
  113690. */
  113691. constructor(ui: TransformNode);
  113692. /**
  113693. * Initializes the behavior
  113694. */
  113695. init(): void;
  113696. private _closestFace;
  113697. private _zeroVector;
  113698. private _lookAtTmpMatrix;
  113699. private _lookAtToRef;
  113700. /**
  113701. * Attaches the AttachToBoxBehavior to the passed in mesh
  113702. * @param target The mesh that the specified node will be attached to
  113703. */
  113704. attach(target: Mesh): void;
  113705. /**
  113706. * Detaches the behavior from the mesh
  113707. */
  113708. detach(): void;
  113709. }
  113710. }
  113711. declare module BABYLON {
  113712. /**
  113713. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113714. */
  113715. export class FadeInOutBehavior implements Behavior<Mesh> {
  113716. /**
  113717. * Time in milliseconds to delay before fading in (Default: 0)
  113718. */
  113719. delay: number;
  113720. /**
  113721. * Time in milliseconds for the mesh to fade in (Default: 300)
  113722. */
  113723. fadeInTime: number;
  113724. private _millisecondsPerFrame;
  113725. private _hovered;
  113726. private _hoverValue;
  113727. private _ownerNode;
  113728. /**
  113729. * Instatiates the FadeInOutBehavior
  113730. */
  113731. constructor();
  113732. /**
  113733. * The name of the behavior
  113734. */
  113735. get name(): string;
  113736. /**
  113737. * Initializes the behavior
  113738. */
  113739. init(): void;
  113740. /**
  113741. * Attaches the fade behavior on the passed in mesh
  113742. * @param ownerNode The mesh that will be faded in/out once attached
  113743. */
  113744. attach(ownerNode: Mesh): void;
  113745. /**
  113746. * Detaches the behavior from the mesh
  113747. */
  113748. detach(): void;
  113749. /**
  113750. * Triggers the mesh to begin fading in or out
  113751. * @param value if the object should fade in or out (true to fade in)
  113752. */
  113753. fadeIn(value: boolean): void;
  113754. private _update;
  113755. private _setAllVisibility;
  113756. }
  113757. }
  113758. declare module BABYLON {
  113759. /**
  113760. * Class containing a set of static utilities functions for managing Pivots
  113761. * @hidden
  113762. */
  113763. export class PivotTools {
  113764. private static _PivotCached;
  113765. private static _OldPivotPoint;
  113766. private static _PivotTranslation;
  113767. private static _PivotTmpVector;
  113768. /** @hidden */
  113769. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113770. /** @hidden */
  113771. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113772. }
  113773. }
  113774. declare module BABYLON {
  113775. /**
  113776. * Class containing static functions to help procedurally build meshes
  113777. */
  113778. export class PlaneBuilder {
  113779. /**
  113780. * Creates a plane mesh
  113781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113787. * @param name defines the name of the mesh
  113788. * @param options defines the options used to create the mesh
  113789. * @param scene defines the hosting scene
  113790. * @returns the plane mesh
  113791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113792. */
  113793. static CreatePlane(name: string, options: {
  113794. size?: number;
  113795. width?: number;
  113796. height?: number;
  113797. sideOrientation?: number;
  113798. frontUVs?: Vector4;
  113799. backUVs?: Vector4;
  113800. updatable?: boolean;
  113801. sourcePlane?: Plane;
  113802. }, scene?: Nullable<Scene>): Mesh;
  113803. }
  113804. }
  113805. declare module BABYLON {
  113806. /**
  113807. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113808. */
  113809. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113810. private static _AnyMouseID;
  113811. /**
  113812. * Abstract mesh the behavior is set on
  113813. */
  113814. attachedNode: AbstractMesh;
  113815. private _dragPlane;
  113816. private _scene;
  113817. private _pointerObserver;
  113818. private _beforeRenderObserver;
  113819. private static _planeScene;
  113820. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113821. /**
  113822. * 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)
  113823. */
  113824. maxDragAngle: number;
  113825. /**
  113826. * @hidden
  113827. */
  113828. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113829. /**
  113830. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113831. */
  113832. currentDraggingPointerID: number;
  113833. /**
  113834. * The last position where the pointer hit the drag plane in world space
  113835. */
  113836. lastDragPosition: Vector3;
  113837. /**
  113838. * If the behavior is currently in a dragging state
  113839. */
  113840. dragging: boolean;
  113841. /**
  113842. * 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)
  113843. */
  113844. dragDeltaRatio: number;
  113845. /**
  113846. * If the drag plane orientation should be updated during the dragging (Default: true)
  113847. */
  113848. updateDragPlane: boolean;
  113849. private _debugMode;
  113850. private _moving;
  113851. /**
  113852. * Fires each time the attached mesh is dragged with the pointer
  113853. * * delta between last drag position and current drag position in world space
  113854. * * dragDistance along the drag axis
  113855. * * dragPlaneNormal normal of the current drag plane used during the drag
  113856. * * dragPlanePoint in world space where the drag intersects the drag plane
  113857. */
  113858. onDragObservable: Observable<{
  113859. delta: Vector3;
  113860. dragPlanePoint: Vector3;
  113861. dragPlaneNormal: Vector3;
  113862. dragDistance: number;
  113863. pointerId: number;
  113864. }>;
  113865. /**
  113866. * Fires each time a drag begins (eg. mouse down on mesh)
  113867. */
  113868. onDragStartObservable: Observable<{
  113869. dragPlanePoint: Vector3;
  113870. pointerId: number;
  113871. }>;
  113872. /**
  113873. * Fires each time a drag ends (eg. mouse release after drag)
  113874. */
  113875. onDragEndObservable: Observable<{
  113876. dragPlanePoint: Vector3;
  113877. pointerId: number;
  113878. }>;
  113879. /**
  113880. * If the attached mesh should be moved when dragged
  113881. */
  113882. moveAttached: boolean;
  113883. /**
  113884. * If the drag behavior will react to drag events (Default: true)
  113885. */
  113886. enabled: boolean;
  113887. /**
  113888. * If pointer events should start and release the drag (Default: true)
  113889. */
  113890. startAndReleaseDragOnPointerEvents: boolean;
  113891. /**
  113892. * If camera controls should be detached during the drag
  113893. */
  113894. detachCameraControls: boolean;
  113895. /**
  113896. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113897. */
  113898. useObjectOrientationForDragging: boolean;
  113899. private _options;
  113900. /**
  113901. * Gets the options used by the behavior
  113902. */
  113903. get options(): {
  113904. dragAxis?: Vector3;
  113905. dragPlaneNormal?: Vector3;
  113906. };
  113907. /**
  113908. * Sets the options used by the behavior
  113909. */
  113910. set options(options: {
  113911. dragAxis?: Vector3;
  113912. dragPlaneNormal?: Vector3;
  113913. });
  113914. /**
  113915. * Creates a pointer drag behavior that can be attached to a mesh
  113916. * @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)
  113917. */
  113918. constructor(options?: {
  113919. dragAxis?: Vector3;
  113920. dragPlaneNormal?: Vector3;
  113921. });
  113922. /**
  113923. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113924. */
  113925. validateDrag: (targetPosition: Vector3) => boolean;
  113926. /**
  113927. * The name of the behavior
  113928. */
  113929. get name(): string;
  113930. /**
  113931. * Initializes the behavior
  113932. */
  113933. init(): void;
  113934. private _tmpVector;
  113935. private _alternatePickedPoint;
  113936. private _worldDragAxis;
  113937. private _targetPosition;
  113938. private _attachedElement;
  113939. /**
  113940. * Attaches the drag behavior the passed in mesh
  113941. * @param ownerNode The mesh that will be dragged around once attached
  113942. * @param predicate Predicate to use for pick filtering
  113943. */
  113944. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113945. /**
  113946. * Force relase the drag action by code.
  113947. */
  113948. releaseDrag(): void;
  113949. private _startDragRay;
  113950. private _lastPointerRay;
  113951. /**
  113952. * Simulates the start of a pointer drag event on the behavior
  113953. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113954. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113955. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113956. */
  113957. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113958. private _startDrag;
  113959. private _dragDelta;
  113960. private _moveDrag;
  113961. private _pickWithRayOnDragPlane;
  113962. private _pointA;
  113963. private _pointB;
  113964. private _pointC;
  113965. private _lineA;
  113966. private _lineB;
  113967. private _localAxis;
  113968. private _lookAt;
  113969. private _updateDragPlanePosition;
  113970. /**
  113971. * Detaches the behavior from the mesh
  113972. */
  113973. detach(): void;
  113974. }
  113975. }
  113976. declare module BABYLON {
  113977. /**
  113978. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113979. */
  113980. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113981. private _dragBehaviorA;
  113982. private _dragBehaviorB;
  113983. private _startDistance;
  113984. private _initialScale;
  113985. private _targetScale;
  113986. private _ownerNode;
  113987. private _sceneRenderObserver;
  113988. /**
  113989. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113990. */
  113991. constructor();
  113992. /**
  113993. * The name of the behavior
  113994. */
  113995. get name(): string;
  113996. /**
  113997. * Initializes the behavior
  113998. */
  113999. init(): void;
  114000. private _getCurrentDistance;
  114001. /**
  114002. * Attaches the scale behavior the passed in mesh
  114003. * @param ownerNode The mesh that will be scaled around once attached
  114004. */
  114005. attach(ownerNode: Mesh): void;
  114006. /**
  114007. * Detaches the behavior from the mesh
  114008. */
  114009. detach(): void;
  114010. }
  114011. }
  114012. declare module BABYLON {
  114013. /**
  114014. * 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
  114015. */
  114016. export class SixDofDragBehavior implements Behavior<Mesh> {
  114017. private static _virtualScene;
  114018. private _ownerNode;
  114019. private _sceneRenderObserver;
  114020. private _scene;
  114021. private _targetPosition;
  114022. private _virtualOriginMesh;
  114023. private _virtualDragMesh;
  114024. private _pointerObserver;
  114025. private _moving;
  114026. private _startingOrientation;
  114027. private _attachedElement;
  114028. /**
  114029. * 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)
  114030. */
  114031. private zDragFactor;
  114032. /**
  114033. * If the object should rotate to face the drag origin
  114034. */
  114035. rotateDraggedObject: boolean;
  114036. /**
  114037. * If the behavior is currently in a dragging state
  114038. */
  114039. dragging: boolean;
  114040. /**
  114041. * 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)
  114042. */
  114043. dragDeltaRatio: number;
  114044. /**
  114045. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114046. */
  114047. currentDraggingPointerID: number;
  114048. /**
  114049. * If camera controls should be detached during the drag
  114050. */
  114051. detachCameraControls: boolean;
  114052. /**
  114053. * Fires each time a drag starts
  114054. */
  114055. onDragStartObservable: Observable<{}>;
  114056. /**
  114057. * Fires each time a drag ends (eg. mouse release after drag)
  114058. */
  114059. onDragEndObservable: Observable<{}>;
  114060. /**
  114061. * 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
  114062. */
  114063. constructor();
  114064. /**
  114065. * The name of the behavior
  114066. */
  114067. get name(): string;
  114068. /**
  114069. * Initializes the behavior
  114070. */
  114071. init(): void;
  114072. /**
  114073. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114074. */
  114075. private get _pointerCamera();
  114076. /**
  114077. * Attaches the scale behavior the passed in mesh
  114078. * @param ownerNode The mesh that will be scaled around once attached
  114079. */
  114080. attach(ownerNode: Mesh): void;
  114081. /**
  114082. * Detaches the behavior from the mesh
  114083. */
  114084. detach(): void;
  114085. }
  114086. }
  114087. declare module BABYLON {
  114088. /**
  114089. * Class used to apply inverse kinematics to bones
  114090. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114091. */
  114092. export class BoneIKController {
  114093. private static _tmpVecs;
  114094. private static _tmpQuat;
  114095. private static _tmpMats;
  114096. /**
  114097. * Gets or sets the target mesh
  114098. */
  114099. targetMesh: AbstractMesh;
  114100. /** Gets or sets the mesh used as pole */
  114101. poleTargetMesh: AbstractMesh;
  114102. /**
  114103. * Gets or sets the bone used as pole
  114104. */
  114105. poleTargetBone: Nullable<Bone>;
  114106. /**
  114107. * Gets or sets the target position
  114108. */
  114109. targetPosition: Vector3;
  114110. /**
  114111. * Gets or sets the pole target position
  114112. */
  114113. poleTargetPosition: Vector3;
  114114. /**
  114115. * Gets or sets the pole target local offset
  114116. */
  114117. poleTargetLocalOffset: Vector3;
  114118. /**
  114119. * Gets or sets the pole angle
  114120. */
  114121. poleAngle: number;
  114122. /**
  114123. * Gets or sets the mesh associated with the controller
  114124. */
  114125. mesh: AbstractMesh;
  114126. /**
  114127. * 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)
  114128. */
  114129. slerpAmount: number;
  114130. private _bone1Quat;
  114131. private _bone1Mat;
  114132. private _bone2Ang;
  114133. private _bone1;
  114134. private _bone2;
  114135. private _bone1Length;
  114136. private _bone2Length;
  114137. private _maxAngle;
  114138. private _maxReach;
  114139. private _rightHandedSystem;
  114140. private _bendAxis;
  114141. private _slerping;
  114142. private _adjustRoll;
  114143. /**
  114144. * Gets or sets maximum allowed angle
  114145. */
  114146. get maxAngle(): number;
  114147. set maxAngle(value: number);
  114148. /**
  114149. * Creates a new BoneIKController
  114150. * @param mesh defines the mesh to control
  114151. * @param bone defines the bone to control
  114152. * @param options defines options to set up the controller
  114153. */
  114154. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114155. targetMesh?: AbstractMesh;
  114156. poleTargetMesh?: AbstractMesh;
  114157. poleTargetBone?: Bone;
  114158. poleTargetLocalOffset?: Vector3;
  114159. poleAngle?: number;
  114160. bendAxis?: Vector3;
  114161. maxAngle?: number;
  114162. slerpAmount?: number;
  114163. });
  114164. private _setMaxAngle;
  114165. /**
  114166. * Force the controller to update the bones
  114167. */
  114168. update(): void;
  114169. }
  114170. }
  114171. declare module BABYLON {
  114172. /**
  114173. * Class used to make a bone look toward a point in space
  114174. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114175. */
  114176. export class BoneLookController {
  114177. private static _tmpVecs;
  114178. private static _tmpQuat;
  114179. private static _tmpMats;
  114180. /**
  114181. * The target Vector3 that the bone will look at
  114182. */
  114183. target: Vector3;
  114184. /**
  114185. * The mesh that the bone is attached to
  114186. */
  114187. mesh: AbstractMesh;
  114188. /**
  114189. * The bone that will be looking to the target
  114190. */
  114191. bone: Bone;
  114192. /**
  114193. * The up axis of the coordinate system that is used when the bone is rotated
  114194. */
  114195. upAxis: Vector3;
  114196. /**
  114197. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114198. */
  114199. upAxisSpace: Space;
  114200. /**
  114201. * Used to make an adjustment to the yaw of the bone
  114202. */
  114203. adjustYaw: number;
  114204. /**
  114205. * Used to make an adjustment to the pitch of the bone
  114206. */
  114207. adjustPitch: number;
  114208. /**
  114209. * Used to make an adjustment to the roll of the bone
  114210. */
  114211. adjustRoll: number;
  114212. /**
  114213. * 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)
  114214. */
  114215. slerpAmount: number;
  114216. private _minYaw;
  114217. private _maxYaw;
  114218. private _minPitch;
  114219. private _maxPitch;
  114220. private _minYawSin;
  114221. private _minYawCos;
  114222. private _maxYawSin;
  114223. private _maxYawCos;
  114224. private _midYawConstraint;
  114225. private _minPitchTan;
  114226. private _maxPitchTan;
  114227. private _boneQuat;
  114228. private _slerping;
  114229. private _transformYawPitch;
  114230. private _transformYawPitchInv;
  114231. private _firstFrameSkipped;
  114232. private _yawRange;
  114233. private _fowardAxis;
  114234. /**
  114235. * Gets or sets the minimum yaw angle that the bone can look to
  114236. */
  114237. get minYaw(): number;
  114238. set minYaw(value: number);
  114239. /**
  114240. * Gets or sets the maximum yaw angle that the bone can look to
  114241. */
  114242. get maxYaw(): number;
  114243. set maxYaw(value: number);
  114244. /**
  114245. * Gets or sets the minimum pitch angle that the bone can look to
  114246. */
  114247. get minPitch(): number;
  114248. set minPitch(value: number);
  114249. /**
  114250. * Gets or sets the maximum pitch angle that the bone can look to
  114251. */
  114252. get maxPitch(): number;
  114253. set maxPitch(value: number);
  114254. /**
  114255. * Create a BoneLookController
  114256. * @param mesh the mesh that the bone belongs to
  114257. * @param bone the bone that will be looking to the target
  114258. * @param target the target Vector3 to look at
  114259. * @param options optional settings:
  114260. * * maxYaw: the maximum angle the bone will yaw to
  114261. * * minYaw: the minimum angle the bone will yaw to
  114262. * * maxPitch: the maximum angle the bone will pitch to
  114263. * * minPitch: the minimum angle the bone will yaw to
  114264. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114265. * * upAxis: the up axis of the coordinate system
  114266. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114267. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114268. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114269. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114270. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114271. * * adjustRoll: used to make an adjustment to the roll of the bone
  114272. **/
  114273. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114274. maxYaw?: number;
  114275. minYaw?: number;
  114276. maxPitch?: number;
  114277. minPitch?: number;
  114278. slerpAmount?: number;
  114279. upAxis?: Vector3;
  114280. upAxisSpace?: Space;
  114281. yawAxis?: Vector3;
  114282. pitchAxis?: Vector3;
  114283. adjustYaw?: number;
  114284. adjustPitch?: number;
  114285. adjustRoll?: number;
  114286. });
  114287. /**
  114288. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114289. */
  114290. update(): void;
  114291. private _getAngleDiff;
  114292. private _getAngleBetween;
  114293. private _isAngleBetween;
  114294. }
  114295. }
  114296. declare module BABYLON {
  114297. /**
  114298. * Manage the gamepad inputs to control an arc rotate camera.
  114299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114300. */
  114301. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114302. /**
  114303. * Defines the camera the input is attached to.
  114304. */
  114305. camera: ArcRotateCamera;
  114306. /**
  114307. * Defines the gamepad the input is gathering event from.
  114308. */
  114309. gamepad: Nullable<Gamepad>;
  114310. /**
  114311. * Defines the gamepad rotation sensiblity.
  114312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114313. */
  114314. gamepadRotationSensibility: number;
  114315. /**
  114316. * Defines the gamepad move sensiblity.
  114317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114318. */
  114319. gamepadMoveSensibility: number;
  114320. private _yAxisScale;
  114321. /**
  114322. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114323. */
  114324. get invertYAxis(): boolean;
  114325. set invertYAxis(value: boolean);
  114326. private _onGamepadConnectedObserver;
  114327. private _onGamepadDisconnectedObserver;
  114328. /**
  114329. * Attach the input controls to a specific dom element to get the input from.
  114330. * @param element Defines the element the controls should be listened from
  114331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114332. */
  114333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114334. /**
  114335. * Detach the current controls from the specified dom element.
  114336. * @param element Defines the element to stop listening the inputs from
  114337. */
  114338. detachControl(element: Nullable<HTMLElement>): void;
  114339. /**
  114340. * Update the current camera state depending on the inputs that have been used this frame.
  114341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114342. */
  114343. checkInputs(): void;
  114344. /**
  114345. * Gets the class name of the current intput.
  114346. * @returns the class name
  114347. */
  114348. getClassName(): string;
  114349. /**
  114350. * Get the friendly name associated with the input class.
  114351. * @returns the input friendly name
  114352. */
  114353. getSimpleName(): string;
  114354. }
  114355. }
  114356. declare module BABYLON {
  114357. interface ArcRotateCameraInputsManager {
  114358. /**
  114359. * Add orientation input support to the input manager.
  114360. * @returns the current input manager
  114361. */
  114362. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114363. }
  114364. /**
  114365. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114367. */
  114368. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114369. /**
  114370. * Defines the camera the input is attached to.
  114371. */
  114372. camera: ArcRotateCamera;
  114373. /**
  114374. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114375. */
  114376. alphaCorrection: number;
  114377. /**
  114378. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114379. */
  114380. gammaCorrection: number;
  114381. private _alpha;
  114382. private _gamma;
  114383. private _dirty;
  114384. private _deviceOrientationHandler;
  114385. /**
  114386. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114387. */
  114388. constructor();
  114389. /**
  114390. * Attach the input controls to a specific dom element to get the input from.
  114391. * @param element Defines the element the controls should be listened from
  114392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114393. */
  114394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114395. /** @hidden */
  114396. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114397. /**
  114398. * Update the current camera state depending on the inputs that have been used this frame.
  114399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114400. */
  114401. checkInputs(): void;
  114402. /**
  114403. * Detach the current controls from the specified dom element.
  114404. * @param element Defines the element to stop listening the inputs from
  114405. */
  114406. detachControl(element: Nullable<HTMLElement>): void;
  114407. /**
  114408. * Gets the class name of the current intput.
  114409. * @returns the class name
  114410. */
  114411. getClassName(): string;
  114412. /**
  114413. * Get the friendly name associated with the input class.
  114414. * @returns the input friendly name
  114415. */
  114416. getSimpleName(): string;
  114417. }
  114418. }
  114419. declare module BABYLON {
  114420. /**
  114421. * Listen to mouse events to control the camera.
  114422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114423. */
  114424. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114425. /**
  114426. * Defines the camera the input is attached to.
  114427. */
  114428. camera: FlyCamera;
  114429. /**
  114430. * Defines if touch is enabled. (Default is true.)
  114431. */
  114432. touchEnabled: boolean;
  114433. /**
  114434. * Defines the buttons associated with the input to handle camera rotation.
  114435. */
  114436. buttons: number[];
  114437. /**
  114438. * Assign buttons for Yaw control.
  114439. */
  114440. buttonsYaw: number[];
  114441. /**
  114442. * Assign buttons for Pitch control.
  114443. */
  114444. buttonsPitch: number[];
  114445. /**
  114446. * Assign buttons for Roll control.
  114447. */
  114448. buttonsRoll: number[];
  114449. /**
  114450. * Detect if any button is being pressed while mouse is moved.
  114451. * -1 = Mouse locked.
  114452. * 0 = Left button.
  114453. * 1 = Middle Button.
  114454. * 2 = Right Button.
  114455. */
  114456. activeButton: number;
  114457. /**
  114458. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114459. * Higher values reduce its sensitivity.
  114460. */
  114461. angularSensibility: number;
  114462. private _mousemoveCallback;
  114463. private _observer;
  114464. private _rollObserver;
  114465. private previousPosition;
  114466. private noPreventDefault;
  114467. private element;
  114468. /**
  114469. * Listen to mouse events to control the camera.
  114470. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114472. */
  114473. constructor(touchEnabled?: boolean);
  114474. /**
  114475. * Attach the mouse control to the HTML DOM element.
  114476. * @param element Defines the element that listens to the input events.
  114477. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114478. */
  114479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114480. /**
  114481. * Detach the current controls from the specified dom element.
  114482. * @param element Defines the element to stop listening the inputs from
  114483. */
  114484. detachControl(element: Nullable<HTMLElement>): void;
  114485. /**
  114486. * Gets the class name of the current input.
  114487. * @returns the class name.
  114488. */
  114489. getClassName(): string;
  114490. /**
  114491. * Get the friendly name associated with the input class.
  114492. * @returns the input's friendly name.
  114493. */
  114494. getSimpleName(): string;
  114495. private _pointerInput;
  114496. private _onMouseMove;
  114497. /**
  114498. * Rotate camera by mouse offset.
  114499. */
  114500. private rotateCamera;
  114501. }
  114502. }
  114503. declare module BABYLON {
  114504. /**
  114505. * Default Inputs manager for the FlyCamera.
  114506. * It groups all the default supported inputs for ease of use.
  114507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114508. */
  114509. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114510. /**
  114511. * Instantiates a new FlyCameraInputsManager.
  114512. * @param camera Defines the camera the inputs belong to.
  114513. */
  114514. constructor(camera: FlyCamera);
  114515. /**
  114516. * Add keyboard input support to the input manager.
  114517. * @returns the new FlyCameraKeyboardMoveInput().
  114518. */
  114519. addKeyboard(): FlyCameraInputsManager;
  114520. /**
  114521. * Add mouse input support to the input manager.
  114522. * @param touchEnabled Enable touch screen support.
  114523. * @returns the new FlyCameraMouseInput().
  114524. */
  114525. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114526. }
  114527. }
  114528. declare module BABYLON {
  114529. /**
  114530. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114531. * such as in a 3D Space Shooter or a Flight Simulator.
  114532. */
  114533. export class FlyCamera extends TargetCamera {
  114534. /**
  114535. * Define the collision ellipsoid of the camera.
  114536. * This is helpful for simulating a camera body, like a player's body.
  114537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114538. */
  114539. ellipsoid: Vector3;
  114540. /**
  114541. * Define an offset for the position of the ellipsoid around the camera.
  114542. * This can be helpful if the camera is attached away from the player's body center,
  114543. * such as at its head.
  114544. */
  114545. ellipsoidOffset: Vector3;
  114546. /**
  114547. * Enable or disable collisions of the camera with the rest of the scene objects.
  114548. */
  114549. checkCollisions: boolean;
  114550. /**
  114551. * Enable or disable gravity on the camera.
  114552. */
  114553. applyGravity: boolean;
  114554. /**
  114555. * Define the current direction the camera is moving to.
  114556. */
  114557. cameraDirection: Vector3;
  114558. /**
  114559. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114560. * This overrides and empties cameraRotation.
  114561. */
  114562. rotationQuaternion: Quaternion;
  114563. /**
  114564. * Track Roll to maintain the wanted Rolling when looking around.
  114565. */
  114566. _trackRoll: number;
  114567. /**
  114568. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114569. */
  114570. rollCorrect: number;
  114571. /**
  114572. * Mimic a banked turn, Rolling the camera when Yawing.
  114573. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114574. */
  114575. bankedTurn: boolean;
  114576. /**
  114577. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114578. */
  114579. bankedTurnLimit: number;
  114580. /**
  114581. * Value of 0 disables the banked Roll.
  114582. * Value of 1 is equal to the Yaw angle in radians.
  114583. */
  114584. bankedTurnMultiplier: number;
  114585. /**
  114586. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114587. */
  114588. inputs: FlyCameraInputsManager;
  114589. /**
  114590. * Gets the input sensibility for mouse input.
  114591. * Higher values reduce sensitivity.
  114592. */
  114593. get angularSensibility(): number;
  114594. /**
  114595. * Sets the input sensibility for a mouse input.
  114596. * Higher values reduce sensitivity.
  114597. */
  114598. set angularSensibility(value: number);
  114599. /**
  114600. * Get the keys for camera movement forward.
  114601. */
  114602. get keysForward(): number[];
  114603. /**
  114604. * Set the keys for camera movement forward.
  114605. */
  114606. set keysForward(value: number[]);
  114607. /**
  114608. * Get the keys for camera movement backward.
  114609. */
  114610. get keysBackward(): number[];
  114611. set keysBackward(value: number[]);
  114612. /**
  114613. * Get the keys for camera movement up.
  114614. */
  114615. get keysUp(): number[];
  114616. /**
  114617. * Set the keys for camera movement up.
  114618. */
  114619. set keysUp(value: number[]);
  114620. /**
  114621. * Get the keys for camera movement down.
  114622. */
  114623. get keysDown(): number[];
  114624. /**
  114625. * Set the keys for camera movement down.
  114626. */
  114627. set keysDown(value: number[]);
  114628. /**
  114629. * Get the keys for camera movement left.
  114630. */
  114631. get keysLeft(): number[];
  114632. /**
  114633. * Set the keys for camera movement left.
  114634. */
  114635. set keysLeft(value: number[]);
  114636. /**
  114637. * Set the keys for camera movement right.
  114638. */
  114639. get keysRight(): number[];
  114640. /**
  114641. * Set the keys for camera movement right.
  114642. */
  114643. set keysRight(value: number[]);
  114644. /**
  114645. * Event raised when the camera collides with a mesh in the scene.
  114646. */
  114647. onCollide: (collidedMesh: AbstractMesh) => void;
  114648. private _collider;
  114649. private _needMoveForGravity;
  114650. private _oldPosition;
  114651. private _diffPosition;
  114652. private _newPosition;
  114653. /** @hidden */
  114654. _localDirection: Vector3;
  114655. /** @hidden */
  114656. _transformedDirection: Vector3;
  114657. /**
  114658. * Instantiates a FlyCamera.
  114659. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114660. * such as in a 3D Space Shooter or a Flight Simulator.
  114661. * @param name Define the name of the camera in the scene.
  114662. * @param position Define the starting position of the camera in the scene.
  114663. * @param scene Define the scene the camera belongs to.
  114664. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114665. */
  114666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114667. /**
  114668. * Attach a control to the HTML DOM element.
  114669. * @param element Defines the element that listens to the input events.
  114670. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114671. */
  114672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114673. /**
  114674. * Detach a control from the HTML DOM element.
  114675. * The camera will stop reacting to that input.
  114676. * @param element Defines the element that listens to the input events.
  114677. */
  114678. detachControl(element: HTMLElement): void;
  114679. private _collisionMask;
  114680. /**
  114681. * Get the mask that the camera ignores in collision events.
  114682. */
  114683. get collisionMask(): number;
  114684. /**
  114685. * Set the mask that the camera ignores in collision events.
  114686. */
  114687. set collisionMask(mask: number);
  114688. /** @hidden */
  114689. _collideWithWorld(displacement: Vector3): void;
  114690. /** @hidden */
  114691. private _onCollisionPositionChange;
  114692. /** @hidden */
  114693. _checkInputs(): void;
  114694. /** @hidden */
  114695. _decideIfNeedsToMove(): boolean;
  114696. /** @hidden */
  114697. _updatePosition(): void;
  114698. /**
  114699. * Restore the Roll to its target value at the rate specified.
  114700. * @param rate - Higher means slower restoring.
  114701. * @hidden
  114702. */
  114703. restoreRoll(rate: number): void;
  114704. /**
  114705. * Destroy the camera and release the current resources held by it.
  114706. */
  114707. dispose(): void;
  114708. /**
  114709. * Get the current object class name.
  114710. * @returns the class name.
  114711. */
  114712. getClassName(): string;
  114713. }
  114714. }
  114715. declare module BABYLON {
  114716. /**
  114717. * Listen to keyboard events to control the camera.
  114718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114719. */
  114720. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114721. /**
  114722. * Defines the camera the input is attached to.
  114723. */
  114724. camera: FlyCamera;
  114725. /**
  114726. * The list of keyboard keys used to control the forward move of the camera.
  114727. */
  114728. keysForward: number[];
  114729. /**
  114730. * The list of keyboard keys used to control the backward move of the camera.
  114731. */
  114732. keysBackward: number[];
  114733. /**
  114734. * The list of keyboard keys used to control the forward move of the camera.
  114735. */
  114736. keysUp: number[];
  114737. /**
  114738. * The list of keyboard keys used to control the backward move of the camera.
  114739. */
  114740. keysDown: number[];
  114741. /**
  114742. * The list of keyboard keys used to control the right strafe move of the camera.
  114743. */
  114744. keysRight: number[];
  114745. /**
  114746. * The list of keyboard keys used to control the left strafe move of the camera.
  114747. */
  114748. keysLeft: number[];
  114749. private _keys;
  114750. private _onCanvasBlurObserver;
  114751. private _onKeyboardObserver;
  114752. private _engine;
  114753. private _scene;
  114754. /**
  114755. * Attach the input controls to a specific dom element to get the input from.
  114756. * @param element Defines the element the controls should be listened from
  114757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114758. */
  114759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114760. /**
  114761. * Detach the current controls from the specified dom element.
  114762. * @param element Defines the element to stop listening the inputs from
  114763. */
  114764. detachControl(element: Nullable<HTMLElement>): void;
  114765. /**
  114766. * Gets the class name of the current intput.
  114767. * @returns the class name
  114768. */
  114769. getClassName(): string;
  114770. /** @hidden */
  114771. _onLostFocus(e: FocusEvent): void;
  114772. /**
  114773. * Get the friendly name associated with the input class.
  114774. * @returns the input friendly name
  114775. */
  114776. getSimpleName(): string;
  114777. /**
  114778. * Update the current camera state depending on the inputs that have been used this frame.
  114779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114780. */
  114781. checkInputs(): void;
  114782. }
  114783. }
  114784. declare module BABYLON {
  114785. /**
  114786. * Manage the mouse wheel inputs to control a follow camera.
  114787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114788. */
  114789. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114790. /**
  114791. * Defines the camera the input is attached to.
  114792. */
  114793. camera: FollowCamera;
  114794. /**
  114795. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114796. */
  114797. axisControlRadius: boolean;
  114798. /**
  114799. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114800. */
  114801. axisControlHeight: boolean;
  114802. /**
  114803. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114804. */
  114805. axisControlRotation: boolean;
  114806. /**
  114807. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114808. * relation to mouseWheel events.
  114809. */
  114810. wheelPrecision: number;
  114811. /**
  114812. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114813. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114814. */
  114815. wheelDeltaPercentage: number;
  114816. private _wheel;
  114817. private _observer;
  114818. /**
  114819. * Attach the input controls to a specific dom element to get the input from.
  114820. * @param element Defines the element the controls should be listened from
  114821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114822. */
  114823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114824. /**
  114825. * Detach the current controls from the specified dom element.
  114826. * @param element Defines the element to stop listening the inputs from
  114827. */
  114828. detachControl(element: Nullable<HTMLElement>): void;
  114829. /**
  114830. * Gets the class name of the current intput.
  114831. * @returns the class name
  114832. */
  114833. getClassName(): string;
  114834. /**
  114835. * Get the friendly name associated with the input class.
  114836. * @returns the input friendly name
  114837. */
  114838. getSimpleName(): string;
  114839. }
  114840. }
  114841. declare module BABYLON {
  114842. /**
  114843. * Manage the pointers inputs to control an follow camera.
  114844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114845. */
  114846. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114847. /**
  114848. * Defines the camera the input is attached to.
  114849. */
  114850. camera: FollowCamera;
  114851. /**
  114852. * Gets the class name of the current input.
  114853. * @returns the class name
  114854. */
  114855. getClassName(): string;
  114856. /**
  114857. * Defines the pointer angular sensibility along the X axis or how fast is
  114858. * the camera rotating.
  114859. * A negative number will reverse the axis direction.
  114860. */
  114861. angularSensibilityX: number;
  114862. /**
  114863. * Defines the pointer angular sensibility along the Y axis or how fast is
  114864. * the camera rotating.
  114865. * A negative number will reverse the axis direction.
  114866. */
  114867. angularSensibilityY: number;
  114868. /**
  114869. * Defines the pointer pinch precision or how fast is the camera zooming.
  114870. * A negative number will reverse the axis direction.
  114871. */
  114872. pinchPrecision: number;
  114873. /**
  114874. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114875. * from 0.
  114876. * It defines the percentage of current camera.radius to use as delta when
  114877. * pinch zoom is used.
  114878. */
  114879. pinchDeltaPercentage: number;
  114880. /**
  114881. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114882. */
  114883. axisXControlRadius: boolean;
  114884. /**
  114885. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114886. */
  114887. axisXControlHeight: boolean;
  114888. /**
  114889. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114890. */
  114891. axisXControlRotation: boolean;
  114892. /**
  114893. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114894. */
  114895. axisYControlRadius: boolean;
  114896. /**
  114897. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114898. */
  114899. axisYControlHeight: boolean;
  114900. /**
  114901. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114902. */
  114903. axisYControlRotation: boolean;
  114904. /**
  114905. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114906. */
  114907. axisPinchControlRadius: boolean;
  114908. /**
  114909. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114910. */
  114911. axisPinchControlHeight: boolean;
  114912. /**
  114913. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114914. */
  114915. axisPinchControlRotation: boolean;
  114916. /**
  114917. * Log error messages if basic misconfiguration has occurred.
  114918. */
  114919. warningEnable: boolean;
  114920. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114921. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114922. private _warningCounter;
  114923. private _warning;
  114924. }
  114925. }
  114926. declare module BABYLON {
  114927. /**
  114928. * Default Inputs manager for the FollowCamera.
  114929. * It groups all the default supported inputs for ease of use.
  114930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114931. */
  114932. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114933. /**
  114934. * Instantiates a new FollowCameraInputsManager.
  114935. * @param camera Defines the camera the inputs belong to
  114936. */
  114937. constructor(camera: FollowCamera);
  114938. /**
  114939. * Add keyboard input support to the input manager.
  114940. * @returns the current input manager
  114941. */
  114942. addKeyboard(): FollowCameraInputsManager;
  114943. /**
  114944. * Add mouse wheel input support to the input manager.
  114945. * @returns the current input manager
  114946. */
  114947. addMouseWheel(): FollowCameraInputsManager;
  114948. /**
  114949. * Add pointers input support to the input manager.
  114950. * @returns the current input manager
  114951. */
  114952. addPointers(): FollowCameraInputsManager;
  114953. /**
  114954. * Add orientation input support to the input manager.
  114955. * @returns the current input manager
  114956. */
  114957. addVRDeviceOrientation(): FollowCameraInputsManager;
  114958. }
  114959. }
  114960. declare module BABYLON {
  114961. /**
  114962. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114963. * an arc rotate version arcFollowCamera are available.
  114964. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114965. */
  114966. export class FollowCamera extends TargetCamera {
  114967. /**
  114968. * Distance the follow camera should follow an object at
  114969. */
  114970. radius: number;
  114971. /**
  114972. * Minimum allowed distance of the camera to the axis of rotation
  114973. * (The camera can not get closer).
  114974. * This can help limiting how the Camera is able to move in the scene.
  114975. */
  114976. lowerRadiusLimit: Nullable<number>;
  114977. /**
  114978. * Maximum allowed distance of the camera to the axis of rotation
  114979. * (The camera can not get further).
  114980. * This can help limiting how the Camera is able to move in the scene.
  114981. */
  114982. upperRadiusLimit: Nullable<number>;
  114983. /**
  114984. * Define a rotation offset between the camera and the object it follows
  114985. */
  114986. rotationOffset: number;
  114987. /**
  114988. * Minimum allowed angle to camera position relative to target object.
  114989. * This can help limiting how the Camera is able to move in the scene.
  114990. */
  114991. lowerRotationOffsetLimit: Nullable<number>;
  114992. /**
  114993. * Maximum allowed angle to camera position relative to target object.
  114994. * This can help limiting how the Camera is able to move in the scene.
  114995. */
  114996. upperRotationOffsetLimit: Nullable<number>;
  114997. /**
  114998. * Define a height offset between the camera and the object it follows.
  114999. * It can help following an object from the top (like a car chaing a plane)
  115000. */
  115001. heightOffset: number;
  115002. /**
  115003. * Minimum allowed height of camera position relative to target object.
  115004. * This can help limiting how the Camera is able to move in the scene.
  115005. */
  115006. lowerHeightOffsetLimit: Nullable<number>;
  115007. /**
  115008. * Maximum allowed height of camera position relative to target object.
  115009. * This can help limiting how the Camera is able to move in the scene.
  115010. */
  115011. upperHeightOffsetLimit: Nullable<number>;
  115012. /**
  115013. * Define how fast the camera can accelerate to follow it s target.
  115014. */
  115015. cameraAcceleration: number;
  115016. /**
  115017. * Define the speed limit of the camera following an object.
  115018. */
  115019. maxCameraSpeed: number;
  115020. /**
  115021. * Define the target of the camera.
  115022. */
  115023. lockedTarget: Nullable<AbstractMesh>;
  115024. /**
  115025. * Defines the input associated with the camera.
  115026. */
  115027. inputs: FollowCameraInputsManager;
  115028. /**
  115029. * Instantiates the follow camera.
  115030. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115031. * @param name Define the name of the camera in the scene
  115032. * @param position Define the position of the camera
  115033. * @param scene Define the scene the camera belong to
  115034. * @param lockedTarget Define the target of the camera
  115035. */
  115036. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115037. private _follow;
  115038. /**
  115039. * Attached controls to the current camera.
  115040. * @param element Defines the element the controls should be listened from
  115041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115042. */
  115043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115044. /**
  115045. * Detach the current controls from the camera.
  115046. * The camera will stop reacting to inputs.
  115047. * @param element Defines the element to stop listening the inputs from
  115048. */
  115049. detachControl(element: HTMLElement): void;
  115050. /** @hidden */
  115051. _checkInputs(): void;
  115052. private _checkLimits;
  115053. /**
  115054. * Gets the camera class name.
  115055. * @returns the class name
  115056. */
  115057. getClassName(): string;
  115058. }
  115059. /**
  115060. * Arc Rotate version of the follow camera.
  115061. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115062. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115063. */
  115064. export class ArcFollowCamera extends TargetCamera {
  115065. /** The longitudinal angle of the camera */
  115066. alpha: number;
  115067. /** The latitudinal angle of the camera */
  115068. beta: number;
  115069. /** The radius of the camera from its target */
  115070. radius: number;
  115071. /** Define the camera target (the messh it should follow) */
  115072. target: Nullable<AbstractMesh>;
  115073. private _cartesianCoordinates;
  115074. /**
  115075. * Instantiates a new ArcFollowCamera
  115076. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115077. * @param name Define the name of the camera
  115078. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115079. * @param beta Define the rotation angle of the camera around the elevation axis
  115080. * @param radius Define the radius of the camera from its target point
  115081. * @param target Define the target of the camera
  115082. * @param scene Define the scene the camera belongs to
  115083. */
  115084. constructor(name: string,
  115085. /** The longitudinal angle of the camera */
  115086. alpha: number,
  115087. /** The latitudinal angle of the camera */
  115088. beta: number,
  115089. /** The radius of the camera from its target */
  115090. radius: number,
  115091. /** Define the camera target (the messh it should follow) */
  115092. target: Nullable<AbstractMesh>, scene: Scene);
  115093. private _follow;
  115094. /** @hidden */
  115095. _checkInputs(): void;
  115096. /**
  115097. * Returns the class name of the object.
  115098. * It is mostly used internally for serialization purposes.
  115099. */
  115100. getClassName(): string;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Manage the keyboard inputs to control the movement of a follow camera.
  115106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115107. */
  115108. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115109. /**
  115110. * Defines the camera the input is attached to.
  115111. */
  115112. camera: FollowCamera;
  115113. /**
  115114. * Defines the list of key codes associated with the up action (increase heightOffset)
  115115. */
  115116. keysHeightOffsetIncr: number[];
  115117. /**
  115118. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115119. */
  115120. keysHeightOffsetDecr: number[];
  115121. /**
  115122. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115123. */
  115124. keysHeightOffsetModifierAlt: boolean;
  115125. /**
  115126. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115127. */
  115128. keysHeightOffsetModifierCtrl: boolean;
  115129. /**
  115130. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115131. */
  115132. keysHeightOffsetModifierShift: boolean;
  115133. /**
  115134. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115135. */
  115136. keysRotationOffsetIncr: number[];
  115137. /**
  115138. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115139. */
  115140. keysRotationOffsetDecr: number[];
  115141. /**
  115142. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115143. */
  115144. keysRotationOffsetModifierAlt: boolean;
  115145. /**
  115146. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115147. */
  115148. keysRotationOffsetModifierCtrl: boolean;
  115149. /**
  115150. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115151. */
  115152. keysRotationOffsetModifierShift: boolean;
  115153. /**
  115154. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115155. */
  115156. keysRadiusIncr: number[];
  115157. /**
  115158. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115159. */
  115160. keysRadiusDecr: number[];
  115161. /**
  115162. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115163. */
  115164. keysRadiusModifierAlt: boolean;
  115165. /**
  115166. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115167. */
  115168. keysRadiusModifierCtrl: boolean;
  115169. /**
  115170. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115171. */
  115172. keysRadiusModifierShift: boolean;
  115173. /**
  115174. * Defines the rate of change of heightOffset.
  115175. */
  115176. heightSensibility: number;
  115177. /**
  115178. * Defines the rate of change of rotationOffset.
  115179. */
  115180. rotationSensibility: number;
  115181. /**
  115182. * Defines the rate of change of radius.
  115183. */
  115184. radiusSensibility: number;
  115185. private _keys;
  115186. private _ctrlPressed;
  115187. private _altPressed;
  115188. private _shiftPressed;
  115189. private _onCanvasBlurObserver;
  115190. private _onKeyboardObserver;
  115191. private _engine;
  115192. private _scene;
  115193. /**
  115194. * Attach the input controls to a specific dom element to get the input from.
  115195. * @param element Defines the element the controls should be listened from
  115196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115197. */
  115198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115199. /**
  115200. * Detach the current controls from the specified dom element.
  115201. * @param element Defines the element to stop listening the inputs from
  115202. */
  115203. detachControl(element: Nullable<HTMLElement>): void;
  115204. /**
  115205. * Update the current camera state depending on the inputs that have been used this frame.
  115206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115207. */
  115208. checkInputs(): void;
  115209. /**
  115210. * Gets the class name of the current input.
  115211. * @returns the class name
  115212. */
  115213. getClassName(): string;
  115214. /**
  115215. * Get the friendly name associated with the input class.
  115216. * @returns the input friendly name
  115217. */
  115218. getSimpleName(): string;
  115219. /**
  115220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115221. * allow modification of the heightOffset value.
  115222. */
  115223. private _modifierHeightOffset;
  115224. /**
  115225. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115226. * allow modification of the rotationOffset value.
  115227. */
  115228. private _modifierRotationOffset;
  115229. /**
  115230. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115231. * allow modification of the radius value.
  115232. */
  115233. private _modifierRadius;
  115234. }
  115235. }
  115236. declare module BABYLON {
  115237. interface FreeCameraInputsManager {
  115238. /**
  115239. * @hidden
  115240. */
  115241. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115242. /**
  115243. * Add orientation input support to the input manager.
  115244. * @returns the current input manager
  115245. */
  115246. addDeviceOrientation(): FreeCameraInputsManager;
  115247. }
  115248. /**
  115249. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115250. * Screen rotation is taken into account.
  115251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115252. */
  115253. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115254. private _camera;
  115255. private _screenOrientationAngle;
  115256. private _constantTranform;
  115257. private _screenQuaternion;
  115258. private _alpha;
  115259. private _beta;
  115260. private _gamma;
  115261. /**
  115262. * Can be used to detect if a device orientation sensor is available on a device
  115263. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115264. * @returns a promise that will resolve on orientation change
  115265. */
  115266. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115267. /**
  115268. * @hidden
  115269. */
  115270. _onDeviceOrientationChangedObservable: Observable<void>;
  115271. /**
  115272. * Instantiates a new input
  115273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115274. */
  115275. constructor();
  115276. /**
  115277. * Define the camera controlled by the input.
  115278. */
  115279. get camera(): FreeCamera;
  115280. set camera(camera: FreeCamera);
  115281. /**
  115282. * Attach the input controls to a specific dom element to get the input from.
  115283. * @param element Defines the element the controls should be listened from
  115284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115285. */
  115286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115287. private _orientationChanged;
  115288. private _deviceOrientation;
  115289. /**
  115290. * Detach the current controls from the specified dom element.
  115291. * @param element Defines the element to stop listening the inputs from
  115292. */
  115293. detachControl(element: Nullable<HTMLElement>): void;
  115294. /**
  115295. * Update the current camera state depending on the inputs that have been used this frame.
  115296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115297. */
  115298. checkInputs(): void;
  115299. /**
  115300. * Gets the class name of the current intput.
  115301. * @returns the class name
  115302. */
  115303. getClassName(): string;
  115304. /**
  115305. * Get the friendly name associated with the input class.
  115306. * @returns the input friendly name
  115307. */
  115308. getSimpleName(): string;
  115309. }
  115310. }
  115311. declare module BABYLON {
  115312. /**
  115313. * Manage the gamepad inputs to control a free camera.
  115314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115315. */
  115316. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115317. /**
  115318. * Define the camera the input is attached to.
  115319. */
  115320. camera: FreeCamera;
  115321. /**
  115322. * Define the Gamepad controlling the input
  115323. */
  115324. gamepad: Nullable<Gamepad>;
  115325. /**
  115326. * Defines the gamepad rotation sensiblity.
  115327. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115328. */
  115329. gamepadAngularSensibility: number;
  115330. /**
  115331. * Defines the gamepad move sensiblity.
  115332. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115333. */
  115334. gamepadMoveSensibility: number;
  115335. private _yAxisScale;
  115336. /**
  115337. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115338. */
  115339. get invertYAxis(): boolean;
  115340. set invertYAxis(value: boolean);
  115341. private _onGamepadConnectedObserver;
  115342. private _onGamepadDisconnectedObserver;
  115343. private _cameraTransform;
  115344. private _deltaTransform;
  115345. private _vector3;
  115346. private _vector2;
  115347. /**
  115348. * Attach the input controls to a specific dom element to get the input from.
  115349. * @param element Defines the element the controls should be listened from
  115350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115351. */
  115352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115353. /**
  115354. * Detach the current controls from the specified dom element.
  115355. * @param element Defines the element to stop listening the inputs from
  115356. */
  115357. detachControl(element: Nullable<HTMLElement>): void;
  115358. /**
  115359. * Update the current camera state depending on the inputs that have been used this frame.
  115360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115361. */
  115362. checkInputs(): void;
  115363. /**
  115364. * Gets the class name of the current intput.
  115365. * @returns the class name
  115366. */
  115367. getClassName(): string;
  115368. /**
  115369. * Get the friendly name associated with the input class.
  115370. * @returns the input friendly name
  115371. */
  115372. getSimpleName(): string;
  115373. }
  115374. }
  115375. declare module BABYLON {
  115376. /**
  115377. * Defines the potential axis of a Joystick
  115378. */
  115379. export enum JoystickAxis {
  115380. /** X axis */
  115381. X = 0,
  115382. /** Y axis */
  115383. Y = 1,
  115384. /** Z axis */
  115385. Z = 2
  115386. }
  115387. /**
  115388. * Class used to define virtual joystick (used in touch mode)
  115389. */
  115390. export class VirtualJoystick {
  115391. /**
  115392. * Gets or sets a boolean indicating that left and right values must be inverted
  115393. */
  115394. reverseLeftRight: boolean;
  115395. /**
  115396. * Gets or sets a boolean indicating that up and down values must be inverted
  115397. */
  115398. reverseUpDown: boolean;
  115399. /**
  115400. * Gets the offset value for the position (ie. the change of the position value)
  115401. */
  115402. deltaPosition: Vector3;
  115403. /**
  115404. * Gets a boolean indicating if the virtual joystick was pressed
  115405. */
  115406. pressed: boolean;
  115407. /**
  115408. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115409. */
  115410. static Canvas: Nullable<HTMLCanvasElement>;
  115411. private static _globalJoystickIndex;
  115412. private static vjCanvasContext;
  115413. private static vjCanvasWidth;
  115414. private static vjCanvasHeight;
  115415. private static halfWidth;
  115416. private _action;
  115417. private _axisTargetedByLeftAndRight;
  115418. private _axisTargetedByUpAndDown;
  115419. private _joystickSensibility;
  115420. private _inversedSensibility;
  115421. private _joystickPointerID;
  115422. private _joystickColor;
  115423. private _joystickPointerPos;
  115424. private _joystickPreviousPointerPos;
  115425. private _joystickPointerStartPos;
  115426. private _deltaJoystickVector;
  115427. private _leftJoystick;
  115428. private _touches;
  115429. private _onPointerDownHandlerRef;
  115430. private _onPointerMoveHandlerRef;
  115431. private _onPointerUpHandlerRef;
  115432. private _onResize;
  115433. /**
  115434. * Creates a new virtual joystick
  115435. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115436. */
  115437. constructor(leftJoystick?: boolean);
  115438. /**
  115439. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115440. * @param newJoystickSensibility defines the new sensibility
  115441. */
  115442. setJoystickSensibility(newJoystickSensibility: number): void;
  115443. private _onPointerDown;
  115444. private _onPointerMove;
  115445. private _onPointerUp;
  115446. /**
  115447. * Change the color of the virtual joystick
  115448. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115449. */
  115450. setJoystickColor(newColor: string): void;
  115451. /**
  115452. * Defines a callback to call when the joystick is touched
  115453. * @param action defines the callback
  115454. */
  115455. setActionOnTouch(action: () => any): void;
  115456. /**
  115457. * Defines which axis you'd like to control for left & right
  115458. * @param axis defines the axis to use
  115459. */
  115460. setAxisForLeftRight(axis: JoystickAxis): void;
  115461. /**
  115462. * Defines which axis you'd like to control for up & down
  115463. * @param axis defines the axis to use
  115464. */
  115465. setAxisForUpDown(axis: JoystickAxis): void;
  115466. private _drawVirtualJoystick;
  115467. /**
  115468. * Release internal HTML canvas
  115469. */
  115470. releaseCanvas(): void;
  115471. }
  115472. }
  115473. declare module BABYLON {
  115474. interface FreeCameraInputsManager {
  115475. /**
  115476. * Add virtual joystick input support to the input manager.
  115477. * @returns the current input manager
  115478. */
  115479. addVirtualJoystick(): FreeCameraInputsManager;
  115480. }
  115481. /**
  115482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115484. */
  115485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115486. /**
  115487. * Defines the camera the input is attached to.
  115488. */
  115489. camera: FreeCamera;
  115490. private _leftjoystick;
  115491. private _rightjoystick;
  115492. /**
  115493. * Gets the left stick of the virtual joystick.
  115494. * @returns The virtual Joystick
  115495. */
  115496. getLeftJoystick(): VirtualJoystick;
  115497. /**
  115498. * Gets the right stick of the virtual joystick.
  115499. * @returns The virtual Joystick
  115500. */
  115501. getRightJoystick(): VirtualJoystick;
  115502. /**
  115503. * Update the current camera state depending on the inputs that have been used this frame.
  115504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115505. */
  115506. checkInputs(): void;
  115507. /**
  115508. * Attach the input controls to a specific dom element to get the input from.
  115509. * @param element Defines the element the controls should be listened from
  115510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115511. */
  115512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115513. /**
  115514. * Detach the current controls from the specified dom element.
  115515. * @param element Defines the element to stop listening the inputs from
  115516. */
  115517. detachControl(element: Nullable<HTMLElement>): void;
  115518. /**
  115519. * Gets the class name of the current intput.
  115520. * @returns the class name
  115521. */
  115522. getClassName(): string;
  115523. /**
  115524. * Get the friendly name associated with the input class.
  115525. * @returns the input friendly name
  115526. */
  115527. getSimpleName(): string;
  115528. }
  115529. }
  115530. declare module BABYLON {
  115531. /**
  115532. * This represents a FPS type of camera controlled by touch.
  115533. * This is like a universal camera minus the Gamepad controls.
  115534. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115535. */
  115536. export class TouchCamera extends FreeCamera {
  115537. /**
  115538. * Defines the touch sensibility for rotation.
  115539. * The higher the faster.
  115540. */
  115541. get touchAngularSensibility(): number;
  115542. set touchAngularSensibility(value: number);
  115543. /**
  115544. * Defines the touch sensibility for move.
  115545. * The higher the faster.
  115546. */
  115547. get touchMoveSensibility(): number;
  115548. set touchMoveSensibility(value: number);
  115549. /**
  115550. * Instantiates a new touch camera.
  115551. * This represents a FPS type of camera controlled by touch.
  115552. * This is like a universal camera minus the Gamepad controls.
  115553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115554. * @param name Define the name of the camera in the scene
  115555. * @param position Define the start position of the camera in the scene
  115556. * @param scene Define the scene the camera belongs to
  115557. */
  115558. constructor(name: string, position: Vector3, scene: Scene);
  115559. /**
  115560. * Gets the current object class name.
  115561. * @return the class name
  115562. */
  115563. getClassName(): string;
  115564. /** @hidden */
  115565. _setupInputs(): void;
  115566. }
  115567. }
  115568. declare module BABYLON {
  115569. /**
  115570. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115571. * being tilted forward or back and left or right.
  115572. */
  115573. export class DeviceOrientationCamera extends FreeCamera {
  115574. private _initialQuaternion;
  115575. private _quaternionCache;
  115576. private _tmpDragQuaternion;
  115577. private _disablePointerInputWhenUsingDeviceOrientation;
  115578. /**
  115579. * Creates a new device orientation camera
  115580. * @param name The name of the camera
  115581. * @param position The start position camera
  115582. * @param scene The scene the camera belongs to
  115583. */
  115584. constructor(name: string, position: Vector3, scene: Scene);
  115585. /**
  115586. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115587. */
  115588. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115589. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115590. private _dragFactor;
  115591. /**
  115592. * Enabled turning on the y axis when the orientation sensor is active
  115593. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115594. */
  115595. enableHorizontalDragging(dragFactor?: number): void;
  115596. /**
  115597. * Gets the current instance class name ("DeviceOrientationCamera").
  115598. * This helps avoiding instanceof at run time.
  115599. * @returns the class name
  115600. */
  115601. getClassName(): string;
  115602. /**
  115603. * @hidden
  115604. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115605. */
  115606. _checkInputs(): void;
  115607. /**
  115608. * Reset the camera to its default orientation on the specified axis only.
  115609. * @param axis The axis to reset
  115610. */
  115611. resetToCurrentRotation(axis?: Axis): void;
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * Defines supported buttons for XBox360 compatible gamepads
  115617. */
  115618. export enum Xbox360Button {
  115619. /** A */
  115620. A = 0,
  115621. /** B */
  115622. B = 1,
  115623. /** X */
  115624. X = 2,
  115625. /** Y */
  115626. Y = 3,
  115627. /** Left button */
  115628. LB = 4,
  115629. /** Right button */
  115630. RB = 5,
  115631. /** Back */
  115632. Back = 8,
  115633. /** Start */
  115634. Start = 9,
  115635. /** Left stick */
  115636. LeftStick = 10,
  115637. /** Right stick */
  115638. RightStick = 11
  115639. }
  115640. /** Defines values for XBox360 DPad */
  115641. export enum Xbox360Dpad {
  115642. /** Up */
  115643. Up = 12,
  115644. /** Down */
  115645. Down = 13,
  115646. /** Left */
  115647. Left = 14,
  115648. /** Right */
  115649. Right = 15
  115650. }
  115651. /**
  115652. * Defines a XBox360 gamepad
  115653. */
  115654. export class Xbox360Pad extends Gamepad {
  115655. private _leftTrigger;
  115656. private _rightTrigger;
  115657. private _onlefttriggerchanged;
  115658. private _onrighttriggerchanged;
  115659. private _onbuttondown;
  115660. private _onbuttonup;
  115661. private _ondpaddown;
  115662. private _ondpadup;
  115663. /** Observable raised when a button is pressed */
  115664. onButtonDownObservable: Observable<Xbox360Button>;
  115665. /** Observable raised when a button is released */
  115666. onButtonUpObservable: Observable<Xbox360Button>;
  115667. /** Observable raised when a pad is pressed */
  115668. onPadDownObservable: Observable<Xbox360Dpad>;
  115669. /** Observable raised when a pad is released */
  115670. onPadUpObservable: Observable<Xbox360Dpad>;
  115671. private _buttonA;
  115672. private _buttonB;
  115673. private _buttonX;
  115674. private _buttonY;
  115675. private _buttonBack;
  115676. private _buttonStart;
  115677. private _buttonLB;
  115678. private _buttonRB;
  115679. private _buttonLeftStick;
  115680. private _buttonRightStick;
  115681. private _dPadUp;
  115682. private _dPadDown;
  115683. private _dPadLeft;
  115684. private _dPadRight;
  115685. private _isXboxOnePad;
  115686. /**
  115687. * Creates a new XBox360 gamepad object
  115688. * @param id defines the id of this gamepad
  115689. * @param index defines its index
  115690. * @param gamepad defines the internal HTML gamepad object
  115691. * @param xboxOne defines if it is a XBox One gamepad
  115692. */
  115693. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115694. /**
  115695. * Defines the callback to call when left trigger is pressed
  115696. * @param callback defines the callback to use
  115697. */
  115698. onlefttriggerchanged(callback: (value: number) => void): void;
  115699. /**
  115700. * Defines the callback to call when right trigger is pressed
  115701. * @param callback defines the callback to use
  115702. */
  115703. onrighttriggerchanged(callback: (value: number) => void): void;
  115704. /**
  115705. * Gets the left trigger value
  115706. */
  115707. get leftTrigger(): number;
  115708. /**
  115709. * Sets the left trigger value
  115710. */
  115711. set leftTrigger(newValue: number);
  115712. /**
  115713. * Gets the right trigger value
  115714. */
  115715. get rightTrigger(): number;
  115716. /**
  115717. * Sets the right trigger value
  115718. */
  115719. set rightTrigger(newValue: number);
  115720. /**
  115721. * Defines the callback to call when a button is pressed
  115722. * @param callback defines the callback to use
  115723. */
  115724. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115725. /**
  115726. * Defines the callback to call when a button is released
  115727. * @param callback defines the callback to use
  115728. */
  115729. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115730. /**
  115731. * Defines the callback to call when a pad is pressed
  115732. * @param callback defines the callback to use
  115733. */
  115734. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115735. /**
  115736. * Defines the callback to call when a pad is released
  115737. * @param callback defines the callback to use
  115738. */
  115739. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115740. private _setButtonValue;
  115741. private _setDPadValue;
  115742. /**
  115743. * Gets the value of the `A` button
  115744. */
  115745. get buttonA(): number;
  115746. /**
  115747. * Sets the value of the `A` button
  115748. */
  115749. set buttonA(value: number);
  115750. /**
  115751. * Gets the value of the `B` button
  115752. */
  115753. get buttonB(): number;
  115754. /**
  115755. * Sets the value of the `B` button
  115756. */
  115757. set buttonB(value: number);
  115758. /**
  115759. * Gets the value of the `X` button
  115760. */
  115761. get buttonX(): number;
  115762. /**
  115763. * Sets the value of the `X` button
  115764. */
  115765. set buttonX(value: number);
  115766. /**
  115767. * Gets the value of the `Y` button
  115768. */
  115769. get buttonY(): number;
  115770. /**
  115771. * Sets the value of the `Y` button
  115772. */
  115773. set buttonY(value: number);
  115774. /**
  115775. * Gets the value of the `Start` button
  115776. */
  115777. get buttonStart(): number;
  115778. /**
  115779. * Sets the value of the `Start` button
  115780. */
  115781. set buttonStart(value: number);
  115782. /**
  115783. * Gets the value of the `Back` button
  115784. */
  115785. get buttonBack(): number;
  115786. /**
  115787. * Sets the value of the `Back` button
  115788. */
  115789. set buttonBack(value: number);
  115790. /**
  115791. * Gets the value of the `Left` button
  115792. */
  115793. get buttonLB(): number;
  115794. /**
  115795. * Sets the value of the `Left` button
  115796. */
  115797. set buttonLB(value: number);
  115798. /**
  115799. * Gets the value of the `Right` button
  115800. */
  115801. get buttonRB(): number;
  115802. /**
  115803. * Sets the value of the `Right` button
  115804. */
  115805. set buttonRB(value: number);
  115806. /**
  115807. * Gets the value of the Left joystick
  115808. */
  115809. get buttonLeftStick(): number;
  115810. /**
  115811. * Sets the value of the Left joystick
  115812. */
  115813. set buttonLeftStick(value: number);
  115814. /**
  115815. * Gets the value of the Right joystick
  115816. */
  115817. get buttonRightStick(): number;
  115818. /**
  115819. * Sets the value of the Right joystick
  115820. */
  115821. set buttonRightStick(value: number);
  115822. /**
  115823. * Gets the value of D-pad up
  115824. */
  115825. get dPadUp(): number;
  115826. /**
  115827. * Sets the value of D-pad up
  115828. */
  115829. set dPadUp(value: number);
  115830. /**
  115831. * Gets the value of D-pad down
  115832. */
  115833. get dPadDown(): number;
  115834. /**
  115835. * Sets the value of D-pad down
  115836. */
  115837. set dPadDown(value: number);
  115838. /**
  115839. * Gets the value of D-pad left
  115840. */
  115841. get dPadLeft(): number;
  115842. /**
  115843. * Sets the value of D-pad left
  115844. */
  115845. set dPadLeft(value: number);
  115846. /**
  115847. * Gets the value of D-pad right
  115848. */
  115849. get dPadRight(): number;
  115850. /**
  115851. * Sets the value of D-pad right
  115852. */
  115853. set dPadRight(value: number);
  115854. /**
  115855. * Force the gamepad to synchronize with device values
  115856. */
  115857. update(): void;
  115858. /**
  115859. * Disposes the gamepad
  115860. */
  115861. dispose(): void;
  115862. }
  115863. }
  115864. declare module BABYLON {
  115865. /**
  115866. * Defines supported buttons for DualShock compatible gamepads
  115867. */
  115868. export enum DualShockButton {
  115869. /** Cross */
  115870. Cross = 0,
  115871. /** Circle */
  115872. Circle = 1,
  115873. /** Square */
  115874. Square = 2,
  115875. /** Triangle */
  115876. Triangle = 3,
  115877. /** L1 */
  115878. L1 = 4,
  115879. /** R1 */
  115880. R1 = 5,
  115881. /** Share */
  115882. Share = 8,
  115883. /** Options */
  115884. Options = 9,
  115885. /** Left stick */
  115886. LeftStick = 10,
  115887. /** Right stick */
  115888. RightStick = 11
  115889. }
  115890. /** Defines values for DualShock DPad */
  115891. export enum DualShockDpad {
  115892. /** Up */
  115893. Up = 12,
  115894. /** Down */
  115895. Down = 13,
  115896. /** Left */
  115897. Left = 14,
  115898. /** Right */
  115899. Right = 15
  115900. }
  115901. /**
  115902. * Defines a DualShock gamepad
  115903. */
  115904. export class DualShockPad extends Gamepad {
  115905. private _leftTrigger;
  115906. private _rightTrigger;
  115907. private _onlefttriggerchanged;
  115908. private _onrighttriggerchanged;
  115909. private _onbuttondown;
  115910. private _onbuttonup;
  115911. private _ondpaddown;
  115912. private _ondpadup;
  115913. /** Observable raised when a button is pressed */
  115914. onButtonDownObservable: Observable<DualShockButton>;
  115915. /** Observable raised when a button is released */
  115916. onButtonUpObservable: Observable<DualShockButton>;
  115917. /** Observable raised when a pad is pressed */
  115918. onPadDownObservable: Observable<DualShockDpad>;
  115919. /** Observable raised when a pad is released */
  115920. onPadUpObservable: Observable<DualShockDpad>;
  115921. private _buttonCross;
  115922. private _buttonCircle;
  115923. private _buttonSquare;
  115924. private _buttonTriangle;
  115925. private _buttonShare;
  115926. private _buttonOptions;
  115927. private _buttonL1;
  115928. private _buttonR1;
  115929. private _buttonLeftStick;
  115930. private _buttonRightStick;
  115931. private _dPadUp;
  115932. private _dPadDown;
  115933. private _dPadLeft;
  115934. private _dPadRight;
  115935. /**
  115936. * Creates a new DualShock gamepad object
  115937. * @param id defines the id of this gamepad
  115938. * @param index defines its index
  115939. * @param gamepad defines the internal HTML gamepad object
  115940. */
  115941. constructor(id: string, index: number, gamepad: any);
  115942. /**
  115943. * Defines the callback to call when left trigger is pressed
  115944. * @param callback defines the callback to use
  115945. */
  115946. onlefttriggerchanged(callback: (value: number) => void): void;
  115947. /**
  115948. * Defines the callback to call when right trigger is pressed
  115949. * @param callback defines the callback to use
  115950. */
  115951. onrighttriggerchanged(callback: (value: number) => void): void;
  115952. /**
  115953. * Gets the left trigger value
  115954. */
  115955. get leftTrigger(): number;
  115956. /**
  115957. * Sets the left trigger value
  115958. */
  115959. set leftTrigger(newValue: number);
  115960. /**
  115961. * Gets the right trigger value
  115962. */
  115963. get rightTrigger(): number;
  115964. /**
  115965. * Sets the right trigger value
  115966. */
  115967. set rightTrigger(newValue: number);
  115968. /**
  115969. * Defines the callback to call when a button is pressed
  115970. * @param callback defines the callback to use
  115971. */
  115972. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115973. /**
  115974. * Defines the callback to call when a button is released
  115975. * @param callback defines the callback to use
  115976. */
  115977. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115978. /**
  115979. * Defines the callback to call when a pad is pressed
  115980. * @param callback defines the callback to use
  115981. */
  115982. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115983. /**
  115984. * Defines the callback to call when a pad is released
  115985. * @param callback defines the callback to use
  115986. */
  115987. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115988. private _setButtonValue;
  115989. private _setDPadValue;
  115990. /**
  115991. * Gets the value of the `Cross` button
  115992. */
  115993. get buttonCross(): number;
  115994. /**
  115995. * Sets the value of the `Cross` button
  115996. */
  115997. set buttonCross(value: number);
  115998. /**
  115999. * Gets the value of the `Circle` button
  116000. */
  116001. get buttonCircle(): number;
  116002. /**
  116003. * Sets the value of the `Circle` button
  116004. */
  116005. set buttonCircle(value: number);
  116006. /**
  116007. * Gets the value of the `Square` button
  116008. */
  116009. get buttonSquare(): number;
  116010. /**
  116011. * Sets the value of the `Square` button
  116012. */
  116013. set buttonSquare(value: number);
  116014. /**
  116015. * Gets the value of the `Triangle` button
  116016. */
  116017. get buttonTriangle(): number;
  116018. /**
  116019. * Sets the value of the `Triangle` button
  116020. */
  116021. set buttonTriangle(value: number);
  116022. /**
  116023. * Gets the value of the `Options` button
  116024. */
  116025. get buttonOptions(): number;
  116026. /**
  116027. * Sets the value of the `Options` button
  116028. */
  116029. set buttonOptions(value: number);
  116030. /**
  116031. * Gets the value of the `Share` button
  116032. */
  116033. get buttonShare(): number;
  116034. /**
  116035. * Sets the value of the `Share` button
  116036. */
  116037. set buttonShare(value: number);
  116038. /**
  116039. * Gets the value of the `L1` button
  116040. */
  116041. get buttonL1(): number;
  116042. /**
  116043. * Sets the value of the `L1` button
  116044. */
  116045. set buttonL1(value: number);
  116046. /**
  116047. * Gets the value of the `R1` button
  116048. */
  116049. get buttonR1(): number;
  116050. /**
  116051. * Sets the value of the `R1` button
  116052. */
  116053. set buttonR1(value: number);
  116054. /**
  116055. * Gets the value of the Left joystick
  116056. */
  116057. get buttonLeftStick(): number;
  116058. /**
  116059. * Sets the value of the Left joystick
  116060. */
  116061. set buttonLeftStick(value: number);
  116062. /**
  116063. * Gets the value of the Right joystick
  116064. */
  116065. get buttonRightStick(): number;
  116066. /**
  116067. * Sets the value of the Right joystick
  116068. */
  116069. set buttonRightStick(value: number);
  116070. /**
  116071. * Gets the value of D-pad up
  116072. */
  116073. get dPadUp(): number;
  116074. /**
  116075. * Sets the value of D-pad up
  116076. */
  116077. set dPadUp(value: number);
  116078. /**
  116079. * Gets the value of D-pad down
  116080. */
  116081. get dPadDown(): number;
  116082. /**
  116083. * Sets the value of D-pad down
  116084. */
  116085. set dPadDown(value: number);
  116086. /**
  116087. * Gets the value of D-pad left
  116088. */
  116089. get dPadLeft(): number;
  116090. /**
  116091. * Sets the value of D-pad left
  116092. */
  116093. set dPadLeft(value: number);
  116094. /**
  116095. * Gets the value of D-pad right
  116096. */
  116097. get dPadRight(): number;
  116098. /**
  116099. * Sets the value of D-pad right
  116100. */
  116101. set dPadRight(value: number);
  116102. /**
  116103. * Force the gamepad to synchronize with device values
  116104. */
  116105. update(): void;
  116106. /**
  116107. * Disposes the gamepad
  116108. */
  116109. dispose(): void;
  116110. }
  116111. }
  116112. declare module BABYLON {
  116113. /**
  116114. * Manager for handling gamepads
  116115. */
  116116. export class GamepadManager {
  116117. private _scene?;
  116118. private _babylonGamepads;
  116119. private _oneGamepadConnected;
  116120. /** @hidden */
  116121. _isMonitoring: boolean;
  116122. private _gamepadEventSupported;
  116123. private _gamepadSupport?;
  116124. /**
  116125. * observable to be triggered when the gamepad controller has been connected
  116126. */
  116127. onGamepadConnectedObservable: Observable<Gamepad>;
  116128. /**
  116129. * observable to be triggered when the gamepad controller has been disconnected
  116130. */
  116131. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116132. private _onGamepadConnectedEvent;
  116133. private _onGamepadDisconnectedEvent;
  116134. /**
  116135. * Initializes the gamepad manager
  116136. * @param _scene BabylonJS scene
  116137. */
  116138. constructor(_scene?: Scene | undefined);
  116139. /**
  116140. * The gamepads in the game pad manager
  116141. */
  116142. get gamepads(): Gamepad[];
  116143. /**
  116144. * Get the gamepad controllers based on type
  116145. * @param type The type of gamepad controller
  116146. * @returns Nullable gamepad
  116147. */
  116148. getGamepadByType(type?: number): Nullable<Gamepad>;
  116149. /**
  116150. * Disposes the gamepad manager
  116151. */
  116152. dispose(): void;
  116153. private _addNewGamepad;
  116154. private _startMonitoringGamepads;
  116155. private _stopMonitoringGamepads;
  116156. /** @hidden */
  116157. _checkGamepadsStatus(): void;
  116158. private _updateGamepadObjects;
  116159. }
  116160. }
  116161. declare module BABYLON {
  116162. interface Scene {
  116163. /** @hidden */
  116164. _gamepadManager: Nullable<GamepadManager>;
  116165. /**
  116166. * Gets the gamepad manager associated with the scene
  116167. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116168. */
  116169. gamepadManager: GamepadManager;
  116170. }
  116171. /**
  116172. * Interface representing a free camera inputs manager
  116173. */
  116174. interface FreeCameraInputsManager {
  116175. /**
  116176. * Adds gamepad input support to the FreeCameraInputsManager.
  116177. * @returns the FreeCameraInputsManager
  116178. */
  116179. addGamepad(): FreeCameraInputsManager;
  116180. }
  116181. /**
  116182. * Interface representing an arc rotate camera inputs manager
  116183. */
  116184. interface ArcRotateCameraInputsManager {
  116185. /**
  116186. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116187. * @returns the camera inputs manager
  116188. */
  116189. addGamepad(): ArcRotateCameraInputsManager;
  116190. }
  116191. /**
  116192. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116193. */
  116194. export class GamepadSystemSceneComponent implements ISceneComponent {
  116195. /**
  116196. * The component name helpfull to identify the component in the list of scene components.
  116197. */
  116198. readonly name: string;
  116199. /**
  116200. * The scene the component belongs to.
  116201. */
  116202. scene: Scene;
  116203. /**
  116204. * Creates a new instance of the component for the given scene
  116205. * @param scene Defines the scene to register the component in
  116206. */
  116207. constructor(scene: Scene);
  116208. /**
  116209. * Registers the component in a given scene
  116210. */
  116211. register(): void;
  116212. /**
  116213. * Rebuilds the elements related to this component in case of
  116214. * context lost for instance.
  116215. */
  116216. rebuild(): void;
  116217. /**
  116218. * Disposes the component and the associated ressources
  116219. */
  116220. dispose(): void;
  116221. private _beforeCameraUpdate;
  116222. }
  116223. }
  116224. declare module BABYLON {
  116225. /**
  116226. * 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,
  116227. * which still works and will still be found in many Playgrounds.
  116228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116229. */
  116230. export class UniversalCamera extends TouchCamera {
  116231. /**
  116232. * Defines the gamepad rotation sensiblity.
  116233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116234. */
  116235. get gamepadAngularSensibility(): number;
  116236. set gamepadAngularSensibility(value: number);
  116237. /**
  116238. * Defines the gamepad move sensiblity.
  116239. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116240. */
  116241. get gamepadMoveSensibility(): number;
  116242. set gamepadMoveSensibility(value: number);
  116243. /**
  116244. * 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,
  116245. * which still works and will still be found in many Playgrounds.
  116246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116247. * @param name Define the name of the camera in the scene
  116248. * @param position Define the start position of the camera in the scene
  116249. * @param scene Define the scene the camera belongs to
  116250. */
  116251. constructor(name: string, position: Vector3, scene: Scene);
  116252. /**
  116253. * Gets the current object class name.
  116254. * @return the class name
  116255. */
  116256. getClassName(): string;
  116257. }
  116258. }
  116259. declare module BABYLON {
  116260. /**
  116261. * This represents a FPS type of camera. This is only here for back compat purpose.
  116262. * Please use the UniversalCamera instead as both are identical.
  116263. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116264. */
  116265. export class GamepadCamera extends UniversalCamera {
  116266. /**
  116267. * Instantiates a new Gamepad Camera
  116268. * This represents a FPS type of camera. This is only here for back compat purpose.
  116269. * Please use the UniversalCamera instead as both are identical.
  116270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116271. * @param name Define the name of the camera in the scene
  116272. * @param position Define the start position of the camera in the scene
  116273. * @param scene Define the scene the camera belongs to
  116274. */
  116275. constructor(name: string, position: Vector3, scene: Scene);
  116276. /**
  116277. * Gets the current object class name.
  116278. * @return the class name
  116279. */
  116280. getClassName(): string;
  116281. }
  116282. }
  116283. declare module BABYLON {
  116284. /** @hidden */
  116285. export var passPixelShader: {
  116286. name: string;
  116287. shader: string;
  116288. };
  116289. }
  116290. declare module BABYLON {
  116291. /** @hidden */
  116292. export var passCubePixelShader: {
  116293. name: string;
  116294. shader: string;
  116295. };
  116296. }
  116297. declare module BABYLON {
  116298. /**
  116299. * PassPostProcess which produces an output the same as it's input
  116300. */
  116301. export class PassPostProcess extends PostProcess {
  116302. /**
  116303. * Creates the PassPostProcess
  116304. * @param name The name of the effect.
  116305. * @param options The required width/height ratio to downsize to before computing the render pass.
  116306. * @param camera The camera to apply the render pass to.
  116307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116308. * @param engine The engine which the post process will be applied. (default: current engine)
  116309. * @param reusable If the post process can be reused on the same frame. (default: false)
  116310. * @param textureType The type of texture to be used when performing the post processing.
  116311. * @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)
  116312. */
  116313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116314. }
  116315. /**
  116316. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116317. */
  116318. export class PassCubePostProcess extends PostProcess {
  116319. private _face;
  116320. /**
  116321. * Gets or sets the cube face to display.
  116322. * * 0 is +X
  116323. * * 1 is -X
  116324. * * 2 is +Y
  116325. * * 3 is -Y
  116326. * * 4 is +Z
  116327. * * 5 is -Z
  116328. */
  116329. get face(): number;
  116330. set face(value: number);
  116331. /**
  116332. * Creates the PassCubePostProcess
  116333. * @param name The name of the effect.
  116334. * @param options The required width/height ratio to downsize to before computing the render pass.
  116335. * @param camera The camera to apply the render pass to.
  116336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116337. * @param engine The engine which the post process will be applied. (default: current engine)
  116338. * @param reusable If the post process can be reused on the same frame. (default: false)
  116339. * @param textureType The type of texture to be used when performing the post processing.
  116340. * @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)
  116341. */
  116342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116343. }
  116344. }
  116345. declare module BABYLON {
  116346. /** @hidden */
  116347. export var anaglyphPixelShader: {
  116348. name: string;
  116349. shader: string;
  116350. };
  116351. }
  116352. declare module BABYLON {
  116353. /**
  116354. * Postprocess used to generate anaglyphic rendering
  116355. */
  116356. export class AnaglyphPostProcess extends PostProcess {
  116357. private _passedProcess;
  116358. /**
  116359. * Creates a new AnaglyphPostProcess
  116360. * @param name defines postprocess name
  116361. * @param options defines creation options or target ratio scale
  116362. * @param rigCameras defines cameras using this postprocess
  116363. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116364. * @param engine defines hosting engine
  116365. * @param reusable defines if the postprocess will be reused multiple times per frame
  116366. */
  116367. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116368. }
  116369. }
  116370. declare module BABYLON {
  116371. /**
  116372. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116373. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116374. */
  116375. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116376. /**
  116377. * Creates a new AnaglyphArcRotateCamera
  116378. * @param name defines camera name
  116379. * @param alpha defines alpha angle (in radians)
  116380. * @param beta defines beta angle (in radians)
  116381. * @param radius defines radius
  116382. * @param target defines camera target
  116383. * @param interaxialDistance defines distance between each color axis
  116384. * @param scene defines the hosting scene
  116385. */
  116386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116387. /**
  116388. * Gets camera class name
  116389. * @returns AnaglyphArcRotateCamera
  116390. */
  116391. getClassName(): string;
  116392. }
  116393. }
  116394. declare module BABYLON {
  116395. /**
  116396. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116397. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116398. */
  116399. export class AnaglyphFreeCamera extends FreeCamera {
  116400. /**
  116401. * Creates a new AnaglyphFreeCamera
  116402. * @param name defines camera name
  116403. * @param position defines initial position
  116404. * @param interaxialDistance defines distance between each color axis
  116405. * @param scene defines the hosting scene
  116406. */
  116407. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116408. /**
  116409. * Gets camera class name
  116410. * @returns AnaglyphFreeCamera
  116411. */
  116412. getClassName(): string;
  116413. }
  116414. }
  116415. declare module BABYLON {
  116416. /**
  116417. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116418. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116419. */
  116420. export class AnaglyphGamepadCamera extends GamepadCamera {
  116421. /**
  116422. * Creates a new AnaglyphGamepadCamera
  116423. * @param name defines camera name
  116424. * @param position defines initial position
  116425. * @param interaxialDistance defines distance between each color axis
  116426. * @param scene defines the hosting scene
  116427. */
  116428. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116429. /**
  116430. * Gets camera class name
  116431. * @returns AnaglyphGamepadCamera
  116432. */
  116433. getClassName(): string;
  116434. }
  116435. }
  116436. declare module BABYLON {
  116437. /**
  116438. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116440. */
  116441. export class AnaglyphUniversalCamera extends UniversalCamera {
  116442. /**
  116443. * Creates a new AnaglyphUniversalCamera
  116444. * @param name defines camera name
  116445. * @param position defines initial position
  116446. * @param interaxialDistance defines distance between each color axis
  116447. * @param scene defines the hosting scene
  116448. */
  116449. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116450. /**
  116451. * Gets camera class name
  116452. * @returns AnaglyphUniversalCamera
  116453. */
  116454. getClassName(): string;
  116455. }
  116456. }
  116457. declare module BABYLON {
  116458. /** @hidden */
  116459. export var stereoscopicInterlacePixelShader: {
  116460. name: string;
  116461. shader: string;
  116462. };
  116463. }
  116464. declare module BABYLON {
  116465. /**
  116466. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116467. */
  116468. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116469. private _stepSize;
  116470. private _passedProcess;
  116471. /**
  116472. * Initializes a StereoscopicInterlacePostProcessI
  116473. * @param name The name of the effect.
  116474. * @param rigCameras The rig cameras to be appled to the post process
  116475. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116476. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116478. * @param engine The engine which the post process will be applied. (default: current engine)
  116479. * @param reusable If the post process can be reused on the same frame. (default: false)
  116480. */
  116481. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116482. }
  116483. /**
  116484. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116485. */
  116486. export class StereoscopicInterlacePostProcess extends PostProcess {
  116487. private _stepSize;
  116488. private _passedProcess;
  116489. /**
  116490. * Initializes a StereoscopicInterlacePostProcess
  116491. * @param name The name of the effect.
  116492. * @param rigCameras The rig cameras to be appled to the post process
  116493. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116495. * @param engine The engine which the post process will be applied. (default: current engine)
  116496. * @param reusable If the post process can be reused on the same frame. (default: false)
  116497. */
  116498. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116499. }
  116500. }
  116501. declare module BABYLON {
  116502. /**
  116503. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116504. * @see http://doc.babylonjs.com/features/cameras
  116505. */
  116506. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116507. /**
  116508. * Creates a new StereoscopicArcRotateCamera
  116509. * @param name defines camera name
  116510. * @param alpha defines alpha angle (in radians)
  116511. * @param beta defines beta angle (in radians)
  116512. * @param radius defines radius
  116513. * @param target defines camera target
  116514. * @param interaxialDistance defines distance between each color axis
  116515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116516. * @param scene defines the hosting scene
  116517. */
  116518. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116519. /**
  116520. * Gets camera class name
  116521. * @returns StereoscopicArcRotateCamera
  116522. */
  116523. getClassName(): string;
  116524. }
  116525. }
  116526. declare module BABYLON {
  116527. /**
  116528. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116529. * @see http://doc.babylonjs.com/features/cameras
  116530. */
  116531. export class StereoscopicFreeCamera extends FreeCamera {
  116532. /**
  116533. * Creates a new StereoscopicFreeCamera
  116534. * @param name defines camera name
  116535. * @param position defines initial position
  116536. * @param interaxialDistance defines distance between each color axis
  116537. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116538. * @param scene defines the hosting scene
  116539. */
  116540. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116541. /**
  116542. * Gets camera class name
  116543. * @returns StereoscopicFreeCamera
  116544. */
  116545. getClassName(): string;
  116546. }
  116547. }
  116548. declare module BABYLON {
  116549. /**
  116550. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116551. * @see http://doc.babylonjs.com/features/cameras
  116552. */
  116553. export class StereoscopicGamepadCamera extends GamepadCamera {
  116554. /**
  116555. * Creates a new StereoscopicGamepadCamera
  116556. * @param name defines camera name
  116557. * @param position defines initial position
  116558. * @param interaxialDistance defines distance between each color axis
  116559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116560. * @param scene defines the hosting scene
  116561. */
  116562. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116563. /**
  116564. * Gets camera class name
  116565. * @returns StereoscopicGamepadCamera
  116566. */
  116567. getClassName(): string;
  116568. }
  116569. }
  116570. declare module BABYLON {
  116571. /**
  116572. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116573. * @see http://doc.babylonjs.com/features/cameras
  116574. */
  116575. export class StereoscopicUniversalCamera extends UniversalCamera {
  116576. /**
  116577. * Creates a new StereoscopicUniversalCamera
  116578. * @param name defines camera name
  116579. * @param position defines initial position
  116580. * @param interaxialDistance defines distance between each color axis
  116581. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116582. * @param scene defines the hosting scene
  116583. */
  116584. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116585. /**
  116586. * Gets camera class name
  116587. * @returns StereoscopicUniversalCamera
  116588. */
  116589. getClassName(): string;
  116590. }
  116591. }
  116592. declare module BABYLON {
  116593. /**
  116594. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116595. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116596. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116597. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116598. */
  116599. export class VirtualJoysticksCamera extends FreeCamera {
  116600. /**
  116601. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116602. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116603. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116604. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116605. * @param name Define the name of the camera in the scene
  116606. * @param position Define the start position of the camera in the scene
  116607. * @param scene Define the scene the camera belongs to
  116608. */
  116609. constructor(name: string, position: Vector3, scene: Scene);
  116610. /**
  116611. * Gets the current object class name.
  116612. * @return the class name
  116613. */
  116614. getClassName(): string;
  116615. }
  116616. }
  116617. declare module BABYLON {
  116618. /**
  116619. * This represents all the required metrics to create a VR camera.
  116620. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116621. */
  116622. export class VRCameraMetrics {
  116623. /**
  116624. * Define the horizontal resolution off the screen.
  116625. */
  116626. hResolution: number;
  116627. /**
  116628. * Define the vertical resolution off the screen.
  116629. */
  116630. vResolution: number;
  116631. /**
  116632. * Define the horizontal screen size.
  116633. */
  116634. hScreenSize: number;
  116635. /**
  116636. * Define the vertical screen size.
  116637. */
  116638. vScreenSize: number;
  116639. /**
  116640. * Define the vertical screen center position.
  116641. */
  116642. vScreenCenter: number;
  116643. /**
  116644. * Define the distance of the eyes to the screen.
  116645. */
  116646. eyeToScreenDistance: number;
  116647. /**
  116648. * Define the distance between both lenses
  116649. */
  116650. lensSeparationDistance: number;
  116651. /**
  116652. * Define the distance between both viewer's eyes.
  116653. */
  116654. interpupillaryDistance: number;
  116655. /**
  116656. * Define the distortion factor of the VR postprocess.
  116657. * Please, touch with care.
  116658. */
  116659. distortionK: number[];
  116660. /**
  116661. * Define the chromatic aberration correction factors for the VR post process.
  116662. */
  116663. chromaAbCorrection: number[];
  116664. /**
  116665. * Define the scale factor of the post process.
  116666. * The smaller the better but the slower.
  116667. */
  116668. postProcessScaleFactor: number;
  116669. /**
  116670. * Define an offset for the lens center.
  116671. */
  116672. lensCenterOffset: number;
  116673. /**
  116674. * Define if the current vr camera should compensate the distortion of the lense or not.
  116675. */
  116676. compensateDistortion: boolean;
  116677. /**
  116678. * Defines if multiview should be enabled when rendering (Default: false)
  116679. */
  116680. multiviewEnabled: boolean;
  116681. /**
  116682. * Gets the rendering aspect ratio based on the provided resolutions.
  116683. */
  116684. get aspectRatio(): number;
  116685. /**
  116686. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116687. */
  116688. get aspectRatioFov(): number;
  116689. /**
  116690. * @hidden
  116691. */
  116692. get leftHMatrix(): Matrix;
  116693. /**
  116694. * @hidden
  116695. */
  116696. get rightHMatrix(): Matrix;
  116697. /**
  116698. * @hidden
  116699. */
  116700. get leftPreViewMatrix(): Matrix;
  116701. /**
  116702. * @hidden
  116703. */
  116704. get rightPreViewMatrix(): Matrix;
  116705. /**
  116706. * Get the default VRMetrics based on the most generic setup.
  116707. * @returns the default vr metrics
  116708. */
  116709. static GetDefault(): VRCameraMetrics;
  116710. }
  116711. }
  116712. declare module BABYLON {
  116713. /** @hidden */
  116714. export var vrDistortionCorrectionPixelShader: {
  116715. name: string;
  116716. shader: string;
  116717. };
  116718. }
  116719. declare module BABYLON {
  116720. /**
  116721. * VRDistortionCorrectionPostProcess used for mobile VR
  116722. */
  116723. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116724. private _isRightEye;
  116725. private _distortionFactors;
  116726. private _postProcessScaleFactor;
  116727. private _lensCenterOffset;
  116728. private _scaleIn;
  116729. private _scaleFactor;
  116730. private _lensCenter;
  116731. /**
  116732. * Initializes the VRDistortionCorrectionPostProcess
  116733. * @param name The name of the effect.
  116734. * @param camera The camera to apply the render pass to.
  116735. * @param isRightEye If this is for the right eye distortion
  116736. * @param vrMetrics All the required metrics for the VR camera
  116737. */
  116738. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116739. }
  116740. }
  116741. declare module BABYLON {
  116742. /**
  116743. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116744. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116745. */
  116746. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116747. /**
  116748. * Creates a new VRDeviceOrientationArcRotateCamera
  116749. * @param name defines camera name
  116750. * @param alpha defines the camera rotation along the logitudinal axis
  116751. * @param beta defines the camera rotation along the latitudinal axis
  116752. * @param radius defines the camera distance from its target
  116753. * @param target defines the camera target
  116754. * @param scene defines the scene the camera belongs to
  116755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116757. */
  116758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116759. /**
  116760. * Gets camera class name
  116761. * @returns VRDeviceOrientationArcRotateCamera
  116762. */
  116763. getClassName(): string;
  116764. }
  116765. }
  116766. declare module BABYLON {
  116767. /**
  116768. * Camera used to simulate VR rendering (based on FreeCamera)
  116769. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116770. */
  116771. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116772. /**
  116773. * Creates a new VRDeviceOrientationFreeCamera
  116774. * @param name defines camera name
  116775. * @param position defines the start position of the camera
  116776. * @param scene defines the scene the camera belongs to
  116777. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116778. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116779. */
  116780. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116781. /**
  116782. * Gets camera class name
  116783. * @returns VRDeviceOrientationFreeCamera
  116784. */
  116785. getClassName(): string;
  116786. }
  116787. }
  116788. declare module BABYLON {
  116789. /**
  116790. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116791. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116792. */
  116793. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116794. /**
  116795. * Creates a new VRDeviceOrientationGamepadCamera
  116796. * @param name defines camera name
  116797. * @param position defines the start position of the camera
  116798. * @param scene defines the scene the camera belongs to
  116799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116801. */
  116802. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116803. /**
  116804. * Gets camera class name
  116805. * @returns VRDeviceOrientationGamepadCamera
  116806. */
  116807. getClassName(): string;
  116808. }
  116809. }
  116810. declare module BABYLON {
  116811. /** @hidden */
  116812. export var imageProcessingPixelShader: {
  116813. name: string;
  116814. shader: string;
  116815. };
  116816. }
  116817. declare module BABYLON {
  116818. /**
  116819. * ImageProcessingPostProcess
  116820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116821. */
  116822. export class ImageProcessingPostProcess extends PostProcess {
  116823. /**
  116824. * Default configuration related to image processing available in the PBR Material.
  116825. */
  116826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116827. /**
  116828. * Gets the image processing configuration used either in this material.
  116829. */
  116830. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116831. /**
  116832. * Sets the Default image processing configuration used either in the this material.
  116833. *
  116834. * If sets to null, the scene one is in use.
  116835. */
  116836. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116837. /**
  116838. * Keep track of the image processing observer to allow dispose and replace.
  116839. */
  116840. private _imageProcessingObserver;
  116841. /**
  116842. * Attaches a new image processing configuration to the PBR Material.
  116843. * @param configuration
  116844. */
  116845. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116846. /**
  116847. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116848. */
  116849. get colorCurves(): Nullable<ColorCurves>;
  116850. /**
  116851. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116852. */
  116853. set colorCurves(value: Nullable<ColorCurves>);
  116854. /**
  116855. * Gets wether the color curves effect is enabled.
  116856. */
  116857. get colorCurvesEnabled(): boolean;
  116858. /**
  116859. * Sets wether the color curves effect is enabled.
  116860. */
  116861. set colorCurvesEnabled(value: boolean);
  116862. /**
  116863. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116864. */
  116865. get colorGradingTexture(): Nullable<BaseTexture>;
  116866. /**
  116867. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116868. */
  116869. set colorGradingTexture(value: Nullable<BaseTexture>);
  116870. /**
  116871. * Gets wether the color grading effect is enabled.
  116872. */
  116873. get colorGradingEnabled(): boolean;
  116874. /**
  116875. * Gets wether the color grading effect is enabled.
  116876. */
  116877. set colorGradingEnabled(value: boolean);
  116878. /**
  116879. * Gets exposure used in the effect.
  116880. */
  116881. get exposure(): number;
  116882. /**
  116883. * Sets exposure used in the effect.
  116884. */
  116885. set exposure(value: number);
  116886. /**
  116887. * Gets wether tonemapping is enabled or not.
  116888. */
  116889. get toneMappingEnabled(): boolean;
  116890. /**
  116891. * Sets wether tonemapping is enabled or not
  116892. */
  116893. set toneMappingEnabled(value: boolean);
  116894. /**
  116895. * Gets the type of tone mapping effect.
  116896. */
  116897. get toneMappingType(): number;
  116898. /**
  116899. * Sets the type of tone mapping effect.
  116900. */
  116901. set toneMappingType(value: number);
  116902. /**
  116903. * Gets contrast used in the effect.
  116904. */
  116905. get contrast(): number;
  116906. /**
  116907. * Sets contrast used in the effect.
  116908. */
  116909. set contrast(value: number);
  116910. /**
  116911. * Gets Vignette stretch size.
  116912. */
  116913. get vignetteStretch(): number;
  116914. /**
  116915. * Sets Vignette stretch size.
  116916. */
  116917. set vignetteStretch(value: number);
  116918. /**
  116919. * Gets Vignette centre X Offset.
  116920. */
  116921. get vignetteCentreX(): number;
  116922. /**
  116923. * Sets Vignette centre X Offset.
  116924. */
  116925. set vignetteCentreX(value: number);
  116926. /**
  116927. * Gets Vignette centre Y Offset.
  116928. */
  116929. get vignetteCentreY(): number;
  116930. /**
  116931. * Sets Vignette centre Y Offset.
  116932. */
  116933. set vignetteCentreY(value: number);
  116934. /**
  116935. * Gets Vignette weight or intensity of the vignette effect.
  116936. */
  116937. get vignetteWeight(): number;
  116938. /**
  116939. * Sets Vignette weight or intensity of the vignette effect.
  116940. */
  116941. set vignetteWeight(value: number);
  116942. /**
  116943. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116944. * if vignetteEnabled is set to true.
  116945. */
  116946. get vignetteColor(): Color4;
  116947. /**
  116948. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116949. * if vignetteEnabled is set to true.
  116950. */
  116951. set vignetteColor(value: Color4);
  116952. /**
  116953. * Gets Camera field of view used by the Vignette effect.
  116954. */
  116955. get vignetteCameraFov(): number;
  116956. /**
  116957. * Sets Camera field of view used by the Vignette effect.
  116958. */
  116959. set vignetteCameraFov(value: number);
  116960. /**
  116961. * Gets the vignette blend mode allowing different kind of effect.
  116962. */
  116963. get vignetteBlendMode(): number;
  116964. /**
  116965. * Sets the vignette blend mode allowing different kind of effect.
  116966. */
  116967. set vignetteBlendMode(value: number);
  116968. /**
  116969. * Gets wether the vignette effect is enabled.
  116970. */
  116971. get vignetteEnabled(): boolean;
  116972. /**
  116973. * Sets wether the vignette effect is enabled.
  116974. */
  116975. set vignetteEnabled(value: boolean);
  116976. private _fromLinearSpace;
  116977. /**
  116978. * Gets wether the input of the processing is in Gamma or Linear Space.
  116979. */
  116980. get fromLinearSpace(): boolean;
  116981. /**
  116982. * Sets wether the input of the processing is in Gamma or Linear Space.
  116983. */
  116984. set fromLinearSpace(value: boolean);
  116985. /**
  116986. * Defines cache preventing GC.
  116987. */
  116988. private _defines;
  116989. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116990. /**
  116991. * "ImageProcessingPostProcess"
  116992. * @returns "ImageProcessingPostProcess"
  116993. */
  116994. getClassName(): string;
  116995. protected _updateParameters(): void;
  116996. dispose(camera?: Camera): void;
  116997. }
  116998. }
  116999. declare module BABYLON {
  117000. /**
  117001. * Class containing static functions to help procedurally build meshes
  117002. */
  117003. export class GroundBuilder {
  117004. /**
  117005. * Creates a ground mesh
  117006. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117007. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117009. * @param name defines the name of the mesh
  117010. * @param options defines the options used to create the mesh
  117011. * @param scene defines the hosting scene
  117012. * @returns the ground mesh
  117013. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117014. */
  117015. static CreateGround(name: string, options: {
  117016. width?: number;
  117017. height?: number;
  117018. subdivisions?: number;
  117019. subdivisionsX?: number;
  117020. subdivisionsY?: number;
  117021. updatable?: boolean;
  117022. }, scene: any): Mesh;
  117023. /**
  117024. * Creates a tiled ground mesh
  117025. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117026. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117027. * * 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
  117028. * * 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
  117029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117030. * @param name defines the name of the mesh
  117031. * @param options defines the options used to create the mesh
  117032. * @param scene defines the hosting scene
  117033. * @returns the tiled ground mesh
  117034. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117035. */
  117036. static CreateTiledGround(name: string, options: {
  117037. xmin: number;
  117038. zmin: number;
  117039. xmax: number;
  117040. zmax: number;
  117041. subdivisions?: {
  117042. w: number;
  117043. h: number;
  117044. };
  117045. precision?: {
  117046. w: number;
  117047. h: number;
  117048. };
  117049. updatable?: boolean;
  117050. }, scene?: Nullable<Scene>): Mesh;
  117051. /**
  117052. * Creates a ground mesh from a height map
  117053. * * The parameter `url` sets the URL of the height map image resource.
  117054. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117055. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117056. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117057. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117058. * * 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.
  117059. * * 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).
  117060. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117062. * @param name defines the name of the mesh
  117063. * @param url defines the url to the height map
  117064. * @param options defines the options used to create the mesh
  117065. * @param scene defines the hosting scene
  117066. * @returns the ground mesh
  117067. * @see https://doc.babylonjs.com/babylon101/height_map
  117068. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117069. */
  117070. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117071. width?: number;
  117072. height?: number;
  117073. subdivisions?: number;
  117074. minHeight?: number;
  117075. maxHeight?: number;
  117076. colorFilter?: Color3;
  117077. alphaFilter?: number;
  117078. updatable?: boolean;
  117079. onReady?: (mesh: GroundMesh) => void;
  117080. }, scene?: Nullable<Scene>): GroundMesh;
  117081. }
  117082. }
  117083. declare module BABYLON {
  117084. /**
  117085. * Class containing static functions to help procedurally build meshes
  117086. */
  117087. export class TorusBuilder {
  117088. /**
  117089. * Creates a torus mesh
  117090. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117091. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117092. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117096. * @param name defines the name of the mesh
  117097. * @param options defines the options used to create the mesh
  117098. * @param scene defines the hosting scene
  117099. * @returns the torus mesh
  117100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117101. */
  117102. static CreateTorus(name: string, options: {
  117103. diameter?: number;
  117104. thickness?: number;
  117105. tessellation?: number;
  117106. updatable?: boolean;
  117107. sideOrientation?: number;
  117108. frontUVs?: Vector4;
  117109. backUVs?: Vector4;
  117110. }, scene: any): Mesh;
  117111. }
  117112. }
  117113. declare module BABYLON {
  117114. /**
  117115. * Class containing static functions to help procedurally build meshes
  117116. */
  117117. export class CylinderBuilder {
  117118. /**
  117119. * Creates a cylinder or a cone mesh
  117120. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117121. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117122. * * 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.
  117123. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117124. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117125. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117126. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117127. * * 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).
  117128. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117129. * * 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).
  117130. * * 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
  117131. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117132. * * 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
  117133. * * 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.
  117134. * * If `enclose` is false, a ring surface is one element.
  117135. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117136. * * 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
  117137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117140. * @param name defines the name of the mesh
  117141. * @param options defines the options used to create the mesh
  117142. * @param scene defines the hosting scene
  117143. * @returns the cylinder mesh
  117144. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117145. */
  117146. static CreateCylinder(name: string, options: {
  117147. height?: number;
  117148. diameterTop?: number;
  117149. diameterBottom?: number;
  117150. diameter?: number;
  117151. tessellation?: number;
  117152. subdivisions?: number;
  117153. arc?: number;
  117154. faceColors?: Color4[];
  117155. faceUV?: Vector4[];
  117156. updatable?: boolean;
  117157. hasRings?: boolean;
  117158. enclose?: boolean;
  117159. cap?: number;
  117160. sideOrientation?: number;
  117161. frontUVs?: Vector4;
  117162. backUVs?: Vector4;
  117163. }, scene: any): Mesh;
  117164. }
  117165. }
  117166. declare module BABYLON {
  117167. /**
  117168. * States of the webXR experience
  117169. */
  117170. export enum WebXRState {
  117171. /**
  117172. * Transitioning to being in XR mode
  117173. */
  117174. ENTERING_XR = 0,
  117175. /**
  117176. * Transitioning to non XR mode
  117177. */
  117178. EXITING_XR = 1,
  117179. /**
  117180. * In XR mode and presenting
  117181. */
  117182. IN_XR = 2,
  117183. /**
  117184. * Not entered XR mode
  117185. */
  117186. NOT_IN_XR = 3
  117187. }
  117188. /**
  117189. * Abstraction of the XR render target
  117190. */
  117191. export interface WebXRRenderTarget extends IDisposable {
  117192. /**
  117193. * xrpresent context of the canvas which can be used to display/mirror xr content
  117194. */
  117195. canvasContext: WebGLRenderingContext;
  117196. /**
  117197. * xr layer for the canvas
  117198. */
  117199. xrLayer: Nullable<XRWebGLLayer>;
  117200. /**
  117201. * Initializes the xr layer for the session
  117202. * @param xrSession xr session
  117203. * @returns a promise that will resolve once the XR Layer has been created
  117204. */
  117205. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117206. }
  117207. }
  117208. declare module BABYLON {
  117209. /**
  117210. * COnfiguration object for WebXR output canvas
  117211. */
  117212. export class WebXRManagedOutputCanvasOptions {
  117213. /**
  117214. * An optional canvas in case you wish to create it yourself and provide it here.
  117215. * If not provided, a new canvas will be created
  117216. */
  117217. canvasElement?: HTMLCanvasElement;
  117218. /**
  117219. * Options for this XR Layer output
  117220. */
  117221. canvasOptions?: XRWebGLLayerOptions;
  117222. /**
  117223. * CSS styling for a newly created canvas (if not provided)
  117224. */
  117225. newCanvasCssStyle?: string;
  117226. /**
  117227. * Get the default values of the configuration object
  117228. * @returns default values of this configuration object
  117229. */
  117230. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117231. }
  117232. /**
  117233. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117234. */
  117235. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117236. private _options;
  117237. private _canvas;
  117238. private _engine;
  117239. /**
  117240. * Rendering context of the canvas which can be used to display/mirror xr content
  117241. */
  117242. canvasContext: WebGLRenderingContext;
  117243. /**
  117244. * xr layer for the canvas
  117245. */
  117246. xrLayer: Nullable<XRWebGLLayer>;
  117247. /**
  117248. * Initializes the canvas to be added/removed upon entering/exiting xr
  117249. * @param _xrSessionManager The XR Session manager
  117250. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117251. */
  117252. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117253. /**
  117254. * Disposes of the object
  117255. */
  117256. dispose(): void;
  117257. /**
  117258. * Initializes the xr layer for the session
  117259. * @param xrSession xr session
  117260. * @returns a promise that will resolve once the XR Layer has been created
  117261. */
  117262. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117263. private _addCanvas;
  117264. private _removeCanvas;
  117265. private _setManagedOutputCanvas;
  117266. }
  117267. }
  117268. declare module BABYLON {
  117269. /**
  117270. * Manages an XRSession to work with Babylon's engine
  117271. * @see https://doc.babylonjs.com/how_to/webxr
  117272. */
  117273. export class WebXRSessionManager implements IDisposable {
  117274. /** The scene which the session should be created for */
  117275. scene: Scene;
  117276. private _referenceSpace;
  117277. private _rttProvider;
  117278. private _sessionEnded;
  117279. private _xrNavigator;
  117280. private baseLayer;
  117281. /**
  117282. * The base reference space from which the session started. good if you want to reset your
  117283. * reference space
  117284. */
  117285. baseReferenceSpace: XRReferenceSpace;
  117286. /**
  117287. * Current XR frame
  117288. */
  117289. currentFrame: Nullable<XRFrame>;
  117290. /** WebXR timestamp updated every frame */
  117291. currentTimestamp: number;
  117292. /**
  117293. * Used just in case of a failure to initialize an immersive session.
  117294. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117295. */
  117296. defaultHeightCompensation: number;
  117297. /**
  117298. * Fires every time a new xrFrame arrives which can be used to update the camera
  117299. */
  117300. onXRFrameObservable: Observable<XRFrame>;
  117301. /**
  117302. * Fires when the reference space changed
  117303. */
  117304. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117305. /**
  117306. * Fires when the xr session is ended either by the device or manually done
  117307. */
  117308. onXRSessionEnded: Observable<any>;
  117309. /**
  117310. * Fires when the xr session is ended either by the device or manually done
  117311. */
  117312. onXRSessionInit: Observable<XRSession>;
  117313. /**
  117314. * Underlying xr session
  117315. */
  117316. session: XRSession;
  117317. /**
  117318. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117319. * or get the offset the player is currently at.
  117320. */
  117321. viewerReferenceSpace: XRReferenceSpace;
  117322. /**
  117323. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117324. * @param scene The scene which the session should be created for
  117325. */
  117326. constructor(
  117327. /** The scene which the session should be created for */
  117328. scene: Scene);
  117329. /**
  117330. * The current reference space used in this session. This reference space can constantly change!
  117331. * It is mainly used to offset the camera's position.
  117332. */
  117333. get referenceSpace(): XRReferenceSpace;
  117334. /**
  117335. * Set a new reference space and triggers the observable
  117336. */
  117337. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117338. /**
  117339. * Disposes of the session manager
  117340. */
  117341. dispose(): void;
  117342. /**
  117343. * Stops the xrSession and restores the render loop
  117344. * @returns Promise which resolves after it exits XR
  117345. */
  117346. exitXRAsync(): Promise<void>;
  117347. /**
  117348. * Gets the correct render target texture to be rendered this frame for this eye
  117349. * @param eye the eye for which to get the render target
  117350. * @returns the render target for the specified eye
  117351. */
  117352. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117353. /**
  117354. * Creates a WebXRRenderTarget object for the XR session
  117355. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117356. * @param options optional options to provide when creating a new render target
  117357. * @returns a WebXR render target to which the session can render
  117358. */
  117359. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117360. /**
  117361. * Initializes the manager
  117362. * After initialization enterXR can be called to start an XR session
  117363. * @returns Promise which resolves after it is initialized
  117364. */
  117365. initializeAsync(): Promise<void>;
  117366. /**
  117367. * Initializes an xr session
  117368. * @param xrSessionMode mode to initialize
  117369. * @param xrSessionInit defines optional and required values to pass to the session builder
  117370. * @returns a promise which will resolve once the session has been initialized
  117371. */
  117372. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117373. /**
  117374. * Checks if a session would be supported for the creation options specified
  117375. * @param sessionMode session mode to check if supported eg. immersive-vr
  117376. * @returns A Promise that resolves to true if supported and false if not
  117377. */
  117378. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117379. /**
  117380. * Resets the reference space to the one started the session
  117381. */
  117382. resetReferenceSpace(): void;
  117383. /**
  117384. * Starts rendering to the xr layer
  117385. */
  117386. runXRRenderLoop(): void;
  117387. /**
  117388. * Sets the reference space on the xr session
  117389. * @param referenceSpaceType space to set
  117390. * @returns a promise that will resolve once the reference space has been set
  117391. */
  117392. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117393. /**
  117394. * Updates the render state of the session
  117395. * @param state state to set
  117396. * @returns a promise that resolves once the render state has been updated
  117397. */
  117398. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117399. /**
  117400. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117401. * @param sessionMode defines the session to test
  117402. * @returns a promise with boolean as final value
  117403. */
  117404. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117405. private _createRenderTargetTexture;
  117406. }
  117407. }
  117408. declare module BABYLON {
  117409. /**
  117410. * WebXR Camera which holds the views for the xrSession
  117411. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117412. */
  117413. export class WebXRCamera extends FreeCamera {
  117414. private _xrSessionManager;
  117415. private _firstFrame;
  117416. private _referenceQuaternion;
  117417. private _referencedPosition;
  117418. private _xrInvPositionCache;
  117419. private _xrInvQuaternionCache;
  117420. /**
  117421. * Should position compensation execute on first frame.
  117422. * This is used when copying the position from a native (non XR) camera
  117423. */
  117424. compensateOnFirstFrame: boolean;
  117425. /**
  117426. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117427. * @param name the name of the camera
  117428. * @param scene the scene to add the camera to
  117429. * @param _xrSessionManager a constructed xr session manager
  117430. */
  117431. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117432. /**
  117433. * Return the user's height, unrelated to the current ground.
  117434. * This will be the y position of this camera, when ground level is 0.
  117435. */
  117436. get realWorldHeight(): number;
  117437. /** @hidden */
  117438. _updateForDualEyeDebugging(): void;
  117439. /**
  117440. * Sets this camera's transformation based on a non-vr camera
  117441. * @param otherCamera the non-vr camera to copy the transformation from
  117442. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117443. */
  117444. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117445. /**
  117446. * Gets the current instance class name ("WebXRCamera").
  117447. * @returns the class name
  117448. */
  117449. getClassName(): string;
  117450. private _updateFromXRSession;
  117451. private _updateNumberOfRigCameras;
  117452. private _updateReferenceSpace;
  117453. private _updateReferenceSpaceOffset;
  117454. }
  117455. }
  117456. declare module BABYLON {
  117457. /**
  117458. * Defining the interface required for a (webxr) feature
  117459. */
  117460. export interface IWebXRFeature extends IDisposable {
  117461. /**
  117462. * Is this feature attached
  117463. */
  117464. attached: boolean;
  117465. /**
  117466. * Should auto-attach be disabled?
  117467. */
  117468. disableAutoAttach: boolean;
  117469. /**
  117470. * Attach the feature to the session
  117471. * Will usually be called by the features manager
  117472. *
  117473. * @param force should attachment be forced (even when already attached)
  117474. * @returns true if successful.
  117475. */
  117476. attach(force?: boolean): boolean;
  117477. /**
  117478. * Detach the feature from the session
  117479. * Will usually be called by the features manager
  117480. *
  117481. * @returns true if successful.
  117482. */
  117483. detach(): boolean;
  117484. }
  117485. /**
  117486. * A list of the currently available features without referencing them
  117487. */
  117488. export class WebXRFeatureName {
  117489. /**
  117490. * The name of the anchor system feature
  117491. */
  117492. static ANCHOR_SYSTEM: string;
  117493. /**
  117494. * The name of the background remover feature
  117495. */
  117496. static BACKGROUND_REMOVER: string;
  117497. /**
  117498. * The name of the hit test feature
  117499. */
  117500. static HIT_TEST: string;
  117501. /**
  117502. * physics impostors for xr controllers feature
  117503. */
  117504. static PHYSICS_CONTROLLERS: string;
  117505. /**
  117506. * The name of the plane detection feature
  117507. */
  117508. static PLANE_DETECTION: string;
  117509. /**
  117510. * The name of the pointer selection feature
  117511. */
  117512. static POINTER_SELECTION: string;
  117513. /**
  117514. * The name of the teleportation feature
  117515. */
  117516. static TELEPORTATION: string;
  117517. }
  117518. /**
  117519. * Defining the constructor of a feature. Used to register the modules.
  117520. */
  117521. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117522. /**
  117523. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117524. * It is mainly used in AR sessions.
  117525. *
  117526. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117527. */
  117528. export class WebXRFeaturesManager implements IDisposable {
  117529. private _xrSessionManager;
  117530. private static readonly _AvailableFeatures;
  117531. private _features;
  117532. /**
  117533. * constructs a new features manages.
  117534. *
  117535. * @param _xrSessionManager an instance of WebXRSessionManager
  117536. */
  117537. constructor(_xrSessionManager: WebXRSessionManager);
  117538. /**
  117539. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117540. * Mainly used internally.
  117541. *
  117542. * @param featureName the name of the feature to register
  117543. * @param constructorFunction the function used to construct the module
  117544. * @param version the (babylon) version of the module
  117545. * @param stable is that a stable version of this module
  117546. */
  117547. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117548. /**
  117549. * Returns a constructor of a specific feature.
  117550. *
  117551. * @param featureName the name of the feature to construct
  117552. * @param version the version of the feature to load
  117553. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117554. * @param options optional options provided to the module.
  117555. * @returns a function that, when called, will return a new instance of this feature
  117556. */
  117557. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117558. /**
  117559. * Can be used to return the list of features currently registered
  117560. *
  117561. * @returns an Array of available features
  117562. */
  117563. static GetAvailableFeatures(): string[];
  117564. /**
  117565. * Gets the versions available for a specific feature
  117566. * @param featureName the name of the feature
  117567. * @returns an array with the available versions
  117568. */
  117569. static GetAvailableVersions(featureName: string): string[];
  117570. /**
  117571. * Return the latest unstable version of this feature
  117572. * @param featureName the name of the feature to search
  117573. * @returns the version number. if not found will return -1
  117574. */
  117575. static GetLatestVersionOfFeature(featureName: string): number;
  117576. /**
  117577. * Return the latest stable version of this feature
  117578. * @param featureName the name of the feature to search
  117579. * @returns the version number. if not found will return -1
  117580. */
  117581. static GetStableVersionOfFeature(featureName: string): number;
  117582. /**
  117583. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117584. * Can be used during a session to start a feature
  117585. * @param featureName the name of feature to attach
  117586. */
  117587. attachFeature(featureName: string): void;
  117588. /**
  117589. * Can be used inside a session or when the session ends to detach a specific feature
  117590. * @param featureName the name of the feature to detach
  117591. */
  117592. detachFeature(featureName: string): void;
  117593. /**
  117594. * Used to disable an already-enabled feature
  117595. * The feature will be disposed and will be recreated once enabled.
  117596. * @param featureName the feature to disable
  117597. * @returns true if disable was successful
  117598. */
  117599. disableFeature(featureName: string | {
  117600. Name: string;
  117601. }): boolean;
  117602. /**
  117603. * dispose this features manager
  117604. */
  117605. dispose(): void;
  117606. /**
  117607. * 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.
  117608. * 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.
  117609. *
  117610. * @param featureName the name of the feature to load or the class of the feature
  117611. * @param version optional version to load. if not provided the latest version will be enabled
  117612. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117613. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117614. * @returns a new constructed feature or throws an error if feature not found.
  117615. */
  117616. enableFeature(featureName: string | {
  117617. Name: string;
  117618. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117619. /**
  117620. * get the implementation of an enabled feature.
  117621. * @param featureName the name of the feature to load
  117622. * @returns the feature class, if found
  117623. */
  117624. getEnabledFeature(featureName: string): IWebXRFeature;
  117625. /**
  117626. * Get the list of enabled features
  117627. * @returns an array of enabled features
  117628. */
  117629. getEnabledFeatures(): string[];
  117630. }
  117631. }
  117632. declare module BABYLON {
  117633. /**
  117634. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117635. * @see https://doc.babylonjs.com/how_to/webxr
  117636. */
  117637. export class WebXRExperienceHelper implements IDisposable {
  117638. private scene;
  117639. private _nonVRCamera;
  117640. private _originalSceneAutoClear;
  117641. private _supported;
  117642. /**
  117643. * Camera used to render xr content
  117644. */
  117645. camera: WebXRCamera;
  117646. /** A features manager for this xr session */
  117647. featuresManager: WebXRFeaturesManager;
  117648. /**
  117649. * Observers registered here will be triggered after the camera's initial transformation is set
  117650. * This can be used to set a different ground level or an extra rotation.
  117651. *
  117652. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117653. * to the position set after this observable is done executing.
  117654. */
  117655. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117656. /**
  117657. * Fires when the state of the experience helper has changed
  117658. */
  117659. onStateChangedObservable: Observable<WebXRState>;
  117660. /** Session manager used to keep track of xr session */
  117661. sessionManager: WebXRSessionManager;
  117662. /**
  117663. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117664. */
  117665. state: WebXRState;
  117666. /**
  117667. * Creates a WebXRExperienceHelper
  117668. * @param scene The scene the helper should be created in
  117669. */
  117670. private constructor();
  117671. /**
  117672. * Creates the experience helper
  117673. * @param scene the scene to attach the experience helper to
  117674. * @returns a promise for the experience helper
  117675. */
  117676. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117677. /**
  117678. * Disposes of the experience helper
  117679. */
  117680. dispose(): void;
  117681. /**
  117682. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117683. * @param sessionMode options for the XR session
  117684. * @param referenceSpaceType frame of reference of the XR session
  117685. * @param renderTarget the output canvas that will be used to enter XR mode
  117686. * @returns promise that resolves after xr mode has entered
  117687. */
  117688. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117689. /**
  117690. * Exits XR mode and returns the scene to its original state
  117691. * @returns promise that resolves after xr mode has exited
  117692. */
  117693. exitXRAsync(): Promise<void>;
  117694. private _nonXRToXRCamera;
  117695. private _setState;
  117696. }
  117697. }
  117698. declare module BABYLON {
  117699. /**
  117700. * X-Y values for axes in WebXR
  117701. */
  117702. export interface IWebXRMotionControllerAxesValue {
  117703. /**
  117704. * The value of the x axis
  117705. */
  117706. x: number;
  117707. /**
  117708. * The value of the y-axis
  117709. */
  117710. y: number;
  117711. }
  117712. /**
  117713. * changed / previous values for the values of this component
  117714. */
  117715. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117716. /**
  117717. * current (this frame) value
  117718. */
  117719. current: T;
  117720. /**
  117721. * previous (last change) value
  117722. */
  117723. previous: T;
  117724. }
  117725. /**
  117726. * Represents changes in the component between current frame and last values recorded
  117727. */
  117728. export interface IWebXRMotionControllerComponentChanges {
  117729. /**
  117730. * will be populated with previous and current values if axes changed
  117731. */
  117732. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117733. /**
  117734. * will be populated with previous and current values if pressed changed
  117735. */
  117736. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117737. /**
  117738. * will be populated with previous and current values if touched changed
  117739. */
  117740. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117741. /**
  117742. * will be populated with previous and current values if value changed
  117743. */
  117744. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117745. }
  117746. /**
  117747. * This class represents a single component (for example button or thumbstick) of a motion controller
  117748. */
  117749. export class WebXRControllerComponent implements IDisposable {
  117750. /**
  117751. * the id of this component
  117752. */
  117753. id: string;
  117754. /**
  117755. * the type of the component
  117756. */
  117757. type: MotionControllerComponentType;
  117758. private _buttonIndex;
  117759. private _axesIndices;
  117760. private _axes;
  117761. private _changes;
  117762. private _currentValue;
  117763. private _hasChanges;
  117764. private _pressed;
  117765. private _touched;
  117766. /**
  117767. * button component type
  117768. */
  117769. static BUTTON_TYPE: MotionControllerComponentType;
  117770. /**
  117771. * squeeze component type
  117772. */
  117773. static SQUEEZE_TYPE: MotionControllerComponentType;
  117774. /**
  117775. * Thumbstick component type
  117776. */
  117777. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117778. /**
  117779. * Touchpad component type
  117780. */
  117781. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117782. /**
  117783. * trigger component type
  117784. */
  117785. static TRIGGER_TYPE: MotionControllerComponentType;
  117786. /**
  117787. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117788. * the axes data changes
  117789. */
  117790. onAxisValueChangedObservable: Observable<{
  117791. x: number;
  117792. y: number;
  117793. }>;
  117794. /**
  117795. * Observers registered here will be triggered when the state of a button changes
  117796. * State change is either pressed / touched / value
  117797. */
  117798. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117799. /**
  117800. * Creates a new component for a motion controller.
  117801. * It is created by the motion controller itself
  117802. *
  117803. * @param id the id of this component
  117804. * @param type the type of the component
  117805. * @param _buttonIndex index in the buttons array of the gamepad
  117806. * @param _axesIndices indices of the values in the axes array of the gamepad
  117807. */
  117808. constructor(
  117809. /**
  117810. * the id of this component
  117811. */
  117812. id: string,
  117813. /**
  117814. * the type of the component
  117815. */
  117816. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117817. /**
  117818. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117819. */
  117820. get axes(): IWebXRMotionControllerAxesValue;
  117821. /**
  117822. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117823. */
  117824. get changes(): IWebXRMotionControllerComponentChanges;
  117825. /**
  117826. * Return whether or not the component changed the last frame
  117827. */
  117828. get hasChanges(): boolean;
  117829. /**
  117830. * is the button currently pressed
  117831. */
  117832. get pressed(): boolean;
  117833. /**
  117834. * is the button currently touched
  117835. */
  117836. get touched(): boolean;
  117837. /**
  117838. * Get the current value of this component
  117839. */
  117840. get value(): number;
  117841. /**
  117842. * Dispose this component
  117843. */
  117844. dispose(): void;
  117845. /**
  117846. * Are there axes correlating to this component
  117847. * @return true is axes data is available
  117848. */
  117849. isAxes(): boolean;
  117850. /**
  117851. * Is this component a button (hence - pressable)
  117852. * @returns true if can be pressed
  117853. */
  117854. isButton(): boolean;
  117855. /**
  117856. * update this component using the gamepad object it is in. Called on every frame
  117857. * @param nativeController the native gamepad controller object
  117858. */
  117859. update(nativeController: IMinimalMotionControllerObject): void;
  117860. }
  117861. }
  117862. declare module BABYLON {
  117863. /**
  117864. * Class used to represent data loading progression
  117865. */
  117866. export class SceneLoaderProgressEvent {
  117867. /** defines if data length to load can be evaluated */
  117868. readonly lengthComputable: boolean;
  117869. /** defines the loaded data length */
  117870. readonly loaded: number;
  117871. /** defines the data length to load */
  117872. readonly total: number;
  117873. /**
  117874. * Create a new progress event
  117875. * @param lengthComputable defines if data length to load can be evaluated
  117876. * @param loaded defines the loaded data length
  117877. * @param total defines the data length to load
  117878. */
  117879. constructor(
  117880. /** defines if data length to load can be evaluated */
  117881. lengthComputable: boolean,
  117882. /** defines the loaded data length */
  117883. loaded: number,
  117884. /** defines the data length to load */
  117885. total: number);
  117886. /**
  117887. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117888. * @param event defines the source event
  117889. * @returns a new SceneLoaderProgressEvent
  117890. */
  117891. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117892. }
  117893. /**
  117894. * Interface used by SceneLoader plugins to define supported file extensions
  117895. */
  117896. export interface ISceneLoaderPluginExtensions {
  117897. /**
  117898. * Defines the list of supported extensions
  117899. */
  117900. [extension: string]: {
  117901. isBinary: boolean;
  117902. };
  117903. }
  117904. /**
  117905. * Interface used by SceneLoader plugin factory
  117906. */
  117907. export interface ISceneLoaderPluginFactory {
  117908. /**
  117909. * Defines the name of the factory
  117910. */
  117911. name: string;
  117912. /**
  117913. * Function called to create a new plugin
  117914. * @return the new plugin
  117915. */
  117916. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117917. /**
  117918. * The callback that returns true if the data can be directly loaded.
  117919. * @param data string containing the file data
  117920. * @returns if the data can be loaded directly
  117921. */
  117922. canDirectLoad?(data: string): boolean;
  117923. }
  117924. /**
  117925. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117926. */
  117927. export interface ISceneLoaderPluginBase {
  117928. /**
  117929. * The friendly name of this plugin.
  117930. */
  117931. name: string;
  117932. /**
  117933. * The file extensions supported by this plugin.
  117934. */
  117935. extensions: string | ISceneLoaderPluginExtensions;
  117936. /**
  117937. * The callback called when loading from a url.
  117938. * @param scene scene loading this url
  117939. * @param url url to load
  117940. * @param onSuccess callback called when the file successfully loads
  117941. * @param onProgress callback called while file is loading (if the server supports this mode)
  117942. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117943. * @param onError callback called when the file fails to load
  117944. * @returns a file request object
  117945. */
  117946. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117947. /**
  117948. * The callback called when loading from a file object.
  117949. * @param scene scene loading this file
  117950. * @param file defines the file to load
  117951. * @param onSuccess defines the callback to call when data is loaded
  117952. * @param onProgress defines the callback to call during loading process
  117953. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117954. * @param onError defines the callback to call when an error occurs
  117955. * @returns a file request object
  117956. */
  117957. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117958. /**
  117959. * The callback that returns true if the data can be directly loaded.
  117960. * @param data string containing the file data
  117961. * @returns if the data can be loaded directly
  117962. */
  117963. canDirectLoad?(data: string): boolean;
  117964. /**
  117965. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117966. * @param scene scene loading this data
  117967. * @param data string containing the data
  117968. * @returns data to pass to the plugin
  117969. */
  117970. directLoad?(scene: Scene, data: string): any;
  117971. /**
  117972. * The callback that allows custom handling of the root url based on the response url.
  117973. * @param rootUrl the original root url
  117974. * @param responseURL the response url if available
  117975. * @returns the new root url
  117976. */
  117977. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117978. }
  117979. /**
  117980. * Interface used to define a SceneLoader plugin
  117981. */
  117982. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117983. /**
  117984. * Import meshes into a scene.
  117985. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117986. * @param scene The scene to import into
  117987. * @param data The data to import
  117988. * @param rootUrl The root url for scene and resources
  117989. * @param meshes The meshes array to import into
  117990. * @param particleSystems The particle systems array to import into
  117991. * @param skeletons The skeletons array to import into
  117992. * @param onError The callback when import fails
  117993. * @returns True if successful or false otherwise
  117994. */
  117995. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117996. /**
  117997. * Load into a scene.
  117998. * @param scene The scene to load into
  117999. * @param data The data to import
  118000. * @param rootUrl The root url for scene and resources
  118001. * @param onError The callback when import fails
  118002. * @returns True if successful or false otherwise
  118003. */
  118004. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  118005. /**
  118006. * Load into an asset container.
  118007. * @param scene The scene to load into
  118008. * @param data The data to import
  118009. * @param rootUrl The root url for scene and resources
  118010. * @param onError The callback when import fails
  118011. * @returns The loaded asset container
  118012. */
  118013. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  118014. }
  118015. /**
  118016. * Interface used to define an async SceneLoader plugin
  118017. */
  118018. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118019. /**
  118020. * Import meshes into a scene.
  118021. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118022. * @param scene The scene to import into
  118023. * @param data The data to import
  118024. * @param rootUrl The root url for scene and resources
  118025. * @param onProgress The callback when the load progresses
  118026. * @param fileName Defines the name of the file to load
  118027. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118028. */
  118029. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118030. meshes: AbstractMesh[];
  118031. particleSystems: IParticleSystem[];
  118032. skeletons: Skeleton[];
  118033. animationGroups: AnimationGroup[];
  118034. }>;
  118035. /**
  118036. * Load into a scene.
  118037. * @param scene The scene to load into
  118038. * @param data The data to import
  118039. * @param rootUrl The root url for scene and resources
  118040. * @param onProgress The callback when the load progresses
  118041. * @param fileName Defines the name of the file to load
  118042. * @returns Nothing
  118043. */
  118044. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118045. /**
  118046. * Load into an asset container.
  118047. * @param scene The scene to load into
  118048. * @param data The data to import
  118049. * @param rootUrl The root url for scene and resources
  118050. * @param onProgress The callback when the load progresses
  118051. * @param fileName Defines the name of the file to load
  118052. * @returns The loaded asset container
  118053. */
  118054. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118055. }
  118056. /**
  118057. * Mode that determines how to handle old animation groups before loading new ones.
  118058. */
  118059. export enum SceneLoaderAnimationGroupLoadingMode {
  118060. /**
  118061. * Reset all old animations to initial state then dispose them.
  118062. */
  118063. Clean = 0,
  118064. /**
  118065. * Stop all old animations.
  118066. */
  118067. Stop = 1,
  118068. /**
  118069. * Restart old animations from first frame.
  118070. */
  118071. Sync = 2,
  118072. /**
  118073. * Old animations remains untouched.
  118074. */
  118075. NoSync = 3
  118076. }
  118077. /**
  118078. * Class used to load scene from various file formats using registered plugins
  118079. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118080. */
  118081. export class SceneLoader {
  118082. /**
  118083. * No logging while loading
  118084. */
  118085. static readonly NO_LOGGING: number;
  118086. /**
  118087. * Minimal logging while loading
  118088. */
  118089. static readonly MINIMAL_LOGGING: number;
  118090. /**
  118091. * Summary logging while loading
  118092. */
  118093. static readonly SUMMARY_LOGGING: number;
  118094. /**
  118095. * Detailled logging while loading
  118096. */
  118097. static readonly DETAILED_LOGGING: number;
  118098. /**
  118099. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118100. */
  118101. static get ForceFullSceneLoadingForIncremental(): boolean;
  118102. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118103. /**
  118104. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118105. */
  118106. static get ShowLoadingScreen(): boolean;
  118107. static set ShowLoadingScreen(value: boolean);
  118108. /**
  118109. * Defines the current logging level (while loading the scene)
  118110. * @ignorenaming
  118111. */
  118112. static get loggingLevel(): number;
  118113. static set loggingLevel(value: number);
  118114. /**
  118115. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118116. */
  118117. static get CleanBoneMatrixWeights(): boolean;
  118118. static set CleanBoneMatrixWeights(value: boolean);
  118119. /**
  118120. * Event raised when a plugin is used to load a scene
  118121. */
  118122. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118123. private static _registeredPlugins;
  118124. private static _getDefaultPlugin;
  118125. private static _getPluginForExtension;
  118126. private static _getPluginForDirectLoad;
  118127. private static _getPluginForFilename;
  118128. private static _getDirectLoad;
  118129. private static _loadData;
  118130. private static _getFileInfo;
  118131. /**
  118132. * Gets a plugin that can load the given extension
  118133. * @param extension defines the extension to load
  118134. * @returns a plugin or null if none works
  118135. */
  118136. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118137. /**
  118138. * Gets a boolean indicating that the given extension can be loaded
  118139. * @param extension defines the extension to load
  118140. * @returns true if the extension is supported
  118141. */
  118142. static IsPluginForExtensionAvailable(extension: string): boolean;
  118143. /**
  118144. * Adds a new plugin to the list of registered plugins
  118145. * @param plugin defines the plugin to add
  118146. */
  118147. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118148. /**
  118149. * Import meshes into a scene
  118150. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118151. * @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)
  118152. * @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)
  118153. * @param scene the instance of BABYLON.Scene to append to
  118154. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118155. * @param onProgress a callback with a progress event for each file being loaded
  118156. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118157. * @param pluginExtension the extension used to determine the plugin
  118158. * @returns The loaded plugin
  118159. */
  118160. 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>;
  118161. /**
  118162. * Import meshes into a scene
  118163. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118164. * @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)
  118165. * @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)
  118166. * @param scene the instance of BABYLON.Scene to append to
  118167. * @param onProgress a callback with a progress event for each file being loaded
  118168. * @param pluginExtension the extension used to determine the plugin
  118169. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118170. */
  118171. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118172. meshes: AbstractMesh[];
  118173. particleSystems: IParticleSystem[];
  118174. skeletons: Skeleton[];
  118175. animationGroups: AnimationGroup[];
  118176. }>;
  118177. /**
  118178. * Load a scene
  118179. * @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)
  118180. * @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)
  118181. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118182. * @param onSuccess a callback with the scene when import succeeds
  118183. * @param onProgress a callback with a progress event for each file being loaded
  118184. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118185. * @param pluginExtension the extension used to determine the plugin
  118186. * @returns The loaded plugin
  118187. */
  118188. 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>;
  118189. /**
  118190. * Load a scene
  118191. * @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)
  118192. * @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)
  118193. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118194. * @param onProgress a callback with a progress event for each file being loaded
  118195. * @param pluginExtension the extension used to determine the plugin
  118196. * @returns The loaded scene
  118197. */
  118198. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118199. /**
  118200. * Append a scene
  118201. * @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)
  118202. * @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)
  118203. * @param scene is the instance of BABYLON.Scene to append to
  118204. * @param onSuccess a callback with the scene when import succeeds
  118205. * @param onProgress a callback with a progress event for each file being loaded
  118206. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118207. * @param pluginExtension the extension used to determine the plugin
  118208. * @returns The loaded plugin
  118209. */
  118210. 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>;
  118211. /**
  118212. * Append a scene
  118213. * @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)
  118214. * @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)
  118215. * @param scene is the instance of BABYLON.Scene to append to
  118216. * @param onProgress a callback with a progress event for each file being loaded
  118217. * @param pluginExtension the extension used to determine the plugin
  118218. * @returns The given scene
  118219. */
  118220. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118221. /**
  118222. * Load a scene into an asset container
  118223. * @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)
  118224. * @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)
  118225. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118226. * @param onSuccess a callback with the scene when import succeeds
  118227. * @param onProgress a callback with a progress event for each file being loaded
  118228. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118229. * @param pluginExtension the extension used to determine the plugin
  118230. * @returns The loaded plugin
  118231. */
  118232. 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>;
  118233. /**
  118234. * Load a scene into an asset container
  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 (default: empty string)
  118237. * @param scene is the instance of Scene to append to
  118238. * @param onProgress a callback with a progress event for each file being loaded
  118239. * @param pluginExtension the extension used to determine the plugin
  118240. * @returns The loaded asset container
  118241. */
  118242. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118243. /**
  118244. * Import animations from a file into a scene
  118245. * @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)
  118246. * @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)
  118247. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118248. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118249. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118250. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118251. * @param onSuccess a callback with the scene when import succeeds
  118252. * @param onProgress a callback with a progress event for each file being loaded
  118253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118254. */
  118255. 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;
  118256. /**
  118257. * Import animations from a file into a scene
  118258. * @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)
  118259. * @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)
  118260. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118261. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118262. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118263. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118264. * @param onSuccess a callback with the scene when import succeeds
  118265. * @param onProgress a callback with a progress event for each file being loaded
  118266. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118267. * @returns the updated scene with imported animations
  118268. */
  118269. 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>;
  118270. }
  118271. }
  118272. declare module BABYLON {
  118273. /**
  118274. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118275. */
  118276. export type MotionControllerHandness = "none" | "left" | "right";
  118277. /**
  118278. * The type of components available in motion controllers.
  118279. * This is not the name of the component.
  118280. */
  118281. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118282. /**
  118283. * The state of a controller component
  118284. */
  118285. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118286. /**
  118287. * The schema of motion controller layout.
  118288. * No object will be initialized using this interface
  118289. * This is used just to define the profile.
  118290. */
  118291. export interface IMotionControllerLayout {
  118292. /**
  118293. * Path to load the assets. Usually relative to the base path
  118294. */
  118295. assetPath: string;
  118296. /**
  118297. * Available components (unsorted)
  118298. */
  118299. components: {
  118300. /**
  118301. * A map of component Ids
  118302. */
  118303. [componentId: string]: {
  118304. /**
  118305. * The type of input the component outputs
  118306. */
  118307. type: MotionControllerComponentType;
  118308. /**
  118309. * The indices of this component in the gamepad object
  118310. */
  118311. gamepadIndices: {
  118312. /**
  118313. * Index of button
  118314. */
  118315. button?: number;
  118316. /**
  118317. * If available, index of x-axis
  118318. */
  118319. xAxis?: number;
  118320. /**
  118321. * If available, index of y-axis
  118322. */
  118323. yAxis?: number;
  118324. };
  118325. /**
  118326. * The mesh's root node name
  118327. */
  118328. rootNodeName: string;
  118329. /**
  118330. * Animation definitions for this model
  118331. */
  118332. visualResponses: {
  118333. [stateKey: string]: {
  118334. /**
  118335. * What property will be animated
  118336. */
  118337. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118338. /**
  118339. * What states influence this visual response
  118340. */
  118341. states: MotionControllerComponentStateType[];
  118342. /**
  118343. * Type of animation - movement or visibility
  118344. */
  118345. valueNodeProperty: "transform" | "visibility";
  118346. /**
  118347. * Base node name to move. Its position will be calculated according to the min and max nodes
  118348. */
  118349. valueNodeName?: string;
  118350. /**
  118351. * Minimum movement node
  118352. */
  118353. minNodeName?: string;
  118354. /**
  118355. * Max movement node
  118356. */
  118357. maxNodeName?: string;
  118358. };
  118359. };
  118360. /**
  118361. * If touch enabled, what is the name of node to display user feedback
  118362. */
  118363. touchPointNodeName?: string;
  118364. };
  118365. };
  118366. /**
  118367. * Is it xr standard mapping or not
  118368. */
  118369. gamepadMapping: "" | "xr-standard";
  118370. /**
  118371. * Base root node of this entire model
  118372. */
  118373. rootNodeName: string;
  118374. /**
  118375. * Defines the main button component id
  118376. */
  118377. selectComponentId: string;
  118378. }
  118379. /**
  118380. * A definition for the layout map in the input profile
  118381. */
  118382. export interface IMotionControllerLayoutMap {
  118383. /**
  118384. * Layouts with handness type as a key
  118385. */
  118386. [handness: string]: IMotionControllerLayout;
  118387. }
  118388. /**
  118389. * The XR Input profile schema
  118390. * Profiles can be found here:
  118391. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118392. */
  118393. export interface IMotionControllerProfile {
  118394. /**
  118395. * fallback profiles for this profileId
  118396. */
  118397. fallbackProfileIds: string[];
  118398. /**
  118399. * The layout map, with handness as key
  118400. */
  118401. layouts: IMotionControllerLayoutMap;
  118402. /**
  118403. * The id of this profile
  118404. * correlates to the profile(s) in the xrInput.profiles array
  118405. */
  118406. profileId: string;
  118407. }
  118408. /**
  118409. * A helper-interface for the 3 meshes needed for controller button animation
  118410. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118411. */
  118412. export interface IMotionControllerButtonMeshMap {
  118413. /**
  118414. * the mesh that defines the pressed value mesh position.
  118415. * This is used to find the max-position of this button
  118416. */
  118417. pressedMesh: AbstractMesh;
  118418. /**
  118419. * the mesh that defines the unpressed value mesh position.
  118420. * This is used to find the min (or initial) position of this button
  118421. */
  118422. unpressedMesh: AbstractMesh;
  118423. /**
  118424. * The mesh that will be changed when value changes
  118425. */
  118426. valueMesh: AbstractMesh;
  118427. }
  118428. /**
  118429. * A helper-interface for the 3 meshes needed for controller axis animation.
  118430. * This will be expanded when touchpad animations are fully supported
  118431. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118432. */
  118433. export interface IMotionControllerMeshMap {
  118434. /**
  118435. * the mesh that defines the maximum value mesh position.
  118436. */
  118437. maxMesh?: AbstractMesh;
  118438. /**
  118439. * the mesh that defines the minimum value mesh position.
  118440. */
  118441. minMesh?: AbstractMesh;
  118442. /**
  118443. * The mesh that will be changed when axis value changes
  118444. */
  118445. valueMesh: AbstractMesh;
  118446. }
  118447. /**
  118448. * The elements needed for change-detection of the gamepad objects in motion controllers
  118449. */
  118450. export interface IMinimalMotionControllerObject {
  118451. /**
  118452. * Available axes of this controller
  118453. */
  118454. axes: number[];
  118455. /**
  118456. * An array of available buttons
  118457. */
  118458. buttons: Array<{
  118459. /**
  118460. * Value of the button/trigger
  118461. */
  118462. value: number;
  118463. /**
  118464. * If the button/trigger is currently touched
  118465. */
  118466. touched: boolean;
  118467. /**
  118468. * If the button/trigger is currently pressed
  118469. */
  118470. pressed: boolean;
  118471. }>;
  118472. }
  118473. /**
  118474. * An Abstract Motion controller
  118475. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118476. * Each component has an observable to check for changes in value and state
  118477. */
  118478. export abstract class WebXRAbstractMotionController implements IDisposable {
  118479. protected scene: Scene;
  118480. protected layout: IMotionControllerLayout;
  118481. /**
  118482. * The gamepad object correlating to this controller
  118483. */
  118484. gamepadObject: IMinimalMotionControllerObject;
  118485. /**
  118486. * handness (left/right/none) of this controller
  118487. */
  118488. handness: MotionControllerHandness;
  118489. private _initComponent;
  118490. private _modelReady;
  118491. /**
  118492. * A map of components (WebXRControllerComponent) in this motion controller
  118493. * Components have a ComponentType and can also have both button and axis definitions
  118494. */
  118495. readonly components: {
  118496. [id: string]: WebXRControllerComponent;
  118497. };
  118498. /**
  118499. * Disable the model's animation. Can be set at any time.
  118500. */
  118501. disableAnimation: boolean;
  118502. /**
  118503. * Observers registered here will be triggered when the model of this controller is done loading
  118504. */
  118505. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118506. /**
  118507. * The profile id of this motion controller
  118508. */
  118509. abstract profileId: string;
  118510. /**
  118511. * The root mesh of the model. It is null if the model was not yet initialized
  118512. */
  118513. rootMesh: Nullable<AbstractMesh>;
  118514. /**
  118515. * constructs a new abstract motion controller
  118516. * @param scene the scene to which the model of the controller will be added
  118517. * @param layout The profile layout to load
  118518. * @param gamepadObject The gamepad object correlating to this controller
  118519. * @param handness handness (left/right/none) of this controller
  118520. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118521. */
  118522. constructor(scene: Scene, layout: IMotionControllerLayout,
  118523. /**
  118524. * The gamepad object correlating to this controller
  118525. */
  118526. gamepadObject: IMinimalMotionControllerObject,
  118527. /**
  118528. * handness (left/right/none) of this controller
  118529. */
  118530. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118531. /**
  118532. * Dispose this controller, the model mesh and all its components
  118533. */
  118534. dispose(): void;
  118535. /**
  118536. * Returns all components of specific type
  118537. * @param type the type to search for
  118538. * @return an array of components with this type
  118539. */
  118540. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118541. /**
  118542. * get a component based an its component id as defined in layout.components
  118543. * @param id the id of the component
  118544. * @returns the component correlates to the id or undefined if not found
  118545. */
  118546. getComponent(id: string): WebXRControllerComponent;
  118547. /**
  118548. * Get the list of components available in this motion controller
  118549. * @returns an array of strings correlating to available components
  118550. */
  118551. getComponentIds(): string[];
  118552. /**
  118553. * Get the first component of specific type
  118554. * @param type type of component to find
  118555. * @return a controller component or null if not found
  118556. */
  118557. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118558. /**
  118559. * Get the main (Select) component of this controller as defined in the layout
  118560. * @returns the main component of this controller
  118561. */
  118562. getMainComponent(): WebXRControllerComponent;
  118563. /**
  118564. * Loads the model correlating to this controller
  118565. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118566. * @returns A promise fulfilled with the result of the model loading
  118567. */
  118568. loadModel(): Promise<boolean>;
  118569. /**
  118570. * Update this model using the current XRFrame
  118571. * @param xrFrame the current xr frame to use and update the model
  118572. */
  118573. updateFromXRFrame(xrFrame: XRFrame): void;
  118574. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118575. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118576. /**
  118577. * Moves the axis on the controller mesh based on its current state
  118578. * @param axis the index of the axis
  118579. * @param axisValue the value of the axis which determines the meshes new position
  118580. * @hidden
  118581. */
  118582. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118583. /**
  118584. * Update the model itself with the current frame data
  118585. * @param xrFrame the frame to use for updating the model mesh
  118586. */
  118587. protected updateModel(xrFrame: XRFrame): void;
  118588. /**
  118589. * Get the filename and path for this controller's model
  118590. * @returns a map of filename and path
  118591. */
  118592. protected abstract _getFilenameAndPath(): {
  118593. filename: string;
  118594. path: string;
  118595. };
  118596. /**
  118597. * This function is called before the mesh is loaded. It checks for loading constraints.
  118598. * For example, this function can check if the GLB loader is available
  118599. * If this function returns false, the generic controller will be loaded instead
  118600. * @returns Is the client ready to load the mesh
  118601. */
  118602. protected abstract _getModelLoadingConstraints(): boolean;
  118603. /**
  118604. * This function will be called after the model was successfully loaded and can be used
  118605. * for mesh transformations before it is available for the user
  118606. * @param meshes the loaded meshes
  118607. */
  118608. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118609. /**
  118610. * Set the root mesh for this controller. Important for the WebXR controller class
  118611. * @param meshes the loaded meshes
  118612. */
  118613. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118614. /**
  118615. * A function executed each frame that updates the mesh (if needed)
  118616. * @param xrFrame the current xrFrame
  118617. */
  118618. protected abstract _updateModel(xrFrame: XRFrame): void;
  118619. private _getGenericFilenameAndPath;
  118620. private _getGenericParentMesh;
  118621. }
  118622. }
  118623. declare module BABYLON {
  118624. /**
  118625. * A generic trigger-only motion controller for WebXR
  118626. */
  118627. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118628. /**
  118629. * Static version of the profile id of this controller
  118630. */
  118631. static ProfileId: string;
  118632. profileId: string;
  118633. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118634. protected _getFilenameAndPath(): {
  118635. filename: string;
  118636. path: string;
  118637. };
  118638. protected _getModelLoadingConstraints(): boolean;
  118639. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118640. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118641. protected _updateModel(): void;
  118642. }
  118643. }
  118644. declare module BABYLON {
  118645. /**
  118646. * Class containing static functions to help procedurally build meshes
  118647. */
  118648. export class SphereBuilder {
  118649. /**
  118650. * Creates a sphere mesh
  118651. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118652. * * 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`)
  118653. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118654. * * 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
  118655. * * 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)
  118656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118659. * @param name defines the name of the mesh
  118660. * @param options defines the options used to create the mesh
  118661. * @param scene defines the hosting scene
  118662. * @returns the sphere mesh
  118663. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118664. */
  118665. static CreateSphere(name: string, options: {
  118666. segments?: number;
  118667. diameter?: number;
  118668. diameterX?: number;
  118669. diameterY?: number;
  118670. diameterZ?: number;
  118671. arc?: number;
  118672. slice?: number;
  118673. sideOrientation?: number;
  118674. frontUVs?: Vector4;
  118675. backUVs?: Vector4;
  118676. updatable?: boolean;
  118677. }, scene?: Nullable<Scene>): Mesh;
  118678. }
  118679. }
  118680. declare module BABYLON {
  118681. /**
  118682. * A profiled motion controller has its profile loaded from an online repository.
  118683. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118684. */
  118685. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118686. private _repositoryUrl;
  118687. private _buttonMeshMapping;
  118688. private _touchDots;
  118689. /**
  118690. * The profile ID of this controller. Will be populated when the controller initializes.
  118691. */
  118692. profileId: string;
  118693. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118694. dispose(): void;
  118695. protected _getFilenameAndPath(): {
  118696. filename: string;
  118697. path: string;
  118698. };
  118699. protected _getModelLoadingConstraints(): boolean;
  118700. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118701. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118702. protected _updateModel(_xrFrame: XRFrame): void;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. /**
  118707. * A construction function type to create a new controller based on an xrInput object
  118708. */
  118709. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118710. /**
  118711. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118712. *
  118713. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118714. * it should be replaced with auto-loaded controllers.
  118715. *
  118716. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118717. */
  118718. export class WebXRMotionControllerManager {
  118719. private static _AvailableControllers;
  118720. private static _Fallbacks;
  118721. private static _ProfileLoadingPromises;
  118722. private static _ProfilesList;
  118723. /**
  118724. * The base URL of the online controller repository. Can be changed at any time.
  118725. */
  118726. static BaseRepositoryUrl: string;
  118727. /**
  118728. * Which repository gets priority - local or online
  118729. */
  118730. static PrioritizeOnlineRepository: boolean;
  118731. /**
  118732. * Use the online repository, or use only locally-defined controllers
  118733. */
  118734. static UseOnlineRepository: boolean;
  118735. /**
  118736. * Clear the cache used for profile loading and reload when requested again
  118737. */
  118738. static ClearProfilesCache(): void;
  118739. /**
  118740. * Register the default fallbacks.
  118741. * This function is called automatically when this file is imported.
  118742. */
  118743. static DefaultFallbacks(): void;
  118744. /**
  118745. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118746. * @param profileId the profile to which a fallback needs to be found
  118747. * @return an array with corresponding fallback profiles
  118748. */
  118749. static FindFallbackWithProfileId(profileId: string): string[];
  118750. /**
  118751. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118752. * The order of search:
  118753. *
  118754. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118755. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118756. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118757. * 4) return the generic trigger controller if none were found
  118758. *
  118759. * @param xrInput the xrInput to which a new controller is initialized
  118760. * @param scene the scene to which the model will be added
  118761. * @param forceProfile force a certain profile for this controller
  118762. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118763. */
  118764. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118765. /**
  118766. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118767. *
  118768. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118769. *
  118770. * @param type the profile type to register
  118771. * @param constructFunction the function to be called when loading this profile
  118772. */
  118773. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118774. /**
  118775. * Register a fallback to a specific profile.
  118776. * @param profileId the profileId that will receive the fallbacks
  118777. * @param fallbacks A list of fallback profiles
  118778. */
  118779. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118780. /**
  118781. * Will update the list of profiles available in the repository
  118782. * @return a promise that resolves to a map of profiles available online
  118783. */
  118784. static UpdateProfilesList(): Promise<{
  118785. [profile: string]: string;
  118786. }>;
  118787. private static _LoadProfileFromRepository;
  118788. private static _LoadProfilesFromAvailableControllers;
  118789. }
  118790. }
  118791. declare module BABYLON {
  118792. /**
  118793. * Configuration options for the WebXR controller creation
  118794. */
  118795. export interface IWebXRControllerOptions {
  118796. /**
  118797. * Should the controller mesh be animated when a user interacts with it
  118798. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118799. */
  118800. disableMotionControllerAnimation?: boolean;
  118801. /**
  118802. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118803. */
  118804. doNotLoadControllerMesh?: boolean;
  118805. /**
  118806. * Force a specific controller type for this controller.
  118807. * This can be used when creating your own profile or when testing different controllers
  118808. */
  118809. forceControllerProfile?: string;
  118810. }
  118811. /**
  118812. * Represents an XR controller
  118813. */
  118814. export class WebXRInputSource {
  118815. private _scene;
  118816. /** The underlying input source for the controller */
  118817. inputSource: XRInputSource;
  118818. private _options;
  118819. private _tmpQuaternion;
  118820. private _tmpVector;
  118821. private _uniqueId;
  118822. /**
  118823. * 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
  118824. */
  118825. grip?: AbstractMesh;
  118826. /**
  118827. * If available, this is the gamepad object related to this controller.
  118828. * Using this object it is possible to get click events and trackpad changes of the
  118829. * webxr controller that is currently being used.
  118830. */
  118831. motionController?: WebXRAbstractMotionController;
  118832. /**
  118833. * Event that fires when the controller is removed/disposed.
  118834. * The object provided as event data is this controller, after associated assets were disposed.
  118835. * uniqueId is still available.
  118836. */
  118837. onDisposeObservable: Observable<WebXRInputSource>;
  118838. /**
  118839. * Will be triggered when the mesh associated with the motion controller is done loading.
  118840. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118841. * A shortened version of controller -> motion controller -> on mesh loaded.
  118842. */
  118843. onMeshLoadedObservable: Observable<AbstractMesh>;
  118844. /**
  118845. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118846. */
  118847. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118848. /**
  118849. * Pointer which can be used to select objects or attach a visible laser to
  118850. */
  118851. pointer: AbstractMesh;
  118852. /**
  118853. * Creates the controller
  118854. * @see https://doc.babylonjs.com/how_to/webxr
  118855. * @param _scene the scene which the controller should be associated to
  118856. * @param inputSource the underlying input source for the controller
  118857. * @param _options options for this controller creation
  118858. */
  118859. constructor(_scene: Scene,
  118860. /** The underlying input source for the controller */
  118861. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118862. /**
  118863. * Get this controllers unique id
  118864. */
  118865. get uniqueId(): string;
  118866. /**
  118867. * Disposes of the object
  118868. */
  118869. dispose(): void;
  118870. /**
  118871. * Gets a world space ray coming from the pointer or grip
  118872. * @param result the resulting ray
  118873. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118874. */
  118875. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118876. /**
  118877. * Updates the controller pose based on the given XRFrame
  118878. * @param xrFrame xr frame to update the pose with
  118879. * @param referenceSpace reference space to use
  118880. */
  118881. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118882. }
  118883. }
  118884. declare module BABYLON {
  118885. /**
  118886. * The schema for initialization options of the XR Input class
  118887. */
  118888. export interface IWebXRInputOptions {
  118889. /**
  118890. * If set to true no model will be automatically loaded
  118891. */
  118892. doNotLoadControllerMeshes?: boolean;
  118893. /**
  118894. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118895. * If not found, the xr input profile data will be used.
  118896. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118897. */
  118898. forceInputProfile?: string;
  118899. /**
  118900. * Do not send a request to the controller repository to load the profile.
  118901. *
  118902. * Instead, use the controllers available in babylon itself.
  118903. */
  118904. disableOnlineControllerRepository?: boolean;
  118905. /**
  118906. * A custom URL for the controllers repository
  118907. */
  118908. customControllersRepositoryURL?: string;
  118909. /**
  118910. * Should the controller model's components not move according to the user input
  118911. */
  118912. disableControllerAnimation?: boolean;
  118913. }
  118914. /**
  118915. * XR input used to track XR inputs such as controllers/rays
  118916. */
  118917. export class WebXRInput implements IDisposable {
  118918. /**
  118919. * the xr session manager for this session
  118920. */
  118921. xrSessionManager: WebXRSessionManager;
  118922. /**
  118923. * the WebXR camera for this session. Mainly used for teleportation
  118924. */
  118925. xrCamera: WebXRCamera;
  118926. private readonly options;
  118927. /**
  118928. * XR controllers being tracked
  118929. */
  118930. controllers: Array<WebXRInputSource>;
  118931. private _frameObserver;
  118932. private _sessionEndedObserver;
  118933. private _sessionInitObserver;
  118934. /**
  118935. * Event when a controller has been connected/added
  118936. */
  118937. onControllerAddedObservable: Observable<WebXRInputSource>;
  118938. /**
  118939. * Event when a controller has been removed/disconnected
  118940. */
  118941. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118942. /**
  118943. * Initializes the WebXRInput
  118944. * @param xrSessionManager the xr session manager for this session
  118945. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118946. * @param options = initialization options for this xr input
  118947. */
  118948. constructor(
  118949. /**
  118950. * the xr session manager for this session
  118951. */
  118952. xrSessionManager: WebXRSessionManager,
  118953. /**
  118954. * the WebXR camera for this session. Mainly used for teleportation
  118955. */
  118956. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118957. private _onInputSourcesChange;
  118958. private _addAndRemoveControllers;
  118959. /**
  118960. * Disposes of the object
  118961. */
  118962. dispose(): void;
  118963. }
  118964. }
  118965. declare module BABYLON {
  118966. /**
  118967. * This is the base class for all WebXR features.
  118968. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118969. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118970. */
  118971. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118972. protected _xrSessionManager: WebXRSessionManager;
  118973. private _attached;
  118974. private _removeOnDetach;
  118975. /**
  118976. * Should auto-attach be disabled?
  118977. */
  118978. disableAutoAttach: boolean;
  118979. /**
  118980. * Construct a new (abstract) WebXR feature
  118981. * @param _xrSessionManager the xr session manager for this feature
  118982. */
  118983. constructor(_xrSessionManager: WebXRSessionManager);
  118984. /**
  118985. * Is this feature attached
  118986. */
  118987. get attached(): boolean;
  118988. /**
  118989. * attach this feature
  118990. *
  118991. * @param force should attachment be forced (even when already attached)
  118992. * @returns true if successful, false is failed or already attached
  118993. */
  118994. attach(force?: boolean): boolean;
  118995. /**
  118996. * detach this feature.
  118997. *
  118998. * @returns true if successful, false if failed or already detached
  118999. */
  119000. detach(): boolean;
  119001. /**
  119002. * Dispose this feature and all of the resources attached
  119003. */
  119004. dispose(): void;
  119005. /**
  119006. * This is used to register callbacks that will automatically be removed when detach is called.
  119007. * @param observable the observable to which the observer will be attached
  119008. * @param callback the callback to register
  119009. */
  119010. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  119011. /**
  119012. * Code in this function will be executed on each xrFrame received from the browser.
  119013. * This function will not execute after the feature is detached.
  119014. * @param _xrFrame the current frame
  119015. */
  119016. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119017. }
  119018. }
  119019. declare module BABYLON {
  119020. /**
  119021. * Renders a layer on top of an existing scene
  119022. */
  119023. export class UtilityLayerRenderer implements IDisposable {
  119024. /** the original scene that will be rendered on top of */
  119025. originalScene: Scene;
  119026. private _pointerCaptures;
  119027. private _lastPointerEvents;
  119028. private static _DefaultUtilityLayer;
  119029. private static _DefaultKeepDepthUtilityLayer;
  119030. private _sharedGizmoLight;
  119031. private _renderCamera;
  119032. /**
  119033. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119034. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119035. * @returns the camera that is used when rendering the utility layer
  119036. */
  119037. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119038. /**
  119039. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119040. * @param cam the camera that should be used when rendering the utility layer
  119041. */
  119042. setRenderCamera(cam: Nullable<Camera>): void;
  119043. /**
  119044. * @hidden
  119045. * Light which used by gizmos to get light shading
  119046. */
  119047. _getSharedGizmoLight(): HemisphericLight;
  119048. /**
  119049. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119050. */
  119051. pickUtilitySceneFirst: boolean;
  119052. /**
  119053. * 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)
  119054. */
  119055. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119056. /**
  119057. * 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)
  119058. */
  119059. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119060. /**
  119061. * The scene that is rendered on top of the original scene
  119062. */
  119063. utilityLayerScene: Scene;
  119064. /**
  119065. * If the utility layer should automatically be rendered on top of existing scene
  119066. */
  119067. shouldRender: boolean;
  119068. /**
  119069. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119070. */
  119071. onlyCheckPointerDownEvents: boolean;
  119072. /**
  119073. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119074. */
  119075. processAllEvents: boolean;
  119076. /**
  119077. * Observable raised when the pointer move from the utility layer scene to the main scene
  119078. */
  119079. onPointerOutObservable: Observable<number>;
  119080. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119081. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119082. private _afterRenderObserver;
  119083. private _sceneDisposeObserver;
  119084. private _originalPointerObserver;
  119085. /**
  119086. * Instantiates a UtilityLayerRenderer
  119087. * @param originalScene the original scene that will be rendered on top of
  119088. * @param handleEvents boolean indicating if the utility layer should handle events
  119089. */
  119090. constructor(
  119091. /** the original scene that will be rendered on top of */
  119092. originalScene: Scene, handleEvents?: boolean);
  119093. private _notifyObservers;
  119094. /**
  119095. * Renders the utility layers scene on top of the original scene
  119096. */
  119097. render(): void;
  119098. /**
  119099. * Disposes of the renderer
  119100. */
  119101. dispose(): void;
  119102. private _updateCamera;
  119103. }
  119104. }
  119105. declare module BABYLON {
  119106. /**
  119107. * Options interface for the pointer selection module
  119108. */
  119109. export interface IWebXRControllerPointerSelectionOptions {
  119110. /**
  119111. * if provided, this scene will be used to render meshes.
  119112. */
  119113. customUtilityLayerScene?: Scene;
  119114. /**
  119115. * 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)
  119116. * If not disabled, the last picked point will be used to execute a pointer up event
  119117. * If disabled, pointer up event will be triggered right after the pointer down event.
  119118. * Used in screen and gaze target ray mode only
  119119. */
  119120. disablePointerUpOnTouchOut: boolean;
  119121. /**
  119122. * For gaze mode (time to select instead of press)
  119123. */
  119124. forceGazeMode: boolean;
  119125. /**
  119126. * 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
  119127. * to start a new countdown to the pointer down event.
  119128. * Defaults to 1.
  119129. */
  119130. gazeModePointerMovedFactor?: number;
  119131. /**
  119132. * Different button type to use instead of the main component
  119133. */
  119134. overrideButtonId?: string;
  119135. /**
  119136. * use this rendering group id for the meshes (optional)
  119137. */
  119138. renderingGroupId?: number;
  119139. /**
  119140. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119141. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119142. * 3000 means 3 seconds between pointing at something and selecting it
  119143. */
  119144. timeToSelect?: number;
  119145. /**
  119146. * Should meshes created here be added to a utility layer or the main scene
  119147. */
  119148. useUtilityLayer?: boolean;
  119149. /**
  119150. * the xr input to use with this pointer selection
  119151. */
  119152. xrInput: WebXRInput;
  119153. }
  119154. /**
  119155. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119156. */
  119157. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119158. private readonly _options;
  119159. private static _idCounter;
  119160. private _attachController;
  119161. private _controllers;
  119162. private _scene;
  119163. private _tmpVectorForPickCompare;
  119164. /**
  119165. * The module's name
  119166. */
  119167. static readonly Name: string;
  119168. /**
  119169. * The (Babylon) version of this module.
  119170. * This is an integer representing the implementation version.
  119171. * This number does not correspond to the WebXR specs version
  119172. */
  119173. static readonly Version: number;
  119174. /**
  119175. * Disable lighting on the laser pointer (so it will always be visible)
  119176. */
  119177. disablePointerLighting: boolean;
  119178. /**
  119179. * Disable lighting on the selection mesh (so it will always be visible)
  119180. */
  119181. disableSelectionMeshLighting: boolean;
  119182. /**
  119183. * Should the laser pointer be displayed
  119184. */
  119185. displayLaserPointer: boolean;
  119186. /**
  119187. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119188. */
  119189. displaySelectionMesh: boolean;
  119190. /**
  119191. * This color will be set to the laser pointer when selection is triggered
  119192. */
  119193. laserPointerPickedColor: Color3;
  119194. /**
  119195. * Default color of the laser pointer
  119196. */
  119197. lasterPointerDefaultColor: Color3;
  119198. /**
  119199. * default color of the selection ring
  119200. */
  119201. selectionMeshDefaultColor: Color3;
  119202. /**
  119203. * This color will be applied to the selection ring when selection is triggered
  119204. */
  119205. selectionMeshPickedColor: Color3;
  119206. /**
  119207. * Optional filter to be used for ray selection. This predicate shares behavior with
  119208. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119209. */
  119210. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119211. /**
  119212. * constructs a new background remover module
  119213. * @param _xrSessionManager the session manager for this module
  119214. * @param _options read-only options to be used in this module
  119215. */
  119216. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119217. /**
  119218. * attach this feature
  119219. * Will usually be called by the features manager
  119220. *
  119221. * @returns true if successful.
  119222. */
  119223. attach(): boolean;
  119224. /**
  119225. * detach this feature.
  119226. * Will usually be called by the features manager
  119227. *
  119228. * @returns true if successful.
  119229. */
  119230. detach(): boolean;
  119231. /**
  119232. * Will get the mesh under a specific pointer.
  119233. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119234. * @param controllerId the controllerId to check
  119235. * @returns The mesh under pointer or null if no mesh is under the pointer
  119236. */
  119237. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119238. /**
  119239. * Get the xr controller that correlates to the pointer id in the pointer event
  119240. *
  119241. * @param id the pointer id to search for
  119242. * @returns the controller that correlates to this id or null if not found
  119243. */
  119244. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119245. protected _onXRFrame(_xrFrame: XRFrame): void;
  119246. private _attachGazeMode;
  119247. private _attachScreenRayMode;
  119248. private _attachTrackedPointerRayMode;
  119249. private _convertNormalToDirectionOfRay;
  119250. private _detachController;
  119251. private _generateNewMeshPair;
  119252. private _pickingMoved;
  119253. private _updatePointerDistance;
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Button which can be used to enter a different mode of XR
  119259. */
  119260. export class WebXREnterExitUIButton {
  119261. /** button element */
  119262. element: HTMLElement;
  119263. /** XR initialization options for the button */
  119264. sessionMode: XRSessionMode;
  119265. /** Reference space type */
  119266. referenceSpaceType: XRReferenceSpaceType;
  119267. /**
  119268. * Creates a WebXREnterExitUIButton
  119269. * @param element button element
  119270. * @param sessionMode XR initialization session mode
  119271. * @param referenceSpaceType the type of reference space to be used
  119272. */
  119273. constructor(
  119274. /** button element */
  119275. element: HTMLElement,
  119276. /** XR initialization options for the button */
  119277. sessionMode: XRSessionMode,
  119278. /** Reference space type */
  119279. referenceSpaceType: XRReferenceSpaceType);
  119280. /**
  119281. * Extendable function which can be used to update the button's visuals when the state changes
  119282. * @param activeButton the current active button in the UI
  119283. */
  119284. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119285. }
  119286. /**
  119287. * Options to create the webXR UI
  119288. */
  119289. export class WebXREnterExitUIOptions {
  119290. /**
  119291. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119292. */
  119293. customButtons?: Array<WebXREnterExitUIButton>;
  119294. /**
  119295. * A reference space type to use when creating the default button.
  119296. * Default is local-floor
  119297. */
  119298. referenceSpaceType?: XRReferenceSpaceType;
  119299. /**
  119300. * Context to enter xr with
  119301. */
  119302. renderTarget?: Nullable<WebXRRenderTarget>;
  119303. /**
  119304. * A session mode to use when creating the default button.
  119305. * Default is immersive-vr
  119306. */
  119307. sessionMode?: XRSessionMode;
  119308. }
  119309. /**
  119310. * UI to allow the user to enter/exit XR mode
  119311. */
  119312. export class WebXREnterExitUI implements IDisposable {
  119313. private scene;
  119314. /** version of the options passed to this UI */
  119315. options: WebXREnterExitUIOptions;
  119316. private _activeButton;
  119317. private _buttons;
  119318. private _overlay;
  119319. /**
  119320. * Fired every time the active button is changed.
  119321. *
  119322. * When xr is entered via a button that launches xr that button will be the callback parameter
  119323. *
  119324. * When exiting xr the callback parameter will be null)
  119325. */
  119326. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119327. /**
  119328. *
  119329. * @param scene babylon scene object to use
  119330. * @param options (read-only) version of the options passed to this UI
  119331. */
  119332. private constructor();
  119333. /**
  119334. * Creates UI to allow the user to enter/exit XR mode
  119335. * @param scene the scene to add the ui to
  119336. * @param helper the xr experience helper to enter/exit xr with
  119337. * @param options options to configure the UI
  119338. * @returns the created ui
  119339. */
  119340. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119341. /**
  119342. * Disposes of the XR UI component
  119343. */
  119344. dispose(): void;
  119345. private _updateButtons;
  119346. }
  119347. }
  119348. declare module BABYLON {
  119349. /**
  119350. * Class containing static functions to help procedurally build meshes
  119351. */
  119352. export class LinesBuilder {
  119353. /**
  119354. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119355. * * 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
  119356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119357. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119358. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119359. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119361. * * 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
  119362. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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#line-system
  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 system mesh
  119369. */
  119370. static CreateLineSystem(name: string, options: {
  119371. lines: Vector3[][];
  119372. updatable?: boolean;
  119373. instance?: Nullable<LinesMesh>;
  119374. colors?: Nullable<Color4[][]>;
  119375. useVertexAlpha?: boolean;
  119376. }, scene: Nullable<Scene>): LinesMesh;
  119377. /**
  119378. * Creates a line mesh
  119379. * 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
  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 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
  119383. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119385. * * When updating an instance, remember that only point positions can change, not the number of points
  119386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119388. * @param name defines the name of the new line system
  119389. * @param options defines the options used to create the line system
  119390. * @param scene defines the hosting scene
  119391. * @returns a new line mesh
  119392. */
  119393. static CreateLines(name: string, options: {
  119394. points: Vector3[];
  119395. updatable?: boolean;
  119396. instance?: Nullable<LinesMesh>;
  119397. colors?: Color4[];
  119398. useVertexAlpha?: boolean;
  119399. }, scene?: Nullable<Scene>): LinesMesh;
  119400. /**
  119401. * Creates a dashed line mesh
  119402. * * 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
  119403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119404. * * The parameter `points` is an array successive Vector3
  119405. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119406. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119407. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119408. * * 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
  119409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119410. * * When updating an instance, remember that only point positions can change, not the number of points
  119411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119412. * @param name defines the name of the mesh
  119413. * @param options defines the options used to create the mesh
  119414. * @param scene defines the hosting scene
  119415. * @returns the dashed line mesh
  119416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119417. */
  119418. static CreateDashedLines(name: string, options: {
  119419. points: Vector3[];
  119420. dashSize?: number;
  119421. gapSize?: number;
  119422. dashNb?: number;
  119423. updatable?: boolean;
  119424. instance?: LinesMesh;
  119425. useVertexAlpha?: boolean;
  119426. }, scene?: Nullable<Scene>): LinesMesh;
  119427. }
  119428. }
  119429. declare module BABYLON {
  119430. /**
  119431. * The options container for the teleportation module
  119432. */
  119433. export interface IWebXRTeleportationOptions {
  119434. /**
  119435. * if provided, this scene will be used to render meshes.
  119436. */
  119437. customUtilityLayerScene?: Scene;
  119438. /**
  119439. * Values to configure the default target mesh
  119440. */
  119441. defaultTargetMeshOptions?: {
  119442. /**
  119443. * Fill color of the teleportation area
  119444. */
  119445. teleportationFillColor?: string;
  119446. /**
  119447. * Border color for the teleportation area
  119448. */
  119449. teleportationBorderColor?: string;
  119450. /**
  119451. * Disable the mesh's animation sequence
  119452. */
  119453. disableAnimation?: boolean;
  119454. /**
  119455. * Disable lighting on the material or the ring and arrow
  119456. */
  119457. disableLighting?: boolean;
  119458. /**
  119459. * Override the default material of the torus and arrow
  119460. */
  119461. torusArrowMaterial?: Material;
  119462. };
  119463. /**
  119464. * A list of meshes to use as floor meshes.
  119465. * Meshes can be added and removed after initializing the feature using the
  119466. * addFloorMesh and removeFloorMesh functions
  119467. * If empty, rotation will still work
  119468. */
  119469. floorMeshes?: AbstractMesh[];
  119470. /**
  119471. * use this rendering group id for the meshes (optional)
  119472. */
  119473. renderingGroupId?: number;
  119474. /**
  119475. * Should teleportation move only to snap points
  119476. */
  119477. snapPointsOnly?: boolean;
  119478. /**
  119479. * An array of points to which the teleportation will snap to.
  119480. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119481. */
  119482. snapPositions?: Vector3[];
  119483. /**
  119484. * How close should the teleportation ray be in order to snap to position.
  119485. * Default to 0.8 units (meters)
  119486. */
  119487. snapToPositionRadius?: number;
  119488. /**
  119489. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119490. * If you want to support rotation, make sure your mesh has a direction indicator.
  119491. *
  119492. * When left untouched, the default mesh will be initialized.
  119493. */
  119494. teleportationTargetMesh?: AbstractMesh;
  119495. /**
  119496. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119497. */
  119498. timeToTeleport?: number;
  119499. /**
  119500. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119501. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119502. */
  119503. useMainComponentOnly?: boolean;
  119504. /**
  119505. * Should meshes created here be added to a utility layer or the main scene
  119506. */
  119507. useUtilityLayer?: boolean;
  119508. /**
  119509. * Babylon XR Input class for controller
  119510. */
  119511. xrInput: WebXRInput;
  119512. }
  119513. /**
  119514. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119515. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119516. * the input of the attached controllers.
  119517. */
  119518. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119519. private _options;
  119520. private _controllers;
  119521. private _currentTeleportationControllerId;
  119522. private _floorMeshes;
  119523. private _quadraticBezierCurve;
  119524. private _selectionFeature;
  119525. private _snapToPositions;
  119526. private _snappedToPoint;
  119527. private _teleportationRingMaterial?;
  119528. private _tmpRay;
  119529. private _tmpVector;
  119530. /**
  119531. * The module's name
  119532. */
  119533. static readonly Name: string;
  119534. /**
  119535. * The (Babylon) version of this module.
  119536. * This is an integer representing the implementation version.
  119537. * This number does not correspond to the webxr specs version
  119538. */
  119539. static readonly Version: number;
  119540. /**
  119541. * Is movement backwards enabled
  119542. */
  119543. backwardsMovementEnabled: boolean;
  119544. /**
  119545. * Distance to travel when moving backwards
  119546. */
  119547. backwardsTeleportationDistance: number;
  119548. /**
  119549. * The distance from the user to the inspection point in the direction of the controller
  119550. * A higher number will allow the user to move further
  119551. * defaults to 5 (meters, in xr units)
  119552. */
  119553. parabolicCheckRadius: number;
  119554. /**
  119555. * Should the module support parabolic ray on top of direct ray
  119556. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119557. * Very helpful when moving between floors / different heights
  119558. */
  119559. parabolicRayEnabled: boolean;
  119560. /**
  119561. * How much rotation should be applied when rotating right and left
  119562. */
  119563. rotationAngle: number;
  119564. /**
  119565. * Is rotation enabled when moving forward?
  119566. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119567. */
  119568. rotationEnabled: boolean;
  119569. /**
  119570. * constructs a new anchor system
  119571. * @param _xrSessionManager an instance of WebXRSessionManager
  119572. * @param _options configuration object for this feature
  119573. */
  119574. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119575. /**
  119576. * Get the snapPointsOnly flag
  119577. */
  119578. get snapPointsOnly(): boolean;
  119579. /**
  119580. * Sets the snapPointsOnly flag
  119581. * @param snapToPoints should teleportation be exclusively to snap points
  119582. */
  119583. set snapPointsOnly(snapToPoints: boolean);
  119584. /**
  119585. * Add a new mesh to the floor meshes array
  119586. * @param mesh the mesh to use as floor mesh
  119587. */
  119588. addFloorMesh(mesh: AbstractMesh): void;
  119589. /**
  119590. * Add a new snap-to point to fix teleportation to this position
  119591. * @param newSnapPoint The new Snap-To point
  119592. */
  119593. addSnapPoint(newSnapPoint: Vector3): void;
  119594. attach(): boolean;
  119595. detach(): boolean;
  119596. dispose(): void;
  119597. /**
  119598. * Remove a mesh from the floor meshes array
  119599. * @param mesh the mesh to remove
  119600. */
  119601. removeFloorMesh(mesh: AbstractMesh): void;
  119602. /**
  119603. * Remove a mesh from the floor meshes array using its name
  119604. * @param name the mesh name to remove
  119605. */
  119606. removeFloorMeshByName(name: string): void;
  119607. /**
  119608. * 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
  119609. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119610. * @returns was the point found and removed or not
  119611. */
  119612. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119613. /**
  119614. * This function sets a selection feature that will be disabled when
  119615. * the forward ray is shown and will be reattached when hidden.
  119616. * This is used to remove the selection rays when moving.
  119617. * @param selectionFeature the feature to disable when forward movement is enabled
  119618. */
  119619. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119620. protected _onXRFrame(_xrFrame: XRFrame): void;
  119621. private _attachController;
  119622. private _createDefaultTargetMesh;
  119623. private _detachController;
  119624. private _findClosestSnapPointWithRadius;
  119625. private _setTargetMeshPosition;
  119626. private _setTargetMeshVisibility;
  119627. private _showParabolicPath;
  119628. private _teleportForward;
  119629. }
  119630. }
  119631. declare module BABYLON {
  119632. /**
  119633. * Options for the default xr helper
  119634. */
  119635. export class WebXRDefaultExperienceOptions {
  119636. /**
  119637. * Enable or disable default UI to enter XR
  119638. */
  119639. disableDefaultUI?: boolean;
  119640. /**
  119641. * Should teleportation not initialize. defaults to false.
  119642. */
  119643. disableTeleportation?: boolean;
  119644. /**
  119645. * Floor meshes that will be used for teleport
  119646. */
  119647. floorMeshes?: Array<AbstractMesh>;
  119648. /**
  119649. * If set to true, the first frame will not be used to reset position
  119650. * The first frame is mainly used when copying transformation from the old camera
  119651. * Mainly used in AR
  119652. */
  119653. ignoreNativeCameraTransformation?: boolean;
  119654. /**
  119655. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119656. */
  119657. inputOptions?: IWebXRInputOptions;
  119658. /**
  119659. * optional configuration for the output canvas
  119660. */
  119661. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119662. /**
  119663. * optional UI options. This can be used among other to change session mode and reference space type
  119664. */
  119665. uiOptions?: WebXREnterExitUIOptions;
  119666. /**
  119667. * When loading teleportation and pointer select, use stable versions instead of latest.
  119668. */
  119669. useStablePlugins?: boolean;
  119670. }
  119671. /**
  119672. * Default experience which provides a similar setup to the previous webVRExperience
  119673. */
  119674. export class WebXRDefaultExperience {
  119675. /**
  119676. * Base experience
  119677. */
  119678. baseExperience: WebXRExperienceHelper;
  119679. /**
  119680. * Enables ui for entering/exiting xr
  119681. */
  119682. enterExitUI: WebXREnterExitUI;
  119683. /**
  119684. * Input experience extension
  119685. */
  119686. input: WebXRInput;
  119687. /**
  119688. * Enables laser pointer and selection
  119689. */
  119690. pointerSelection: WebXRControllerPointerSelection;
  119691. /**
  119692. * Default target xr should render to
  119693. */
  119694. renderTarget: WebXRRenderTarget;
  119695. /**
  119696. * Enables teleportation
  119697. */
  119698. teleportation: WebXRMotionControllerTeleportation;
  119699. private constructor();
  119700. /**
  119701. * Creates the default xr experience
  119702. * @param scene scene
  119703. * @param options options for basic configuration
  119704. * @returns resulting WebXRDefaultExperience
  119705. */
  119706. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119707. /**
  119708. * DIsposes of the experience helper
  119709. */
  119710. dispose(): void;
  119711. }
  119712. }
  119713. declare module BABYLON {
  119714. /**
  119715. * Options to modify the vr teleportation behavior.
  119716. */
  119717. export interface VRTeleportationOptions {
  119718. /**
  119719. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119720. */
  119721. floorMeshName?: string;
  119722. /**
  119723. * A list of meshes to be used as the teleportation floor. (default: empty)
  119724. */
  119725. floorMeshes?: Mesh[];
  119726. /**
  119727. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119728. */
  119729. teleportationMode?: number;
  119730. /**
  119731. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119732. */
  119733. teleportationTime?: number;
  119734. /**
  119735. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119736. */
  119737. teleportationSpeed?: number;
  119738. /**
  119739. * The easing function used in the animation or null for Linear. (default CircleEase)
  119740. */
  119741. easingFunction?: EasingFunction;
  119742. }
  119743. /**
  119744. * Options to modify the vr experience helper's behavior.
  119745. */
  119746. export interface VRExperienceHelperOptions extends WebVROptions {
  119747. /**
  119748. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119749. */
  119750. createDeviceOrientationCamera?: boolean;
  119751. /**
  119752. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119753. */
  119754. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119755. /**
  119756. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119757. */
  119758. laserToggle?: boolean;
  119759. /**
  119760. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119761. */
  119762. floorMeshes?: Mesh[];
  119763. /**
  119764. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119765. */
  119766. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119767. /**
  119768. * Defines if WebXR should be used instead of WebVR (if available)
  119769. */
  119770. useXR?: boolean;
  119771. }
  119772. /**
  119773. * Event containing information after VR has been entered
  119774. */
  119775. export class OnAfterEnteringVRObservableEvent {
  119776. /**
  119777. * If entering vr was successful
  119778. */
  119779. success: boolean;
  119780. }
  119781. /**
  119782. * Helps to quickly add VR support to an existing scene.
  119783. * See http://doc.babylonjs.com/how_to/webvr_helper
  119784. */
  119785. export class VRExperienceHelper {
  119786. /** Options to modify the vr experience helper's behavior. */
  119787. webVROptions: VRExperienceHelperOptions;
  119788. private _scene;
  119789. private _position;
  119790. private _btnVR;
  119791. private _btnVRDisplayed;
  119792. private _webVRsupported;
  119793. private _webVRready;
  119794. private _webVRrequesting;
  119795. private _webVRpresenting;
  119796. private _hasEnteredVR;
  119797. private _fullscreenVRpresenting;
  119798. private _inputElement;
  119799. private _webVRCamera;
  119800. private _vrDeviceOrientationCamera;
  119801. private _deviceOrientationCamera;
  119802. private _existingCamera;
  119803. private _onKeyDown;
  119804. private _onVrDisplayPresentChange;
  119805. private _onVRDisplayChanged;
  119806. private _onVRRequestPresentStart;
  119807. private _onVRRequestPresentComplete;
  119808. /**
  119809. * 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)
  119810. */
  119811. enableGazeEvenWhenNoPointerLock: boolean;
  119812. /**
  119813. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119814. */
  119815. exitVROnDoubleTap: boolean;
  119816. /**
  119817. * Observable raised right before entering VR.
  119818. */
  119819. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119820. /**
  119821. * Observable raised when entering VR has completed.
  119822. */
  119823. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119824. /**
  119825. * Observable raised when exiting VR.
  119826. */
  119827. onExitingVRObservable: Observable<VRExperienceHelper>;
  119828. /**
  119829. * Observable raised when controller mesh is loaded.
  119830. */
  119831. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119832. /** Return this.onEnteringVRObservable
  119833. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119834. */
  119835. get onEnteringVR(): Observable<VRExperienceHelper>;
  119836. /** Return this.onExitingVRObservable
  119837. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119838. */
  119839. get onExitingVR(): Observable<VRExperienceHelper>;
  119840. /** Return this.onControllerMeshLoadedObservable
  119841. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119842. */
  119843. get onControllerMeshLoaded(): Observable<WebVRController>;
  119844. private _rayLength;
  119845. private _useCustomVRButton;
  119846. private _teleportationRequested;
  119847. private _teleportActive;
  119848. private _floorMeshName;
  119849. private _floorMeshesCollection;
  119850. private _teleportationMode;
  119851. private _teleportationTime;
  119852. private _teleportationSpeed;
  119853. private _teleportationEasing;
  119854. private _rotationAllowed;
  119855. private _teleportBackwardsVector;
  119856. private _teleportationTarget;
  119857. private _isDefaultTeleportationTarget;
  119858. private _postProcessMove;
  119859. private _teleportationFillColor;
  119860. private _teleportationBorderColor;
  119861. private _rotationAngle;
  119862. private _haloCenter;
  119863. private _cameraGazer;
  119864. private _padSensibilityUp;
  119865. private _padSensibilityDown;
  119866. private _leftController;
  119867. private _rightController;
  119868. private _gazeColor;
  119869. private _laserColor;
  119870. private _pickedLaserColor;
  119871. private _pickedGazeColor;
  119872. /**
  119873. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119874. */
  119875. onNewMeshSelected: Observable<AbstractMesh>;
  119876. /**
  119877. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119878. * This observable will provide the mesh and the controller used to select the mesh
  119879. */
  119880. onMeshSelectedWithController: Observable<{
  119881. mesh: AbstractMesh;
  119882. controller: WebVRController;
  119883. }>;
  119884. /**
  119885. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119886. */
  119887. onNewMeshPicked: Observable<PickingInfo>;
  119888. private _circleEase;
  119889. /**
  119890. * Observable raised before camera teleportation
  119891. */
  119892. onBeforeCameraTeleport: Observable<Vector3>;
  119893. /**
  119894. * Observable raised after camera teleportation
  119895. */
  119896. onAfterCameraTeleport: Observable<Vector3>;
  119897. /**
  119898. * Observable raised when current selected mesh gets unselected
  119899. */
  119900. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119901. private _raySelectionPredicate;
  119902. /**
  119903. * To be optionaly changed by user to define custom ray selection
  119904. */
  119905. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119906. /**
  119907. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119908. */
  119909. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119910. /**
  119911. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119912. */
  119913. teleportationEnabled: boolean;
  119914. private _defaultHeight;
  119915. private _teleportationInitialized;
  119916. private _interactionsEnabled;
  119917. private _interactionsRequested;
  119918. private _displayGaze;
  119919. private _displayLaserPointer;
  119920. /**
  119921. * The mesh used to display where the user is going to teleport.
  119922. */
  119923. get teleportationTarget(): Mesh;
  119924. /**
  119925. * Sets the mesh to be used to display where the user is going to teleport.
  119926. */
  119927. set teleportationTarget(value: Mesh);
  119928. /**
  119929. * 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
  119930. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119931. * See http://doc.babylonjs.com/resources/baking_transformations
  119932. */
  119933. get gazeTrackerMesh(): Mesh;
  119934. set gazeTrackerMesh(value: Mesh);
  119935. /**
  119936. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119937. */
  119938. updateGazeTrackerScale: boolean;
  119939. /**
  119940. * If the gaze trackers color should be updated when selecting meshes
  119941. */
  119942. updateGazeTrackerColor: boolean;
  119943. /**
  119944. * If the controller laser color should be updated when selecting meshes
  119945. */
  119946. updateControllerLaserColor: boolean;
  119947. /**
  119948. * The gaze tracking mesh corresponding to the left controller
  119949. */
  119950. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119951. /**
  119952. * The gaze tracking mesh corresponding to the right controller
  119953. */
  119954. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119955. /**
  119956. * If the ray of the gaze should be displayed.
  119957. */
  119958. get displayGaze(): boolean;
  119959. /**
  119960. * Sets if the ray of the gaze should be displayed.
  119961. */
  119962. set displayGaze(value: boolean);
  119963. /**
  119964. * If the ray of the LaserPointer should be displayed.
  119965. */
  119966. get displayLaserPointer(): boolean;
  119967. /**
  119968. * Sets if the ray of the LaserPointer should be displayed.
  119969. */
  119970. set displayLaserPointer(value: boolean);
  119971. /**
  119972. * The deviceOrientationCamera used as the camera when not in VR.
  119973. */
  119974. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119975. /**
  119976. * Based on the current WebVR support, returns the current VR camera used.
  119977. */
  119978. get currentVRCamera(): Nullable<Camera>;
  119979. /**
  119980. * The webVRCamera which is used when in VR.
  119981. */
  119982. get webVRCamera(): WebVRFreeCamera;
  119983. /**
  119984. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119985. */
  119986. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119987. /**
  119988. * The html button that is used to trigger entering into VR.
  119989. */
  119990. get vrButton(): Nullable<HTMLButtonElement>;
  119991. private get _teleportationRequestInitiated();
  119992. /**
  119993. * Defines whether or not Pointer lock should be requested when switching to
  119994. * full screen.
  119995. */
  119996. requestPointerLockOnFullScreen: boolean;
  119997. /**
  119998. * If asking to force XR, this will be populated with the default xr experience
  119999. */
  120000. xr: WebXRDefaultExperience;
  120001. /**
  120002. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  120003. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  120004. */
  120005. xrTestDone: boolean;
  120006. /**
  120007. * Instantiates a VRExperienceHelper.
  120008. * Helps to quickly add VR support to an existing scene.
  120009. * @param scene The scene the VRExperienceHelper belongs to.
  120010. * @param webVROptions Options to modify the vr experience helper's behavior.
  120011. */
  120012. constructor(scene: Scene,
  120013. /** Options to modify the vr experience helper's behavior. */
  120014. webVROptions?: VRExperienceHelperOptions);
  120015. private completeVRInit;
  120016. private _onDefaultMeshLoaded;
  120017. private _onResize;
  120018. private _onFullscreenChange;
  120019. /**
  120020. * Gets a value indicating if we are currently in VR mode.
  120021. */
  120022. get isInVRMode(): boolean;
  120023. private onVrDisplayPresentChange;
  120024. private onVRDisplayChanged;
  120025. private moveButtonToBottomRight;
  120026. private displayVRButton;
  120027. private updateButtonVisibility;
  120028. private _cachedAngularSensibility;
  120029. /**
  120030. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120031. * Otherwise, will use the fullscreen API.
  120032. */
  120033. enterVR(): void;
  120034. /**
  120035. * Attempt to exit VR, or fullscreen.
  120036. */
  120037. exitVR(): void;
  120038. /**
  120039. * The position of the vr experience helper.
  120040. */
  120041. get position(): Vector3;
  120042. /**
  120043. * Sets the position of the vr experience helper.
  120044. */
  120045. set position(value: Vector3);
  120046. /**
  120047. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120048. */
  120049. enableInteractions(): void;
  120050. private get _noControllerIsActive();
  120051. private beforeRender;
  120052. private _isTeleportationFloor;
  120053. /**
  120054. * Adds a floor mesh to be used for teleportation.
  120055. * @param floorMesh the mesh to be used for teleportation.
  120056. */
  120057. addFloorMesh(floorMesh: Mesh): void;
  120058. /**
  120059. * Removes a floor mesh from being used for teleportation.
  120060. * @param floorMesh the mesh to be removed.
  120061. */
  120062. removeFloorMesh(floorMesh: Mesh): void;
  120063. /**
  120064. * Enables interactions and teleportation using the VR controllers and gaze.
  120065. * @param vrTeleportationOptions options to modify teleportation behavior.
  120066. */
  120067. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120068. private _onNewGamepadConnected;
  120069. private _tryEnableInteractionOnController;
  120070. private _onNewGamepadDisconnected;
  120071. private _enableInteractionOnController;
  120072. private _checkTeleportWithRay;
  120073. private _checkRotate;
  120074. private _checkTeleportBackwards;
  120075. private _enableTeleportationOnController;
  120076. private _createTeleportationCircles;
  120077. private _displayTeleportationTarget;
  120078. private _hideTeleportationTarget;
  120079. private _rotateCamera;
  120080. private _moveTeleportationSelectorTo;
  120081. private _workingVector;
  120082. private _workingQuaternion;
  120083. private _workingMatrix;
  120084. /**
  120085. * Time Constant Teleportation Mode
  120086. */
  120087. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120088. /**
  120089. * Speed Constant Teleportation Mode
  120090. */
  120091. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120092. /**
  120093. * Teleports the users feet to the desired location
  120094. * @param location The location where the user's feet should be placed
  120095. */
  120096. teleportCamera(location: Vector3): void;
  120097. private _convertNormalToDirectionOfRay;
  120098. private _castRayAndSelectObject;
  120099. private _notifySelectedMeshUnselected;
  120100. /**
  120101. * Permanently set new colors for the laser pointer
  120102. * @param color the new laser color
  120103. * @param pickedColor the new laser color when picked mesh detected
  120104. */
  120105. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120106. /**
  120107. * Set lighting enabled / disabled on the laser pointer of both controllers
  120108. * @param enabled should the lighting be enabled on the laser pointer
  120109. */
  120110. setLaserLightingState(enabled?: boolean): void;
  120111. /**
  120112. * Permanently set new colors for the gaze pointer
  120113. * @param color the new gaze color
  120114. * @param pickedColor the new gaze color when picked mesh detected
  120115. */
  120116. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120117. /**
  120118. * Sets the color of the laser ray from the vr controllers.
  120119. * @param color new color for the ray.
  120120. */
  120121. changeLaserColor(color: Color3): void;
  120122. /**
  120123. * Sets the color of the ray from the vr headsets gaze.
  120124. * @param color new color for the ray.
  120125. */
  120126. changeGazeColor(color: Color3): void;
  120127. /**
  120128. * Exits VR and disposes of the vr experience helper
  120129. */
  120130. dispose(): void;
  120131. /**
  120132. * Gets the name of the VRExperienceHelper class
  120133. * @returns "VRExperienceHelper"
  120134. */
  120135. getClassName(): string;
  120136. }
  120137. }
  120138. declare module BABYLON {
  120139. /**
  120140. * Contains an array of blocks representing the octree
  120141. */
  120142. export interface IOctreeContainer<T> {
  120143. /**
  120144. * Blocks within the octree
  120145. */
  120146. blocks: Array<OctreeBlock<T>>;
  120147. }
  120148. /**
  120149. * Class used to store a cell in an octree
  120150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120151. */
  120152. export class OctreeBlock<T> {
  120153. /**
  120154. * Gets the content of the current block
  120155. */
  120156. entries: T[];
  120157. /**
  120158. * Gets the list of block children
  120159. */
  120160. blocks: Array<OctreeBlock<T>>;
  120161. private _depth;
  120162. private _maxDepth;
  120163. private _capacity;
  120164. private _minPoint;
  120165. private _maxPoint;
  120166. private _boundingVectors;
  120167. private _creationFunc;
  120168. /**
  120169. * Creates a new block
  120170. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120171. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120172. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120173. * @param depth defines the current depth of this block in the octree
  120174. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120175. * @param creationFunc defines a callback to call when an element is added to the block
  120176. */
  120177. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120178. /**
  120179. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120180. */
  120181. get capacity(): number;
  120182. /**
  120183. * Gets the minimum vector (in world space) of the block's bounding box
  120184. */
  120185. get minPoint(): Vector3;
  120186. /**
  120187. * Gets the maximum vector (in world space) of the block's bounding box
  120188. */
  120189. get maxPoint(): Vector3;
  120190. /**
  120191. * Add a new element to this block
  120192. * @param entry defines the element to add
  120193. */
  120194. addEntry(entry: T): void;
  120195. /**
  120196. * Remove an element from this block
  120197. * @param entry defines the element to remove
  120198. */
  120199. removeEntry(entry: T): void;
  120200. /**
  120201. * Add an array of elements to this block
  120202. * @param entries defines the array of elements to add
  120203. */
  120204. addEntries(entries: T[]): void;
  120205. /**
  120206. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120207. * @param frustumPlanes defines the frustum planes to test
  120208. * @param selection defines the array to store current content if selection is positive
  120209. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120210. */
  120211. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120212. /**
  120213. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120214. * @param sphereCenter defines the bounding sphere center
  120215. * @param sphereRadius defines the bounding sphere radius
  120216. * @param selection defines the array to store current content if selection is positive
  120217. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120218. */
  120219. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120220. /**
  120221. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120222. * @param ray defines the ray to test with
  120223. * @param selection defines the array to store current content if selection is positive
  120224. */
  120225. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120226. /**
  120227. * Subdivide the content into child blocks (this block will then be empty)
  120228. */
  120229. createInnerBlocks(): void;
  120230. /**
  120231. * @hidden
  120232. */
  120233. 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;
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /**
  120238. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120240. */
  120241. export class Octree<T> {
  120242. /** 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.) */
  120243. maxDepth: number;
  120244. /**
  120245. * Blocks within the octree containing objects
  120246. */
  120247. blocks: Array<OctreeBlock<T>>;
  120248. /**
  120249. * Content stored in the octree
  120250. */
  120251. dynamicContent: T[];
  120252. private _maxBlockCapacity;
  120253. private _selectionContent;
  120254. private _creationFunc;
  120255. /**
  120256. * Creates a octree
  120257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120258. * @param creationFunc function to be used to instatiate the octree
  120259. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120260. * @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.)
  120261. */
  120262. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120263. /** 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.) */
  120264. maxDepth?: number);
  120265. /**
  120266. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120267. * @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);
  120268. * @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);
  120269. * @param entries meshes to be added to the octree blocks
  120270. */
  120271. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120272. /**
  120273. * Adds a mesh to the octree
  120274. * @param entry Mesh to add to the octree
  120275. */
  120276. addMesh(entry: T): void;
  120277. /**
  120278. * Remove an element from the octree
  120279. * @param entry defines the element to remove
  120280. */
  120281. removeMesh(entry: T): void;
  120282. /**
  120283. * Selects an array of meshes within the frustum
  120284. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120285. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120286. * @returns array of meshes within the frustum
  120287. */
  120288. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120289. /**
  120290. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120291. * @param sphereCenter defines the bounding sphere center
  120292. * @param sphereRadius defines the bounding sphere radius
  120293. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120294. * @returns an array of objects that intersect the sphere
  120295. */
  120296. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120297. /**
  120298. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120299. * @param ray defines the ray to test with
  120300. * @returns array of intersected objects
  120301. */
  120302. intersectsRay(ray: Ray): SmartArray<T>;
  120303. /**
  120304. * Adds a mesh into the octree block if it intersects the block
  120305. */
  120306. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120307. /**
  120308. * Adds a submesh into the octree block if it intersects the block
  120309. */
  120310. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120311. }
  120312. }
  120313. declare module BABYLON {
  120314. interface Scene {
  120315. /**
  120316. * @hidden
  120317. * Backing Filed
  120318. */
  120319. _selectionOctree: Octree<AbstractMesh>;
  120320. /**
  120321. * Gets the octree used to boost mesh selection (picking)
  120322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120323. */
  120324. selectionOctree: Octree<AbstractMesh>;
  120325. /**
  120326. * Creates or updates the octree used to boost selection (picking)
  120327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120328. * @param maxCapacity defines the maximum capacity per leaf
  120329. * @param maxDepth defines the maximum depth of the octree
  120330. * @returns an octree of AbstractMesh
  120331. */
  120332. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120333. }
  120334. interface AbstractMesh {
  120335. /**
  120336. * @hidden
  120337. * Backing Field
  120338. */
  120339. _submeshesOctree: Octree<SubMesh>;
  120340. /**
  120341. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120342. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120343. * @param maxCapacity defines the maximum size of each block (64 by default)
  120344. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120345. * @returns the new octree
  120346. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120348. */
  120349. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120350. }
  120351. /**
  120352. * Defines the octree scene component responsible to manage any octrees
  120353. * in a given scene.
  120354. */
  120355. export class OctreeSceneComponent {
  120356. /**
  120357. * The component name help to identify the component in the list of scene components.
  120358. */
  120359. readonly name: string;
  120360. /**
  120361. * The scene the component belongs to.
  120362. */
  120363. scene: Scene;
  120364. /**
  120365. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120366. */
  120367. readonly checksIsEnabled: boolean;
  120368. /**
  120369. * Creates a new instance of the component for the given scene
  120370. * @param scene Defines the scene to register the component in
  120371. */
  120372. constructor(scene: Scene);
  120373. /**
  120374. * Registers the component in a given scene
  120375. */
  120376. register(): void;
  120377. /**
  120378. * Return the list of active meshes
  120379. * @returns the list of active meshes
  120380. */
  120381. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120382. /**
  120383. * Return the list of active sub meshes
  120384. * @param mesh The mesh to get the candidates sub meshes from
  120385. * @returns the list of active sub meshes
  120386. */
  120387. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120388. private _tempRay;
  120389. /**
  120390. * Return the list of sub meshes intersecting with a given local ray
  120391. * @param mesh defines the mesh to find the submesh for
  120392. * @param localRay defines the ray in local space
  120393. * @returns the list of intersecting sub meshes
  120394. */
  120395. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120396. /**
  120397. * Return the list of sub meshes colliding with a collider
  120398. * @param mesh defines the mesh to find the submesh for
  120399. * @param collider defines the collider to evaluate the collision against
  120400. * @returns the list of colliding sub meshes
  120401. */
  120402. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120403. /**
  120404. * Rebuilds the elements related to this component in case of
  120405. * context lost for instance.
  120406. */
  120407. rebuild(): void;
  120408. /**
  120409. * Disposes the component and the associated ressources.
  120410. */
  120411. dispose(): void;
  120412. }
  120413. }
  120414. declare module BABYLON {
  120415. /**
  120416. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120417. */
  120418. export class Gizmo implements IDisposable {
  120419. /** The utility layer the gizmo will be added to */
  120420. gizmoLayer: UtilityLayerRenderer;
  120421. /**
  120422. * The root mesh of the gizmo
  120423. */
  120424. _rootMesh: Mesh;
  120425. private _attachedMesh;
  120426. /**
  120427. * Ratio for the scale of the gizmo (Default: 1)
  120428. */
  120429. scaleRatio: number;
  120430. /**
  120431. * If a custom mesh has been set (Default: false)
  120432. */
  120433. protected _customMeshSet: boolean;
  120434. /**
  120435. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120436. * * When set, interactions will be enabled
  120437. */
  120438. get attachedMesh(): Nullable<AbstractMesh>;
  120439. set attachedMesh(value: Nullable<AbstractMesh>);
  120440. /**
  120441. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120442. * @param mesh The mesh to replace the default mesh of the gizmo
  120443. */
  120444. setCustomMesh(mesh: Mesh): void;
  120445. /**
  120446. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120447. */
  120448. updateGizmoRotationToMatchAttachedMesh: boolean;
  120449. /**
  120450. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120451. */
  120452. updateGizmoPositionToMatchAttachedMesh: boolean;
  120453. /**
  120454. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120455. */
  120456. updateScale: boolean;
  120457. protected _interactionsEnabled: boolean;
  120458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120459. private _beforeRenderObserver;
  120460. private _tempVector;
  120461. /**
  120462. * Creates a gizmo
  120463. * @param gizmoLayer The utility layer the gizmo will be added to
  120464. */
  120465. constructor(
  120466. /** The utility layer the gizmo will be added to */
  120467. gizmoLayer?: UtilityLayerRenderer);
  120468. /**
  120469. * Updates the gizmo to match the attached mesh's position/rotation
  120470. */
  120471. protected _update(): void;
  120472. /**
  120473. * Disposes of the gizmo
  120474. */
  120475. dispose(): void;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * Single plane drag gizmo
  120481. */
  120482. export class PlaneDragGizmo extends Gizmo {
  120483. /**
  120484. * Drag behavior responsible for the gizmos dragging interactions
  120485. */
  120486. dragBehavior: PointerDragBehavior;
  120487. private _pointerObserver;
  120488. /**
  120489. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120490. */
  120491. snapDistance: number;
  120492. /**
  120493. * Event that fires each time the gizmo snaps to a new location.
  120494. * * snapDistance is the the change in distance
  120495. */
  120496. onSnapObservable: Observable<{
  120497. snapDistance: number;
  120498. }>;
  120499. private _plane;
  120500. private _coloredMaterial;
  120501. private _hoverMaterial;
  120502. private _isEnabled;
  120503. private _parent;
  120504. /** @hidden */
  120505. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120506. /** @hidden */
  120507. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120508. /**
  120509. * Creates a PlaneDragGizmo
  120510. * @param gizmoLayer The utility layer the gizmo will be added to
  120511. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120512. * @param color The color of the gizmo
  120513. */
  120514. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120515. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120516. /**
  120517. * If the gizmo is enabled
  120518. */
  120519. set isEnabled(value: boolean);
  120520. get isEnabled(): boolean;
  120521. /**
  120522. * Disposes of the gizmo
  120523. */
  120524. dispose(): void;
  120525. }
  120526. }
  120527. declare module BABYLON {
  120528. /**
  120529. * Gizmo that enables dragging a mesh along 3 axis
  120530. */
  120531. export class PositionGizmo extends Gizmo {
  120532. /**
  120533. * Internal gizmo used for interactions on the x axis
  120534. */
  120535. xGizmo: AxisDragGizmo;
  120536. /**
  120537. * Internal gizmo used for interactions on the y axis
  120538. */
  120539. yGizmo: AxisDragGizmo;
  120540. /**
  120541. * Internal gizmo used for interactions on the z axis
  120542. */
  120543. zGizmo: AxisDragGizmo;
  120544. /**
  120545. * Internal gizmo used for interactions on the yz plane
  120546. */
  120547. xPlaneGizmo: PlaneDragGizmo;
  120548. /**
  120549. * Internal gizmo used for interactions on the xz plane
  120550. */
  120551. yPlaneGizmo: PlaneDragGizmo;
  120552. /**
  120553. * Internal gizmo used for interactions on the xy plane
  120554. */
  120555. zPlaneGizmo: PlaneDragGizmo;
  120556. /**
  120557. * private variables
  120558. */
  120559. private _meshAttached;
  120560. private _updateGizmoRotationToMatchAttachedMesh;
  120561. private _snapDistance;
  120562. private _scaleRatio;
  120563. /** Fires an event when any of it's sub gizmos are dragged */
  120564. onDragStartObservable: Observable<unknown>;
  120565. /** Fires an event when any of it's sub gizmos are released from dragging */
  120566. onDragEndObservable: Observable<unknown>;
  120567. /**
  120568. * If set to true, planar drag is enabled
  120569. */
  120570. private _planarGizmoEnabled;
  120571. get attachedMesh(): Nullable<AbstractMesh>;
  120572. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120573. /**
  120574. * Creates a PositionGizmo
  120575. * @param gizmoLayer The utility layer the gizmo will be added to
  120576. */
  120577. constructor(gizmoLayer?: UtilityLayerRenderer);
  120578. /**
  120579. * If the planar drag gizmo is enabled
  120580. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120581. */
  120582. set planarGizmoEnabled(value: boolean);
  120583. get planarGizmoEnabled(): boolean;
  120584. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120585. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120586. /**
  120587. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120588. */
  120589. set snapDistance(value: number);
  120590. get snapDistance(): number;
  120591. /**
  120592. * Ratio for the scale of the gizmo (Default: 1)
  120593. */
  120594. set scaleRatio(value: number);
  120595. get scaleRatio(): number;
  120596. /**
  120597. * Disposes of the gizmo
  120598. */
  120599. dispose(): void;
  120600. /**
  120601. * CustomMeshes are not supported by this gizmo
  120602. * @param mesh The mesh to replace the default mesh of the gizmo
  120603. */
  120604. setCustomMesh(mesh: Mesh): void;
  120605. }
  120606. }
  120607. declare module BABYLON {
  120608. /**
  120609. * Single axis drag gizmo
  120610. */
  120611. export class AxisDragGizmo extends Gizmo {
  120612. /**
  120613. * Drag behavior responsible for the gizmos dragging interactions
  120614. */
  120615. dragBehavior: PointerDragBehavior;
  120616. private _pointerObserver;
  120617. /**
  120618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120619. */
  120620. snapDistance: number;
  120621. /**
  120622. * Event that fires each time the gizmo snaps to a new location.
  120623. * * snapDistance is the the change in distance
  120624. */
  120625. onSnapObservable: Observable<{
  120626. snapDistance: number;
  120627. }>;
  120628. private _isEnabled;
  120629. private _parent;
  120630. private _arrow;
  120631. private _coloredMaterial;
  120632. private _hoverMaterial;
  120633. /** @hidden */
  120634. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120635. /** @hidden */
  120636. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120637. /**
  120638. * Creates an AxisDragGizmo
  120639. * @param gizmoLayer The utility layer the gizmo will be added to
  120640. * @param dragAxis The axis which the gizmo will be able to drag on
  120641. * @param color The color of the gizmo
  120642. */
  120643. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120645. /**
  120646. * If the gizmo is enabled
  120647. */
  120648. set isEnabled(value: boolean);
  120649. get isEnabled(): boolean;
  120650. /**
  120651. * Disposes of the gizmo
  120652. */
  120653. dispose(): void;
  120654. }
  120655. }
  120656. declare module BABYLON.Debug {
  120657. /**
  120658. * The Axes viewer will show 3 axes in a specific point in space
  120659. */
  120660. export class AxesViewer {
  120661. private _xAxis;
  120662. private _yAxis;
  120663. private _zAxis;
  120664. private _scaleLinesFactor;
  120665. private _instanced;
  120666. /**
  120667. * Gets the hosting scene
  120668. */
  120669. scene: Scene;
  120670. /**
  120671. * Gets or sets a number used to scale line length
  120672. */
  120673. scaleLines: number;
  120674. /** Gets the node hierarchy used to render x-axis */
  120675. get xAxis(): TransformNode;
  120676. /** Gets the node hierarchy used to render y-axis */
  120677. get yAxis(): TransformNode;
  120678. /** Gets the node hierarchy used to render z-axis */
  120679. get zAxis(): TransformNode;
  120680. /**
  120681. * Creates a new AxesViewer
  120682. * @param scene defines the hosting scene
  120683. * @param scaleLines defines a number used to scale line length (1 by default)
  120684. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120685. * @param xAxis defines the node hierarchy used to render the x-axis
  120686. * @param yAxis defines the node hierarchy used to render the y-axis
  120687. * @param zAxis defines the node hierarchy used to render the z-axis
  120688. */
  120689. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120690. /**
  120691. * Force the viewer to update
  120692. * @param position defines the position of the viewer
  120693. * @param xaxis defines the x axis of the viewer
  120694. * @param yaxis defines the y axis of the viewer
  120695. * @param zaxis defines the z axis of the viewer
  120696. */
  120697. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120698. /**
  120699. * Creates an instance of this axes viewer.
  120700. * @returns a new axes viewer with instanced meshes
  120701. */
  120702. createInstance(): AxesViewer;
  120703. /** Releases resources */
  120704. dispose(): void;
  120705. private static _SetRenderingGroupId;
  120706. }
  120707. }
  120708. declare module BABYLON.Debug {
  120709. /**
  120710. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120711. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120712. */
  120713. export class BoneAxesViewer extends AxesViewer {
  120714. /**
  120715. * Gets or sets the target mesh where to display the axes viewer
  120716. */
  120717. mesh: Nullable<Mesh>;
  120718. /**
  120719. * Gets or sets the target bone where to display the axes viewer
  120720. */
  120721. bone: Nullable<Bone>;
  120722. /** Gets current position */
  120723. pos: Vector3;
  120724. /** Gets direction of X axis */
  120725. xaxis: Vector3;
  120726. /** Gets direction of Y axis */
  120727. yaxis: Vector3;
  120728. /** Gets direction of Z axis */
  120729. zaxis: Vector3;
  120730. /**
  120731. * Creates a new BoneAxesViewer
  120732. * @param scene defines the hosting scene
  120733. * @param bone defines the target bone
  120734. * @param mesh defines the target mesh
  120735. * @param scaleLines defines a scaling factor for line length (1 by default)
  120736. */
  120737. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120738. /**
  120739. * Force the viewer to update
  120740. */
  120741. update(): void;
  120742. /** Releases resources */
  120743. dispose(): void;
  120744. }
  120745. }
  120746. declare module BABYLON {
  120747. /**
  120748. * Interface used to define scene explorer extensibility option
  120749. */
  120750. export interface IExplorerExtensibilityOption {
  120751. /**
  120752. * Define the option label
  120753. */
  120754. label: string;
  120755. /**
  120756. * Defines the action to execute on click
  120757. */
  120758. action: (entity: any) => void;
  120759. }
  120760. /**
  120761. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120762. */
  120763. export interface IExplorerExtensibilityGroup {
  120764. /**
  120765. * Defines a predicate to test if a given type mut be extended
  120766. */
  120767. predicate: (entity: any) => boolean;
  120768. /**
  120769. * Gets the list of options added to a type
  120770. */
  120771. entries: IExplorerExtensibilityOption[];
  120772. }
  120773. /**
  120774. * Interface used to define the options to use to create the Inspector
  120775. */
  120776. export interface IInspectorOptions {
  120777. /**
  120778. * Display in overlay mode (default: false)
  120779. */
  120780. overlay?: boolean;
  120781. /**
  120782. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120783. */
  120784. globalRoot?: HTMLElement;
  120785. /**
  120786. * Display the Scene explorer
  120787. */
  120788. showExplorer?: boolean;
  120789. /**
  120790. * Display the property inspector
  120791. */
  120792. showInspector?: boolean;
  120793. /**
  120794. * Display in embed mode (both panes on the right)
  120795. */
  120796. embedMode?: boolean;
  120797. /**
  120798. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120799. */
  120800. handleResize?: boolean;
  120801. /**
  120802. * Allow the panes to popup (default: true)
  120803. */
  120804. enablePopup?: boolean;
  120805. /**
  120806. * Allow the panes to be closed by users (default: true)
  120807. */
  120808. enableClose?: boolean;
  120809. /**
  120810. * Optional list of extensibility entries
  120811. */
  120812. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120813. /**
  120814. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120815. */
  120816. inspectorURL?: string;
  120817. /**
  120818. * Optional initial tab (default to DebugLayerTab.Properties)
  120819. */
  120820. initialTab?: DebugLayerTab;
  120821. }
  120822. interface Scene {
  120823. /**
  120824. * @hidden
  120825. * Backing field
  120826. */
  120827. _debugLayer: DebugLayer;
  120828. /**
  120829. * Gets the debug layer (aka Inspector) associated with the scene
  120830. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120831. */
  120832. debugLayer: DebugLayer;
  120833. }
  120834. /**
  120835. * Enum of inspector action tab
  120836. */
  120837. export enum DebugLayerTab {
  120838. /**
  120839. * Properties tag (default)
  120840. */
  120841. Properties = 0,
  120842. /**
  120843. * Debug tab
  120844. */
  120845. Debug = 1,
  120846. /**
  120847. * Statistics tab
  120848. */
  120849. Statistics = 2,
  120850. /**
  120851. * Tools tab
  120852. */
  120853. Tools = 3,
  120854. /**
  120855. * Settings tab
  120856. */
  120857. Settings = 4
  120858. }
  120859. /**
  120860. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120861. * what is happening in your scene
  120862. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120863. */
  120864. export class DebugLayer {
  120865. /**
  120866. * Define the url to get the inspector script from.
  120867. * By default it uses the babylonjs CDN.
  120868. * @ignoreNaming
  120869. */
  120870. static InspectorURL: string;
  120871. private _scene;
  120872. private BJSINSPECTOR;
  120873. private _onPropertyChangedObservable?;
  120874. /**
  120875. * Observable triggered when a property is changed through the inspector.
  120876. */
  120877. get onPropertyChangedObservable(): any;
  120878. /**
  120879. * Instantiates a new debug layer.
  120880. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120881. * what is happening in your scene
  120882. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120883. * @param scene Defines the scene to inspect
  120884. */
  120885. constructor(scene: Scene);
  120886. /** Creates the inspector window. */
  120887. private _createInspector;
  120888. /**
  120889. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120890. * @param entity defines the entity to select
  120891. * @param lineContainerTitle defines the specific block to highlight
  120892. */
  120893. select(entity: any, lineContainerTitle?: string): void;
  120894. /** Get the inspector from bundle or global */
  120895. private _getGlobalInspector;
  120896. /**
  120897. * Get if the inspector is visible or not.
  120898. * @returns true if visible otherwise, false
  120899. */
  120900. isVisible(): boolean;
  120901. /**
  120902. * Hide the inspector and close its window.
  120903. */
  120904. hide(): void;
  120905. /**
  120906. * Launch the debugLayer.
  120907. * @param config Define the configuration of the inspector
  120908. * @return a promise fulfilled when the debug layer is visible
  120909. */
  120910. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120911. }
  120912. }
  120913. declare module BABYLON {
  120914. /**
  120915. * Class containing static functions to help procedurally build meshes
  120916. */
  120917. export class BoxBuilder {
  120918. /**
  120919. * Creates a box mesh
  120920. * * The parameter `size` sets the size (float) of each box side (default 1)
  120921. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120922. * * 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)
  120923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120928. * @param name defines the name of the mesh
  120929. * @param options defines the options used to create the mesh
  120930. * @param scene defines the hosting scene
  120931. * @returns the box mesh
  120932. */
  120933. static CreateBox(name: string, options: {
  120934. size?: number;
  120935. width?: number;
  120936. height?: number;
  120937. depth?: number;
  120938. faceUV?: Vector4[];
  120939. faceColors?: Color4[];
  120940. sideOrientation?: number;
  120941. frontUVs?: Vector4;
  120942. backUVs?: Vector4;
  120943. wrap?: boolean;
  120944. topBaseAt?: number;
  120945. bottomBaseAt?: number;
  120946. updatable?: boolean;
  120947. }, scene?: Nullable<Scene>): Mesh;
  120948. }
  120949. }
  120950. declare module BABYLON.Debug {
  120951. /**
  120952. * Used to show the physics impostor around the specific mesh
  120953. */
  120954. export class PhysicsViewer {
  120955. /** @hidden */
  120956. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120957. /** @hidden */
  120958. protected _meshes: Array<Nullable<AbstractMesh>>;
  120959. /** @hidden */
  120960. protected _scene: Nullable<Scene>;
  120961. /** @hidden */
  120962. protected _numMeshes: number;
  120963. /** @hidden */
  120964. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120965. private _renderFunction;
  120966. private _utilityLayer;
  120967. private _debugBoxMesh;
  120968. private _debugSphereMesh;
  120969. private _debugCylinderMesh;
  120970. private _debugMaterial;
  120971. private _debugMeshMeshes;
  120972. /**
  120973. * Creates a new PhysicsViewer
  120974. * @param scene defines the hosting scene
  120975. */
  120976. constructor(scene: Scene);
  120977. /** @hidden */
  120978. protected _updateDebugMeshes(): void;
  120979. /**
  120980. * Renders a specified physic impostor
  120981. * @param impostor defines the impostor to render
  120982. * @param targetMesh defines the mesh represented by the impostor
  120983. * @returns the new debug mesh used to render the impostor
  120984. */
  120985. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120986. /**
  120987. * Hides a specified physic impostor
  120988. * @param impostor defines the impostor to hide
  120989. */
  120990. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120991. private _getDebugMaterial;
  120992. private _getDebugBoxMesh;
  120993. private _getDebugSphereMesh;
  120994. private _getDebugCylinderMesh;
  120995. private _getDebugMeshMesh;
  120996. private _getDebugMesh;
  120997. /** Releases all resources */
  120998. dispose(): void;
  120999. }
  121000. }
  121001. declare module BABYLON {
  121002. /**
  121003. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121004. * in order to better appreciate the issue one might have.
  121005. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121006. */
  121007. export class RayHelper {
  121008. /**
  121009. * Defines the ray we are currently tryin to visualize.
  121010. */
  121011. ray: Nullable<Ray>;
  121012. private _renderPoints;
  121013. private _renderLine;
  121014. private _renderFunction;
  121015. private _scene;
  121016. private _updateToMeshFunction;
  121017. private _attachedToMesh;
  121018. private _meshSpaceDirection;
  121019. private _meshSpaceOrigin;
  121020. /**
  121021. * Helper function to create a colored helper in a scene in one line.
  121022. * @param ray Defines the ray we are currently tryin to visualize
  121023. * @param scene Defines the scene the ray is used in
  121024. * @param color Defines the color we want to see the ray in
  121025. * @returns The newly created ray helper.
  121026. */
  121027. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121028. /**
  121029. * Instantiate a new ray helper.
  121030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121031. * in order to better appreciate the issue one might have.
  121032. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121033. * @param ray Defines the ray we are currently tryin to visualize
  121034. */
  121035. constructor(ray: Ray);
  121036. /**
  121037. * Shows the ray we are willing to debug.
  121038. * @param scene Defines the scene the ray needs to be rendered in
  121039. * @param color Defines the color the ray needs to be rendered in
  121040. */
  121041. show(scene: Scene, color?: Color3): void;
  121042. /**
  121043. * Hides the ray we are debugging.
  121044. */
  121045. hide(): void;
  121046. private _render;
  121047. /**
  121048. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121049. * @param mesh Defines the mesh we want the helper attached to
  121050. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121051. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121052. * @param length Defines the length of the ray
  121053. */
  121054. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121055. /**
  121056. * Detach the ray helper from the mesh it has previously been attached to.
  121057. */
  121058. detachFromMesh(): void;
  121059. private _updateToMesh;
  121060. /**
  121061. * Dispose the helper and release its associated resources.
  121062. */
  121063. dispose(): void;
  121064. }
  121065. }
  121066. declare module BABYLON.Debug {
  121067. /**
  121068. * Class used to render a debug view of a given skeleton
  121069. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121070. */
  121071. export class SkeletonViewer {
  121072. /** defines the skeleton to render */
  121073. skeleton: Skeleton;
  121074. /** defines the mesh attached to the skeleton */
  121075. mesh: AbstractMesh;
  121076. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121077. autoUpdateBonesMatrices: boolean;
  121078. /** defines the rendering group id to use with the viewer */
  121079. renderingGroupId: number;
  121080. /** Gets or sets the color used to render the skeleton */
  121081. color: Color3;
  121082. private _scene;
  121083. private _debugLines;
  121084. private _debugMesh;
  121085. private _isEnabled;
  121086. private _renderFunction;
  121087. private _utilityLayer;
  121088. /**
  121089. * Returns the mesh used to render the bones
  121090. */
  121091. get debugMesh(): Nullable<LinesMesh>;
  121092. /**
  121093. * Creates a new SkeletonViewer
  121094. * @param skeleton defines the skeleton to render
  121095. * @param mesh defines the mesh attached to the skeleton
  121096. * @param scene defines the hosting scene
  121097. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121098. * @param renderingGroupId defines the rendering group id to use with the viewer
  121099. */
  121100. constructor(
  121101. /** defines the skeleton to render */
  121102. skeleton: Skeleton,
  121103. /** defines the mesh attached to the skeleton */
  121104. mesh: AbstractMesh, scene: Scene,
  121105. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121106. autoUpdateBonesMatrices?: boolean,
  121107. /** defines the rendering group id to use with the viewer */
  121108. renderingGroupId?: number);
  121109. /** Gets or sets a boolean indicating if the viewer is enabled */
  121110. set isEnabled(value: boolean);
  121111. get isEnabled(): boolean;
  121112. private _getBonePosition;
  121113. private _getLinesForBonesWithLength;
  121114. private _getLinesForBonesNoLength;
  121115. /** Update the viewer to sync with current skeleton state */
  121116. update(): void;
  121117. /** Release associated resources */
  121118. dispose(): void;
  121119. }
  121120. }
  121121. declare module BABYLON {
  121122. /**
  121123. * Options to create the null engine
  121124. */
  121125. export class NullEngineOptions {
  121126. /**
  121127. * Render width (Default: 512)
  121128. */
  121129. renderWidth: number;
  121130. /**
  121131. * Render height (Default: 256)
  121132. */
  121133. renderHeight: number;
  121134. /**
  121135. * Texture size (Default: 512)
  121136. */
  121137. textureSize: number;
  121138. /**
  121139. * If delta time between frames should be constant
  121140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121141. */
  121142. deterministicLockstep: boolean;
  121143. /**
  121144. * Maximum about of steps between frames (Default: 4)
  121145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121146. */
  121147. lockstepMaxSteps: number;
  121148. }
  121149. /**
  121150. * The null engine class provides support for headless version of babylon.js.
  121151. * This can be used in server side scenario or for testing purposes
  121152. */
  121153. export class NullEngine extends Engine {
  121154. private _options;
  121155. /**
  121156. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121158. * @returns true if engine is in deterministic lock step mode
  121159. */
  121160. isDeterministicLockStep(): boolean;
  121161. /**
  121162. * Gets the max steps when engine is running in deterministic lock step
  121163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121164. * @returns the max steps
  121165. */
  121166. getLockstepMaxSteps(): number;
  121167. /**
  121168. * Gets the current hardware scaling level.
  121169. * By default the hardware scaling level is computed from the window device ratio.
  121170. * 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.
  121171. * @returns a number indicating the current hardware scaling level
  121172. */
  121173. getHardwareScalingLevel(): number;
  121174. constructor(options?: NullEngineOptions);
  121175. /**
  121176. * Creates a vertex buffer
  121177. * @param vertices the data for the vertex buffer
  121178. * @returns the new WebGL static buffer
  121179. */
  121180. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121181. /**
  121182. * Creates a new index buffer
  121183. * @param indices defines the content of the index buffer
  121184. * @param updatable defines if the index buffer must be updatable
  121185. * @returns a new webGL buffer
  121186. */
  121187. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121188. /**
  121189. * Clear the current render buffer or the current render target (if any is set up)
  121190. * @param color defines the color to use
  121191. * @param backBuffer defines if the back buffer must be cleared
  121192. * @param depth defines if the depth buffer must be cleared
  121193. * @param stencil defines if the stencil buffer must be cleared
  121194. */
  121195. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121196. /**
  121197. * Gets the current render width
  121198. * @param useScreen defines if screen size must be used (or the current render target if any)
  121199. * @returns a number defining the current render width
  121200. */
  121201. getRenderWidth(useScreen?: boolean): number;
  121202. /**
  121203. * Gets the current render height
  121204. * @param useScreen defines if screen size must be used (or the current render target if any)
  121205. * @returns a number defining the current render height
  121206. */
  121207. getRenderHeight(useScreen?: boolean): number;
  121208. /**
  121209. * Set the WebGL's viewport
  121210. * @param viewport defines the viewport element to be used
  121211. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121212. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121213. */
  121214. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121215. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121216. /**
  121217. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121218. * @param pipelineContext defines the pipeline context to use
  121219. * @param uniformsNames defines the list of uniform names
  121220. * @returns an array of webGL uniform locations
  121221. */
  121222. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121223. /**
  121224. * Gets the lsit of active attributes for a given webGL program
  121225. * @param pipelineContext defines the pipeline context to use
  121226. * @param attributesNames defines the list of attribute names to get
  121227. * @returns an array of indices indicating the offset of each attribute
  121228. */
  121229. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121230. /**
  121231. * Binds an effect to the webGL context
  121232. * @param effect defines the effect to bind
  121233. */
  121234. bindSamplers(effect: Effect): void;
  121235. /**
  121236. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121237. * @param effect defines the effect to activate
  121238. */
  121239. enableEffect(effect: Effect): void;
  121240. /**
  121241. * Set various states to the webGL context
  121242. * @param culling defines backface culling state
  121243. * @param zOffset defines the value to apply to zOffset (0 by default)
  121244. * @param force defines if states must be applied even if cache is up to date
  121245. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121246. */
  121247. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121248. /**
  121249. * Set the value of an uniform to an array of int32
  121250. * @param uniform defines the webGL uniform location where to store the value
  121251. * @param array defines the array of int32 to store
  121252. */
  121253. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121254. /**
  121255. * Set the value of an uniform to an array of int32 (stored as vec2)
  121256. * @param uniform defines the webGL uniform location where to store the value
  121257. * @param array defines the array of int32 to store
  121258. */
  121259. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121260. /**
  121261. * Set the value of an uniform to an array of int32 (stored as vec3)
  121262. * @param uniform defines the webGL uniform location where to store the value
  121263. * @param array defines the array of int32 to store
  121264. */
  121265. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121266. /**
  121267. * Set the value of an uniform to an array of int32 (stored as vec4)
  121268. * @param uniform defines the webGL uniform location where to store the value
  121269. * @param array defines the array of int32 to store
  121270. */
  121271. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121272. /**
  121273. * Set the value of an uniform to an array of float32
  121274. * @param uniform defines the webGL uniform location where to store the value
  121275. * @param array defines the array of float32 to store
  121276. */
  121277. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121278. /**
  121279. * Set the value of an uniform to an array of float32 (stored as vec2)
  121280. * @param uniform defines the webGL uniform location where to store the value
  121281. * @param array defines the array of float32 to store
  121282. */
  121283. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121284. /**
  121285. * Set the value of an uniform to an array of float32 (stored as vec3)
  121286. * @param uniform defines the webGL uniform location where to store the value
  121287. * @param array defines the array of float32 to store
  121288. */
  121289. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121290. /**
  121291. * Set the value of an uniform to an array of float32 (stored as vec4)
  121292. * @param uniform defines the webGL uniform location where to store the value
  121293. * @param array defines the array of float32 to store
  121294. */
  121295. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121296. /**
  121297. * Set the value of an uniform to an array of number
  121298. * @param uniform defines the webGL uniform location where to store the value
  121299. * @param array defines the array of number to store
  121300. */
  121301. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121302. /**
  121303. * Set the value of an uniform to an array of number (stored as vec2)
  121304. * @param uniform defines the webGL uniform location where to store the value
  121305. * @param array defines the array of number to store
  121306. */
  121307. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121308. /**
  121309. * Set the value of an uniform to an array of number (stored as vec3)
  121310. * @param uniform defines the webGL uniform location where to store the value
  121311. * @param array defines the array of number to store
  121312. */
  121313. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121314. /**
  121315. * Set the value of an uniform to an array of number (stored as vec4)
  121316. * @param uniform defines the webGL uniform location where to store the value
  121317. * @param array defines the array of number to store
  121318. */
  121319. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121320. /**
  121321. * Set the value of an uniform to an array of float32 (stored as matrices)
  121322. * @param uniform defines the webGL uniform location where to store the value
  121323. * @param matrices defines the array of float32 to store
  121324. */
  121325. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121326. /**
  121327. * Set the value of an uniform to a matrix (3x3)
  121328. * @param uniform defines the webGL uniform location where to store the value
  121329. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121330. */
  121331. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121332. /**
  121333. * Set the value of an uniform to a matrix (2x2)
  121334. * @param uniform defines the webGL uniform location where to store the value
  121335. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121336. */
  121337. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121338. /**
  121339. * Set the value of an uniform to a number (float)
  121340. * @param uniform defines the webGL uniform location where to store the value
  121341. * @param value defines the float number to store
  121342. */
  121343. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121344. /**
  121345. * Set the value of an uniform to a vec2
  121346. * @param uniform defines the webGL uniform location where to store the value
  121347. * @param x defines the 1st component of the value
  121348. * @param y defines the 2nd component of the value
  121349. */
  121350. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121351. /**
  121352. * Set the value of an uniform to a vec3
  121353. * @param uniform defines the webGL uniform location where to store the value
  121354. * @param x defines the 1st component of the value
  121355. * @param y defines the 2nd component of the value
  121356. * @param z defines the 3rd component of the value
  121357. */
  121358. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121359. /**
  121360. * Set the value of an uniform to a boolean
  121361. * @param uniform defines the webGL uniform location where to store the value
  121362. * @param bool defines the boolean to store
  121363. */
  121364. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121365. /**
  121366. * Set the value of an uniform to a vec4
  121367. * @param uniform defines the webGL uniform location where to store the value
  121368. * @param x defines the 1st component of the value
  121369. * @param y defines the 2nd component of the value
  121370. * @param z defines the 3rd component of the value
  121371. * @param w defines the 4th component of the value
  121372. */
  121373. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121374. /**
  121375. * Sets the current alpha mode
  121376. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121377. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121378. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121379. */
  121380. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121381. /**
  121382. * Bind webGl buffers directly to the webGL context
  121383. * @param vertexBuffers defines the vertex buffer to bind
  121384. * @param indexBuffer defines the index buffer to bind
  121385. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121386. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121387. * @param effect defines the effect associated with the vertex buffer
  121388. */
  121389. bindBuffers(vertexBuffers: {
  121390. [key: string]: VertexBuffer;
  121391. }, indexBuffer: DataBuffer, effect: Effect): void;
  121392. /**
  121393. * Force the entire cache to be cleared
  121394. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121395. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121396. */
  121397. wipeCaches(bruteForce?: boolean): void;
  121398. /**
  121399. * Send a draw order
  121400. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121401. * @param indexStart defines the starting index
  121402. * @param indexCount defines the number of index to draw
  121403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121404. */
  121405. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121406. /**
  121407. * Draw a list of indexed primitives
  121408. * @param fillMode defines the primitive to use
  121409. * @param indexStart defines the starting index
  121410. * @param indexCount defines the number of index to draw
  121411. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121412. */
  121413. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121414. /**
  121415. * Draw a list of unindexed primitives
  121416. * @param fillMode defines the primitive to use
  121417. * @param verticesStart defines the index of first vertex to draw
  121418. * @param verticesCount defines the count of vertices to draw
  121419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121420. */
  121421. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121422. /** @hidden */
  121423. _createTexture(): WebGLTexture;
  121424. /** @hidden */
  121425. _releaseTexture(texture: InternalTexture): void;
  121426. /**
  121427. * Usually called from Texture.ts.
  121428. * Passed information to create a WebGLTexture
  121429. * @param urlArg defines a value which contains one of the following:
  121430. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121431. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121432. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121433. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121434. * @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)
  121435. * @param scene needed for loading to the correct scene
  121436. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121437. * @param onLoad optional callback to be called upon successful completion
  121438. * @param onError optional callback to be called upon failure
  121439. * @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
  121440. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121441. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121442. * @param forcedExtension defines the extension to use to pick the right loader
  121443. * @param mimeType defines an optional mime type
  121444. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121445. */
  121446. 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;
  121447. /**
  121448. * Creates a new render target texture
  121449. * @param size defines the size of the texture
  121450. * @param options defines the options used to create the texture
  121451. * @returns a new render target texture stored in an InternalTexture
  121452. */
  121453. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121454. /**
  121455. * Update the sampling mode of a given texture
  121456. * @param samplingMode defines the required sampling mode
  121457. * @param texture defines the texture to update
  121458. */
  121459. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121460. /**
  121461. * Binds the frame buffer to the specified texture.
  121462. * @param texture The texture to render to or null for the default canvas
  121463. * @param faceIndex The face of the texture to render to in case of cube texture
  121464. * @param requiredWidth The width of the target to render to
  121465. * @param requiredHeight The height of the target to render to
  121466. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121467. * @param lodLevel defines le lod level to bind to the frame buffer
  121468. */
  121469. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121470. /**
  121471. * Unbind the current render target texture from the webGL context
  121472. * @param texture defines the render target texture to unbind
  121473. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121474. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121475. */
  121476. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121477. /**
  121478. * Creates a dynamic vertex buffer
  121479. * @param vertices the data for the dynamic vertex buffer
  121480. * @returns the new WebGL dynamic buffer
  121481. */
  121482. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121483. /**
  121484. * Update the content of a dynamic texture
  121485. * @param texture defines the texture to update
  121486. * @param canvas defines the canvas containing the source
  121487. * @param invertY defines if data must be stored with Y axis inverted
  121488. * @param premulAlpha defines if alpha is stored as premultiplied
  121489. * @param format defines the format of the data
  121490. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121491. */
  121492. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121493. /**
  121494. * Gets a boolean indicating if all created effects are ready
  121495. * @returns true if all effects are ready
  121496. */
  121497. areAllEffectsReady(): boolean;
  121498. /**
  121499. * @hidden
  121500. * Get the current error code of the webGL context
  121501. * @returns the error code
  121502. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121503. */
  121504. getError(): number;
  121505. /** @hidden */
  121506. _getUnpackAlignement(): number;
  121507. /** @hidden */
  121508. _unpackFlipY(value: boolean): void;
  121509. /**
  121510. * Update a dynamic index buffer
  121511. * @param indexBuffer defines the target index buffer
  121512. * @param indices defines the data to update
  121513. * @param offset defines the offset in the target index buffer where update should start
  121514. */
  121515. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121516. /**
  121517. * Updates a dynamic vertex buffer.
  121518. * @param vertexBuffer the vertex buffer to update
  121519. * @param vertices the data used to update the vertex buffer
  121520. * @param byteOffset the byte offset of the data (optional)
  121521. * @param byteLength the byte length of the data (optional)
  121522. */
  121523. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121524. /** @hidden */
  121525. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121526. /** @hidden */
  121527. _bindTexture(channel: number, texture: InternalTexture): void;
  121528. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121529. /**
  121530. * 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
  121531. */
  121532. releaseEffects(): void;
  121533. displayLoadingUI(): void;
  121534. hideLoadingUI(): void;
  121535. /** @hidden */
  121536. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121537. /** @hidden */
  121538. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121539. /** @hidden */
  121540. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121541. /** @hidden */
  121542. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121543. }
  121544. }
  121545. declare module BABYLON {
  121546. /**
  121547. * @hidden
  121548. **/
  121549. export class _TimeToken {
  121550. _startTimeQuery: Nullable<WebGLQuery>;
  121551. _endTimeQuery: Nullable<WebGLQuery>;
  121552. _timeElapsedQuery: Nullable<WebGLQuery>;
  121553. _timeElapsedQueryEnded: boolean;
  121554. }
  121555. }
  121556. declare module BABYLON {
  121557. /** @hidden */
  121558. export class _OcclusionDataStorage {
  121559. /** @hidden */
  121560. occlusionInternalRetryCounter: number;
  121561. /** @hidden */
  121562. isOcclusionQueryInProgress: boolean;
  121563. /** @hidden */
  121564. isOccluded: boolean;
  121565. /** @hidden */
  121566. occlusionRetryCount: number;
  121567. /** @hidden */
  121568. occlusionType: number;
  121569. /** @hidden */
  121570. occlusionQueryAlgorithmType: number;
  121571. }
  121572. interface Engine {
  121573. /**
  121574. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121575. * @return the new query
  121576. */
  121577. createQuery(): WebGLQuery;
  121578. /**
  121579. * Delete and release a webGL query
  121580. * @param query defines the query to delete
  121581. * @return the current engine
  121582. */
  121583. deleteQuery(query: WebGLQuery): Engine;
  121584. /**
  121585. * Check if a given query has resolved and got its value
  121586. * @param query defines the query to check
  121587. * @returns true if the query got its value
  121588. */
  121589. isQueryResultAvailable(query: WebGLQuery): boolean;
  121590. /**
  121591. * Gets the value of a given query
  121592. * @param query defines the query to check
  121593. * @returns the value of the query
  121594. */
  121595. getQueryResult(query: WebGLQuery): number;
  121596. /**
  121597. * Initiates an occlusion query
  121598. * @param algorithmType defines the algorithm to use
  121599. * @param query defines the query to use
  121600. * @returns the current engine
  121601. * @see http://doc.babylonjs.com/features/occlusionquery
  121602. */
  121603. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121604. /**
  121605. * Ends an occlusion query
  121606. * @see http://doc.babylonjs.com/features/occlusionquery
  121607. * @param algorithmType defines the algorithm to use
  121608. * @returns the current engine
  121609. */
  121610. endOcclusionQuery(algorithmType: number): Engine;
  121611. /**
  121612. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121613. * Please note that only one query can be issued at a time
  121614. * @returns a time token used to track the time span
  121615. */
  121616. startTimeQuery(): Nullable<_TimeToken>;
  121617. /**
  121618. * Ends a time query
  121619. * @param token defines the token used to measure the time span
  121620. * @returns the time spent (in ns)
  121621. */
  121622. endTimeQuery(token: _TimeToken): int;
  121623. /** @hidden */
  121624. _currentNonTimestampToken: Nullable<_TimeToken>;
  121625. /** @hidden */
  121626. _createTimeQuery(): WebGLQuery;
  121627. /** @hidden */
  121628. _deleteTimeQuery(query: WebGLQuery): void;
  121629. /** @hidden */
  121630. _getGlAlgorithmType(algorithmType: number): number;
  121631. /** @hidden */
  121632. _getTimeQueryResult(query: WebGLQuery): any;
  121633. /** @hidden */
  121634. _getTimeQueryAvailability(query: WebGLQuery): any;
  121635. }
  121636. interface AbstractMesh {
  121637. /**
  121638. * Backing filed
  121639. * @hidden
  121640. */
  121641. __occlusionDataStorage: _OcclusionDataStorage;
  121642. /**
  121643. * Access property
  121644. * @hidden
  121645. */
  121646. _occlusionDataStorage: _OcclusionDataStorage;
  121647. /**
  121648. * 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.
  121649. * The default value is -1 which means don't break the query and wait till the result
  121650. * @see http://doc.babylonjs.com/features/occlusionquery
  121651. */
  121652. occlusionRetryCount: number;
  121653. /**
  121654. * 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:
  121655. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121656. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121657. * * 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.
  121658. * @see http://doc.babylonjs.com/features/occlusionquery
  121659. */
  121660. occlusionType: number;
  121661. /**
  121662. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121663. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121664. * * 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.
  121665. * @see http://doc.babylonjs.com/features/occlusionquery
  121666. */
  121667. occlusionQueryAlgorithmType: number;
  121668. /**
  121669. * 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
  121670. * @see http://doc.babylonjs.com/features/occlusionquery
  121671. */
  121672. isOccluded: boolean;
  121673. /**
  121674. * Flag to check the progress status of the query
  121675. * @see http://doc.babylonjs.com/features/occlusionquery
  121676. */
  121677. isOcclusionQueryInProgress: boolean;
  121678. }
  121679. }
  121680. declare module BABYLON {
  121681. /** @hidden */
  121682. export var _forceTransformFeedbackToBundle: boolean;
  121683. interface Engine {
  121684. /**
  121685. * Creates a webGL transform feedback object
  121686. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121687. * @returns the webGL transform feedback object
  121688. */
  121689. createTransformFeedback(): WebGLTransformFeedback;
  121690. /**
  121691. * Delete a webGL transform feedback object
  121692. * @param value defines the webGL transform feedback object to delete
  121693. */
  121694. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121695. /**
  121696. * Bind a webGL transform feedback object to the webgl context
  121697. * @param value defines the webGL transform feedback object to bind
  121698. */
  121699. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121700. /**
  121701. * Begins a transform feedback operation
  121702. * @param usePoints defines if points or triangles must be used
  121703. */
  121704. beginTransformFeedback(usePoints: boolean): void;
  121705. /**
  121706. * Ends a transform feedback operation
  121707. */
  121708. endTransformFeedback(): void;
  121709. /**
  121710. * Specify the varyings to use with transform feedback
  121711. * @param program defines the associated webGL program
  121712. * @param value defines the list of strings representing the varying names
  121713. */
  121714. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121715. /**
  121716. * Bind a webGL buffer for a transform feedback operation
  121717. * @param value defines the webGL buffer to bind
  121718. */
  121719. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121720. }
  121721. }
  121722. declare module BABYLON {
  121723. /**
  121724. * Creation options of the multi render target texture.
  121725. */
  121726. export interface IMultiRenderTargetOptions {
  121727. /**
  121728. * Define if the texture needs to create mip maps after render.
  121729. */
  121730. generateMipMaps?: boolean;
  121731. /**
  121732. * Define the types of all the draw buffers we want to create
  121733. */
  121734. types?: number[];
  121735. /**
  121736. * Define the sampling modes of all the draw buffers we want to create
  121737. */
  121738. samplingModes?: number[];
  121739. /**
  121740. * Define if a depth buffer is required
  121741. */
  121742. generateDepthBuffer?: boolean;
  121743. /**
  121744. * Define if a stencil buffer is required
  121745. */
  121746. generateStencilBuffer?: boolean;
  121747. /**
  121748. * Define if a depth texture is required instead of a depth buffer
  121749. */
  121750. generateDepthTexture?: boolean;
  121751. /**
  121752. * Define the number of desired draw buffers
  121753. */
  121754. textureCount?: number;
  121755. /**
  121756. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121757. */
  121758. doNotChangeAspectRatio?: boolean;
  121759. /**
  121760. * Define the default type of the buffers we are creating
  121761. */
  121762. defaultType?: number;
  121763. }
  121764. /**
  121765. * A multi render target, like a render target provides the ability to render to a texture.
  121766. * Unlike the render target, it can render to several draw buffers in one draw.
  121767. * This is specially interesting in deferred rendering or for any effects requiring more than
  121768. * just one color from a single pass.
  121769. */
  121770. export class MultiRenderTarget extends RenderTargetTexture {
  121771. private _internalTextures;
  121772. private _textures;
  121773. private _multiRenderTargetOptions;
  121774. /**
  121775. * Get if draw buffers are currently supported by the used hardware and browser.
  121776. */
  121777. get isSupported(): boolean;
  121778. /**
  121779. * Get the list of textures generated by the multi render target.
  121780. */
  121781. get textures(): Texture[];
  121782. /**
  121783. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121784. */
  121785. get depthTexture(): Texture;
  121786. /**
  121787. * Set the wrapping mode on U of all the textures we are rendering to.
  121788. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121789. */
  121790. set wrapU(wrap: number);
  121791. /**
  121792. * Set the wrapping mode on V of all the textures we are rendering to.
  121793. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121794. */
  121795. set wrapV(wrap: number);
  121796. /**
  121797. * Instantiate a new multi render target texture.
  121798. * A multi render target, like a render target provides the ability to render to a texture.
  121799. * Unlike the render target, it can render to several draw buffers in one draw.
  121800. * This is specially interesting in deferred rendering or for any effects requiring more than
  121801. * just one color from a single pass.
  121802. * @param name Define the name of the texture
  121803. * @param size Define the size of the buffers to render to
  121804. * @param count Define the number of target we are rendering into
  121805. * @param scene Define the scene the texture belongs to
  121806. * @param options Define the options used to create the multi render target
  121807. */
  121808. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121809. /** @hidden */
  121810. _rebuild(): void;
  121811. private _createInternalTextures;
  121812. private _createTextures;
  121813. /**
  121814. * Define the number of samples used if MSAA is enabled.
  121815. */
  121816. get samples(): number;
  121817. set samples(value: number);
  121818. /**
  121819. * Resize all the textures in the multi render target.
  121820. * Be carrefull as it will recreate all the data in the new texture.
  121821. * @param size Define the new size
  121822. */
  121823. resize(size: any): void;
  121824. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121825. /**
  121826. * Dispose the render targets and their associated resources
  121827. */
  121828. dispose(): void;
  121829. /**
  121830. * Release all the underlying texture used as draw buffers.
  121831. */
  121832. releaseInternalTextures(): void;
  121833. }
  121834. }
  121835. declare module BABYLON {
  121836. interface ThinEngine {
  121837. /**
  121838. * Unbind a list of render target textures from the webGL context
  121839. * This is used only when drawBuffer extension or webGL2 are active
  121840. * @param textures defines the render target textures to unbind
  121841. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121842. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121843. */
  121844. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121845. /**
  121846. * Create a multi render target texture
  121847. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121848. * @param size defines the size of the texture
  121849. * @param options defines the creation options
  121850. * @returns the cube texture as an InternalTexture
  121851. */
  121852. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121853. /**
  121854. * Update the sample count for a given multiple render target texture
  121855. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121856. * @param textures defines the textures to update
  121857. * @param samples defines the sample count to set
  121858. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121859. */
  121860. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121861. }
  121862. }
  121863. declare module BABYLON {
  121864. /**
  121865. * Class used to define an additional view for the engine
  121866. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121867. */
  121868. export class EngineView {
  121869. /** Defines the canvas where to render the view */
  121870. target: HTMLCanvasElement;
  121871. /** Defines an optional camera used to render the view (will use active camera else) */
  121872. camera?: Camera;
  121873. }
  121874. interface Engine {
  121875. /**
  121876. * Gets or sets the HTML element to use for attaching events
  121877. */
  121878. inputElement: Nullable<HTMLElement>;
  121879. /**
  121880. * Gets the current engine view
  121881. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121882. */
  121883. activeView: Nullable<EngineView>;
  121884. /** Gets or sets the list of views */
  121885. views: EngineView[];
  121886. /**
  121887. * Register a new child canvas
  121888. * @param canvas defines the canvas to register
  121889. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121890. * @returns the associated view
  121891. */
  121892. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121893. /**
  121894. * Remove a registered child canvas
  121895. * @param canvas defines the canvas to remove
  121896. * @returns the current engine
  121897. */
  121898. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121899. }
  121900. }
  121901. declare module BABYLON {
  121902. interface Engine {
  121903. /** @hidden */
  121904. _excludedCompressedTextures: string[];
  121905. /** @hidden */
  121906. _textureFormatInUse: string;
  121907. /**
  121908. * Gets the list of texture formats supported
  121909. */
  121910. readonly texturesSupported: Array<string>;
  121911. /**
  121912. * Gets the texture format in use
  121913. */
  121914. readonly textureFormatInUse: Nullable<string>;
  121915. /**
  121916. * Set the compressed texture extensions or file names to skip.
  121917. *
  121918. * @param skippedFiles defines the list of those texture files you want to skip
  121919. * Example: [".dds", ".env", "myfile.png"]
  121920. */
  121921. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121922. /**
  121923. * Set the compressed texture format to use, based on the formats you have, and the formats
  121924. * supported by the hardware / browser.
  121925. *
  121926. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121927. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121928. * to API arguments needed to compressed textures. This puts the burden on the container
  121929. * generator to house the arcane code for determining these for current & future formats.
  121930. *
  121931. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121932. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121933. *
  121934. * Note: The result of this call is not taken into account when a texture is base64.
  121935. *
  121936. * @param formatsAvailable defines the list of those format families you have created
  121937. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121938. *
  121939. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121940. * @returns The extension selected.
  121941. */
  121942. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121943. }
  121944. }
  121945. declare module BABYLON {
  121946. /**
  121947. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121948. */
  121949. export interface CubeMapInfo {
  121950. /**
  121951. * The pixel array for the front face.
  121952. * This is stored in format, left to right, up to down format.
  121953. */
  121954. front: Nullable<ArrayBufferView>;
  121955. /**
  121956. * The pixel array for the back face.
  121957. * This is stored in format, left to right, up to down format.
  121958. */
  121959. back: Nullable<ArrayBufferView>;
  121960. /**
  121961. * The pixel array for the left face.
  121962. * This is stored in format, left to right, up to down format.
  121963. */
  121964. left: Nullable<ArrayBufferView>;
  121965. /**
  121966. * The pixel array for the right face.
  121967. * This is stored in format, left to right, up to down format.
  121968. */
  121969. right: Nullable<ArrayBufferView>;
  121970. /**
  121971. * The pixel array for the up face.
  121972. * This is stored in format, left to right, up to down format.
  121973. */
  121974. up: Nullable<ArrayBufferView>;
  121975. /**
  121976. * The pixel array for the down face.
  121977. * This is stored in format, left to right, up to down format.
  121978. */
  121979. down: Nullable<ArrayBufferView>;
  121980. /**
  121981. * The size of the cubemap stored.
  121982. *
  121983. * Each faces will be size * size pixels.
  121984. */
  121985. size: number;
  121986. /**
  121987. * The format of the texture.
  121988. *
  121989. * RGBA, RGB.
  121990. */
  121991. format: number;
  121992. /**
  121993. * The type of the texture data.
  121994. *
  121995. * UNSIGNED_INT, FLOAT.
  121996. */
  121997. type: number;
  121998. /**
  121999. * Specifies whether the texture is in gamma space.
  122000. */
  122001. gammaSpace: boolean;
  122002. }
  122003. /**
  122004. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  122005. */
  122006. export class PanoramaToCubeMapTools {
  122007. private static FACE_FRONT;
  122008. private static FACE_BACK;
  122009. private static FACE_RIGHT;
  122010. private static FACE_LEFT;
  122011. private static FACE_DOWN;
  122012. private static FACE_UP;
  122013. /**
  122014. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  122015. *
  122016. * @param float32Array The source data.
  122017. * @param inputWidth The width of the input panorama.
  122018. * @param inputHeight The height of the input panorama.
  122019. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122020. * @return The cubemap data
  122021. */
  122022. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122023. private static CreateCubemapTexture;
  122024. private static CalcProjectionSpherical;
  122025. }
  122026. }
  122027. declare module BABYLON {
  122028. /**
  122029. * Helper class dealing with the extraction of spherical polynomial dataArray
  122030. * from a cube map.
  122031. */
  122032. export class CubeMapToSphericalPolynomialTools {
  122033. private static FileFaces;
  122034. /**
  122035. * Converts a texture to the according Spherical Polynomial data.
  122036. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122037. *
  122038. * @param texture The texture to extract the information from.
  122039. * @return The Spherical Polynomial data.
  122040. */
  122041. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122042. /**
  122043. * Converts a cubemap to the according Spherical Polynomial data.
  122044. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122045. *
  122046. * @param cubeInfo The Cube map to extract the information from.
  122047. * @return The Spherical Polynomial data.
  122048. */
  122049. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. interface BaseTexture {
  122054. /**
  122055. * Get the polynomial representation of the texture data.
  122056. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122057. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122058. */
  122059. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122060. }
  122061. }
  122062. declare module BABYLON {
  122063. /** @hidden */
  122064. export var rgbdEncodePixelShader: {
  122065. name: string;
  122066. shader: string;
  122067. };
  122068. }
  122069. declare module BABYLON {
  122070. /** @hidden */
  122071. export var rgbdDecodePixelShader: {
  122072. name: string;
  122073. shader: string;
  122074. };
  122075. }
  122076. declare module BABYLON {
  122077. /**
  122078. * Raw texture data and descriptor sufficient for WebGL texture upload
  122079. */
  122080. export interface EnvironmentTextureInfo {
  122081. /**
  122082. * Version of the environment map
  122083. */
  122084. version: number;
  122085. /**
  122086. * Width of image
  122087. */
  122088. width: number;
  122089. /**
  122090. * Irradiance information stored in the file.
  122091. */
  122092. irradiance: any;
  122093. /**
  122094. * Specular information stored in the file.
  122095. */
  122096. specular: any;
  122097. }
  122098. /**
  122099. * Defines One Image in the file. It requires only the position in the file
  122100. * as well as the length.
  122101. */
  122102. interface BufferImageData {
  122103. /**
  122104. * Length of the image data.
  122105. */
  122106. length: number;
  122107. /**
  122108. * Position of the data from the null terminator delimiting the end of the JSON.
  122109. */
  122110. position: number;
  122111. }
  122112. /**
  122113. * Defines the specular data enclosed in the file.
  122114. * This corresponds to the version 1 of the data.
  122115. */
  122116. export interface EnvironmentTextureSpecularInfoV1 {
  122117. /**
  122118. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122119. */
  122120. specularDataPosition?: number;
  122121. /**
  122122. * This contains all the images data needed to reconstruct the cubemap.
  122123. */
  122124. mipmaps: Array<BufferImageData>;
  122125. /**
  122126. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122127. */
  122128. lodGenerationScale: number;
  122129. }
  122130. /**
  122131. * Sets of helpers addressing the serialization and deserialization of environment texture
  122132. * stored in a BabylonJS env file.
  122133. * Those files are usually stored as .env files.
  122134. */
  122135. export class EnvironmentTextureTools {
  122136. /**
  122137. * Magic number identifying the env file.
  122138. */
  122139. private static _MagicBytes;
  122140. /**
  122141. * Gets the environment info from an env file.
  122142. * @param data The array buffer containing the .env bytes.
  122143. * @returns the environment file info (the json header) if successfully parsed.
  122144. */
  122145. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122146. /**
  122147. * Creates an environment texture from a loaded cube texture.
  122148. * @param texture defines the cube texture to convert in env file
  122149. * @return a promise containing the environment data if succesfull.
  122150. */
  122151. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122152. /**
  122153. * Creates a JSON representation of the spherical data.
  122154. * @param texture defines the texture containing the polynomials
  122155. * @return the JSON representation of the spherical info
  122156. */
  122157. private static _CreateEnvTextureIrradiance;
  122158. /**
  122159. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122160. * @param data the image data
  122161. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122162. * @return the views described by info providing access to the underlying buffer
  122163. */
  122164. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122165. /**
  122166. * Uploads the texture info contained in the env file to the GPU.
  122167. * @param texture defines the internal texture to upload to
  122168. * @param data defines the data to load
  122169. * @param info defines the texture info retrieved through the GetEnvInfo method
  122170. * @returns a promise
  122171. */
  122172. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122173. private static _OnImageReadyAsync;
  122174. /**
  122175. * Uploads the levels of image data to the GPU.
  122176. * @param texture defines the internal texture to upload to
  122177. * @param imageData defines the array buffer views of image data [mipmap][face]
  122178. * @returns a promise
  122179. */
  122180. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122181. /**
  122182. * Uploads spherical polynomials information to the texture.
  122183. * @param texture defines the texture we are trying to upload the information to
  122184. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122185. */
  122186. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122187. /** @hidden */
  122188. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /**
  122193. * Contains position and normal vectors for a vertex
  122194. */
  122195. export class PositionNormalVertex {
  122196. /** the position of the vertex (defaut: 0,0,0) */
  122197. position: Vector3;
  122198. /** the normal of the vertex (defaut: 0,1,0) */
  122199. normal: Vector3;
  122200. /**
  122201. * Creates a PositionNormalVertex
  122202. * @param position the position of the vertex (defaut: 0,0,0)
  122203. * @param normal the normal of the vertex (defaut: 0,1,0)
  122204. */
  122205. constructor(
  122206. /** the position of the vertex (defaut: 0,0,0) */
  122207. position?: Vector3,
  122208. /** the normal of the vertex (defaut: 0,1,0) */
  122209. normal?: Vector3);
  122210. /**
  122211. * Clones the PositionNormalVertex
  122212. * @returns the cloned PositionNormalVertex
  122213. */
  122214. clone(): PositionNormalVertex;
  122215. }
  122216. /**
  122217. * Contains position, normal and uv vectors for a vertex
  122218. */
  122219. export class PositionNormalTextureVertex {
  122220. /** the position of the vertex (defaut: 0,0,0) */
  122221. position: Vector3;
  122222. /** the normal of the vertex (defaut: 0,1,0) */
  122223. normal: Vector3;
  122224. /** the uv of the vertex (default: 0,0) */
  122225. uv: Vector2;
  122226. /**
  122227. * Creates a PositionNormalTextureVertex
  122228. * @param position the position of the vertex (defaut: 0,0,0)
  122229. * @param normal the normal of the vertex (defaut: 0,1,0)
  122230. * @param uv the uv of the vertex (default: 0,0)
  122231. */
  122232. constructor(
  122233. /** the position of the vertex (defaut: 0,0,0) */
  122234. position?: Vector3,
  122235. /** the normal of the vertex (defaut: 0,1,0) */
  122236. normal?: Vector3,
  122237. /** the uv of the vertex (default: 0,0) */
  122238. uv?: Vector2);
  122239. /**
  122240. * Clones the PositionNormalTextureVertex
  122241. * @returns the cloned PositionNormalTextureVertex
  122242. */
  122243. clone(): PositionNormalTextureVertex;
  122244. }
  122245. }
  122246. declare module BABYLON {
  122247. /** @hidden */
  122248. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122249. private _genericAttributeLocation;
  122250. private _varyingLocationCount;
  122251. private _varyingLocationMap;
  122252. private _replacements;
  122253. private _textureCount;
  122254. private _uniforms;
  122255. lineProcessor(line: string): string;
  122256. attributeProcessor(attribute: string): string;
  122257. varyingProcessor(varying: string, isFragment: boolean): string;
  122258. uniformProcessor(uniform: string): string;
  122259. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122260. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122261. }
  122262. }
  122263. declare module BABYLON {
  122264. /**
  122265. * Container for accessors for natively-stored mesh data buffers.
  122266. */
  122267. class NativeDataBuffer extends DataBuffer {
  122268. /**
  122269. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122270. */
  122271. nativeIndexBuffer?: any;
  122272. /**
  122273. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122274. */
  122275. nativeVertexBuffer?: any;
  122276. }
  122277. /** @hidden */
  122278. class NativeTexture extends InternalTexture {
  122279. getInternalTexture(): InternalTexture;
  122280. getViewCount(): number;
  122281. }
  122282. /** @hidden */
  122283. export class NativeEngine extends Engine {
  122284. private readonly _native;
  122285. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122286. private readonly INVALID_HANDLE;
  122287. getHardwareScalingLevel(): number;
  122288. constructor();
  122289. /**
  122290. * Can be used to override the current requestAnimationFrame requester.
  122291. * @hidden
  122292. */
  122293. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122294. /**
  122295. * Override default engine behavior.
  122296. * @param color
  122297. * @param backBuffer
  122298. * @param depth
  122299. * @param stencil
  122300. */
  122301. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122302. /**
  122303. * Gets host document
  122304. * @returns the host document object
  122305. */
  122306. getHostDocument(): Nullable<Document>;
  122307. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122308. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122309. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122310. recordVertexArrayObject(vertexBuffers: {
  122311. [key: string]: VertexBuffer;
  122312. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122313. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122314. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122315. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122316. /**
  122317. * Draw a list of indexed primitives
  122318. * @param fillMode defines the primitive to use
  122319. * @param indexStart defines the starting index
  122320. * @param indexCount defines the number of index to draw
  122321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122322. */
  122323. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122324. /**
  122325. * Draw a list of unindexed primitives
  122326. * @param fillMode defines the primitive to use
  122327. * @param verticesStart defines the index of first vertex to draw
  122328. * @param verticesCount defines the count of vertices to draw
  122329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122330. */
  122331. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122332. createPipelineContext(): IPipelineContext;
  122333. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122334. /** @hidden */
  122335. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122336. /** @hidden */
  122337. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122338. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122339. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122340. protected _setProgram(program: WebGLProgram): void;
  122341. _releaseEffect(effect: Effect): void;
  122342. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122343. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122344. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122345. bindSamplers(effect: Effect): void;
  122346. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122347. getRenderWidth(useScreen?: boolean): number;
  122348. getRenderHeight(useScreen?: boolean): number;
  122349. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122350. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122351. /**
  122352. * Set the z offset to apply to current rendering
  122353. * @param value defines the offset to apply
  122354. */
  122355. setZOffset(value: number): void;
  122356. /**
  122357. * Gets the current value of the zOffset
  122358. * @returns the current zOffset state
  122359. */
  122360. getZOffset(): number;
  122361. /**
  122362. * Enable or disable depth buffering
  122363. * @param enable defines the state to set
  122364. */
  122365. setDepthBuffer(enable: boolean): void;
  122366. /**
  122367. * Gets a boolean indicating if depth writing is enabled
  122368. * @returns the current depth writing state
  122369. */
  122370. getDepthWrite(): boolean;
  122371. /**
  122372. * Enable or disable depth writing
  122373. * @param enable defines the state to set
  122374. */
  122375. setDepthWrite(enable: boolean): void;
  122376. /**
  122377. * Enable or disable color writing
  122378. * @param enable defines the state to set
  122379. */
  122380. setColorWrite(enable: boolean): void;
  122381. /**
  122382. * Gets a boolean indicating if color writing is enabled
  122383. * @returns the current color writing state
  122384. */
  122385. getColorWrite(): boolean;
  122386. /**
  122387. * Sets alpha constants used by some alpha blending modes
  122388. * @param r defines the red component
  122389. * @param g defines the green component
  122390. * @param b defines the blue component
  122391. * @param a defines the alpha component
  122392. */
  122393. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122394. /**
  122395. * Sets the current alpha mode
  122396. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122397. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122398. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122399. */
  122400. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122401. /**
  122402. * Gets the current alpha mode
  122403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122404. * @returns the current alpha mode
  122405. */
  122406. getAlphaMode(): number;
  122407. setInt(uniform: WebGLUniformLocation, int: number): void;
  122408. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122409. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122410. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122411. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122412. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122413. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122414. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122415. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122416. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122417. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122418. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122419. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122420. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122421. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122422. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122423. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122424. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122425. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122426. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122427. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122428. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122429. wipeCaches(bruteForce?: boolean): void;
  122430. _createTexture(): WebGLTexture;
  122431. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122432. /**
  122433. * Usually called from Texture.ts.
  122434. * Passed information to create a WebGLTexture
  122435. * @param urlArg defines a value which contains one of the following:
  122436. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122437. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122438. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122439. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122440. * @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)
  122441. * @param scene needed for loading to the correct scene
  122442. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122443. * @param onLoad optional callback to be called upon successful completion
  122444. * @param onError optional callback to be called upon failure
  122445. * @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
  122446. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122447. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122448. * @param forcedExtension defines the extension to use to pick the right loader
  122449. * @param mimeType defines an optional mime type
  122450. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122451. */
  122452. 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;
  122453. /**
  122454. * Creates a cube texture
  122455. * @param rootUrl defines the url where the files to load is located
  122456. * @param scene defines the current scene
  122457. * @param files defines the list of files to load (1 per face)
  122458. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122459. * @param onLoad defines an optional callback raised when the texture is loaded
  122460. * @param onError defines an optional callback raised if there is an issue to load the texture
  122461. * @param format defines the format of the data
  122462. * @param forcedExtension defines the extension to use to pick the right loader
  122463. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122464. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122465. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122466. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122467. * @returns the cube texture as an InternalTexture
  122468. */
  122469. 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;
  122470. private _getSamplingFilter;
  122471. private static _GetNativeTextureFormat;
  122472. createRenderTargetTexture(size: number | {
  122473. width: number;
  122474. height: number;
  122475. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122476. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122477. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122479. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122480. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122481. /**
  122482. * Updates a dynamic vertex buffer.
  122483. * @param vertexBuffer the vertex buffer to update
  122484. * @param data the data used to update the vertex buffer
  122485. * @param byteOffset the byte offset of the data (optional)
  122486. * @param byteLength the byte length of the data (optional)
  122487. */
  122488. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122489. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122490. private _updateAnisotropicLevel;
  122491. private _getAddressMode;
  122492. /** @hidden */
  122493. _bindTexture(channel: number, texture: InternalTexture): void;
  122494. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122495. releaseEffects(): void;
  122496. /** @hidden */
  122497. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122498. /** @hidden */
  122499. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122500. /** @hidden */
  122501. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122502. /** @hidden */
  122503. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122504. }
  122505. }
  122506. declare module BABYLON {
  122507. /**
  122508. * Gather the list of clipboard event types as constants.
  122509. */
  122510. export class ClipboardEventTypes {
  122511. /**
  122512. * The clipboard event is fired when a copy command is active (pressed).
  122513. */
  122514. static readonly COPY: number;
  122515. /**
  122516. * The clipboard event is fired when a cut command is active (pressed).
  122517. */
  122518. static readonly CUT: number;
  122519. /**
  122520. * The clipboard event is fired when a paste command is active (pressed).
  122521. */
  122522. static readonly PASTE: number;
  122523. }
  122524. /**
  122525. * This class is used to store clipboard related info for the onClipboardObservable event.
  122526. */
  122527. export class ClipboardInfo {
  122528. /**
  122529. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122530. */
  122531. type: number;
  122532. /**
  122533. * Defines the related dom event
  122534. */
  122535. event: ClipboardEvent;
  122536. /**
  122537. *Creates an instance of ClipboardInfo.
  122538. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122539. * @param event Defines the related dom event
  122540. */
  122541. constructor(
  122542. /**
  122543. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122544. */
  122545. type: number,
  122546. /**
  122547. * Defines the related dom event
  122548. */
  122549. event: ClipboardEvent);
  122550. /**
  122551. * Get the clipboard event's type from the keycode.
  122552. * @param keyCode Defines the keyCode for the current keyboard event.
  122553. * @return {number}
  122554. */
  122555. static GetTypeFromCharacter(keyCode: number): number;
  122556. }
  122557. }
  122558. declare module BABYLON {
  122559. /**
  122560. * Google Daydream controller
  122561. */
  122562. export class DaydreamController extends WebVRController {
  122563. /**
  122564. * Base Url for the controller model.
  122565. */
  122566. static MODEL_BASE_URL: string;
  122567. /**
  122568. * File name for the controller model.
  122569. */
  122570. static MODEL_FILENAME: string;
  122571. /**
  122572. * Gamepad Id prefix used to identify Daydream Controller.
  122573. */
  122574. static readonly GAMEPAD_ID_PREFIX: string;
  122575. /**
  122576. * Creates a new DaydreamController from a gamepad
  122577. * @param vrGamepad the gamepad that the controller should be created from
  122578. */
  122579. constructor(vrGamepad: any);
  122580. /**
  122581. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122582. * @param scene scene in which to add meshes
  122583. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122584. */
  122585. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122586. /**
  122587. * Called once for each button that changed state since the last frame
  122588. * @param buttonIdx Which button index changed
  122589. * @param state New state of the button
  122590. * @param changes Which properties on the state changed since last frame
  122591. */
  122592. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122593. }
  122594. }
  122595. declare module BABYLON {
  122596. /**
  122597. * Gear VR Controller
  122598. */
  122599. export class GearVRController extends WebVRController {
  122600. /**
  122601. * Base Url for the controller model.
  122602. */
  122603. static MODEL_BASE_URL: string;
  122604. /**
  122605. * File name for the controller model.
  122606. */
  122607. static MODEL_FILENAME: string;
  122608. /**
  122609. * Gamepad Id prefix used to identify this controller.
  122610. */
  122611. static readonly GAMEPAD_ID_PREFIX: string;
  122612. private readonly _buttonIndexToObservableNameMap;
  122613. /**
  122614. * Creates a new GearVRController from a gamepad
  122615. * @param vrGamepad the gamepad that the controller should be created from
  122616. */
  122617. constructor(vrGamepad: any);
  122618. /**
  122619. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122620. * @param scene scene in which to add meshes
  122621. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122622. */
  122623. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122624. /**
  122625. * Called once for each button that changed state since the last frame
  122626. * @param buttonIdx Which button index changed
  122627. * @param state New state of the button
  122628. * @param changes Which properties on the state changed since last frame
  122629. */
  122630. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122631. }
  122632. }
  122633. declare module BABYLON {
  122634. /**
  122635. * Generic Controller
  122636. */
  122637. export class GenericController extends WebVRController {
  122638. /**
  122639. * Base Url for the controller model.
  122640. */
  122641. static readonly MODEL_BASE_URL: string;
  122642. /**
  122643. * File name for the controller model.
  122644. */
  122645. static readonly MODEL_FILENAME: string;
  122646. /**
  122647. * Creates a new GenericController from a gamepad
  122648. * @param vrGamepad the gamepad that the controller should be created from
  122649. */
  122650. constructor(vrGamepad: any);
  122651. /**
  122652. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122653. * @param scene scene in which to add meshes
  122654. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122655. */
  122656. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122657. /**
  122658. * Called once for each button that changed state since the last frame
  122659. * @param buttonIdx Which button index changed
  122660. * @param state New state of the button
  122661. * @param changes Which properties on the state changed since last frame
  122662. */
  122663. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * Oculus Touch Controller
  122669. */
  122670. export class OculusTouchController extends WebVRController {
  122671. /**
  122672. * Base Url for the controller model.
  122673. */
  122674. static MODEL_BASE_URL: string;
  122675. /**
  122676. * File name for the left controller model.
  122677. */
  122678. static MODEL_LEFT_FILENAME: string;
  122679. /**
  122680. * File name for the right controller model.
  122681. */
  122682. static MODEL_RIGHT_FILENAME: string;
  122683. /**
  122684. * Base Url for the Quest controller model.
  122685. */
  122686. static QUEST_MODEL_BASE_URL: string;
  122687. /**
  122688. * @hidden
  122689. * If the controllers are running on a device that needs the updated Quest controller models
  122690. */
  122691. static _IsQuest: boolean;
  122692. /**
  122693. * Fired when the secondary trigger on this controller is modified
  122694. */
  122695. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122696. /**
  122697. * Fired when the thumb rest on this controller is modified
  122698. */
  122699. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122700. /**
  122701. * Creates a new OculusTouchController from a gamepad
  122702. * @param vrGamepad the gamepad that the controller should be created from
  122703. */
  122704. constructor(vrGamepad: any);
  122705. /**
  122706. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122707. * @param scene scene in which to add meshes
  122708. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122709. */
  122710. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122711. /**
  122712. * Fired when the A button on this controller is modified
  122713. */
  122714. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122715. /**
  122716. * Fired when the B button on this controller is modified
  122717. */
  122718. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122719. /**
  122720. * Fired when the X button on this controller is modified
  122721. */
  122722. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122723. /**
  122724. * Fired when the Y button on this controller is modified
  122725. */
  122726. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122727. /**
  122728. * Called once for each button that changed state since the last frame
  122729. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122730. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122731. * 2) secondary trigger (same)
  122732. * 3) A (right) X (left), touch, pressed = value
  122733. * 4) B / Y
  122734. * 5) thumb rest
  122735. * @param buttonIdx Which button index changed
  122736. * @param state New state of the button
  122737. * @param changes Which properties on the state changed since last frame
  122738. */
  122739. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122740. }
  122741. }
  122742. declare module BABYLON {
  122743. /**
  122744. * Vive Controller
  122745. */
  122746. export class ViveController extends WebVRController {
  122747. /**
  122748. * Base Url for the controller model.
  122749. */
  122750. static MODEL_BASE_URL: string;
  122751. /**
  122752. * File name for the controller model.
  122753. */
  122754. static MODEL_FILENAME: string;
  122755. /**
  122756. * Creates a new ViveController from a gamepad
  122757. * @param vrGamepad the gamepad that the controller should be created from
  122758. */
  122759. constructor(vrGamepad: any);
  122760. /**
  122761. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122762. * @param scene scene in which to add meshes
  122763. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122764. */
  122765. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122766. /**
  122767. * Fired when the left button on this controller is modified
  122768. */
  122769. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122770. /**
  122771. * Fired when the right button on this controller is modified
  122772. */
  122773. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122774. /**
  122775. * Fired when the menu button on this controller is modified
  122776. */
  122777. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122778. /**
  122779. * Called once for each button that changed state since the last frame
  122780. * Vive mapping:
  122781. * 0: touchpad
  122782. * 1: trigger
  122783. * 2: left AND right buttons
  122784. * 3: menu button
  122785. * @param buttonIdx Which button index changed
  122786. * @param state New state of the button
  122787. * @param changes Which properties on the state changed since last frame
  122788. */
  122789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122790. }
  122791. }
  122792. declare module BABYLON {
  122793. /**
  122794. * Defines the WindowsMotionController object that the state of the windows motion controller
  122795. */
  122796. export class WindowsMotionController extends WebVRController {
  122797. /**
  122798. * The base url used to load the left and right controller models
  122799. */
  122800. static MODEL_BASE_URL: string;
  122801. /**
  122802. * The name of the left controller model file
  122803. */
  122804. static MODEL_LEFT_FILENAME: string;
  122805. /**
  122806. * The name of the right controller model file
  122807. */
  122808. static MODEL_RIGHT_FILENAME: string;
  122809. /**
  122810. * The controller name prefix for this controller type
  122811. */
  122812. static readonly GAMEPAD_ID_PREFIX: string;
  122813. /**
  122814. * The controller id pattern for this controller type
  122815. */
  122816. private static readonly GAMEPAD_ID_PATTERN;
  122817. private _loadedMeshInfo;
  122818. protected readonly _mapping: {
  122819. buttons: string[];
  122820. buttonMeshNames: {
  122821. trigger: string;
  122822. menu: string;
  122823. grip: string;
  122824. thumbstick: string;
  122825. trackpad: string;
  122826. };
  122827. buttonObservableNames: {
  122828. trigger: string;
  122829. menu: string;
  122830. grip: string;
  122831. thumbstick: string;
  122832. trackpad: string;
  122833. };
  122834. axisMeshNames: string[];
  122835. pointingPoseMeshName: string;
  122836. };
  122837. /**
  122838. * Fired when the trackpad on this controller is clicked
  122839. */
  122840. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122841. /**
  122842. * Fired when the trackpad on this controller is modified
  122843. */
  122844. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122845. /**
  122846. * The current x and y values of this controller's trackpad
  122847. */
  122848. trackpad: StickValues;
  122849. /**
  122850. * Creates a new WindowsMotionController from a gamepad
  122851. * @param vrGamepad the gamepad that the controller should be created from
  122852. */
  122853. constructor(vrGamepad: any);
  122854. /**
  122855. * Fired when the trigger on this controller is modified
  122856. */
  122857. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122858. /**
  122859. * Fired when the menu button on this controller is modified
  122860. */
  122861. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122862. /**
  122863. * Fired when the grip button on this controller is modified
  122864. */
  122865. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122866. /**
  122867. * Fired when the thumbstick button on this controller is modified
  122868. */
  122869. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122870. /**
  122871. * Fired when the touchpad button on this controller is modified
  122872. */
  122873. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122874. /**
  122875. * Fired when the touchpad values on this controller are modified
  122876. */
  122877. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122878. protected _updateTrackpad(): void;
  122879. /**
  122880. * Called once per frame by the engine.
  122881. */
  122882. update(): void;
  122883. /**
  122884. * Called once for each button that changed state since the last frame
  122885. * @param buttonIdx Which button index changed
  122886. * @param state New state of the button
  122887. * @param changes Which properties on the state changed since last frame
  122888. */
  122889. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122890. /**
  122891. * Moves the buttons on the controller mesh based on their current state
  122892. * @param buttonName the name of the button to move
  122893. * @param buttonValue the value of the button which determines the buttons new position
  122894. */
  122895. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122896. /**
  122897. * Moves the axis on the controller mesh based on its current state
  122898. * @param axis the index of the axis
  122899. * @param axisValue the value of the axis which determines the meshes new position
  122900. * @hidden
  122901. */
  122902. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122903. /**
  122904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122905. * @param scene scene in which to add meshes
  122906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122907. */
  122908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122909. /**
  122910. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122911. * can be transformed by button presses and axes values, based on this._mapping.
  122912. *
  122913. * @param scene scene in which the meshes exist
  122914. * @param meshes list of meshes that make up the controller model to process
  122915. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122916. */
  122917. private processModel;
  122918. private createMeshInfo;
  122919. /**
  122920. * Gets the ray of the controller in the direction the controller is pointing
  122921. * @param length the length the resulting ray should be
  122922. * @returns a ray in the direction the controller is pointing
  122923. */
  122924. getForwardRay(length?: number): Ray;
  122925. /**
  122926. * Disposes of the controller
  122927. */
  122928. dispose(): void;
  122929. }
  122930. /**
  122931. * This class represents a new windows motion controller in XR.
  122932. */
  122933. export class XRWindowsMotionController extends WindowsMotionController {
  122934. /**
  122935. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122936. */
  122937. protected readonly _mapping: {
  122938. buttons: string[];
  122939. buttonMeshNames: {
  122940. trigger: string;
  122941. menu: string;
  122942. grip: string;
  122943. thumbstick: string;
  122944. trackpad: string;
  122945. };
  122946. buttonObservableNames: {
  122947. trigger: string;
  122948. menu: string;
  122949. grip: string;
  122950. thumbstick: string;
  122951. trackpad: string;
  122952. };
  122953. axisMeshNames: string[];
  122954. pointingPoseMeshName: string;
  122955. };
  122956. /**
  122957. * Construct a new XR-Based windows motion controller
  122958. *
  122959. * @param gamepadInfo the gamepad object from the browser
  122960. */
  122961. constructor(gamepadInfo: any);
  122962. /**
  122963. * holds the thumbstick values (X,Y)
  122964. */
  122965. thumbstickValues: StickValues;
  122966. /**
  122967. * Fired when the thumbstick on this controller is clicked
  122968. */
  122969. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122970. /**
  122971. * Fired when the thumbstick on this controller is modified
  122972. */
  122973. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122974. /**
  122975. * Fired when the touchpad button on this controller is modified
  122976. */
  122977. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122978. /**
  122979. * Fired when the touchpad values on this controller are modified
  122980. */
  122981. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122982. /**
  122983. * Fired when the thumbstick button on this controller is modified
  122984. * here to prevent breaking changes
  122985. */
  122986. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122987. /**
  122988. * updating the thumbstick(!) and not the trackpad.
  122989. * This is named this way due to the difference between WebVR and XR and to avoid
  122990. * changing the parent class.
  122991. */
  122992. protected _updateTrackpad(): void;
  122993. /**
  122994. * Disposes the class with joy
  122995. */
  122996. dispose(): void;
  122997. }
  122998. }
  122999. declare module BABYLON {
  123000. /**
  123001. * Class containing static functions to help procedurally build meshes
  123002. */
  123003. export class PolyhedronBuilder {
  123004. /**
  123005. * Creates a polyhedron mesh
  123006. * * 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
  123007. * * The parameter `size` (positive float, default 1) sets the polygon size
  123008. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123009. * * 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`
  123010. * * 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
  123011. * * 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)`)
  123012. * * 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
  123013. * * 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
  123014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123017. * @param name defines the name of the mesh
  123018. * @param options defines the options used to create the mesh
  123019. * @param scene defines the hosting scene
  123020. * @returns the polyhedron mesh
  123021. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123022. */
  123023. static CreatePolyhedron(name: string, options: {
  123024. type?: number;
  123025. size?: number;
  123026. sizeX?: number;
  123027. sizeY?: number;
  123028. sizeZ?: number;
  123029. custom?: any;
  123030. faceUV?: Vector4[];
  123031. faceColors?: Color4[];
  123032. flat?: boolean;
  123033. updatable?: boolean;
  123034. sideOrientation?: number;
  123035. frontUVs?: Vector4;
  123036. backUVs?: Vector4;
  123037. }, scene?: Nullable<Scene>): Mesh;
  123038. }
  123039. }
  123040. declare module BABYLON {
  123041. /**
  123042. * Gizmo that enables scaling a mesh along 3 axis
  123043. */
  123044. export class ScaleGizmo extends Gizmo {
  123045. /**
  123046. * Internal gizmo used for interactions on the x axis
  123047. */
  123048. xGizmo: AxisScaleGizmo;
  123049. /**
  123050. * Internal gizmo used for interactions on the y axis
  123051. */
  123052. yGizmo: AxisScaleGizmo;
  123053. /**
  123054. * Internal gizmo used for interactions on the z axis
  123055. */
  123056. zGizmo: AxisScaleGizmo;
  123057. /**
  123058. * Internal gizmo used to scale all axis equally
  123059. */
  123060. uniformScaleGizmo: AxisScaleGizmo;
  123061. private _meshAttached;
  123062. private _updateGizmoRotationToMatchAttachedMesh;
  123063. private _snapDistance;
  123064. private _scaleRatio;
  123065. private _uniformScalingMesh;
  123066. private _octahedron;
  123067. private _sensitivity;
  123068. /** Fires an event when any of it's sub gizmos are dragged */
  123069. onDragStartObservable: Observable<unknown>;
  123070. /** Fires an event when any of it's sub gizmos are released from dragging */
  123071. onDragEndObservable: Observable<unknown>;
  123072. get attachedMesh(): Nullable<AbstractMesh>;
  123073. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123074. /**
  123075. * Creates a ScaleGizmo
  123076. * @param gizmoLayer The utility layer the gizmo will be added to
  123077. */
  123078. constructor(gizmoLayer?: UtilityLayerRenderer);
  123079. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123080. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123081. /**
  123082. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123083. */
  123084. set snapDistance(value: number);
  123085. get snapDistance(): number;
  123086. /**
  123087. * Ratio for the scale of the gizmo (Default: 1)
  123088. */
  123089. set scaleRatio(value: number);
  123090. get scaleRatio(): number;
  123091. /**
  123092. * Sensitivity factor for dragging (Default: 1)
  123093. */
  123094. set sensitivity(value: number);
  123095. get sensitivity(): number;
  123096. /**
  123097. * Disposes of the gizmo
  123098. */
  123099. dispose(): void;
  123100. }
  123101. }
  123102. declare module BABYLON {
  123103. /**
  123104. * Single axis scale gizmo
  123105. */
  123106. export class AxisScaleGizmo extends Gizmo {
  123107. /**
  123108. * Drag behavior responsible for the gizmos dragging interactions
  123109. */
  123110. dragBehavior: PointerDragBehavior;
  123111. private _pointerObserver;
  123112. /**
  123113. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123114. */
  123115. snapDistance: number;
  123116. /**
  123117. * Event that fires each time the gizmo snaps to a new location.
  123118. * * snapDistance is the the change in distance
  123119. */
  123120. onSnapObservable: Observable<{
  123121. snapDistance: number;
  123122. }>;
  123123. /**
  123124. * If the scaling operation should be done on all axis (default: false)
  123125. */
  123126. uniformScaling: boolean;
  123127. /**
  123128. * Custom sensitivity value for the drag strength
  123129. */
  123130. sensitivity: number;
  123131. private _isEnabled;
  123132. private _parent;
  123133. private _arrow;
  123134. private _coloredMaterial;
  123135. private _hoverMaterial;
  123136. /**
  123137. * Creates an AxisScaleGizmo
  123138. * @param gizmoLayer The utility layer the gizmo will be added to
  123139. * @param dragAxis The axis which the gizmo will be able to scale on
  123140. * @param color The color of the gizmo
  123141. */
  123142. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123143. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123144. /**
  123145. * If the gizmo is enabled
  123146. */
  123147. set isEnabled(value: boolean);
  123148. get isEnabled(): boolean;
  123149. /**
  123150. * Disposes of the gizmo
  123151. */
  123152. dispose(): void;
  123153. /**
  123154. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123155. * @param mesh The mesh to replace the default mesh of the gizmo
  123156. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123157. */
  123158. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Bounding box gizmo
  123164. */
  123165. export class BoundingBoxGizmo extends Gizmo {
  123166. private _lineBoundingBox;
  123167. private _rotateSpheresParent;
  123168. private _scaleBoxesParent;
  123169. private _boundingDimensions;
  123170. private _renderObserver;
  123171. private _pointerObserver;
  123172. private _scaleDragSpeed;
  123173. private _tmpQuaternion;
  123174. private _tmpVector;
  123175. private _tmpRotationMatrix;
  123176. /**
  123177. * 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)
  123178. */
  123179. ignoreChildren: boolean;
  123180. /**
  123181. * 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)
  123182. */
  123183. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123184. /**
  123185. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123186. */
  123187. rotationSphereSize: number;
  123188. /**
  123189. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123190. */
  123191. scaleBoxSize: number;
  123192. /**
  123193. * 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)
  123194. */
  123195. fixedDragMeshScreenSize: boolean;
  123196. /**
  123197. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123198. */
  123199. fixedDragMeshScreenSizeDistanceFactor: number;
  123200. /**
  123201. * Fired when a rotation sphere or scale box is dragged
  123202. */
  123203. onDragStartObservable: Observable<{}>;
  123204. /**
  123205. * Fired when a scale box is dragged
  123206. */
  123207. onScaleBoxDragObservable: Observable<{}>;
  123208. /**
  123209. * Fired when a scale box drag is ended
  123210. */
  123211. onScaleBoxDragEndObservable: Observable<{}>;
  123212. /**
  123213. * Fired when a rotation sphere is dragged
  123214. */
  123215. onRotationSphereDragObservable: Observable<{}>;
  123216. /**
  123217. * Fired when a rotation sphere drag is ended
  123218. */
  123219. onRotationSphereDragEndObservable: Observable<{}>;
  123220. /**
  123221. * 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)
  123222. */
  123223. scalePivot: Nullable<Vector3>;
  123224. /**
  123225. * Mesh used as a pivot to rotate the attached mesh
  123226. */
  123227. private _anchorMesh;
  123228. private _existingMeshScale;
  123229. private _dragMesh;
  123230. private pointerDragBehavior;
  123231. private coloredMaterial;
  123232. private hoverColoredMaterial;
  123233. /**
  123234. * Sets the color of the bounding box gizmo
  123235. * @param color the color to set
  123236. */
  123237. setColor(color: Color3): void;
  123238. /**
  123239. * Creates an BoundingBoxGizmo
  123240. * @param gizmoLayer The utility layer the gizmo will be added to
  123241. * @param color The color of the gizmo
  123242. */
  123243. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123244. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123245. private _selectNode;
  123246. /**
  123247. * Updates the bounding box information for the Gizmo
  123248. */
  123249. updateBoundingBox(): void;
  123250. private _updateRotationSpheres;
  123251. private _updateScaleBoxes;
  123252. /**
  123253. * Enables rotation on the specified axis and disables rotation on the others
  123254. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123255. */
  123256. setEnabledRotationAxis(axis: string): void;
  123257. /**
  123258. * Enables/disables scaling
  123259. * @param enable if scaling should be enabled
  123260. * @param homogeneousScaling defines if scaling should only be homogeneous
  123261. */
  123262. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123263. private _updateDummy;
  123264. /**
  123265. * Enables a pointer drag behavior on the bounding box of the gizmo
  123266. */
  123267. enableDragBehavior(): void;
  123268. /**
  123269. * Disposes of the gizmo
  123270. */
  123271. dispose(): void;
  123272. /**
  123273. * 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)
  123274. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123275. * @returns the bounding box mesh with the passed in mesh as a child
  123276. */
  123277. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123278. /**
  123279. * CustomMeshes are not supported by this gizmo
  123280. * @param mesh The mesh to replace the default mesh of the gizmo
  123281. */
  123282. setCustomMesh(mesh: Mesh): void;
  123283. }
  123284. }
  123285. declare module BABYLON {
  123286. /**
  123287. * Single plane rotation gizmo
  123288. */
  123289. export class PlaneRotationGizmo extends Gizmo {
  123290. /**
  123291. * Drag behavior responsible for the gizmos dragging interactions
  123292. */
  123293. dragBehavior: PointerDragBehavior;
  123294. private _pointerObserver;
  123295. /**
  123296. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123297. */
  123298. snapDistance: number;
  123299. /**
  123300. * Event that fires each time the gizmo snaps to a new location.
  123301. * * snapDistance is the the change in distance
  123302. */
  123303. onSnapObservable: Observable<{
  123304. snapDistance: number;
  123305. }>;
  123306. private _isEnabled;
  123307. private _parent;
  123308. /**
  123309. * Creates a PlaneRotationGizmo
  123310. * @param gizmoLayer The utility layer the gizmo will be added to
  123311. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123312. * @param color The color of the gizmo
  123313. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123314. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123315. */
  123316. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123318. /**
  123319. * If the gizmo is enabled
  123320. */
  123321. set isEnabled(value: boolean);
  123322. get isEnabled(): boolean;
  123323. /**
  123324. * Disposes of the gizmo
  123325. */
  123326. dispose(): void;
  123327. }
  123328. }
  123329. declare module BABYLON {
  123330. /**
  123331. * Gizmo that enables rotating a mesh along 3 axis
  123332. */
  123333. export class RotationGizmo extends Gizmo {
  123334. /**
  123335. * Internal gizmo used for interactions on the x axis
  123336. */
  123337. xGizmo: PlaneRotationGizmo;
  123338. /**
  123339. * Internal gizmo used for interactions on the y axis
  123340. */
  123341. yGizmo: PlaneRotationGizmo;
  123342. /**
  123343. * Internal gizmo used for interactions on the z axis
  123344. */
  123345. zGizmo: PlaneRotationGizmo;
  123346. /** Fires an event when any of it's sub gizmos are dragged */
  123347. onDragStartObservable: Observable<unknown>;
  123348. /** Fires an event when any of it's sub gizmos are released from dragging */
  123349. onDragEndObservable: Observable<unknown>;
  123350. private _meshAttached;
  123351. get attachedMesh(): Nullable<AbstractMesh>;
  123352. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123353. /**
  123354. * Creates a RotationGizmo
  123355. * @param gizmoLayer The utility layer the gizmo will be added to
  123356. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123357. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123358. */
  123359. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123360. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123361. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123362. /**
  123363. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123364. */
  123365. set snapDistance(value: number);
  123366. get snapDistance(): number;
  123367. /**
  123368. * Ratio for the scale of the gizmo (Default: 1)
  123369. */
  123370. set scaleRatio(value: number);
  123371. get scaleRatio(): number;
  123372. /**
  123373. * Disposes of the gizmo
  123374. */
  123375. dispose(): void;
  123376. /**
  123377. * CustomMeshes are not supported by this gizmo
  123378. * @param mesh The mesh to replace the default mesh of the gizmo
  123379. */
  123380. setCustomMesh(mesh: Mesh): void;
  123381. }
  123382. }
  123383. declare module BABYLON {
  123384. /**
  123385. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123386. */
  123387. export class GizmoManager implements IDisposable {
  123388. private scene;
  123389. /**
  123390. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123391. */
  123392. gizmos: {
  123393. positionGizmo: Nullable<PositionGizmo>;
  123394. rotationGizmo: Nullable<RotationGizmo>;
  123395. scaleGizmo: Nullable<ScaleGizmo>;
  123396. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123397. };
  123398. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123399. clearGizmoOnEmptyPointerEvent: boolean;
  123400. /** Fires an event when the manager is attached to a mesh */
  123401. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123402. private _gizmosEnabled;
  123403. private _pointerObserver;
  123404. private _attachedMesh;
  123405. private _boundingBoxColor;
  123406. private _defaultUtilityLayer;
  123407. private _defaultKeepDepthUtilityLayer;
  123408. /**
  123409. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123410. */
  123411. boundingBoxDragBehavior: SixDofDragBehavior;
  123412. /**
  123413. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123414. */
  123415. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123416. /**
  123417. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123418. */
  123419. usePointerToAttachGizmos: boolean;
  123420. /**
  123421. * Utility layer that the bounding box gizmo belongs to
  123422. */
  123423. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123424. /**
  123425. * Utility layer that all gizmos besides bounding box belong to
  123426. */
  123427. get utilityLayer(): UtilityLayerRenderer;
  123428. /**
  123429. * Instatiates a gizmo manager
  123430. * @param scene the scene to overlay the gizmos on top of
  123431. */
  123432. constructor(scene: Scene);
  123433. /**
  123434. * Attaches a set of gizmos to the specified mesh
  123435. * @param mesh The mesh the gizmo's should be attached to
  123436. */
  123437. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123438. /**
  123439. * If the position gizmo is enabled
  123440. */
  123441. set positionGizmoEnabled(value: boolean);
  123442. get positionGizmoEnabled(): boolean;
  123443. /**
  123444. * If the rotation gizmo is enabled
  123445. */
  123446. set rotationGizmoEnabled(value: boolean);
  123447. get rotationGizmoEnabled(): boolean;
  123448. /**
  123449. * If the scale gizmo is enabled
  123450. */
  123451. set scaleGizmoEnabled(value: boolean);
  123452. get scaleGizmoEnabled(): boolean;
  123453. /**
  123454. * If the boundingBox gizmo is enabled
  123455. */
  123456. set boundingBoxGizmoEnabled(value: boolean);
  123457. get boundingBoxGizmoEnabled(): boolean;
  123458. /**
  123459. * Disposes of the gizmo manager
  123460. */
  123461. dispose(): void;
  123462. }
  123463. }
  123464. declare module BABYLON {
  123465. /**
  123466. * A directional light is defined by a direction (what a surprise!).
  123467. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123468. * 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.
  123469. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123470. */
  123471. export class DirectionalLight extends ShadowLight {
  123472. private _shadowFrustumSize;
  123473. /**
  123474. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123475. */
  123476. get shadowFrustumSize(): number;
  123477. /**
  123478. * Specifies a fix frustum size for the shadow generation.
  123479. */
  123480. set shadowFrustumSize(value: number);
  123481. private _shadowOrthoScale;
  123482. /**
  123483. * Gets the shadow projection scale against the optimal computed one.
  123484. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123485. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123486. */
  123487. get shadowOrthoScale(): number;
  123488. /**
  123489. * Sets the shadow projection scale against the optimal computed one.
  123490. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123491. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123492. */
  123493. set shadowOrthoScale(value: number);
  123494. /**
  123495. * Automatically compute the projection matrix to best fit (including all the casters)
  123496. * on each frame.
  123497. */
  123498. autoUpdateExtends: boolean;
  123499. /**
  123500. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123501. * on each frame. autoUpdateExtends must be set to true for this to work
  123502. */
  123503. autoCalcShadowZBounds: boolean;
  123504. private _orthoLeft;
  123505. private _orthoRight;
  123506. private _orthoTop;
  123507. private _orthoBottom;
  123508. /**
  123509. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123510. * The directional light is emitted from everywhere in the given direction.
  123511. * It can cast shadows.
  123512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123513. * @param name The friendly name of the light
  123514. * @param direction The direction of the light
  123515. * @param scene The scene the light belongs to
  123516. */
  123517. constructor(name: string, direction: Vector3, scene: Scene);
  123518. /**
  123519. * Returns the string "DirectionalLight".
  123520. * @return The class name
  123521. */
  123522. getClassName(): string;
  123523. /**
  123524. * Returns the integer 1.
  123525. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123526. */
  123527. getTypeID(): number;
  123528. /**
  123529. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123530. * Returns the DirectionalLight Shadow projection matrix.
  123531. */
  123532. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123533. /**
  123534. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123535. * Returns the DirectionalLight Shadow projection matrix.
  123536. */
  123537. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123538. /**
  123539. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123540. * Returns the DirectionalLight Shadow projection matrix.
  123541. */
  123542. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123543. protected _buildUniformLayout(): void;
  123544. /**
  123545. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123546. * @param effect The effect to update
  123547. * @param lightIndex The index of the light in the effect to update
  123548. * @returns The directional light
  123549. */
  123550. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123551. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123552. /**
  123553. * Gets the minZ used for shadow according to both the scene and the light.
  123554. *
  123555. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123556. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123557. * @param activeCamera The camera we are returning the min for
  123558. * @returns the depth min z
  123559. */
  123560. getDepthMinZ(activeCamera: Camera): number;
  123561. /**
  123562. * Gets the maxZ used for shadow according to both the scene and the light.
  123563. *
  123564. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123565. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123566. * @param activeCamera The camera we are returning the max for
  123567. * @returns the depth max z
  123568. */
  123569. getDepthMaxZ(activeCamera: Camera): number;
  123570. /**
  123571. * Prepares the list of defines specific to the light type.
  123572. * @param defines the list of defines
  123573. * @param lightIndex defines the index of the light for the effect
  123574. */
  123575. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * Class containing static functions to help procedurally build meshes
  123581. */
  123582. export class HemisphereBuilder {
  123583. /**
  123584. * Creates a hemisphere mesh
  123585. * @param name defines the name of the mesh
  123586. * @param options defines the options used to create the mesh
  123587. * @param scene defines the hosting scene
  123588. * @returns the hemisphere mesh
  123589. */
  123590. static CreateHemisphere(name: string, options: {
  123591. segments?: number;
  123592. diameter?: number;
  123593. sideOrientation?: number;
  123594. }, scene: any): Mesh;
  123595. }
  123596. }
  123597. declare module BABYLON {
  123598. /**
  123599. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123600. * These values define a cone of light starting from the position, emitting toward the direction.
  123601. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123602. * and the exponent defines the speed of the decay of the light with distance (reach).
  123603. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123604. */
  123605. export class SpotLight extends ShadowLight {
  123606. private _angle;
  123607. private _innerAngle;
  123608. private _cosHalfAngle;
  123609. private _lightAngleScale;
  123610. private _lightAngleOffset;
  123611. /**
  123612. * Gets the cone angle of the spot light in Radians.
  123613. */
  123614. get angle(): number;
  123615. /**
  123616. * Sets the cone angle of the spot light in Radians.
  123617. */
  123618. set angle(value: number);
  123619. /**
  123620. * Only used in gltf falloff mode, this defines the angle where
  123621. * the directional falloff will start before cutting at angle which could be seen
  123622. * as outer angle.
  123623. */
  123624. get innerAngle(): number;
  123625. /**
  123626. * Only used in gltf falloff mode, this defines the angle where
  123627. * the directional falloff will start before cutting at angle which could be seen
  123628. * as outer angle.
  123629. */
  123630. set innerAngle(value: number);
  123631. private _shadowAngleScale;
  123632. /**
  123633. * Allows scaling the angle of the light for shadow generation only.
  123634. */
  123635. get shadowAngleScale(): number;
  123636. /**
  123637. * Allows scaling the angle of the light for shadow generation only.
  123638. */
  123639. set shadowAngleScale(value: number);
  123640. /**
  123641. * The light decay speed with the distance from the emission spot.
  123642. */
  123643. exponent: number;
  123644. private _projectionTextureMatrix;
  123645. /**
  123646. * Allows reading the projecton texture
  123647. */
  123648. get projectionTextureMatrix(): Matrix;
  123649. protected _projectionTextureLightNear: number;
  123650. /**
  123651. * Gets the near clip of the Spotlight for texture projection.
  123652. */
  123653. get projectionTextureLightNear(): number;
  123654. /**
  123655. * Sets the near clip of the Spotlight for texture projection.
  123656. */
  123657. set projectionTextureLightNear(value: number);
  123658. protected _projectionTextureLightFar: number;
  123659. /**
  123660. * Gets the far clip of the Spotlight for texture projection.
  123661. */
  123662. get projectionTextureLightFar(): number;
  123663. /**
  123664. * Sets the far clip of the Spotlight for texture projection.
  123665. */
  123666. set projectionTextureLightFar(value: number);
  123667. protected _projectionTextureUpDirection: Vector3;
  123668. /**
  123669. * Gets the Up vector of the Spotlight for texture projection.
  123670. */
  123671. get projectionTextureUpDirection(): Vector3;
  123672. /**
  123673. * Sets the Up vector of the Spotlight for texture projection.
  123674. */
  123675. set projectionTextureUpDirection(value: Vector3);
  123676. private _projectionTexture;
  123677. /**
  123678. * Gets the projection texture of the light.
  123679. */
  123680. get projectionTexture(): Nullable<BaseTexture>;
  123681. /**
  123682. * Sets the projection texture of the light.
  123683. */
  123684. set projectionTexture(value: Nullable<BaseTexture>);
  123685. private _projectionTextureViewLightDirty;
  123686. private _projectionTextureProjectionLightDirty;
  123687. private _projectionTextureDirty;
  123688. private _projectionTextureViewTargetVector;
  123689. private _projectionTextureViewLightMatrix;
  123690. private _projectionTextureProjectionLightMatrix;
  123691. private _projectionTextureScalingMatrix;
  123692. /**
  123693. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123694. * It can cast shadows.
  123695. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123696. * @param name The light friendly name
  123697. * @param position The position of the spot light in the scene
  123698. * @param direction The direction of the light in the scene
  123699. * @param angle The cone angle of the light in Radians
  123700. * @param exponent The light decay speed with the distance from the emission spot
  123701. * @param scene The scene the lights belongs to
  123702. */
  123703. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123704. /**
  123705. * Returns the string "SpotLight".
  123706. * @returns the class name
  123707. */
  123708. getClassName(): string;
  123709. /**
  123710. * Returns the integer 2.
  123711. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123712. */
  123713. getTypeID(): number;
  123714. /**
  123715. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123716. */
  123717. protected _setDirection(value: Vector3): void;
  123718. /**
  123719. * Overrides the position setter to recompute the projection texture view light Matrix.
  123720. */
  123721. protected _setPosition(value: Vector3): void;
  123722. /**
  123723. * 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.
  123724. * Returns the SpotLight.
  123725. */
  123726. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123727. protected _computeProjectionTextureViewLightMatrix(): void;
  123728. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123729. /**
  123730. * Main function for light texture projection matrix computing.
  123731. */
  123732. protected _computeProjectionTextureMatrix(): void;
  123733. protected _buildUniformLayout(): void;
  123734. private _computeAngleValues;
  123735. /**
  123736. * Sets the passed Effect "effect" with the Light textures.
  123737. * @param effect The effect to update
  123738. * @param lightIndex The index of the light in the effect to update
  123739. * @returns The light
  123740. */
  123741. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123742. /**
  123743. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123744. * @param effect The effect to update
  123745. * @param lightIndex The index of the light in the effect to update
  123746. * @returns The spot light
  123747. */
  123748. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123749. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123750. /**
  123751. * Disposes the light and the associated resources.
  123752. */
  123753. dispose(): void;
  123754. /**
  123755. * Prepares the list of defines specific to the light type.
  123756. * @param defines the list of defines
  123757. * @param lightIndex defines the index of the light for the effect
  123758. */
  123759. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123760. }
  123761. }
  123762. declare module BABYLON {
  123763. /**
  123764. * Gizmo that enables viewing a light
  123765. */
  123766. export class LightGizmo extends Gizmo {
  123767. private _lightMesh;
  123768. private _material;
  123769. private _cachedPosition;
  123770. private _cachedForward;
  123771. private _attachedMeshParent;
  123772. /**
  123773. * Creates a LightGizmo
  123774. * @param gizmoLayer The utility layer the gizmo will be added to
  123775. */
  123776. constructor(gizmoLayer?: UtilityLayerRenderer);
  123777. private _light;
  123778. /**
  123779. * The light that the gizmo is attached to
  123780. */
  123781. set light(light: Nullable<Light>);
  123782. get light(): Nullable<Light>;
  123783. /**
  123784. * Gets the material used to render the light gizmo
  123785. */
  123786. get material(): StandardMaterial;
  123787. /**
  123788. * @hidden
  123789. * Updates the gizmo to match the attached mesh's position/rotation
  123790. */
  123791. protected _update(): void;
  123792. private static _Scale;
  123793. /**
  123794. * Creates the lines for a light mesh
  123795. */
  123796. private static _CreateLightLines;
  123797. /**
  123798. * Disposes of the light gizmo
  123799. */
  123800. dispose(): void;
  123801. private static _CreateHemisphericLightMesh;
  123802. private static _CreatePointLightMesh;
  123803. private static _CreateSpotLightMesh;
  123804. private static _CreateDirectionalLightMesh;
  123805. }
  123806. }
  123807. declare module BABYLON {
  123808. /** @hidden */
  123809. export var backgroundFragmentDeclaration: {
  123810. name: string;
  123811. shader: string;
  123812. };
  123813. }
  123814. declare module BABYLON {
  123815. /** @hidden */
  123816. export var backgroundUboDeclaration: {
  123817. name: string;
  123818. shader: string;
  123819. };
  123820. }
  123821. declare module BABYLON {
  123822. /** @hidden */
  123823. export var backgroundPixelShader: {
  123824. name: string;
  123825. shader: string;
  123826. };
  123827. }
  123828. declare module BABYLON {
  123829. /** @hidden */
  123830. export var backgroundVertexDeclaration: {
  123831. name: string;
  123832. shader: string;
  123833. };
  123834. }
  123835. declare module BABYLON {
  123836. /** @hidden */
  123837. export var backgroundVertexShader: {
  123838. name: string;
  123839. shader: string;
  123840. };
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Background material used to create an efficient environement around your scene.
  123845. */
  123846. export class BackgroundMaterial extends PushMaterial {
  123847. /**
  123848. * Standard reflectance value at parallel view angle.
  123849. */
  123850. static StandardReflectance0: number;
  123851. /**
  123852. * Standard reflectance value at grazing angle.
  123853. */
  123854. static StandardReflectance90: number;
  123855. protected _primaryColor: Color3;
  123856. /**
  123857. * Key light Color (multiply against the environement texture)
  123858. */
  123859. primaryColor: Color3;
  123860. protected __perceptualColor: Nullable<Color3>;
  123861. /**
  123862. * Experimental Internal Use Only.
  123863. *
  123864. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123865. * This acts as a helper to set the primary color to a more "human friendly" value.
  123866. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123867. * output color as close as possible from the chosen value.
  123868. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123869. * part of lighting setup.)
  123870. */
  123871. get _perceptualColor(): Nullable<Color3>;
  123872. set _perceptualColor(value: Nullable<Color3>);
  123873. protected _primaryColorShadowLevel: float;
  123874. /**
  123875. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123876. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123877. */
  123878. get primaryColorShadowLevel(): float;
  123879. set primaryColorShadowLevel(value: float);
  123880. protected _primaryColorHighlightLevel: float;
  123881. /**
  123882. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123883. * The primary color is used at the level chosen to define what the white area would look.
  123884. */
  123885. get primaryColorHighlightLevel(): float;
  123886. set primaryColorHighlightLevel(value: float);
  123887. protected _reflectionTexture: Nullable<BaseTexture>;
  123888. /**
  123889. * Reflection Texture used in the material.
  123890. * Should be author in a specific way for the best result (refer to the documentation).
  123891. */
  123892. reflectionTexture: Nullable<BaseTexture>;
  123893. protected _reflectionBlur: float;
  123894. /**
  123895. * Reflection Texture level of blur.
  123896. *
  123897. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123898. * texture twice.
  123899. */
  123900. reflectionBlur: float;
  123901. protected _diffuseTexture: Nullable<BaseTexture>;
  123902. /**
  123903. * Diffuse Texture used in the material.
  123904. * Should be author in a specific way for the best result (refer to the documentation).
  123905. */
  123906. diffuseTexture: Nullable<BaseTexture>;
  123907. protected _shadowLights: Nullable<IShadowLight[]>;
  123908. /**
  123909. * Specify the list of lights casting shadow on the material.
  123910. * All scene shadow lights will be included if null.
  123911. */
  123912. shadowLights: Nullable<IShadowLight[]>;
  123913. protected _shadowLevel: float;
  123914. /**
  123915. * Helps adjusting the shadow to a softer level if required.
  123916. * 0 means black shadows and 1 means no shadows.
  123917. */
  123918. shadowLevel: float;
  123919. protected _sceneCenter: Vector3;
  123920. /**
  123921. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123922. * It is usually zero but might be interesting to modify according to your setup.
  123923. */
  123924. sceneCenter: Vector3;
  123925. protected _opacityFresnel: boolean;
  123926. /**
  123927. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123928. * This helps ensuring a nice transition when the camera goes under the ground.
  123929. */
  123930. opacityFresnel: boolean;
  123931. protected _reflectionFresnel: boolean;
  123932. /**
  123933. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123934. * This helps adding a mirror texture on the ground.
  123935. */
  123936. reflectionFresnel: boolean;
  123937. protected _reflectionFalloffDistance: number;
  123938. /**
  123939. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123940. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123941. */
  123942. reflectionFalloffDistance: number;
  123943. protected _reflectionAmount: number;
  123944. /**
  123945. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123946. */
  123947. reflectionAmount: number;
  123948. protected _reflectionReflectance0: number;
  123949. /**
  123950. * This specifies the weight of the reflection at grazing angle.
  123951. */
  123952. reflectionReflectance0: number;
  123953. protected _reflectionReflectance90: number;
  123954. /**
  123955. * This specifies the weight of the reflection at a perpendicular point of view.
  123956. */
  123957. reflectionReflectance90: number;
  123958. /**
  123959. * Sets the reflection reflectance fresnel values according to the default standard
  123960. * empirically know to work well :-)
  123961. */
  123962. set reflectionStandardFresnelWeight(value: number);
  123963. protected _useRGBColor: boolean;
  123964. /**
  123965. * Helps to directly use the maps channels instead of their level.
  123966. */
  123967. useRGBColor: boolean;
  123968. protected _enableNoise: boolean;
  123969. /**
  123970. * This helps reducing the banding effect that could occur on the background.
  123971. */
  123972. enableNoise: boolean;
  123973. /**
  123974. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123975. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123976. * Recommended to be keep at 1.0 except for special cases.
  123977. */
  123978. get fovMultiplier(): number;
  123979. set fovMultiplier(value: number);
  123980. private _fovMultiplier;
  123981. /**
  123982. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123983. */
  123984. useEquirectangularFOV: boolean;
  123985. private _maxSimultaneousLights;
  123986. /**
  123987. * Number of Simultaneous lights allowed on the material.
  123988. */
  123989. maxSimultaneousLights: int;
  123990. /**
  123991. * Default configuration related to image processing available in the Background Material.
  123992. */
  123993. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123994. /**
  123995. * Keep track of the image processing observer to allow dispose and replace.
  123996. */
  123997. private _imageProcessingObserver;
  123998. /**
  123999. * Attaches a new image processing configuration to the PBR Material.
  124000. * @param configuration (if null the scene configuration will be use)
  124001. */
  124002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124003. /**
  124004. * Gets the image processing configuration used either in this material.
  124005. */
  124006. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  124007. /**
  124008. * Sets the Default image processing configuration used either in the this material.
  124009. *
  124010. * If sets to null, the scene one is in use.
  124011. */
  124012. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  124013. /**
  124014. * Gets wether the color curves effect is enabled.
  124015. */
  124016. get cameraColorCurvesEnabled(): boolean;
  124017. /**
  124018. * Sets wether the color curves effect is enabled.
  124019. */
  124020. set cameraColorCurvesEnabled(value: boolean);
  124021. /**
  124022. * Gets wether the color grading effect is enabled.
  124023. */
  124024. get cameraColorGradingEnabled(): boolean;
  124025. /**
  124026. * Gets wether the color grading effect is enabled.
  124027. */
  124028. set cameraColorGradingEnabled(value: boolean);
  124029. /**
  124030. * Gets wether tonemapping is enabled or not.
  124031. */
  124032. get cameraToneMappingEnabled(): boolean;
  124033. /**
  124034. * Sets wether tonemapping is enabled or not
  124035. */
  124036. set cameraToneMappingEnabled(value: boolean);
  124037. /**
  124038. * The camera exposure used on this material.
  124039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124040. * This corresponds to a photographic exposure.
  124041. */
  124042. get cameraExposure(): float;
  124043. /**
  124044. * The camera exposure used on this material.
  124045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124046. * This corresponds to a photographic exposure.
  124047. */
  124048. set cameraExposure(value: float);
  124049. /**
  124050. * Gets The camera contrast used on this material.
  124051. */
  124052. get cameraContrast(): float;
  124053. /**
  124054. * Sets The camera contrast used on this material.
  124055. */
  124056. set cameraContrast(value: float);
  124057. /**
  124058. * Gets the Color Grading 2D Lookup Texture.
  124059. */
  124060. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124061. /**
  124062. * Sets the Color Grading 2D Lookup Texture.
  124063. */
  124064. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124065. /**
  124066. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124067. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124068. * 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;
  124069. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124070. */
  124071. get cameraColorCurves(): Nullable<ColorCurves>;
  124072. /**
  124073. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124074. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124075. * 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;
  124076. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124077. */
  124078. set cameraColorCurves(value: Nullable<ColorCurves>);
  124079. /**
  124080. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124081. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124082. */
  124083. switchToBGR: boolean;
  124084. private _renderTargets;
  124085. private _reflectionControls;
  124086. private _white;
  124087. private _primaryShadowColor;
  124088. private _primaryHighlightColor;
  124089. /**
  124090. * Instantiates a Background Material in the given scene
  124091. * @param name The friendly name of the material
  124092. * @param scene The scene to add the material to
  124093. */
  124094. constructor(name: string, scene: Scene);
  124095. /**
  124096. * Gets a boolean indicating that current material needs to register RTT
  124097. */
  124098. get hasRenderTargetTextures(): boolean;
  124099. /**
  124100. * The entire material has been created in order to prevent overdraw.
  124101. * @returns false
  124102. */
  124103. needAlphaTesting(): boolean;
  124104. /**
  124105. * The entire material has been created in order to prevent overdraw.
  124106. * @returns true if blending is enable
  124107. */
  124108. needAlphaBlending(): boolean;
  124109. /**
  124110. * Checks wether the material is ready to be rendered for a given mesh.
  124111. * @param mesh The mesh to render
  124112. * @param subMesh The submesh to check against
  124113. * @param useInstances Specify wether or not the material is used with instances
  124114. * @returns true if all the dependencies are ready (Textures, Effects...)
  124115. */
  124116. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124117. /**
  124118. * Compute the primary color according to the chosen perceptual color.
  124119. */
  124120. private _computePrimaryColorFromPerceptualColor;
  124121. /**
  124122. * Compute the highlights and shadow colors according to their chosen levels.
  124123. */
  124124. private _computePrimaryColors;
  124125. /**
  124126. * Build the uniform buffer used in the material.
  124127. */
  124128. buildUniformLayout(): void;
  124129. /**
  124130. * Unbind the material.
  124131. */
  124132. unbind(): void;
  124133. /**
  124134. * Bind only the world matrix to the material.
  124135. * @param world The world matrix to bind.
  124136. */
  124137. bindOnlyWorldMatrix(world: Matrix): void;
  124138. /**
  124139. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124140. * @param world The world matrix to bind.
  124141. * @param subMesh The submesh to bind for.
  124142. */
  124143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124144. /**
  124145. * Checks to see if a texture is used in the material.
  124146. * @param texture - Base texture to use.
  124147. * @returns - Boolean specifying if a texture is used in the material.
  124148. */
  124149. hasTexture(texture: BaseTexture): boolean;
  124150. /**
  124151. * Dispose the material.
  124152. * @param forceDisposeEffect Force disposal of the associated effect.
  124153. * @param forceDisposeTextures Force disposal of the associated textures.
  124154. */
  124155. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124156. /**
  124157. * Clones the material.
  124158. * @param name The cloned name.
  124159. * @returns The cloned material.
  124160. */
  124161. clone(name: string): BackgroundMaterial;
  124162. /**
  124163. * Serializes the current material to its JSON representation.
  124164. * @returns The JSON representation.
  124165. */
  124166. serialize(): any;
  124167. /**
  124168. * Gets the class name of the material
  124169. * @returns "BackgroundMaterial"
  124170. */
  124171. getClassName(): string;
  124172. /**
  124173. * Parse a JSON input to create back a background material.
  124174. * @param source The JSON data to parse
  124175. * @param scene The scene to create the parsed material in
  124176. * @param rootUrl The root url of the assets the material depends upon
  124177. * @returns the instantiated BackgroundMaterial.
  124178. */
  124179. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124180. }
  124181. }
  124182. declare module BABYLON {
  124183. /**
  124184. * Represents the different options available during the creation of
  124185. * a Environment helper.
  124186. *
  124187. * This can control the default ground, skybox and image processing setup of your scene.
  124188. */
  124189. export interface IEnvironmentHelperOptions {
  124190. /**
  124191. * Specifies whether or not to create a ground.
  124192. * True by default.
  124193. */
  124194. createGround: boolean;
  124195. /**
  124196. * Specifies the ground size.
  124197. * 15 by default.
  124198. */
  124199. groundSize: number;
  124200. /**
  124201. * The texture used on the ground for the main color.
  124202. * Comes from the BabylonJS CDN by default.
  124203. *
  124204. * Remarks: Can be either a texture or a url.
  124205. */
  124206. groundTexture: string | BaseTexture;
  124207. /**
  124208. * The color mixed in the ground texture by default.
  124209. * BabylonJS clearColor by default.
  124210. */
  124211. groundColor: Color3;
  124212. /**
  124213. * Specifies the ground opacity.
  124214. * 1 by default.
  124215. */
  124216. groundOpacity: number;
  124217. /**
  124218. * Enables the ground to receive shadows.
  124219. * True by default.
  124220. */
  124221. enableGroundShadow: boolean;
  124222. /**
  124223. * Helps preventing the shadow to be fully black on the ground.
  124224. * 0.5 by default.
  124225. */
  124226. groundShadowLevel: number;
  124227. /**
  124228. * Creates a mirror texture attach to the ground.
  124229. * false by default.
  124230. */
  124231. enableGroundMirror: boolean;
  124232. /**
  124233. * Specifies the ground mirror size ratio.
  124234. * 0.3 by default as the default kernel is 64.
  124235. */
  124236. groundMirrorSizeRatio: number;
  124237. /**
  124238. * Specifies the ground mirror blur kernel size.
  124239. * 64 by default.
  124240. */
  124241. groundMirrorBlurKernel: number;
  124242. /**
  124243. * Specifies the ground mirror visibility amount.
  124244. * 1 by default
  124245. */
  124246. groundMirrorAmount: number;
  124247. /**
  124248. * Specifies the ground mirror reflectance weight.
  124249. * This uses the standard weight of the background material to setup the fresnel effect
  124250. * of the mirror.
  124251. * 1 by default.
  124252. */
  124253. groundMirrorFresnelWeight: number;
  124254. /**
  124255. * Specifies the ground mirror Falloff distance.
  124256. * This can helps reducing the size of the reflection.
  124257. * 0 by Default.
  124258. */
  124259. groundMirrorFallOffDistance: number;
  124260. /**
  124261. * Specifies the ground mirror texture type.
  124262. * Unsigned Int by Default.
  124263. */
  124264. groundMirrorTextureType: number;
  124265. /**
  124266. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124267. * the shown objects.
  124268. */
  124269. groundYBias: number;
  124270. /**
  124271. * Specifies whether or not to create a skybox.
  124272. * True by default.
  124273. */
  124274. createSkybox: boolean;
  124275. /**
  124276. * Specifies the skybox size.
  124277. * 20 by default.
  124278. */
  124279. skyboxSize: number;
  124280. /**
  124281. * The texture used on the skybox for the main color.
  124282. * Comes from the BabylonJS CDN by default.
  124283. *
  124284. * Remarks: Can be either a texture or a url.
  124285. */
  124286. skyboxTexture: string | BaseTexture;
  124287. /**
  124288. * The color mixed in the skybox texture by default.
  124289. * BabylonJS clearColor by default.
  124290. */
  124291. skyboxColor: Color3;
  124292. /**
  124293. * The background rotation around the Y axis of the scene.
  124294. * This helps aligning the key lights of your scene with the background.
  124295. * 0 by default.
  124296. */
  124297. backgroundYRotation: number;
  124298. /**
  124299. * Compute automatically the size of the elements to best fit with the scene.
  124300. */
  124301. sizeAuto: boolean;
  124302. /**
  124303. * Default position of the rootMesh if autoSize is not true.
  124304. */
  124305. rootPosition: Vector3;
  124306. /**
  124307. * Sets up the image processing in the scene.
  124308. * true by default.
  124309. */
  124310. setupImageProcessing: boolean;
  124311. /**
  124312. * The texture used as your environment texture in the scene.
  124313. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124314. *
  124315. * Remarks: Can be either a texture or a url.
  124316. */
  124317. environmentTexture: string | BaseTexture;
  124318. /**
  124319. * The value of the exposure to apply to the scene.
  124320. * 0.6 by default if setupImageProcessing is true.
  124321. */
  124322. cameraExposure: number;
  124323. /**
  124324. * The value of the contrast to apply to the scene.
  124325. * 1.6 by default if setupImageProcessing is true.
  124326. */
  124327. cameraContrast: number;
  124328. /**
  124329. * Specifies whether or not tonemapping should be enabled in the scene.
  124330. * true by default if setupImageProcessing is true.
  124331. */
  124332. toneMappingEnabled: boolean;
  124333. }
  124334. /**
  124335. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124336. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124337. * It also helps with the default setup of your imageProcessing configuration.
  124338. */
  124339. export class EnvironmentHelper {
  124340. /**
  124341. * Default ground texture URL.
  124342. */
  124343. private static _groundTextureCDNUrl;
  124344. /**
  124345. * Default skybox texture URL.
  124346. */
  124347. private static _skyboxTextureCDNUrl;
  124348. /**
  124349. * Default environment texture URL.
  124350. */
  124351. private static _environmentTextureCDNUrl;
  124352. /**
  124353. * Creates the default options for the helper.
  124354. */
  124355. private static _getDefaultOptions;
  124356. private _rootMesh;
  124357. /**
  124358. * Gets the root mesh created by the helper.
  124359. */
  124360. get rootMesh(): Mesh;
  124361. private _skybox;
  124362. /**
  124363. * Gets the skybox created by the helper.
  124364. */
  124365. get skybox(): Nullable<Mesh>;
  124366. private _skyboxTexture;
  124367. /**
  124368. * Gets the skybox texture created by the helper.
  124369. */
  124370. get skyboxTexture(): Nullable<BaseTexture>;
  124371. private _skyboxMaterial;
  124372. /**
  124373. * Gets the skybox material created by the helper.
  124374. */
  124375. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124376. private _ground;
  124377. /**
  124378. * Gets the ground mesh created by the helper.
  124379. */
  124380. get ground(): Nullable<Mesh>;
  124381. private _groundTexture;
  124382. /**
  124383. * Gets the ground texture created by the helper.
  124384. */
  124385. get groundTexture(): Nullable<BaseTexture>;
  124386. private _groundMirror;
  124387. /**
  124388. * Gets the ground mirror created by the helper.
  124389. */
  124390. get groundMirror(): Nullable<MirrorTexture>;
  124391. /**
  124392. * Gets the ground mirror render list to helps pushing the meshes
  124393. * you wish in the ground reflection.
  124394. */
  124395. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124396. private _groundMaterial;
  124397. /**
  124398. * Gets the ground material created by the helper.
  124399. */
  124400. get groundMaterial(): Nullable<BackgroundMaterial>;
  124401. /**
  124402. * Stores the creation options.
  124403. */
  124404. private readonly _scene;
  124405. private _options;
  124406. /**
  124407. * This observable will be notified with any error during the creation of the environment,
  124408. * mainly texture creation errors.
  124409. */
  124410. onErrorObservable: Observable<{
  124411. message?: string;
  124412. exception?: any;
  124413. }>;
  124414. /**
  124415. * constructor
  124416. * @param options Defines the options we want to customize the helper
  124417. * @param scene The scene to add the material to
  124418. */
  124419. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124420. /**
  124421. * Updates the background according to the new options
  124422. * @param options
  124423. */
  124424. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124425. /**
  124426. * Sets the primary color of all the available elements.
  124427. * @param color the main color to affect to the ground and the background
  124428. */
  124429. setMainColor(color: Color3): void;
  124430. /**
  124431. * Setup the image processing according to the specified options.
  124432. */
  124433. private _setupImageProcessing;
  124434. /**
  124435. * Setup the environment texture according to the specified options.
  124436. */
  124437. private _setupEnvironmentTexture;
  124438. /**
  124439. * Setup the background according to the specified options.
  124440. */
  124441. private _setupBackground;
  124442. /**
  124443. * Get the scene sizes according to the setup.
  124444. */
  124445. private _getSceneSize;
  124446. /**
  124447. * Setup the ground according to the specified options.
  124448. */
  124449. private _setupGround;
  124450. /**
  124451. * Setup the ground material according to the specified options.
  124452. */
  124453. private _setupGroundMaterial;
  124454. /**
  124455. * Setup the ground diffuse texture according to the specified options.
  124456. */
  124457. private _setupGroundDiffuseTexture;
  124458. /**
  124459. * Setup the ground mirror texture according to the specified options.
  124460. */
  124461. private _setupGroundMirrorTexture;
  124462. /**
  124463. * Setup the ground to receive the mirror texture.
  124464. */
  124465. private _setupMirrorInGroundMaterial;
  124466. /**
  124467. * Setup the skybox according to the specified options.
  124468. */
  124469. private _setupSkybox;
  124470. /**
  124471. * Setup the skybox material according to the specified options.
  124472. */
  124473. private _setupSkyboxMaterial;
  124474. /**
  124475. * Setup the skybox reflection texture according to the specified options.
  124476. */
  124477. private _setupSkyboxReflectionTexture;
  124478. private _errorHandler;
  124479. /**
  124480. * Dispose all the elements created by the Helper.
  124481. */
  124482. dispose(): void;
  124483. }
  124484. }
  124485. declare module BABYLON {
  124486. /**
  124487. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124488. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124489. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124490. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124491. */
  124492. export class PhotoDome extends TransformNode {
  124493. /**
  124494. * Define the image as a Monoscopic panoramic 360 image.
  124495. */
  124496. static readonly MODE_MONOSCOPIC: number;
  124497. /**
  124498. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124499. */
  124500. static readonly MODE_TOPBOTTOM: number;
  124501. /**
  124502. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124503. */
  124504. static readonly MODE_SIDEBYSIDE: number;
  124505. private _useDirectMapping;
  124506. /**
  124507. * The texture being displayed on the sphere
  124508. */
  124509. protected _photoTexture: Texture;
  124510. /**
  124511. * Gets or sets the texture being displayed on the sphere
  124512. */
  124513. get photoTexture(): Texture;
  124514. set photoTexture(value: Texture);
  124515. /**
  124516. * Observable raised when an error occured while loading the 360 image
  124517. */
  124518. onLoadErrorObservable: Observable<string>;
  124519. /**
  124520. * The skybox material
  124521. */
  124522. protected _material: BackgroundMaterial;
  124523. /**
  124524. * The surface used for the skybox
  124525. */
  124526. protected _mesh: Mesh;
  124527. /**
  124528. * Gets the mesh used for the skybox.
  124529. */
  124530. get mesh(): Mesh;
  124531. /**
  124532. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124533. * Also see the options.resolution property.
  124534. */
  124535. get fovMultiplier(): number;
  124536. set fovMultiplier(value: number);
  124537. private _imageMode;
  124538. /**
  124539. * Gets or set the current video mode for the video. It can be:
  124540. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124541. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124542. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124543. */
  124544. get imageMode(): number;
  124545. set imageMode(value: number);
  124546. /**
  124547. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124548. * @param name Element's name, child elements will append suffixes for their own names.
  124549. * @param urlsOfPhoto defines the url of the photo to display
  124550. * @param options defines an object containing optional or exposed sub element properties
  124551. * @param onError defines a callback called when an error occured while loading the texture
  124552. */
  124553. constructor(name: string, urlOfPhoto: string, options: {
  124554. resolution?: number;
  124555. size?: number;
  124556. useDirectMapping?: boolean;
  124557. faceForward?: boolean;
  124558. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124559. private _onBeforeCameraRenderObserver;
  124560. private _changeImageMode;
  124561. /**
  124562. * Releases resources associated with this node.
  124563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124565. */
  124566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124567. }
  124568. }
  124569. declare module BABYLON {
  124570. /**
  124571. * Class used to host RGBD texture specific utilities
  124572. */
  124573. export class RGBDTextureTools {
  124574. /**
  124575. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124576. * @param texture the texture to expand.
  124577. */
  124578. static ExpandRGBDTexture(texture: Texture): void;
  124579. }
  124580. }
  124581. declare module BABYLON {
  124582. /**
  124583. * Class used to host texture specific utilities
  124584. */
  124585. export class BRDFTextureTools {
  124586. /**
  124587. * Prevents texture cache collision
  124588. */
  124589. private static _instanceNumber;
  124590. /**
  124591. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124592. * @param scene defines the hosting scene
  124593. * @returns the environment BRDF texture
  124594. */
  124595. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124596. private static _environmentBRDFBase64Texture;
  124597. }
  124598. }
  124599. declare module BABYLON {
  124600. /**
  124601. * @hidden
  124602. */
  124603. export interface IMaterialClearCoatDefines {
  124604. CLEARCOAT: boolean;
  124605. CLEARCOAT_DEFAULTIOR: boolean;
  124606. CLEARCOAT_TEXTURE: boolean;
  124607. CLEARCOAT_TEXTUREDIRECTUV: number;
  124608. CLEARCOAT_BUMP: boolean;
  124609. CLEARCOAT_BUMPDIRECTUV: number;
  124610. CLEARCOAT_TINT: boolean;
  124611. CLEARCOAT_TINT_TEXTURE: boolean;
  124612. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124613. /** @hidden */
  124614. _areTexturesDirty: boolean;
  124615. }
  124616. /**
  124617. * Define the code related to the clear coat parameters of the pbr material.
  124618. */
  124619. export class PBRClearCoatConfiguration {
  124620. /**
  124621. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124622. * The default fits with a polyurethane material.
  124623. */
  124624. private static readonly _DefaultIndexOfRefraction;
  124625. private _isEnabled;
  124626. /**
  124627. * Defines if the clear coat is enabled in the material.
  124628. */
  124629. isEnabled: boolean;
  124630. /**
  124631. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124632. */
  124633. intensity: number;
  124634. /**
  124635. * Defines the clear coat layer roughness.
  124636. */
  124637. roughness: number;
  124638. private _indexOfRefraction;
  124639. /**
  124640. * Defines the index of refraction of the clear coat.
  124641. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124642. * The default fits with a polyurethane material.
  124643. * Changing the default value is more performance intensive.
  124644. */
  124645. indexOfRefraction: number;
  124646. private _texture;
  124647. /**
  124648. * Stores the clear coat values in a texture.
  124649. */
  124650. texture: Nullable<BaseTexture>;
  124651. private _bumpTexture;
  124652. /**
  124653. * Define the clear coat specific bump texture.
  124654. */
  124655. bumpTexture: Nullable<BaseTexture>;
  124656. private _isTintEnabled;
  124657. /**
  124658. * Defines if the clear coat tint is enabled in the material.
  124659. */
  124660. isTintEnabled: boolean;
  124661. /**
  124662. * Defines the clear coat tint of the material.
  124663. * This is only use if tint is enabled
  124664. */
  124665. tintColor: Color3;
  124666. /**
  124667. * Defines the distance at which the tint color should be found in the
  124668. * clear coat media.
  124669. * This is only use if tint is enabled
  124670. */
  124671. tintColorAtDistance: number;
  124672. /**
  124673. * Defines the clear coat layer thickness.
  124674. * This is only use if tint is enabled
  124675. */
  124676. tintThickness: number;
  124677. private _tintTexture;
  124678. /**
  124679. * Stores the clear tint values in a texture.
  124680. * rgb is tint
  124681. * a is a thickness factor
  124682. */
  124683. tintTexture: Nullable<BaseTexture>;
  124684. /** @hidden */
  124685. private _internalMarkAllSubMeshesAsTexturesDirty;
  124686. /** @hidden */
  124687. _markAllSubMeshesAsTexturesDirty(): void;
  124688. /**
  124689. * Instantiate a new istance of clear coat configuration.
  124690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124691. */
  124692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124693. /**
  124694. * Gets wehter the submesh is ready to be used or not.
  124695. * @param defines the list of "defines" to update.
  124696. * @param scene defines the scene the material belongs to.
  124697. * @param engine defines the engine the material belongs to.
  124698. * @param disableBumpMap defines wether the material disables bump or not.
  124699. * @returns - boolean indicating that the submesh is ready or not.
  124700. */
  124701. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124702. /**
  124703. * Checks to see if a texture is used in the material.
  124704. * @param defines the list of "defines" to update.
  124705. * @param scene defines the scene to the material belongs to.
  124706. */
  124707. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124708. /**
  124709. * Binds the material data.
  124710. * @param uniformBuffer defines the Uniform buffer to fill in.
  124711. * @param scene defines the scene the material belongs to.
  124712. * @param engine defines the engine the material belongs to.
  124713. * @param disableBumpMap defines wether the material disables bump or not.
  124714. * @param isFrozen defines wether the material is frozen or not.
  124715. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124716. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124717. */
  124718. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124719. /**
  124720. * Checks to see if a texture is used in the material.
  124721. * @param texture - Base texture to use.
  124722. * @returns - Boolean specifying if a texture is used in the material.
  124723. */
  124724. hasTexture(texture: BaseTexture): boolean;
  124725. /**
  124726. * Returns an array of the actively used textures.
  124727. * @param activeTextures Array of BaseTextures
  124728. */
  124729. getActiveTextures(activeTextures: BaseTexture[]): void;
  124730. /**
  124731. * Returns the animatable textures.
  124732. * @param animatables Array of animatable textures.
  124733. */
  124734. getAnimatables(animatables: IAnimatable[]): void;
  124735. /**
  124736. * Disposes the resources of the material.
  124737. * @param forceDisposeTextures - Forces the disposal of all textures.
  124738. */
  124739. dispose(forceDisposeTextures?: boolean): void;
  124740. /**
  124741. * Get the current class name of the texture useful for serialization or dynamic coding.
  124742. * @returns "PBRClearCoatConfiguration"
  124743. */
  124744. getClassName(): string;
  124745. /**
  124746. * Add fallbacks to the effect fallbacks list.
  124747. * @param defines defines the Base texture to use.
  124748. * @param fallbacks defines the current fallback list.
  124749. * @param currentRank defines the current fallback rank.
  124750. * @returns the new fallback rank.
  124751. */
  124752. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124753. /**
  124754. * Add the required uniforms to the current list.
  124755. * @param uniforms defines the current uniform list.
  124756. */
  124757. static AddUniforms(uniforms: string[]): void;
  124758. /**
  124759. * Add the required samplers to the current list.
  124760. * @param samplers defines the current sampler list.
  124761. */
  124762. static AddSamplers(samplers: string[]): void;
  124763. /**
  124764. * Add the required uniforms to the current buffer.
  124765. * @param uniformBuffer defines the current uniform buffer.
  124766. */
  124767. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124768. /**
  124769. * Makes a duplicate of the current configuration into another one.
  124770. * @param clearCoatConfiguration define the config where to copy the info
  124771. */
  124772. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124773. /**
  124774. * Serializes this clear coat configuration.
  124775. * @returns - An object with the serialized config.
  124776. */
  124777. serialize(): any;
  124778. /**
  124779. * Parses a anisotropy Configuration from a serialized object.
  124780. * @param source - Serialized object.
  124781. * @param scene Defines the scene we are parsing for
  124782. * @param rootUrl Defines the rootUrl to load from
  124783. */
  124784. parse(source: any, scene: Scene, rootUrl: string): void;
  124785. }
  124786. }
  124787. declare module BABYLON {
  124788. /**
  124789. * @hidden
  124790. */
  124791. export interface IMaterialAnisotropicDefines {
  124792. ANISOTROPIC: boolean;
  124793. ANISOTROPIC_TEXTURE: boolean;
  124794. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124795. MAINUV1: boolean;
  124796. _areTexturesDirty: boolean;
  124797. _needUVs: boolean;
  124798. }
  124799. /**
  124800. * Define the code related to the anisotropic parameters of the pbr material.
  124801. */
  124802. export class PBRAnisotropicConfiguration {
  124803. private _isEnabled;
  124804. /**
  124805. * Defines if the anisotropy is enabled in the material.
  124806. */
  124807. isEnabled: boolean;
  124808. /**
  124809. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124810. */
  124811. intensity: number;
  124812. /**
  124813. * Defines if the effect is along the tangents, bitangents or in between.
  124814. * By default, the effect is "strectching" the highlights along the tangents.
  124815. */
  124816. direction: Vector2;
  124817. private _texture;
  124818. /**
  124819. * Stores the anisotropy values in a texture.
  124820. * rg is direction (like normal from -1 to 1)
  124821. * b is a intensity
  124822. */
  124823. texture: Nullable<BaseTexture>;
  124824. /** @hidden */
  124825. private _internalMarkAllSubMeshesAsTexturesDirty;
  124826. /** @hidden */
  124827. _markAllSubMeshesAsTexturesDirty(): void;
  124828. /**
  124829. * Instantiate a new istance of anisotropy configuration.
  124830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124831. */
  124832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124833. /**
  124834. * Specifies that the submesh is ready to be used.
  124835. * @param defines the list of "defines" to update.
  124836. * @param scene defines the scene the material belongs to.
  124837. * @returns - boolean indicating that the submesh is ready or not.
  124838. */
  124839. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124840. /**
  124841. * Checks to see if a texture is used in the material.
  124842. * @param defines the list of "defines" to update.
  124843. * @param mesh the mesh we are preparing the defines for.
  124844. * @param scene defines the scene the material belongs to.
  124845. */
  124846. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124847. /**
  124848. * Binds the material data.
  124849. * @param uniformBuffer defines the Uniform buffer to fill in.
  124850. * @param scene defines the scene the material belongs to.
  124851. * @param isFrozen defines wether the material is frozen or not.
  124852. */
  124853. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124854. /**
  124855. * Checks to see if a texture is used in the material.
  124856. * @param texture - Base texture to use.
  124857. * @returns - Boolean specifying if a texture is used in the material.
  124858. */
  124859. hasTexture(texture: BaseTexture): boolean;
  124860. /**
  124861. * Returns an array of the actively used textures.
  124862. * @param activeTextures Array of BaseTextures
  124863. */
  124864. getActiveTextures(activeTextures: BaseTexture[]): void;
  124865. /**
  124866. * Returns the animatable textures.
  124867. * @param animatables Array of animatable textures.
  124868. */
  124869. getAnimatables(animatables: IAnimatable[]): void;
  124870. /**
  124871. * Disposes the resources of the material.
  124872. * @param forceDisposeTextures - Forces the disposal of all textures.
  124873. */
  124874. dispose(forceDisposeTextures?: boolean): void;
  124875. /**
  124876. * Get the current class name of the texture useful for serialization or dynamic coding.
  124877. * @returns "PBRAnisotropicConfiguration"
  124878. */
  124879. getClassName(): string;
  124880. /**
  124881. * Add fallbacks to the effect fallbacks list.
  124882. * @param defines defines the Base texture to use.
  124883. * @param fallbacks defines the current fallback list.
  124884. * @param currentRank defines the current fallback rank.
  124885. * @returns the new fallback rank.
  124886. */
  124887. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124888. /**
  124889. * Add the required uniforms to the current list.
  124890. * @param uniforms defines the current uniform list.
  124891. */
  124892. static AddUniforms(uniforms: string[]): void;
  124893. /**
  124894. * Add the required uniforms to the current buffer.
  124895. * @param uniformBuffer defines the current uniform buffer.
  124896. */
  124897. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124898. /**
  124899. * Add the required samplers to the current list.
  124900. * @param samplers defines the current sampler list.
  124901. */
  124902. static AddSamplers(samplers: string[]): void;
  124903. /**
  124904. * Makes a duplicate of the current configuration into another one.
  124905. * @param anisotropicConfiguration define the config where to copy the info
  124906. */
  124907. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124908. /**
  124909. * Serializes this anisotropy configuration.
  124910. * @returns - An object with the serialized config.
  124911. */
  124912. serialize(): any;
  124913. /**
  124914. * Parses a anisotropy Configuration from a serialized object.
  124915. * @param source - Serialized object.
  124916. * @param scene Defines the scene we are parsing for
  124917. * @param rootUrl Defines the rootUrl to load from
  124918. */
  124919. parse(source: any, scene: Scene, rootUrl: string): void;
  124920. }
  124921. }
  124922. declare module BABYLON {
  124923. /**
  124924. * @hidden
  124925. */
  124926. export interface IMaterialBRDFDefines {
  124927. BRDF_V_HEIGHT_CORRELATED: boolean;
  124928. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124929. SPHERICAL_HARMONICS: boolean;
  124930. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124931. /** @hidden */
  124932. _areMiscDirty: boolean;
  124933. }
  124934. /**
  124935. * Define the code related to the BRDF parameters of the pbr material.
  124936. */
  124937. export class PBRBRDFConfiguration {
  124938. /**
  124939. * Default value used for the energy conservation.
  124940. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124941. */
  124942. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124943. /**
  124944. * Default value used for the Smith Visibility Height Correlated mode.
  124945. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124946. */
  124947. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124948. /**
  124949. * Default value used for the IBL diffuse part.
  124950. * This can help switching back to the polynomials mode globally which is a tiny bit
  124951. * less GPU intensive at the drawback of a lower quality.
  124952. */
  124953. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124954. /**
  124955. * Default value used for activating energy conservation for the specular workflow.
  124956. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124957. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124958. */
  124959. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124960. private _useEnergyConservation;
  124961. /**
  124962. * Defines if the material uses energy conservation.
  124963. */
  124964. useEnergyConservation: boolean;
  124965. private _useSmithVisibilityHeightCorrelated;
  124966. /**
  124967. * LEGACY Mode set to false
  124968. * Defines if the material uses height smith correlated visibility term.
  124969. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124970. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124971. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124972. * Not relying on height correlated will also disable energy conservation.
  124973. */
  124974. useSmithVisibilityHeightCorrelated: boolean;
  124975. private _useSphericalHarmonics;
  124976. /**
  124977. * LEGACY Mode set to false
  124978. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124979. * diffuse part of the IBL.
  124980. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124981. * to the ground truth.
  124982. */
  124983. useSphericalHarmonics: boolean;
  124984. private _useSpecularGlossinessInputEnergyConservation;
  124985. /**
  124986. * Defines if the material uses energy conservation, when the specular workflow is active.
  124987. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124988. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124989. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124990. */
  124991. useSpecularGlossinessInputEnergyConservation: boolean;
  124992. /** @hidden */
  124993. private _internalMarkAllSubMeshesAsMiscDirty;
  124994. /** @hidden */
  124995. _markAllSubMeshesAsMiscDirty(): void;
  124996. /**
  124997. * Instantiate a new istance of clear coat configuration.
  124998. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124999. */
  125000. constructor(markAllSubMeshesAsMiscDirty: () => void);
  125001. /**
  125002. * Checks to see if a texture is used in the material.
  125003. * @param defines the list of "defines" to update.
  125004. */
  125005. prepareDefines(defines: IMaterialBRDFDefines): void;
  125006. /**
  125007. * Get the current class name of the texture useful for serialization or dynamic coding.
  125008. * @returns "PBRClearCoatConfiguration"
  125009. */
  125010. getClassName(): string;
  125011. /**
  125012. * Makes a duplicate of the current configuration into another one.
  125013. * @param brdfConfiguration define the config where to copy the info
  125014. */
  125015. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  125016. /**
  125017. * Serializes this BRDF configuration.
  125018. * @returns - An object with the serialized config.
  125019. */
  125020. serialize(): any;
  125021. /**
  125022. * Parses a anisotropy Configuration from a serialized object.
  125023. * @param source - Serialized object.
  125024. * @param scene Defines the scene we are parsing for
  125025. * @param rootUrl Defines the rootUrl to load from
  125026. */
  125027. parse(source: any, scene: Scene, rootUrl: string): void;
  125028. }
  125029. }
  125030. declare module BABYLON {
  125031. /**
  125032. * @hidden
  125033. */
  125034. export interface IMaterialSheenDefines {
  125035. SHEEN: boolean;
  125036. SHEEN_TEXTURE: boolean;
  125037. SHEEN_TEXTUREDIRECTUV: number;
  125038. SHEEN_LINKWITHALBEDO: boolean;
  125039. SHEEN_ROUGHNESS: boolean;
  125040. SHEEN_ALBEDOSCALING: boolean;
  125041. /** @hidden */
  125042. _areTexturesDirty: boolean;
  125043. }
  125044. /**
  125045. * Define the code related to the Sheen parameters of the pbr material.
  125046. */
  125047. export class PBRSheenConfiguration {
  125048. private _isEnabled;
  125049. /**
  125050. * Defines if the material uses sheen.
  125051. */
  125052. isEnabled: boolean;
  125053. private _linkSheenWithAlbedo;
  125054. /**
  125055. * Defines if the sheen is linked to the sheen color.
  125056. */
  125057. linkSheenWithAlbedo: boolean;
  125058. /**
  125059. * Defines the sheen intensity.
  125060. */
  125061. intensity: number;
  125062. /**
  125063. * Defines the sheen color.
  125064. */
  125065. color: Color3;
  125066. private _texture;
  125067. /**
  125068. * Stores the sheen tint values in a texture.
  125069. * rgb is tint
  125070. * a is a intensity
  125071. */
  125072. texture: Nullable<BaseTexture>;
  125073. private _roughness;
  125074. /**
  125075. * Defines the sheen roughness.
  125076. * It is not taken into account if linkSheenWithAlbedo is true.
  125077. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125078. */
  125079. roughness: Nullable<number>;
  125080. private _albedoScaling;
  125081. /**
  125082. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125083. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125084. * making it easier to setup and tweak the effect
  125085. */
  125086. albedoScaling: boolean;
  125087. /** @hidden */
  125088. private _internalMarkAllSubMeshesAsTexturesDirty;
  125089. /** @hidden */
  125090. _markAllSubMeshesAsTexturesDirty(): void;
  125091. /**
  125092. * Instantiate a new istance of clear coat configuration.
  125093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125094. */
  125095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125096. /**
  125097. * Specifies that the submesh is ready to be used.
  125098. * @param defines the list of "defines" to update.
  125099. * @param scene defines the scene the material belongs to.
  125100. * @returns - boolean indicating that the submesh is ready or not.
  125101. */
  125102. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125103. /**
  125104. * Checks to see if a texture is used in the material.
  125105. * @param defines the list of "defines" to update.
  125106. * @param scene defines the scene the material belongs to.
  125107. */
  125108. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125109. /**
  125110. * Binds the material data.
  125111. * @param uniformBuffer defines the Uniform buffer to fill in.
  125112. * @param scene defines the scene the material belongs to.
  125113. * @param isFrozen defines wether the material is frozen or not.
  125114. */
  125115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125116. /**
  125117. * Checks to see if a texture is used in the material.
  125118. * @param texture - Base texture to use.
  125119. * @returns - Boolean specifying if a texture is used in the material.
  125120. */
  125121. hasTexture(texture: BaseTexture): boolean;
  125122. /**
  125123. * Returns an array of the actively used textures.
  125124. * @param activeTextures Array of BaseTextures
  125125. */
  125126. getActiveTextures(activeTextures: BaseTexture[]): void;
  125127. /**
  125128. * Returns the animatable textures.
  125129. * @param animatables Array of animatable textures.
  125130. */
  125131. getAnimatables(animatables: IAnimatable[]): void;
  125132. /**
  125133. * Disposes the resources of the material.
  125134. * @param forceDisposeTextures - Forces the disposal of all textures.
  125135. */
  125136. dispose(forceDisposeTextures?: boolean): void;
  125137. /**
  125138. * Get the current class name of the texture useful for serialization or dynamic coding.
  125139. * @returns "PBRSheenConfiguration"
  125140. */
  125141. getClassName(): string;
  125142. /**
  125143. * Add fallbacks to the effect fallbacks list.
  125144. * @param defines defines the Base texture to use.
  125145. * @param fallbacks defines the current fallback list.
  125146. * @param currentRank defines the current fallback rank.
  125147. * @returns the new fallback rank.
  125148. */
  125149. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125150. /**
  125151. * Add the required uniforms to the current list.
  125152. * @param uniforms defines the current uniform list.
  125153. */
  125154. static AddUniforms(uniforms: string[]): void;
  125155. /**
  125156. * Add the required uniforms to the current buffer.
  125157. * @param uniformBuffer defines the current uniform buffer.
  125158. */
  125159. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125160. /**
  125161. * Add the required samplers to the current list.
  125162. * @param samplers defines the current sampler list.
  125163. */
  125164. static AddSamplers(samplers: string[]): void;
  125165. /**
  125166. * Makes a duplicate of the current configuration into another one.
  125167. * @param sheenConfiguration define the config where to copy the info
  125168. */
  125169. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125170. /**
  125171. * Serializes this BRDF configuration.
  125172. * @returns - An object with the serialized config.
  125173. */
  125174. serialize(): any;
  125175. /**
  125176. * Parses a anisotropy Configuration from a serialized object.
  125177. * @param source - Serialized object.
  125178. * @param scene Defines the scene we are parsing for
  125179. * @param rootUrl Defines the rootUrl to load from
  125180. */
  125181. parse(source: any, scene: Scene, rootUrl: string): void;
  125182. }
  125183. }
  125184. declare module BABYLON {
  125185. /**
  125186. * @hidden
  125187. */
  125188. export interface IMaterialSubSurfaceDefines {
  125189. SUBSURFACE: boolean;
  125190. SS_REFRACTION: boolean;
  125191. SS_TRANSLUCENCY: boolean;
  125192. SS_SCATERRING: boolean;
  125193. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125194. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125195. SS_REFRACTIONMAP_3D: boolean;
  125196. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125197. SS_LODINREFRACTIONALPHA: boolean;
  125198. SS_GAMMAREFRACTION: boolean;
  125199. SS_RGBDREFRACTION: boolean;
  125200. SS_LINEARSPECULARREFRACTION: boolean;
  125201. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125202. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125203. /** @hidden */
  125204. _areTexturesDirty: boolean;
  125205. }
  125206. /**
  125207. * Define the code related to the sub surface parameters of the pbr material.
  125208. */
  125209. export class PBRSubSurfaceConfiguration {
  125210. private _isRefractionEnabled;
  125211. /**
  125212. * Defines if the refraction is enabled in the material.
  125213. */
  125214. isRefractionEnabled: boolean;
  125215. private _isTranslucencyEnabled;
  125216. /**
  125217. * Defines if the translucency is enabled in the material.
  125218. */
  125219. isTranslucencyEnabled: boolean;
  125220. private _isScatteringEnabled;
  125221. /**
  125222. * Defines the refraction intensity of the material.
  125223. * The refraction when enabled replaces the Diffuse part of the material.
  125224. * The intensity helps transitionning between diffuse and refraction.
  125225. */
  125226. refractionIntensity: number;
  125227. /**
  125228. * Defines the translucency intensity of the material.
  125229. * When translucency has been enabled, this defines how much of the "translucency"
  125230. * is addded to the diffuse part of the material.
  125231. */
  125232. translucencyIntensity: number;
  125233. /**
  125234. * Defines the scattering intensity of the material.
  125235. * When scattering has been enabled, this defines how much of the "scattered light"
  125236. * is addded to the diffuse part of the material.
  125237. */
  125238. scatteringIntensity: number;
  125239. private _thicknessTexture;
  125240. /**
  125241. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125242. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125243. * 0 would mean minimumThickness
  125244. * 1 would mean maximumThickness
  125245. * The other channels might be use as a mask to vary the different effects intensity.
  125246. */
  125247. thicknessTexture: Nullable<BaseTexture>;
  125248. private _refractionTexture;
  125249. /**
  125250. * Defines the texture to use for refraction.
  125251. */
  125252. refractionTexture: Nullable<BaseTexture>;
  125253. private _indexOfRefraction;
  125254. /**
  125255. * Defines the index of refraction used in the material.
  125256. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125257. */
  125258. indexOfRefraction: number;
  125259. private _invertRefractionY;
  125260. /**
  125261. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125262. */
  125263. invertRefractionY: boolean;
  125264. private _linkRefractionWithTransparency;
  125265. /**
  125266. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125267. * Materials half opaque for instance using refraction could benefit from this control.
  125268. */
  125269. linkRefractionWithTransparency: boolean;
  125270. /**
  125271. * Defines the minimum thickness stored in the thickness map.
  125272. * If no thickness map is defined, this value will be used to simulate thickness.
  125273. */
  125274. minimumThickness: number;
  125275. /**
  125276. * Defines the maximum thickness stored in the thickness map.
  125277. */
  125278. maximumThickness: number;
  125279. /**
  125280. * Defines the volume tint of the material.
  125281. * This is used for both translucency and scattering.
  125282. */
  125283. tintColor: Color3;
  125284. /**
  125285. * Defines the distance at which the tint color should be found in the media.
  125286. * This is used for refraction only.
  125287. */
  125288. tintColorAtDistance: number;
  125289. /**
  125290. * Defines how far each channel transmit through the media.
  125291. * It is defined as a color to simplify it selection.
  125292. */
  125293. diffusionDistance: Color3;
  125294. private _useMaskFromThicknessTexture;
  125295. /**
  125296. * Stores the intensity of the different subsurface effects in the thickness texture.
  125297. * * the green channel is the translucency intensity.
  125298. * * the blue channel is the scattering intensity.
  125299. * * the alpha channel is the refraction intensity.
  125300. */
  125301. useMaskFromThicknessTexture: boolean;
  125302. /** @hidden */
  125303. private _internalMarkAllSubMeshesAsTexturesDirty;
  125304. /** @hidden */
  125305. _markAllSubMeshesAsTexturesDirty(): void;
  125306. /**
  125307. * Instantiate a new istance of sub surface configuration.
  125308. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125309. */
  125310. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125311. /**
  125312. * Gets wehter the submesh is ready to be used or not.
  125313. * @param defines the list of "defines" to update.
  125314. * @param scene defines the scene the material belongs to.
  125315. * @returns - boolean indicating that the submesh is ready or not.
  125316. */
  125317. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125318. /**
  125319. * Checks to see if a texture is used in the material.
  125320. * @param defines the list of "defines" to update.
  125321. * @param scene defines the scene to the material belongs to.
  125322. */
  125323. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125324. /**
  125325. * Binds the material data.
  125326. * @param uniformBuffer defines the Uniform buffer to fill in.
  125327. * @param scene defines the scene the material belongs to.
  125328. * @param engine defines the engine the material belongs to.
  125329. * @param isFrozen defines wether the material is frozen or not.
  125330. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125331. */
  125332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125333. /**
  125334. * Unbinds the material from the mesh.
  125335. * @param activeEffect defines the effect that should be unbound from.
  125336. * @returns true if unbound, otherwise false
  125337. */
  125338. unbind(activeEffect: Effect): boolean;
  125339. /**
  125340. * Returns the texture used for refraction or null if none is used.
  125341. * @param scene defines the scene the material belongs to.
  125342. * @returns - Refraction texture if present. If no refraction texture and refraction
  125343. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125344. */
  125345. private _getRefractionTexture;
  125346. /**
  125347. * Returns true if alpha blending should be disabled.
  125348. */
  125349. get disableAlphaBlending(): boolean;
  125350. /**
  125351. * Fills the list of render target textures.
  125352. * @param renderTargets the list of render targets to update
  125353. */
  125354. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125355. /**
  125356. * Checks to see if a texture is used in the material.
  125357. * @param texture - Base texture to use.
  125358. * @returns - Boolean specifying if a texture is used in the material.
  125359. */
  125360. hasTexture(texture: BaseTexture): boolean;
  125361. /**
  125362. * Gets a boolean indicating that current material needs to register RTT
  125363. * @returns true if this uses a render target otherwise false.
  125364. */
  125365. hasRenderTargetTextures(): boolean;
  125366. /**
  125367. * Returns an array of the actively used textures.
  125368. * @param activeTextures Array of BaseTextures
  125369. */
  125370. getActiveTextures(activeTextures: BaseTexture[]): void;
  125371. /**
  125372. * Returns the animatable textures.
  125373. * @param animatables Array of animatable textures.
  125374. */
  125375. getAnimatables(animatables: IAnimatable[]): void;
  125376. /**
  125377. * Disposes the resources of the material.
  125378. * @param forceDisposeTextures - Forces the disposal of all textures.
  125379. */
  125380. dispose(forceDisposeTextures?: boolean): void;
  125381. /**
  125382. * Get the current class name of the texture useful for serialization or dynamic coding.
  125383. * @returns "PBRSubSurfaceConfiguration"
  125384. */
  125385. getClassName(): string;
  125386. /**
  125387. * Add fallbacks to the effect fallbacks list.
  125388. * @param defines defines the Base texture to use.
  125389. * @param fallbacks defines the current fallback list.
  125390. * @param currentRank defines the current fallback rank.
  125391. * @returns the new fallback rank.
  125392. */
  125393. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125394. /**
  125395. * Add the required uniforms to the current list.
  125396. * @param uniforms defines the current uniform list.
  125397. */
  125398. static AddUniforms(uniforms: string[]): void;
  125399. /**
  125400. * Add the required samplers to the current list.
  125401. * @param samplers defines the current sampler list.
  125402. */
  125403. static AddSamplers(samplers: string[]): void;
  125404. /**
  125405. * Add the required uniforms to the current buffer.
  125406. * @param uniformBuffer defines the current uniform buffer.
  125407. */
  125408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125409. /**
  125410. * Makes a duplicate of the current configuration into another one.
  125411. * @param configuration define the config where to copy the info
  125412. */
  125413. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125414. /**
  125415. * Serializes this Sub Surface configuration.
  125416. * @returns - An object with the serialized config.
  125417. */
  125418. serialize(): any;
  125419. /**
  125420. * Parses a anisotropy Configuration from a serialized object.
  125421. * @param source - Serialized object.
  125422. * @param scene Defines the scene we are parsing for
  125423. * @param rootUrl Defines the rootUrl to load from
  125424. */
  125425. parse(source: any, scene: Scene, rootUrl: string): void;
  125426. }
  125427. }
  125428. declare module BABYLON {
  125429. /** @hidden */
  125430. export var pbrFragmentDeclaration: {
  125431. name: string;
  125432. shader: string;
  125433. };
  125434. }
  125435. declare module BABYLON {
  125436. /** @hidden */
  125437. export var pbrUboDeclaration: {
  125438. name: string;
  125439. shader: string;
  125440. };
  125441. }
  125442. declare module BABYLON {
  125443. /** @hidden */
  125444. export var pbrFragmentExtraDeclaration: {
  125445. name: string;
  125446. shader: string;
  125447. };
  125448. }
  125449. declare module BABYLON {
  125450. /** @hidden */
  125451. export var pbrFragmentSamplersDeclaration: {
  125452. name: string;
  125453. shader: string;
  125454. };
  125455. }
  125456. declare module BABYLON {
  125457. /** @hidden */
  125458. export var pbrHelperFunctions: {
  125459. name: string;
  125460. shader: string;
  125461. };
  125462. }
  125463. declare module BABYLON {
  125464. /** @hidden */
  125465. export var harmonicsFunctions: {
  125466. name: string;
  125467. shader: string;
  125468. };
  125469. }
  125470. declare module BABYLON {
  125471. /** @hidden */
  125472. export var pbrDirectLightingSetupFunctions: {
  125473. name: string;
  125474. shader: string;
  125475. };
  125476. }
  125477. declare module BABYLON {
  125478. /** @hidden */
  125479. export var pbrDirectLightingFalloffFunctions: {
  125480. name: string;
  125481. shader: string;
  125482. };
  125483. }
  125484. declare module BABYLON {
  125485. /** @hidden */
  125486. export var pbrBRDFFunctions: {
  125487. name: string;
  125488. shader: string;
  125489. };
  125490. }
  125491. declare module BABYLON {
  125492. /** @hidden */
  125493. export var pbrDirectLightingFunctions: {
  125494. name: string;
  125495. shader: string;
  125496. };
  125497. }
  125498. declare module BABYLON {
  125499. /** @hidden */
  125500. export var pbrIBLFunctions: {
  125501. name: string;
  125502. shader: string;
  125503. };
  125504. }
  125505. declare module BABYLON {
  125506. /** @hidden */
  125507. export var pbrBlockAlbedoOpacity: {
  125508. name: string;
  125509. shader: string;
  125510. };
  125511. }
  125512. declare module BABYLON {
  125513. /** @hidden */
  125514. export var pbrBlockReflectivity: {
  125515. name: string;
  125516. shader: string;
  125517. };
  125518. }
  125519. declare module BABYLON {
  125520. /** @hidden */
  125521. export var pbrBlockAmbientOcclusion: {
  125522. name: string;
  125523. shader: string;
  125524. };
  125525. }
  125526. declare module BABYLON {
  125527. /** @hidden */
  125528. export var pbrBlockAlphaFresnel: {
  125529. name: string;
  125530. shader: string;
  125531. };
  125532. }
  125533. declare module BABYLON {
  125534. /** @hidden */
  125535. export var pbrBlockAnisotropic: {
  125536. name: string;
  125537. shader: string;
  125538. };
  125539. }
  125540. declare module BABYLON {
  125541. /** @hidden */
  125542. export var pbrBlockReflection: {
  125543. name: string;
  125544. shader: string;
  125545. };
  125546. }
  125547. declare module BABYLON {
  125548. /** @hidden */
  125549. export var pbrBlockSheen: {
  125550. name: string;
  125551. shader: string;
  125552. };
  125553. }
  125554. declare module BABYLON {
  125555. /** @hidden */
  125556. export var pbrBlockClearcoat: {
  125557. name: string;
  125558. shader: string;
  125559. };
  125560. }
  125561. declare module BABYLON {
  125562. /** @hidden */
  125563. export var pbrBlockSubSurface: {
  125564. name: string;
  125565. shader: string;
  125566. };
  125567. }
  125568. declare module BABYLON {
  125569. /** @hidden */
  125570. export var pbrBlockNormalGeometric: {
  125571. name: string;
  125572. shader: string;
  125573. };
  125574. }
  125575. declare module BABYLON {
  125576. /** @hidden */
  125577. export var pbrBlockNormalFinal: {
  125578. name: string;
  125579. shader: string;
  125580. };
  125581. }
  125582. declare module BABYLON {
  125583. /** @hidden */
  125584. export var pbrBlockGeometryInfo: {
  125585. name: string;
  125586. shader: string;
  125587. };
  125588. }
  125589. declare module BABYLON {
  125590. /** @hidden */
  125591. export var pbrBlockReflectance0: {
  125592. name: string;
  125593. shader: string;
  125594. };
  125595. }
  125596. declare module BABYLON {
  125597. /** @hidden */
  125598. export var pbrBlockReflectance: {
  125599. name: string;
  125600. shader: string;
  125601. };
  125602. }
  125603. declare module BABYLON {
  125604. /** @hidden */
  125605. export var pbrBlockDirectLighting: {
  125606. name: string;
  125607. shader: string;
  125608. };
  125609. }
  125610. declare module BABYLON {
  125611. /** @hidden */
  125612. export var pbrBlockFinalLitComponents: {
  125613. name: string;
  125614. shader: string;
  125615. };
  125616. }
  125617. declare module BABYLON {
  125618. /** @hidden */
  125619. export var pbrBlockFinalUnlitComponents: {
  125620. name: string;
  125621. shader: string;
  125622. };
  125623. }
  125624. declare module BABYLON {
  125625. /** @hidden */
  125626. export var pbrBlockFinalColorComposition: {
  125627. name: string;
  125628. shader: string;
  125629. };
  125630. }
  125631. declare module BABYLON {
  125632. /** @hidden */
  125633. export var pbrBlockImageProcessing: {
  125634. name: string;
  125635. shader: string;
  125636. };
  125637. }
  125638. declare module BABYLON {
  125639. /** @hidden */
  125640. export var pbrDebug: {
  125641. name: string;
  125642. shader: string;
  125643. };
  125644. }
  125645. declare module BABYLON {
  125646. /** @hidden */
  125647. export var pbrPixelShader: {
  125648. name: string;
  125649. shader: string;
  125650. };
  125651. }
  125652. declare module BABYLON {
  125653. /** @hidden */
  125654. export var pbrVertexDeclaration: {
  125655. name: string;
  125656. shader: string;
  125657. };
  125658. }
  125659. declare module BABYLON {
  125660. /** @hidden */
  125661. export var pbrVertexShader: {
  125662. name: string;
  125663. shader: string;
  125664. };
  125665. }
  125666. declare module BABYLON {
  125667. /**
  125668. * Manages the defines for the PBR Material.
  125669. * @hidden
  125670. */
  125671. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125672. PBR: boolean;
  125673. MAINUV1: boolean;
  125674. MAINUV2: boolean;
  125675. UV1: boolean;
  125676. UV2: boolean;
  125677. ALBEDO: boolean;
  125678. GAMMAALBEDO: boolean;
  125679. ALBEDODIRECTUV: number;
  125680. VERTEXCOLOR: boolean;
  125681. AMBIENT: boolean;
  125682. AMBIENTDIRECTUV: number;
  125683. AMBIENTINGRAYSCALE: boolean;
  125684. OPACITY: boolean;
  125685. VERTEXALPHA: boolean;
  125686. OPACITYDIRECTUV: number;
  125687. OPACITYRGB: boolean;
  125688. ALPHATEST: boolean;
  125689. DEPTHPREPASS: boolean;
  125690. ALPHABLEND: boolean;
  125691. ALPHAFROMALBEDO: boolean;
  125692. ALPHATESTVALUE: string;
  125693. SPECULAROVERALPHA: boolean;
  125694. RADIANCEOVERALPHA: boolean;
  125695. ALPHAFRESNEL: boolean;
  125696. LINEARALPHAFRESNEL: boolean;
  125697. PREMULTIPLYALPHA: boolean;
  125698. EMISSIVE: boolean;
  125699. EMISSIVEDIRECTUV: number;
  125700. REFLECTIVITY: boolean;
  125701. REFLECTIVITYDIRECTUV: number;
  125702. SPECULARTERM: boolean;
  125703. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125704. MICROSURFACEAUTOMATIC: boolean;
  125705. LODBASEDMICROSFURACE: boolean;
  125706. MICROSURFACEMAP: boolean;
  125707. MICROSURFACEMAPDIRECTUV: number;
  125708. METALLICWORKFLOW: boolean;
  125709. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125710. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125711. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125712. AOSTOREINMETALMAPRED: boolean;
  125713. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125714. ENVIRONMENTBRDF: boolean;
  125715. ENVIRONMENTBRDF_RGBD: boolean;
  125716. NORMAL: boolean;
  125717. TANGENT: boolean;
  125718. BUMP: boolean;
  125719. BUMPDIRECTUV: number;
  125720. OBJECTSPACE_NORMALMAP: boolean;
  125721. PARALLAX: boolean;
  125722. PARALLAXOCCLUSION: boolean;
  125723. NORMALXYSCALE: boolean;
  125724. LIGHTMAP: boolean;
  125725. LIGHTMAPDIRECTUV: number;
  125726. USELIGHTMAPASSHADOWMAP: boolean;
  125727. GAMMALIGHTMAP: boolean;
  125728. RGBDLIGHTMAP: boolean;
  125729. REFLECTION: boolean;
  125730. REFLECTIONMAP_3D: boolean;
  125731. REFLECTIONMAP_SPHERICAL: boolean;
  125732. REFLECTIONMAP_PLANAR: boolean;
  125733. REFLECTIONMAP_CUBIC: boolean;
  125734. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125735. REFLECTIONMAP_PROJECTION: boolean;
  125736. REFLECTIONMAP_SKYBOX: boolean;
  125737. REFLECTIONMAP_EXPLICIT: boolean;
  125738. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125739. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125740. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125741. INVERTCUBICMAP: boolean;
  125742. USESPHERICALFROMREFLECTIONMAP: boolean;
  125743. USEIRRADIANCEMAP: boolean;
  125744. SPHERICAL_HARMONICS: boolean;
  125745. USESPHERICALINVERTEX: boolean;
  125746. REFLECTIONMAP_OPPOSITEZ: boolean;
  125747. LODINREFLECTIONALPHA: boolean;
  125748. GAMMAREFLECTION: boolean;
  125749. RGBDREFLECTION: boolean;
  125750. LINEARSPECULARREFLECTION: boolean;
  125751. RADIANCEOCCLUSION: boolean;
  125752. HORIZONOCCLUSION: boolean;
  125753. INSTANCES: boolean;
  125754. NUM_BONE_INFLUENCERS: number;
  125755. BonesPerMesh: number;
  125756. BONETEXTURE: boolean;
  125757. NONUNIFORMSCALING: boolean;
  125758. MORPHTARGETS: boolean;
  125759. MORPHTARGETS_NORMAL: boolean;
  125760. MORPHTARGETS_TANGENT: boolean;
  125761. MORPHTARGETS_UV: boolean;
  125762. NUM_MORPH_INFLUENCERS: number;
  125763. IMAGEPROCESSING: boolean;
  125764. VIGNETTE: boolean;
  125765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125766. VIGNETTEBLENDMODEOPAQUE: boolean;
  125767. TONEMAPPING: boolean;
  125768. TONEMAPPING_ACES: boolean;
  125769. CONTRAST: boolean;
  125770. COLORCURVES: boolean;
  125771. COLORGRADING: boolean;
  125772. COLORGRADING3D: boolean;
  125773. SAMPLER3DGREENDEPTH: boolean;
  125774. SAMPLER3DBGRMAP: boolean;
  125775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125776. EXPOSURE: boolean;
  125777. MULTIVIEW: boolean;
  125778. USEPHYSICALLIGHTFALLOFF: boolean;
  125779. USEGLTFLIGHTFALLOFF: boolean;
  125780. TWOSIDEDLIGHTING: boolean;
  125781. SHADOWFLOAT: boolean;
  125782. CLIPPLANE: boolean;
  125783. CLIPPLANE2: boolean;
  125784. CLIPPLANE3: boolean;
  125785. CLIPPLANE4: boolean;
  125786. CLIPPLANE5: boolean;
  125787. CLIPPLANE6: boolean;
  125788. POINTSIZE: boolean;
  125789. FOG: boolean;
  125790. LOGARITHMICDEPTH: boolean;
  125791. FORCENORMALFORWARD: boolean;
  125792. SPECULARAA: boolean;
  125793. CLEARCOAT: boolean;
  125794. CLEARCOAT_DEFAULTIOR: boolean;
  125795. CLEARCOAT_TEXTURE: boolean;
  125796. CLEARCOAT_TEXTUREDIRECTUV: number;
  125797. CLEARCOAT_BUMP: boolean;
  125798. CLEARCOAT_BUMPDIRECTUV: number;
  125799. CLEARCOAT_TINT: boolean;
  125800. CLEARCOAT_TINT_TEXTURE: boolean;
  125801. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125802. ANISOTROPIC: boolean;
  125803. ANISOTROPIC_TEXTURE: boolean;
  125804. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125805. BRDF_V_HEIGHT_CORRELATED: boolean;
  125806. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125807. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125808. SHEEN: boolean;
  125809. SHEEN_TEXTURE: boolean;
  125810. SHEEN_TEXTUREDIRECTUV: number;
  125811. SHEEN_LINKWITHALBEDO: boolean;
  125812. SHEEN_ROUGHNESS: boolean;
  125813. SHEEN_ALBEDOSCALING: boolean;
  125814. SUBSURFACE: boolean;
  125815. SS_REFRACTION: boolean;
  125816. SS_TRANSLUCENCY: boolean;
  125817. SS_SCATERRING: boolean;
  125818. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125819. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125820. SS_REFRACTIONMAP_3D: boolean;
  125821. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125822. SS_LODINREFRACTIONALPHA: boolean;
  125823. SS_GAMMAREFRACTION: boolean;
  125824. SS_RGBDREFRACTION: boolean;
  125825. SS_LINEARSPECULARREFRACTION: boolean;
  125826. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125827. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125828. UNLIT: boolean;
  125829. DEBUGMODE: number;
  125830. /**
  125831. * Initializes the PBR Material defines.
  125832. */
  125833. constructor();
  125834. /**
  125835. * Resets the PBR Material defines.
  125836. */
  125837. reset(): void;
  125838. }
  125839. /**
  125840. * The Physically based material base class of BJS.
  125841. *
  125842. * This offers the main features of a standard PBR material.
  125843. * For more information, please refer to the documentation :
  125844. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125845. */
  125846. export abstract class PBRBaseMaterial extends PushMaterial {
  125847. /**
  125848. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125849. */
  125850. static readonly PBRMATERIAL_OPAQUE: number;
  125851. /**
  125852. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125853. */
  125854. static readonly PBRMATERIAL_ALPHATEST: number;
  125855. /**
  125856. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125857. */
  125858. static readonly PBRMATERIAL_ALPHABLEND: number;
  125859. /**
  125860. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125861. * They are also discarded below the alpha cutoff threshold to improve performances.
  125862. */
  125863. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125864. /**
  125865. * Defines the default value of how much AO map is occluding the analytical lights
  125866. * (point spot...).
  125867. */
  125868. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125869. /**
  125870. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125871. */
  125872. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125873. /**
  125874. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125875. * to enhance interoperability with other engines.
  125876. */
  125877. static readonly LIGHTFALLOFF_GLTF: number;
  125878. /**
  125879. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125880. * to enhance interoperability with other materials.
  125881. */
  125882. static readonly LIGHTFALLOFF_STANDARD: number;
  125883. /**
  125884. * Intensity of the direct lights e.g. the four lights available in your scene.
  125885. * This impacts both the direct diffuse and specular highlights.
  125886. */
  125887. protected _directIntensity: number;
  125888. /**
  125889. * Intensity of the emissive part of the material.
  125890. * This helps controlling the emissive effect without modifying the emissive color.
  125891. */
  125892. protected _emissiveIntensity: number;
  125893. /**
  125894. * Intensity of the environment e.g. how much the environment will light the object
  125895. * either through harmonics for rough material or through the refelction for shiny ones.
  125896. */
  125897. protected _environmentIntensity: number;
  125898. /**
  125899. * This is a special control allowing the reduction of the specular highlights coming from the
  125900. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125901. */
  125902. protected _specularIntensity: number;
  125903. /**
  125904. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125905. */
  125906. private _lightingInfos;
  125907. /**
  125908. * Debug Control allowing disabling the bump map on this material.
  125909. */
  125910. protected _disableBumpMap: boolean;
  125911. /**
  125912. * AKA Diffuse Texture in standard nomenclature.
  125913. */
  125914. protected _albedoTexture: Nullable<BaseTexture>;
  125915. /**
  125916. * AKA Occlusion Texture in other nomenclature.
  125917. */
  125918. protected _ambientTexture: Nullable<BaseTexture>;
  125919. /**
  125920. * AKA Occlusion Texture Intensity in other nomenclature.
  125921. */
  125922. protected _ambientTextureStrength: number;
  125923. /**
  125924. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125925. * 1 means it completely occludes it
  125926. * 0 mean it has no impact
  125927. */
  125928. protected _ambientTextureImpactOnAnalyticalLights: number;
  125929. /**
  125930. * Stores the alpha values in a texture.
  125931. */
  125932. protected _opacityTexture: Nullable<BaseTexture>;
  125933. /**
  125934. * Stores the reflection values in a texture.
  125935. */
  125936. protected _reflectionTexture: Nullable<BaseTexture>;
  125937. /**
  125938. * Stores the emissive values in a texture.
  125939. */
  125940. protected _emissiveTexture: Nullable<BaseTexture>;
  125941. /**
  125942. * AKA Specular texture in other nomenclature.
  125943. */
  125944. protected _reflectivityTexture: Nullable<BaseTexture>;
  125945. /**
  125946. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125947. */
  125948. protected _metallicTexture: Nullable<BaseTexture>;
  125949. /**
  125950. * Specifies the metallic scalar of the metallic/roughness workflow.
  125951. * Can also be used to scale the metalness values of the metallic texture.
  125952. */
  125953. protected _metallic: Nullable<number>;
  125954. /**
  125955. * Specifies the roughness scalar of the metallic/roughness workflow.
  125956. * Can also be used to scale the roughness values of the metallic texture.
  125957. */
  125958. protected _roughness: Nullable<number>;
  125959. /**
  125960. * Specifies the an F0 factor to help configuring the material F0.
  125961. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125962. * to 0.5 the previously hard coded value stays the same.
  125963. * Can also be used to scale the F0 values of the metallic texture.
  125964. */
  125965. protected _metallicF0Factor: number;
  125966. /**
  125967. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125968. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125969. * your expectation as it multiplies with the texture data.
  125970. */
  125971. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125972. /**
  125973. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125974. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125975. */
  125976. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125977. /**
  125978. * Stores surface normal data used to displace a mesh in a texture.
  125979. */
  125980. protected _bumpTexture: Nullable<BaseTexture>;
  125981. /**
  125982. * Stores the pre-calculated light information of a mesh in a texture.
  125983. */
  125984. protected _lightmapTexture: Nullable<BaseTexture>;
  125985. /**
  125986. * The color of a material in ambient lighting.
  125987. */
  125988. protected _ambientColor: Color3;
  125989. /**
  125990. * AKA Diffuse Color in other nomenclature.
  125991. */
  125992. protected _albedoColor: Color3;
  125993. /**
  125994. * AKA Specular Color in other nomenclature.
  125995. */
  125996. protected _reflectivityColor: Color3;
  125997. /**
  125998. * The color applied when light is reflected from a material.
  125999. */
  126000. protected _reflectionColor: Color3;
  126001. /**
  126002. * The color applied when light is emitted from a material.
  126003. */
  126004. protected _emissiveColor: Color3;
  126005. /**
  126006. * AKA Glossiness in other nomenclature.
  126007. */
  126008. protected _microSurface: number;
  126009. /**
  126010. * Specifies that the material will use the light map as a show map.
  126011. */
  126012. protected _useLightmapAsShadowmap: boolean;
  126013. /**
  126014. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126015. * makes the reflect vector face the model (under horizon).
  126016. */
  126017. protected _useHorizonOcclusion: boolean;
  126018. /**
  126019. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126020. * too much the area relying on ambient texture to define their ambient occlusion.
  126021. */
  126022. protected _useRadianceOcclusion: boolean;
  126023. /**
  126024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126025. */
  126026. protected _useAlphaFromAlbedoTexture: boolean;
  126027. /**
  126028. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126029. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126030. */
  126031. protected _useSpecularOverAlpha: boolean;
  126032. /**
  126033. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126034. */
  126035. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126036. /**
  126037. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126038. */
  126039. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126040. /**
  126041. * Specifies if the metallic texture contains the roughness information in its green channel.
  126042. */
  126043. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126044. /**
  126045. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126046. */
  126047. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126048. /**
  126049. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126050. */
  126051. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126052. /**
  126053. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126054. */
  126055. protected _useAmbientInGrayScale: boolean;
  126056. /**
  126057. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126058. * The material will try to infer what glossiness each pixel should be.
  126059. */
  126060. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126061. /**
  126062. * Defines the falloff type used in this material.
  126063. * It by default is Physical.
  126064. */
  126065. protected _lightFalloff: number;
  126066. /**
  126067. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126068. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126069. */
  126070. protected _useRadianceOverAlpha: boolean;
  126071. /**
  126072. * Allows using an object space normal map (instead of tangent space).
  126073. */
  126074. protected _useObjectSpaceNormalMap: boolean;
  126075. /**
  126076. * Allows using the bump map in parallax mode.
  126077. */
  126078. protected _useParallax: boolean;
  126079. /**
  126080. * Allows using the bump map in parallax occlusion mode.
  126081. */
  126082. protected _useParallaxOcclusion: boolean;
  126083. /**
  126084. * Controls the scale bias of the parallax mode.
  126085. */
  126086. protected _parallaxScaleBias: number;
  126087. /**
  126088. * If sets to true, disables all the lights affecting the material.
  126089. */
  126090. protected _disableLighting: boolean;
  126091. /**
  126092. * Number of Simultaneous lights allowed on the material.
  126093. */
  126094. protected _maxSimultaneousLights: number;
  126095. /**
  126096. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126097. */
  126098. protected _invertNormalMapX: boolean;
  126099. /**
  126100. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126101. */
  126102. protected _invertNormalMapY: boolean;
  126103. /**
  126104. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126105. */
  126106. protected _twoSidedLighting: boolean;
  126107. /**
  126108. * Defines the alpha limits in alpha test mode.
  126109. */
  126110. protected _alphaCutOff: number;
  126111. /**
  126112. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126113. */
  126114. protected _forceAlphaTest: boolean;
  126115. /**
  126116. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126117. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126118. */
  126119. protected _useAlphaFresnel: boolean;
  126120. /**
  126121. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126122. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126123. */
  126124. protected _useLinearAlphaFresnel: boolean;
  126125. /**
  126126. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126127. * from cos thetav and roughness:
  126128. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126129. */
  126130. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126131. /**
  126132. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126133. */
  126134. protected _forceIrradianceInFragment: boolean;
  126135. /**
  126136. * Force normal to face away from face.
  126137. */
  126138. protected _forceNormalForward: boolean;
  126139. /**
  126140. * Enables specular anti aliasing in the PBR shader.
  126141. * It will both interacts on the Geometry for analytical and IBL lighting.
  126142. * It also prefilter the roughness map based on the bump values.
  126143. */
  126144. protected _enableSpecularAntiAliasing: boolean;
  126145. /**
  126146. * Default configuration related to image processing available in the PBR Material.
  126147. */
  126148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126149. /**
  126150. * Keep track of the image processing observer to allow dispose and replace.
  126151. */
  126152. private _imageProcessingObserver;
  126153. /**
  126154. * Attaches a new image processing configuration to the PBR Material.
  126155. * @param configuration
  126156. */
  126157. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126158. /**
  126159. * Stores the available render targets.
  126160. */
  126161. private _renderTargets;
  126162. /**
  126163. * Sets the global ambient color for the material used in lighting calculations.
  126164. */
  126165. private _globalAmbientColor;
  126166. /**
  126167. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126168. */
  126169. private _useLogarithmicDepth;
  126170. /**
  126171. * If set to true, no lighting calculations will be applied.
  126172. */
  126173. private _unlit;
  126174. private _debugMode;
  126175. /**
  126176. * @hidden
  126177. * This is reserved for the inspector.
  126178. * Defines the material debug mode.
  126179. * It helps seeing only some components of the material while troubleshooting.
  126180. */
  126181. debugMode: number;
  126182. /**
  126183. * @hidden
  126184. * This is reserved for the inspector.
  126185. * Specify from where on screen the debug mode should start.
  126186. * The value goes from -1 (full screen) to 1 (not visible)
  126187. * It helps with side by side comparison against the final render
  126188. * This defaults to -1
  126189. */
  126190. private debugLimit;
  126191. /**
  126192. * @hidden
  126193. * This is reserved for the inspector.
  126194. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126195. * You can use the factor to better multiply the final value.
  126196. */
  126197. private debugFactor;
  126198. /**
  126199. * Defines the clear coat layer parameters for the material.
  126200. */
  126201. readonly clearCoat: PBRClearCoatConfiguration;
  126202. /**
  126203. * Defines the anisotropic parameters for the material.
  126204. */
  126205. readonly anisotropy: PBRAnisotropicConfiguration;
  126206. /**
  126207. * Defines the BRDF parameters for the material.
  126208. */
  126209. readonly brdf: PBRBRDFConfiguration;
  126210. /**
  126211. * Defines the Sheen parameters for the material.
  126212. */
  126213. readonly sheen: PBRSheenConfiguration;
  126214. /**
  126215. * Defines the SubSurface parameters for the material.
  126216. */
  126217. readonly subSurface: PBRSubSurfaceConfiguration;
  126218. /**
  126219. * Custom callback helping to override the default shader used in the material.
  126220. */
  126221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126222. protected _rebuildInParallel: boolean;
  126223. /**
  126224. * Instantiates a new PBRMaterial instance.
  126225. *
  126226. * @param name The material name
  126227. * @param scene The scene the material will be use in.
  126228. */
  126229. constructor(name: string, scene: Scene);
  126230. /**
  126231. * Gets a boolean indicating that current material needs to register RTT
  126232. */
  126233. get hasRenderTargetTextures(): boolean;
  126234. /**
  126235. * Gets the name of the material class.
  126236. */
  126237. getClassName(): string;
  126238. /**
  126239. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126240. */
  126241. get useLogarithmicDepth(): boolean;
  126242. /**
  126243. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126244. */
  126245. set useLogarithmicDepth(value: boolean);
  126246. /**
  126247. * Returns true if alpha blending should be disabled.
  126248. */
  126249. protected get _disableAlphaBlending(): boolean;
  126250. /**
  126251. * Specifies whether or not this material should be rendered in alpha blend mode.
  126252. */
  126253. needAlphaBlending(): boolean;
  126254. /**
  126255. * Specifies whether or not this material should be rendered in alpha test mode.
  126256. */
  126257. needAlphaTesting(): boolean;
  126258. /**
  126259. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126260. */
  126261. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126262. /**
  126263. * Gets the texture used for the alpha test.
  126264. */
  126265. getAlphaTestTexture(): Nullable<BaseTexture>;
  126266. /**
  126267. * Specifies that the submesh is ready to be used.
  126268. * @param mesh - BJS mesh.
  126269. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126270. * @param useInstances - Specifies that instances should be used.
  126271. * @returns - boolean indicating that the submesh is ready or not.
  126272. */
  126273. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126274. /**
  126275. * Specifies if the material uses metallic roughness workflow.
  126276. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126277. */
  126278. isMetallicWorkflow(): boolean;
  126279. private _prepareEffect;
  126280. private _prepareDefines;
  126281. /**
  126282. * Force shader compilation
  126283. */
  126284. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126285. /**
  126286. * Initializes the uniform buffer layout for the shader.
  126287. */
  126288. buildUniformLayout(): void;
  126289. /**
  126290. * Unbinds the material from the mesh
  126291. */
  126292. unbind(): void;
  126293. /**
  126294. * Binds the submesh data.
  126295. * @param world - The world matrix.
  126296. * @param mesh - The BJS mesh.
  126297. * @param subMesh - A submesh of the BJS mesh.
  126298. */
  126299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126300. /**
  126301. * Returns the animatable textures.
  126302. * @returns - Array of animatable textures.
  126303. */
  126304. getAnimatables(): IAnimatable[];
  126305. /**
  126306. * Returns the texture used for reflections.
  126307. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126308. */
  126309. private _getReflectionTexture;
  126310. /**
  126311. * Returns an array of the actively used textures.
  126312. * @returns - Array of BaseTextures
  126313. */
  126314. getActiveTextures(): BaseTexture[];
  126315. /**
  126316. * Checks to see if a texture is used in the material.
  126317. * @param texture - Base texture to use.
  126318. * @returns - Boolean specifying if a texture is used in the material.
  126319. */
  126320. hasTexture(texture: BaseTexture): boolean;
  126321. /**
  126322. * Disposes the resources of the material.
  126323. * @param forceDisposeEffect - Forces the disposal of effects.
  126324. * @param forceDisposeTextures - Forces the disposal of all textures.
  126325. */
  126326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126327. }
  126328. }
  126329. declare module BABYLON {
  126330. /**
  126331. * The Physically based material of BJS.
  126332. *
  126333. * This offers the main features of a standard PBR material.
  126334. * For more information, please refer to the documentation :
  126335. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126336. */
  126337. export class PBRMaterial extends PBRBaseMaterial {
  126338. /**
  126339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126340. */
  126341. static readonly PBRMATERIAL_OPAQUE: number;
  126342. /**
  126343. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126344. */
  126345. static readonly PBRMATERIAL_ALPHATEST: number;
  126346. /**
  126347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126348. */
  126349. static readonly PBRMATERIAL_ALPHABLEND: number;
  126350. /**
  126351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126352. * They are also discarded below the alpha cutoff threshold to improve performances.
  126353. */
  126354. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126355. /**
  126356. * Defines the default value of how much AO map is occluding the analytical lights
  126357. * (point spot...).
  126358. */
  126359. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126360. /**
  126361. * Intensity of the direct lights e.g. the four lights available in your scene.
  126362. * This impacts both the direct diffuse and specular highlights.
  126363. */
  126364. directIntensity: number;
  126365. /**
  126366. * Intensity of the emissive part of the material.
  126367. * This helps controlling the emissive effect without modifying the emissive color.
  126368. */
  126369. emissiveIntensity: number;
  126370. /**
  126371. * Intensity of the environment e.g. how much the environment will light the object
  126372. * either through harmonics for rough material or through the refelction for shiny ones.
  126373. */
  126374. environmentIntensity: number;
  126375. /**
  126376. * This is a special control allowing the reduction of the specular highlights coming from the
  126377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126378. */
  126379. specularIntensity: number;
  126380. /**
  126381. * Debug Control allowing disabling the bump map on this material.
  126382. */
  126383. disableBumpMap: boolean;
  126384. /**
  126385. * AKA Diffuse Texture in standard nomenclature.
  126386. */
  126387. albedoTexture: BaseTexture;
  126388. /**
  126389. * AKA Occlusion Texture in other nomenclature.
  126390. */
  126391. ambientTexture: BaseTexture;
  126392. /**
  126393. * AKA Occlusion Texture Intensity in other nomenclature.
  126394. */
  126395. ambientTextureStrength: number;
  126396. /**
  126397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126398. * 1 means it completely occludes it
  126399. * 0 mean it has no impact
  126400. */
  126401. ambientTextureImpactOnAnalyticalLights: number;
  126402. /**
  126403. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126404. */
  126405. opacityTexture: BaseTexture;
  126406. /**
  126407. * Stores the reflection values in a texture.
  126408. */
  126409. reflectionTexture: Nullable<BaseTexture>;
  126410. /**
  126411. * Stores the emissive values in a texture.
  126412. */
  126413. emissiveTexture: BaseTexture;
  126414. /**
  126415. * AKA Specular texture in other nomenclature.
  126416. */
  126417. reflectivityTexture: BaseTexture;
  126418. /**
  126419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126420. */
  126421. metallicTexture: BaseTexture;
  126422. /**
  126423. * Specifies the metallic scalar of the metallic/roughness workflow.
  126424. * Can also be used to scale the metalness values of the metallic texture.
  126425. */
  126426. metallic: Nullable<number>;
  126427. /**
  126428. * Specifies the roughness scalar of the metallic/roughness workflow.
  126429. * Can also be used to scale the roughness values of the metallic texture.
  126430. */
  126431. roughness: Nullable<number>;
  126432. /**
  126433. * Specifies the an F0 factor to help configuring the material F0.
  126434. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126435. * to 0.5 the previously hard coded value stays the same.
  126436. * Can also be used to scale the F0 values of the metallic texture.
  126437. */
  126438. metallicF0Factor: number;
  126439. /**
  126440. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126441. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126442. * your expectation as it multiplies with the texture data.
  126443. */
  126444. useMetallicF0FactorFromMetallicTexture: boolean;
  126445. /**
  126446. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126447. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126448. */
  126449. microSurfaceTexture: BaseTexture;
  126450. /**
  126451. * Stores surface normal data used to displace a mesh in a texture.
  126452. */
  126453. bumpTexture: BaseTexture;
  126454. /**
  126455. * Stores the pre-calculated light information of a mesh in a texture.
  126456. */
  126457. lightmapTexture: BaseTexture;
  126458. /**
  126459. * Stores the refracted light information in a texture.
  126460. */
  126461. get refractionTexture(): Nullable<BaseTexture>;
  126462. set refractionTexture(value: Nullable<BaseTexture>);
  126463. /**
  126464. * The color of a material in ambient lighting.
  126465. */
  126466. ambientColor: Color3;
  126467. /**
  126468. * AKA Diffuse Color in other nomenclature.
  126469. */
  126470. albedoColor: Color3;
  126471. /**
  126472. * AKA Specular Color in other nomenclature.
  126473. */
  126474. reflectivityColor: Color3;
  126475. /**
  126476. * The color reflected from the material.
  126477. */
  126478. reflectionColor: Color3;
  126479. /**
  126480. * The color emitted from the material.
  126481. */
  126482. emissiveColor: Color3;
  126483. /**
  126484. * AKA Glossiness in other nomenclature.
  126485. */
  126486. microSurface: number;
  126487. /**
  126488. * source material index of refraction (IOR)' / 'destination material IOR.
  126489. */
  126490. get indexOfRefraction(): number;
  126491. set indexOfRefraction(value: number);
  126492. /**
  126493. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126494. */
  126495. get invertRefractionY(): boolean;
  126496. set invertRefractionY(value: boolean);
  126497. /**
  126498. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126499. * Materials half opaque for instance using refraction could benefit from this control.
  126500. */
  126501. get linkRefractionWithTransparency(): boolean;
  126502. set linkRefractionWithTransparency(value: boolean);
  126503. /**
  126504. * If true, the light map contains occlusion information instead of lighting info.
  126505. */
  126506. useLightmapAsShadowmap: boolean;
  126507. /**
  126508. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126509. */
  126510. useAlphaFromAlbedoTexture: boolean;
  126511. /**
  126512. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126513. */
  126514. forceAlphaTest: boolean;
  126515. /**
  126516. * Defines the alpha limits in alpha test mode.
  126517. */
  126518. alphaCutOff: number;
  126519. /**
  126520. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126521. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126522. */
  126523. useSpecularOverAlpha: boolean;
  126524. /**
  126525. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126526. */
  126527. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126528. /**
  126529. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126530. */
  126531. useRoughnessFromMetallicTextureAlpha: boolean;
  126532. /**
  126533. * Specifies if the metallic texture contains the roughness information in its green channel.
  126534. */
  126535. useRoughnessFromMetallicTextureGreen: boolean;
  126536. /**
  126537. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126538. */
  126539. useMetallnessFromMetallicTextureBlue: boolean;
  126540. /**
  126541. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126542. */
  126543. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126544. /**
  126545. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126546. */
  126547. useAmbientInGrayScale: boolean;
  126548. /**
  126549. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126550. * The material will try to infer what glossiness each pixel should be.
  126551. */
  126552. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126553. /**
  126554. * BJS is using an harcoded light falloff based on a manually sets up range.
  126555. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126556. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126557. */
  126558. get usePhysicalLightFalloff(): boolean;
  126559. /**
  126560. * BJS is using an harcoded light falloff based on a manually sets up range.
  126561. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126562. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126563. */
  126564. set usePhysicalLightFalloff(value: boolean);
  126565. /**
  126566. * In order to support the falloff compatibility with gltf, a special mode has been added
  126567. * to reproduce the gltf light falloff.
  126568. */
  126569. get useGLTFLightFalloff(): boolean;
  126570. /**
  126571. * In order to support the falloff compatibility with gltf, a special mode has been added
  126572. * to reproduce the gltf light falloff.
  126573. */
  126574. set useGLTFLightFalloff(value: boolean);
  126575. /**
  126576. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126577. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126578. */
  126579. useRadianceOverAlpha: boolean;
  126580. /**
  126581. * Allows using an object space normal map (instead of tangent space).
  126582. */
  126583. useObjectSpaceNormalMap: boolean;
  126584. /**
  126585. * Allows using the bump map in parallax mode.
  126586. */
  126587. useParallax: boolean;
  126588. /**
  126589. * Allows using the bump map in parallax occlusion mode.
  126590. */
  126591. useParallaxOcclusion: boolean;
  126592. /**
  126593. * Controls the scale bias of the parallax mode.
  126594. */
  126595. parallaxScaleBias: number;
  126596. /**
  126597. * If sets to true, disables all the lights affecting the material.
  126598. */
  126599. disableLighting: boolean;
  126600. /**
  126601. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126602. */
  126603. forceIrradianceInFragment: boolean;
  126604. /**
  126605. * Number of Simultaneous lights allowed on the material.
  126606. */
  126607. maxSimultaneousLights: number;
  126608. /**
  126609. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126610. */
  126611. invertNormalMapX: boolean;
  126612. /**
  126613. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126614. */
  126615. invertNormalMapY: boolean;
  126616. /**
  126617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126618. */
  126619. twoSidedLighting: boolean;
  126620. /**
  126621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126622. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126623. */
  126624. useAlphaFresnel: boolean;
  126625. /**
  126626. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126627. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126628. */
  126629. useLinearAlphaFresnel: boolean;
  126630. /**
  126631. * Let user defines the brdf lookup texture used for IBL.
  126632. * A default 8bit version is embedded but you could point at :
  126633. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126634. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126635. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126636. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126637. */
  126638. environmentBRDFTexture: Nullable<BaseTexture>;
  126639. /**
  126640. * Force normal to face away from face.
  126641. */
  126642. forceNormalForward: boolean;
  126643. /**
  126644. * Enables specular anti aliasing in the PBR shader.
  126645. * It will both interacts on the Geometry for analytical and IBL lighting.
  126646. * It also prefilter the roughness map based on the bump values.
  126647. */
  126648. enableSpecularAntiAliasing: boolean;
  126649. /**
  126650. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126651. * makes the reflect vector face the model (under horizon).
  126652. */
  126653. useHorizonOcclusion: boolean;
  126654. /**
  126655. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126656. * too much the area relying on ambient texture to define their ambient occlusion.
  126657. */
  126658. useRadianceOcclusion: boolean;
  126659. /**
  126660. * If set to true, no lighting calculations will be applied.
  126661. */
  126662. unlit: boolean;
  126663. /**
  126664. * Gets the image processing configuration used either in this material.
  126665. */
  126666. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126667. /**
  126668. * Sets the Default image processing configuration used either in the this material.
  126669. *
  126670. * If sets to null, the scene one is in use.
  126671. */
  126672. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126673. /**
  126674. * Gets wether the color curves effect is enabled.
  126675. */
  126676. get cameraColorCurvesEnabled(): boolean;
  126677. /**
  126678. * Sets wether the color curves effect is enabled.
  126679. */
  126680. set cameraColorCurvesEnabled(value: boolean);
  126681. /**
  126682. * Gets wether the color grading effect is enabled.
  126683. */
  126684. get cameraColorGradingEnabled(): boolean;
  126685. /**
  126686. * Gets wether the color grading effect is enabled.
  126687. */
  126688. set cameraColorGradingEnabled(value: boolean);
  126689. /**
  126690. * Gets wether tonemapping is enabled or not.
  126691. */
  126692. get cameraToneMappingEnabled(): boolean;
  126693. /**
  126694. * Sets wether tonemapping is enabled or not
  126695. */
  126696. set cameraToneMappingEnabled(value: boolean);
  126697. /**
  126698. * The camera exposure used on this material.
  126699. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126700. * This corresponds to a photographic exposure.
  126701. */
  126702. get cameraExposure(): number;
  126703. /**
  126704. * The camera exposure used on this material.
  126705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126706. * This corresponds to a photographic exposure.
  126707. */
  126708. set cameraExposure(value: number);
  126709. /**
  126710. * Gets The camera contrast used on this material.
  126711. */
  126712. get cameraContrast(): number;
  126713. /**
  126714. * Sets The camera contrast used on this material.
  126715. */
  126716. set cameraContrast(value: number);
  126717. /**
  126718. * Gets the Color Grading 2D Lookup Texture.
  126719. */
  126720. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126721. /**
  126722. * Sets the Color Grading 2D Lookup Texture.
  126723. */
  126724. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126725. /**
  126726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126728. * 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;
  126729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126730. */
  126731. get cameraColorCurves(): Nullable<ColorCurves>;
  126732. /**
  126733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126735. * 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;
  126736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126737. */
  126738. set cameraColorCurves(value: Nullable<ColorCurves>);
  126739. /**
  126740. * Instantiates a new PBRMaterial instance.
  126741. *
  126742. * @param name The material name
  126743. * @param scene The scene the material will be use in.
  126744. */
  126745. constructor(name: string, scene: Scene);
  126746. /**
  126747. * Returns the name of this material class.
  126748. */
  126749. getClassName(): string;
  126750. /**
  126751. * Makes a duplicate of the current material.
  126752. * @param name - name to use for the new material.
  126753. */
  126754. clone(name: string): PBRMaterial;
  126755. /**
  126756. * Serializes this PBR Material.
  126757. * @returns - An object with the serialized material.
  126758. */
  126759. serialize(): any;
  126760. /**
  126761. * Parses a PBR Material from a serialized object.
  126762. * @param source - Serialized object.
  126763. * @param scene - BJS scene instance.
  126764. * @param rootUrl - url for the scene object
  126765. * @returns - PBRMaterial
  126766. */
  126767. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126768. }
  126769. }
  126770. declare module BABYLON {
  126771. /**
  126772. * Direct draw surface info
  126773. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126774. */
  126775. export interface DDSInfo {
  126776. /**
  126777. * Width of the texture
  126778. */
  126779. width: number;
  126780. /**
  126781. * Width of the texture
  126782. */
  126783. height: number;
  126784. /**
  126785. * Number of Mipmaps for the texture
  126786. * @see https://en.wikipedia.org/wiki/Mipmap
  126787. */
  126788. mipmapCount: number;
  126789. /**
  126790. * If the textures format is a known fourCC format
  126791. * @see https://www.fourcc.org/
  126792. */
  126793. isFourCC: boolean;
  126794. /**
  126795. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126796. */
  126797. isRGB: boolean;
  126798. /**
  126799. * If the texture is a lumincance format
  126800. */
  126801. isLuminance: boolean;
  126802. /**
  126803. * If this is a cube texture
  126804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126805. */
  126806. isCube: boolean;
  126807. /**
  126808. * If the texture is a compressed format eg. FOURCC_DXT1
  126809. */
  126810. isCompressed: boolean;
  126811. /**
  126812. * The dxgiFormat of the texture
  126813. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126814. */
  126815. dxgiFormat: number;
  126816. /**
  126817. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126818. */
  126819. textureType: number;
  126820. /**
  126821. * Sphericle polynomial created for the dds texture
  126822. */
  126823. sphericalPolynomial?: SphericalPolynomial;
  126824. }
  126825. /**
  126826. * Class used to provide DDS decompression tools
  126827. */
  126828. export class DDSTools {
  126829. /**
  126830. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126831. */
  126832. static StoreLODInAlphaChannel: boolean;
  126833. /**
  126834. * Gets DDS information from an array buffer
  126835. * @param data defines the array buffer view to read data from
  126836. * @returns the DDS information
  126837. */
  126838. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126839. private static _FloatView;
  126840. private static _Int32View;
  126841. private static _ToHalfFloat;
  126842. private static _FromHalfFloat;
  126843. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126844. private static _GetHalfFloatRGBAArrayBuffer;
  126845. private static _GetFloatRGBAArrayBuffer;
  126846. private static _GetFloatAsUIntRGBAArrayBuffer;
  126847. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126848. private static _GetRGBAArrayBuffer;
  126849. private static _ExtractLongWordOrder;
  126850. private static _GetRGBArrayBuffer;
  126851. private static _GetLuminanceArrayBuffer;
  126852. /**
  126853. * Uploads DDS Levels to a Babylon Texture
  126854. * @hidden
  126855. */
  126856. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126857. }
  126858. interface ThinEngine {
  126859. /**
  126860. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126861. * @param rootUrl defines the url where the file to load is located
  126862. * @param scene defines the current scene
  126863. * @param lodScale defines scale to apply to the mip map selection
  126864. * @param lodOffset defines offset to apply to the mip map selection
  126865. * @param onLoad defines an optional callback raised when the texture is loaded
  126866. * @param onError defines an optional callback raised if there is an issue to load the texture
  126867. * @param format defines the format of the data
  126868. * @param forcedExtension defines the extension to use to pick the right loader
  126869. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126870. * @returns the cube texture as an InternalTexture
  126871. */
  126872. 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;
  126873. }
  126874. }
  126875. declare module BABYLON {
  126876. /**
  126877. * Implementation of the DDS Texture Loader.
  126878. * @hidden
  126879. */
  126880. export class _DDSTextureLoader implements IInternalTextureLoader {
  126881. /**
  126882. * Defines wether the loader supports cascade loading the different faces.
  126883. */
  126884. readonly supportCascades: boolean;
  126885. /**
  126886. * This returns if the loader support the current file information.
  126887. * @param extension defines the file extension of the file being loaded
  126888. * @returns true if the loader can load the specified file
  126889. */
  126890. canLoad(extension: string): boolean;
  126891. /**
  126892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126893. * @param data contains the texture data
  126894. * @param texture defines the BabylonJS internal texture
  126895. * @param createPolynomials will be true if polynomials have been requested
  126896. * @param onLoad defines the callback to trigger once the texture is ready
  126897. * @param onError defines the callback to trigger in case of error
  126898. */
  126899. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126900. /**
  126901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126902. * @param data contains the texture data
  126903. * @param texture defines the BabylonJS internal texture
  126904. * @param callback defines the method to call once ready to upload
  126905. */
  126906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126907. }
  126908. }
  126909. declare module BABYLON {
  126910. /**
  126911. * Implementation of the ENV Texture Loader.
  126912. * @hidden
  126913. */
  126914. export class _ENVTextureLoader implements IInternalTextureLoader {
  126915. /**
  126916. * Defines wether the loader supports cascade loading the different faces.
  126917. */
  126918. readonly supportCascades: boolean;
  126919. /**
  126920. * This returns if the loader support the current file information.
  126921. * @param extension defines the file extension of the file being loaded
  126922. * @returns true if the loader can load the specified file
  126923. */
  126924. canLoad(extension: string): boolean;
  126925. /**
  126926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126927. * @param data contains the texture data
  126928. * @param texture defines the BabylonJS internal texture
  126929. * @param createPolynomials will be true if polynomials have been requested
  126930. * @param onLoad defines the callback to trigger once the texture is ready
  126931. * @param onError defines the callback to trigger in case of error
  126932. */
  126933. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126934. /**
  126935. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126936. * @param data contains the texture data
  126937. * @param texture defines the BabylonJS internal texture
  126938. * @param callback defines the method to call once ready to upload
  126939. */
  126940. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126941. }
  126942. }
  126943. declare module BABYLON {
  126944. /**
  126945. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126946. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126947. */
  126948. export class KhronosTextureContainer {
  126949. /** contents of the KTX container file */
  126950. data: ArrayBufferView;
  126951. private static HEADER_LEN;
  126952. private static COMPRESSED_2D;
  126953. private static COMPRESSED_3D;
  126954. private static TEX_2D;
  126955. private static TEX_3D;
  126956. /**
  126957. * Gets the openGL type
  126958. */
  126959. glType: number;
  126960. /**
  126961. * Gets the openGL type size
  126962. */
  126963. glTypeSize: number;
  126964. /**
  126965. * Gets the openGL format
  126966. */
  126967. glFormat: number;
  126968. /**
  126969. * Gets the openGL internal format
  126970. */
  126971. glInternalFormat: number;
  126972. /**
  126973. * Gets the base internal format
  126974. */
  126975. glBaseInternalFormat: number;
  126976. /**
  126977. * Gets image width in pixel
  126978. */
  126979. pixelWidth: number;
  126980. /**
  126981. * Gets image height in pixel
  126982. */
  126983. pixelHeight: number;
  126984. /**
  126985. * Gets image depth in pixels
  126986. */
  126987. pixelDepth: number;
  126988. /**
  126989. * Gets the number of array elements
  126990. */
  126991. numberOfArrayElements: number;
  126992. /**
  126993. * Gets the number of faces
  126994. */
  126995. numberOfFaces: number;
  126996. /**
  126997. * Gets the number of mipmap levels
  126998. */
  126999. numberOfMipmapLevels: number;
  127000. /**
  127001. * Gets the bytes of key value data
  127002. */
  127003. bytesOfKeyValueData: number;
  127004. /**
  127005. * Gets the load type
  127006. */
  127007. loadType: number;
  127008. /**
  127009. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  127010. */
  127011. isInvalid: boolean;
  127012. /**
  127013. * Creates a new KhronosTextureContainer
  127014. * @param data contents of the KTX container file
  127015. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  127016. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127017. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127018. */
  127019. constructor(
  127020. /** contents of the KTX container file */
  127021. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127022. /**
  127023. * Uploads KTX content to a Babylon Texture.
  127024. * It is assumed that the texture has already been created & is currently bound
  127025. * @hidden
  127026. */
  127027. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127028. private _upload2DCompressedLevels;
  127029. /**
  127030. * Checks if the given data starts with a KTX file identifier.
  127031. * @param data the data to check
  127032. * @returns true if the data is a KTX file or false otherwise
  127033. */
  127034. static IsValid(data: ArrayBufferView): boolean;
  127035. }
  127036. }
  127037. declare module BABYLON {
  127038. /**
  127039. * Class for loading KTX2 files
  127040. * !!! Experimental Extension Subject to Changes !!!
  127041. * @hidden
  127042. */
  127043. export class KhronosTextureContainer2 {
  127044. private static _ModulePromise;
  127045. private static _TranscodeFormat;
  127046. constructor(engine: ThinEngine);
  127047. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127048. private _determineTranscodeFormat;
  127049. /**
  127050. * Checks if the given data starts with a KTX2 file identifier.
  127051. * @param data the data to check
  127052. * @returns true if the data is a KTX2 file or false otherwise
  127053. */
  127054. static IsValid(data: ArrayBufferView): boolean;
  127055. }
  127056. }
  127057. declare module BABYLON {
  127058. /**
  127059. * Implementation of the KTX Texture Loader.
  127060. * @hidden
  127061. */
  127062. export class _KTXTextureLoader implements IInternalTextureLoader {
  127063. /**
  127064. * Defines wether the loader supports cascade loading the different faces.
  127065. */
  127066. readonly supportCascades: boolean;
  127067. /**
  127068. * This returns if the loader support the current file information.
  127069. * @param extension defines the file extension of the file being loaded
  127070. * @returns true if the loader can load the specified file
  127071. */
  127072. canLoad(extension: string): boolean;
  127073. /**
  127074. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127075. * @param data contains the texture data
  127076. * @param texture defines the BabylonJS internal texture
  127077. * @param createPolynomials will be true if polynomials have been requested
  127078. * @param onLoad defines the callback to trigger once the texture is ready
  127079. * @param onError defines the callback to trigger in case of error
  127080. */
  127081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127082. /**
  127083. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127084. * @param data contains the texture data
  127085. * @param texture defines the BabylonJS internal texture
  127086. * @param callback defines the method to call once ready to upload
  127087. */
  127088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127089. }
  127090. }
  127091. declare module BABYLON {
  127092. /** @hidden */
  127093. export var _forceSceneHelpersToBundle: boolean;
  127094. interface Scene {
  127095. /**
  127096. * Creates a default light for the scene.
  127097. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127098. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127099. */
  127100. createDefaultLight(replace?: boolean): void;
  127101. /**
  127102. * Creates a default camera for the scene.
  127103. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127104. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127105. * @param replace has default false, when true replaces the active camera in the scene
  127106. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127107. */
  127108. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127109. /**
  127110. * Creates a default camera and a default light.
  127111. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127112. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127113. * @param replace has the default false, when true replaces the active camera/light in the scene
  127114. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127115. */
  127116. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127117. /**
  127118. * Creates a new sky box
  127119. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127120. * @param environmentTexture defines the texture to use as environment texture
  127121. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127122. * @param scale defines the overall scale of the skybox
  127123. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127124. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127125. * @returns a new mesh holding the sky box
  127126. */
  127127. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127128. /**
  127129. * Creates a new environment
  127130. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127131. * @param options defines the options you can use to configure the environment
  127132. * @returns the new EnvironmentHelper
  127133. */
  127134. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127135. /**
  127136. * Creates a new VREXperienceHelper
  127137. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127138. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127139. * @returns a new VREXperienceHelper
  127140. */
  127141. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127142. /**
  127143. * Creates a new WebXRDefaultExperience
  127144. * @see http://doc.babylonjs.com/how_to/webxr
  127145. * @param options experience options
  127146. * @returns a promise for a new WebXRDefaultExperience
  127147. */
  127148. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127149. }
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127154. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127155. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127156. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127157. */
  127158. export class VideoDome extends TransformNode {
  127159. /**
  127160. * Define the video source as a Monoscopic panoramic 360 video.
  127161. */
  127162. static readonly MODE_MONOSCOPIC: number;
  127163. /**
  127164. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127165. */
  127166. static readonly MODE_TOPBOTTOM: number;
  127167. /**
  127168. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127169. */
  127170. static readonly MODE_SIDEBYSIDE: number;
  127171. private _halfDome;
  127172. private _useDirectMapping;
  127173. /**
  127174. * The video texture being displayed on the sphere
  127175. */
  127176. protected _videoTexture: VideoTexture;
  127177. /**
  127178. * Gets the video texture being displayed on the sphere
  127179. */
  127180. get videoTexture(): VideoTexture;
  127181. /**
  127182. * The skybox material
  127183. */
  127184. protected _material: BackgroundMaterial;
  127185. /**
  127186. * The surface used for the skybox
  127187. */
  127188. protected _mesh: Mesh;
  127189. /**
  127190. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127191. */
  127192. private _halfDomeMask;
  127193. /**
  127194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127195. * Also see the options.resolution property.
  127196. */
  127197. get fovMultiplier(): number;
  127198. set fovMultiplier(value: number);
  127199. private _videoMode;
  127200. /**
  127201. * Gets or set the current video mode for the video. It can be:
  127202. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127203. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127204. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127205. */
  127206. get videoMode(): number;
  127207. set videoMode(value: number);
  127208. /**
  127209. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127210. *
  127211. */
  127212. get halfDome(): boolean;
  127213. /**
  127214. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127215. */
  127216. set halfDome(enabled: boolean);
  127217. /**
  127218. * Oberserver used in Stereoscopic VR Mode.
  127219. */
  127220. private _onBeforeCameraRenderObserver;
  127221. /**
  127222. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127223. * @param name Element's name, child elements will append suffixes for their own names.
  127224. * @param urlsOrVideo defines the url(s) or the video element to use
  127225. * @param options An object containing optional or exposed sub element properties
  127226. */
  127227. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127228. resolution?: number;
  127229. clickToPlay?: boolean;
  127230. autoPlay?: boolean;
  127231. loop?: boolean;
  127232. size?: number;
  127233. poster?: string;
  127234. faceForward?: boolean;
  127235. useDirectMapping?: boolean;
  127236. halfDomeMode?: boolean;
  127237. }, scene: Scene);
  127238. private _changeVideoMode;
  127239. /**
  127240. * Releases resources associated with this node.
  127241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127243. */
  127244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127245. }
  127246. }
  127247. declare module BABYLON {
  127248. /**
  127249. * This class can be used to get instrumentation data from a Babylon engine
  127250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127251. */
  127252. export class EngineInstrumentation implements IDisposable {
  127253. /**
  127254. * Define the instrumented engine.
  127255. */
  127256. engine: Engine;
  127257. private _captureGPUFrameTime;
  127258. private _gpuFrameTimeToken;
  127259. private _gpuFrameTime;
  127260. private _captureShaderCompilationTime;
  127261. private _shaderCompilationTime;
  127262. private _onBeginFrameObserver;
  127263. private _onEndFrameObserver;
  127264. private _onBeforeShaderCompilationObserver;
  127265. private _onAfterShaderCompilationObserver;
  127266. /**
  127267. * Gets the perf counter used for GPU frame time
  127268. */
  127269. get gpuFrameTimeCounter(): PerfCounter;
  127270. /**
  127271. * Gets the GPU frame time capture status
  127272. */
  127273. get captureGPUFrameTime(): boolean;
  127274. /**
  127275. * Enable or disable the GPU frame time capture
  127276. */
  127277. set captureGPUFrameTime(value: boolean);
  127278. /**
  127279. * Gets the perf counter used for shader compilation time
  127280. */
  127281. get shaderCompilationTimeCounter(): PerfCounter;
  127282. /**
  127283. * Gets the shader compilation time capture status
  127284. */
  127285. get captureShaderCompilationTime(): boolean;
  127286. /**
  127287. * Enable or disable the shader compilation time capture
  127288. */
  127289. set captureShaderCompilationTime(value: boolean);
  127290. /**
  127291. * Instantiates a new engine instrumentation.
  127292. * This class can be used to get instrumentation data from a Babylon engine
  127293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127294. * @param engine Defines the engine to instrument
  127295. */
  127296. constructor(
  127297. /**
  127298. * Define the instrumented engine.
  127299. */
  127300. engine: Engine);
  127301. /**
  127302. * Dispose and release associated resources.
  127303. */
  127304. dispose(): void;
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * This class can be used to get instrumentation data from a Babylon engine
  127310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127311. */
  127312. export class SceneInstrumentation implements IDisposable {
  127313. /**
  127314. * Defines the scene to instrument
  127315. */
  127316. scene: Scene;
  127317. private _captureActiveMeshesEvaluationTime;
  127318. private _activeMeshesEvaluationTime;
  127319. private _captureRenderTargetsRenderTime;
  127320. private _renderTargetsRenderTime;
  127321. private _captureFrameTime;
  127322. private _frameTime;
  127323. private _captureRenderTime;
  127324. private _renderTime;
  127325. private _captureInterFrameTime;
  127326. private _interFrameTime;
  127327. private _captureParticlesRenderTime;
  127328. private _particlesRenderTime;
  127329. private _captureSpritesRenderTime;
  127330. private _spritesRenderTime;
  127331. private _capturePhysicsTime;
  127332. private _physicsTime;
  127333. private _captureAnimationsTime;
  127334. private _animationsTime;
  127335. private _captureCameraRenderTime;
  127336. private _cameraRenderTime;
  127337. private _onBeforeActiveMeshesEvaluationObserver;
  127338. private _onAfterActiveMeshesEvaluationObserver;
  127339. private _onBeforeRenderTargetsRenderObserver;
  127340. private _onAfterRenderTargetsRenderObserver;
  127341. private _onAfterRenderObserver;
  127342. private _onBeforeDrawPhaseObserver;
  127343. private _onAfterDrawPhaseObserver;
  127344. private _onBeforeAnimationsObserver;
  127345. private _onBeforeParticlesRenderingObserver;
  127346. private _onAfterParticlesRenderingObserver;
  127347. private _onBeforeSpritesRenderingObserver;
  127348. private _onAfterSpritesRenderingObserver;
  127349. private _onBeforePhysicsObserver;
  127350. private _onAfterPhysicsObserver;
  127351. private _onAfterAnimationsObserver;
  127352. private _onBeforeCameraRenderObserver;
  127353. private _onAfterCameraRenderObserver;
  127354. /**
  127355. * Gets the perf counter used for active meshes evaluation time
  127356. */
  127357. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127358. /**
  127359. * Gets the active meshes evaluation time capture status
  127360. */
  127361. get captureActiveMeshesEvaluationTime(): boolean;
  127362. /**
  127363. * Enable or disable the active meshes evaluation time capture
  127364. */
  127365. set captureActiveMeshesEvaluationTime(value: boolean);
  127366. /**
  127367. * Gets the perf counter used for render targets render time
  127368. */
  127369. get renderTargetsRenderTimeCounter(): PerfCounter;
  127370. /**
  127371. * Gets the render targets render time capture status
  127372. */
  127373. get captureRenderTargetsRenderTime(): boolean;
  127374. /**
  127375. * Enable or disable the render targets render time capture
  127376. */
  127377. set captureRenderTargetsRenderTime(value: boolean);
  127378. /**
  127379. * Gets the perf counter used for particles render time
  127380. */
  127381. get particlesRenderTimeCounter(): PerfCounter;
  127382. /**
  127383. * Gets the particles render time capture status
  127384. */
  127385. get captureParticlesRenderTime(): boolean;
  127386. /**
  127387. * Enable or disable the particles render time capture
  127388. */
  127389. set captureParticlesRenderTime(value: boolean);
  127390. /**
  127391. * Gets the perf counter used for sprites render time
  127392. */
  127393. get spritesRenderTimeCounter(): PerfCounter;
  127394. /**
  127395. * Gets the sprites render time capture status
  127396. */
  127397. get captureSpritesRenderTime(): boolean;
  127398. /**
  127399. * Enable or disable the sprites render time capture
  127400. */
  127401. set captureSpritesRenderTime(value: boolean);
  127402. /**
  127403. * Gets the perf counter used for physics time
  127404. */
  127405. get physicsTimeCounter(): PerfCounter;
  127406. /**
  127407. * Gets the physics time capture status
  127408. */
  127409. get capturePhysicsTime(): boolean;
  127410. /**
  127411. * Enable or disable the physics time capture
  127412. */
  127413. set capturePhysicsTime(value: boolean);
  127414. /**
  127415. * Gets the perf counter used for animations time
  127416. */
  127417. get animationsTimeCounter(): PerfCounter;
  127418. /**
  127419. * Gets the animations time capture status
  127420. */
  127421. get captureAnimationsTime(): boolean;
  127422. /**
  127423. * Enable or disable the animations time capture
  127424. */
  127425. set captureAnimationsTime(value: boolean);
  127426. /**
  127427. * Gets the perf counter used for frame time capture
  127428. */
  127429. get frameTimeCounter(): PerfCounter;
  127430. /**
  127431. * Gets the frame time capture status
  127432. */
  127433. get captureFrameTime(): boolean;
  127434. /**
  127435. * Enable or disable the frame time capture
  127436. */
  127437. set captureFrameTime(value: boolean);
  127438. /**
  127439. * Gets the perf counter used for inter-frames time capture
  127440. */
  127441. get interFrameTimeCounter(): PerfCounter;
  127442. /**
  127443. * Gets the inter-frames time capture status
  127444. */
  127445. get captureInterFrameTime(): boolean;
  127446. /**
  127447. * Enable or disable the inter-frames time capture
  127448. */
  127449. set captureInterFrameTime(value: boolean);
  127450. /**
  127451. * Gets the perf counter used for render time capture
  127452. */
  127453. get renderTimeCounter(): PerfCounter;
  127454. /**
  127455. * Gets the render time capture status
  127456. */
  127457. get captureRenderTime(): boolean;
  127458. /**
  127459. * Enable or disable the render time capture
  127460. */
  127461. set captureRenderTime(value: boolean);
  127462. /**
  127463. * Gets the perf counter used for camera render time capture
  127464. */
  127465. get cameraRenderTimeCounter(): PerfCounter;
  127466. /**
  127467. * Gets the camera render time capture status
  127468. */
  127469. get captureCameraRenderTime(): boolean;
  127470. /**
  127471. * Enable or disable the camera render time capture
  127472. */
  127473. set captureCameraRenderTime(value: boolean);
  127474. /**
  127475. * Gets the perf counter used for draw calls
  127476. */
  127477. get drawCallsCounter(): PerfCounter;
  127478. /**
  127479. * Instantiates a new scene instrumentation.
  127480. * This class can be used to get instrumentation data from a Babylon engine
  127481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127482. * @param scene Defines the scene to instrument
  127483. */
  127484. constructor(
  127485. /**
  127486. * Defines the scene to instrument
  127487. */
  127488. scene: Scene);
  127489. /**
  127490. * Dispose and release associated resources.
  127491. */
  127492. dispose(): void;
  127493. }
  127494. }
  127495. declare module BABYLON {
  127496. /** @hidden */
  127497. export var glowMapGenerationPixelShader: {
  127498. name: string;
  127499. shader: string;
  127500. };
  127501. }
  127502. declare module BABYLON {
  127503. /** @hidden */
  127504. export var glowMapGenerationVertexShader: {
  127505. name: string;
  127506. shader: string;
  127507. };
  127508. }
  127509. declare module BABYLON {
  127510. /**
  127511. * Effect layer options. This helps customizing the behaviour
  127512. * of the effect layer.
  127513. */
  127514. export interface IEffectLayerOptions {
  127515. /**
  127516. * Multiplication factor apply to the canvas size to compute the render target size
  127517. * used to generated the objects (the smaller the faster).
  127518. */
  127519. mainTextureRatio: number;
  127520. /**
  127521. * Enforces a fixed size texture to ensure effect stability across devices.
  127522. */
  127523. mainTextureFixedSize?: number;
  127524. /**
  127525. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127526. */
  127527. alphaBlendingMode: number;
  127528. /**
  127529. * The camera attached to the layer.
  127530. */
  127531. camera: Nullable<Camera>;
  127532. /**
  127533. * The rendering group to draw the layer in.
  127534. */
  127535. renderingGroupId: number;
  127536. }
  127537. /**
  127538. * The effect layer Helps adding post process effect blended with the main pass.
  127539. *
  127540. * This can be for instance use to generate glow or higlight effects on the scene.
  127541. *
  127542. * The effect layer class can not be used directly and is intented to inherited from to be
  127543. * customized per effects.
  127544. */
  127545. export abstract class EffectLayer {
  127546. private _vertexBuffers;
  127547. private _indexBuffer;
  127548. private _cachedDefines;
  127549. private _effectLayerMapGenerationEffect;
  127550. private _effectLayerOptions;
  127551. private _mergeEffect;
  127552. protected _scene: Scene;
  127553. protected _engine: Engine;
  127554. protected _maxSize: number;
  127555. protected _mainTextureDesiredSize: ISize;
  127556. protected _mainTexture: RenderTargetTexture;
  127557. protected _shouldRender: boolean;
  127558. protected _postProcesses: PostProcess[];
  127559. protected _textures: BaseTexture[];
  127560. protected _emissiveTextureAndColor: {
  127561. texture: Nullable<BaseTexture>;
  127562. color: Color4;
  127563. };
  127564. /**
  127565. * The name of the layer
  127566. */
  127567. name: string;
  127568. /**
  127569. * The clear color of the texture used to generate the glow map.
  127570. */
  127571. neutralColor: Color4;
  127572. /**
  127573. * Specifies whether the highlight layer is enabled or not.
  127574. */
  127575. isEnabled: boolean;
  127576. /**
  127577. * Gets the camera attached to the layer.
  127578. */
  127579. get camera(): Nullable<Camera>;
  127580. /**
  127581. * Gets the rendering group id the layer should render in.
  127582. */
  127583. get renderingGroupId(): number;
  127584. set renderingGroupId(renderingGroupId: number);
  127585. /**
  127586. * An event triggered when the effect layer has been disposed.
  127587. */
  127588. onDisposeObservable: Observable<EffectLayer>;
  127589. /**
  127590. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127591. */
  127592. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127593. /**
  127594. * An event triggered when the generated texture is being merged in the scene.
  127595. */
  127596. onBeforeComposeObservable: Observable<EffectLayer>;
  127597. /**
  127598. * An event triggered when the mesh is rendered into the effect render target.
  127599. */
  127600. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127601. /**
  127602. * An event triggered after the mesh has been rendered into the effect render target.
  127603. */
  127604. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127605. /**
  127606. * An event triggered when the generated texture has been merged in the scene.
  127607. */
  127608. onAfterComposeObservable: Observable<EffectLayer>;
  127609. /**
  127610. * An event triggered when the efffect layer changes its size.
  127611. */
  127612. onSizeChangedObservable: Observable<EffectLayer>;
  127613. /** @hidden */
  127614. static _SceneComponentInitialization: (scene: Scene) => void;
  127615. /**
  127616. * Instantiates a new effect Layer and references it in the scene.
  127617. * @param name The name of the layer
  127618. * @param scene The scene to use the layer in
  127619. */
  127620. constructor(
  127621. /** The Friendly of the effect in the scene */
  127622. name: string, scene: Scene);
  127623. /**
  127624. * Get the effect name of the layer.
  127625. * @return The effect name
  127626. */
  127627. abstract getEffectName(): string;
  127628. /**
  127629. * Checks for the readiness of the element composing the layer.
  127630. * @param subMesh the mesh to check for
  127631. * @param useInstances specify whether or not to use instances to render the mesh
  127632. * @return true if ready otherwise, false
  127633. */
  127634. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127635. /**
  127636. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127637. * @returns true if the effect requires stencil during the main canvas render pass.
  127638. */
  127639. abstract needStencil(): boolean;
  127640. /**
  127641. * Create the merge effect. This is the shader use to blit the information back
  127642. * to the main canvas at the end of the scene rendering.
  127643. * @returns The effect containing the shader used to merge the effect on the main canvas
  127644. */
  127645. protected abstract _createMergeEffect(): Effect;
  127646. /**
  127647. * Creates the render target textures and post processes used in the effect layer.
  127648. */
  127649. protected abstract _createTextureAndPostProcesses(): void;
  127650. /**
  127651. * Implementation specific of rendering the generating effect on the main canvas.
  127652. * @param effect The effect used to render through
  127653. */
  127654. protected abstract _internalRender(effect: Effect): void;
  127655. /**
  127656. * Sets the required values for both the emissive texture and and the main color.
  127657. */
  127658. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127659. /**
  127660. * Free any resources and references associated to a mesh.
  127661. * Internal use
  127662. * @param mesh The mesh to free.
  127663. */
  127664. abstract _disposeMesh(mesh: Mesh): void;
  127665. /**
  127666. * Serializes this layer (Glow or Highlight for example)
  127667. * @returns a serialized layer object
  127668. */
  127669. abstract serialize?(): any;
  127670. /**
  127671. * Initializes the effect layer with the required options.
  127672. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127673. */
  127674. protected _init(options: Partial<IEffectLayerOptions>): void;
  127675. /**
  127676. * Generates the index buffer of the full screen quad blending to the main canvas.
  127677. */
  127678. private _generateIndexBuffer;
  127679. /**
  127680. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127681. */
  127682. private _generateVertexBuffer;
  127683. /**
  127684. * Sets the main texture desired size which is the closest power of two
  127685. * of the engine canvas size.
  127686. */
  127687. private _setMainTextureSize;
  127688. /**
  127689. * Creates the main texture for the effect layer.
  127690. */
  127691. protected _createMainTexture(): void;
  127692. /**
  127693. * Adds specific effects defines.
  127694. * @param defines The defines to add specifics to.
  127695. */
  127696. protected _addCustomEffectDefines(defines: string[]): void;
  127697. /**
  127698. * Checks for the readiness of the element composing the layer.
  127699. * @param subMesh the mesh to check for
  127700. * @param useInstances specify whether or not to use instances to render the mesh
  127701. * @param emissiveTexture the associated emissive texture used to generate the glow
  127702. * @return true if ready otherwise, false
  127703. */
  127704. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127705. /**
  127706. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127707. */
  127708. render(): void;
  127709. /**
  127710. * Determine if a given mesh will be used in the current effect.
  127711. * @param mesh mesh to test
  127712. * @returns true if the mesh will be used
  127713. */
  127714. hasMesh(mesh: AbstractMesh): boolean;
  127715. /**
  127716. * Returns true if the layer contains information to display, otherwise false.
  127717. * @returns true if the glow layer should be rendered
  127718. */
  127719. shouldRender(): boolean;
  127720. /**
  127721. * Returns true if the mesh should render, otherwise false.
  127722. * @param mesh The mesh to render
  127723. * @returns true if it should render otherwise false
  127724. */
  127725. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127726. /**
  127727. * Returns true if the mesh can be rendered, otherwise false.
  127728. * @param mesh The mesh to render
  127729. * @param material The material used on the mesh
  127730. * @returns true if it can be rendered otherwise false
  127731. */
  127732. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127733. /**
  127734. * Returns true if the mesh should render, otherwise false.
  127735. * @param mesh The mesh to render
  127736. * @returns true if it should render otherwise false
  127737. */
  127738. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127739. /**
  127740. * Renders the submesh passed in parameter to the generation map.
  127741. */
  127742. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127743. /**
  127744. * Defines whether the current material of the mesh should be use to render the effect.
  127745. * @param mesh defines the current mesh to render
  127746. */
  127747. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127748. /**
  127749. * Rebuild the required buffers.
  127750. * @hidden Internal use only.
  127751. */
  127752. _rebuild(): void;
  127753. /**
  127754. * Dispose only the render target textures and post process.
  127755. */
  127756. private _disposeTextureAndPostProcesses;
  127757. /**
  127758. * Dispose the highlight layer and free resources.
  127759. */
  127760. dispose(): void;
  127761. /**
  127762. * Gets the class name of the effect layer
  127763. * @returns the string with the class name of the effect layer
  127764. */
  127765. getClassName(): string;
  127766. /**
  127767. * Creates an effect layer from parsed effect layer data
  127768. * @param parsedEffectLayer defines effect layer data
  127769. * @param scene defines the current scene
  127770. * @param rootUrl defines the root URL containing the effect layer information
  127771. * @returns a parsed effect Layer
  127772. */
  127773. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127774. }
  127775. }
  127776. declare module BABYLON {
  127777. interface AbstractScene {
  127778. /**
  127779. * The list of effect layers (highlights/glow) added to the scene
  127780. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127781. * @see http://doc.babylonjs.com/how_to/glow_layer
  127782. */
  127783. effectLayers: Array<EffectLayer>;
  127784. /**
  127785. * Removes the given effect layer from this scene.
  127786. * @param toRemove defines the effect layer to remove
  127787. * @returns the index of the removed effect layer
  127788. */
  127789. removeEffectLayer(toRemove: EffectLayer): number;
  127790. /**
  127791. * Adds the given effect layer to this scene
  127792. * @param newEffectLayer defines the effect layer to add
  127793. */
  127794. addEffectLayer(newEffectLayer: EffectLayer): void;
  127795. }
  127796. /**
  127797. * Defines the layer scene component responsible to manage any effect layers
  127798. * in a given scene.
  127799. */
  127800. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127801. /**
  127802. * The component name helpfull to identify the component in the list of scene components.
  127803. */
  127804. readonly name: string;
  127805. /**
  127806. * The scene the component belongs to.
  127807. */
  127808. scene: Scene;
  127809. private _engine;
  127810. private _renderEffects;
  127811. private _needStencil;
  127812. private _previousStencilState;
  127813. /**
  127814. * Creates a new instance of the component for the given scene
  127815. * @param scene Defines the scene to register the component in
  127816. */
  127817. constructor(scene: Scene);
  127818. /**
  127819. * Registers the component in a given scene
  127820. */
  127821. register(): void;
  127822. /**
  127823. * Rebuilds the elements related to this component in case of
  127824. * context lost for instance.
  127825. */
  127826. rebuild(): void;
  127827. /**
  127828. * Serializes the component data to the specified json object
  127829. * @param serializationObject The object to serialize to
  127830. */
  127831. serialize(serializationObject: any): void;
  127832. /**
  127833. * Adds all the elements from the container to the scene
  127834. * @param container the container holding the elements
  127835. */
  127836. addFromContainer(container: AbstractScene): void;
  127837. /**
  127838. * Removes all the elements in the container from the scene
  127839. * @param container contains the elements to remove
  127840. * @param dispose if the removed element should be disposed (default: false)
  127841. */
  127842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127843. /**
  127844. * Disposes the component and the associated ressources.
  127845. */
  127846. dispose(): void;
  127847. private _isReadyForMesh;
  127848. private _renderMainTexture;
  127849. private _setStencil;
  127850. private _setStencilBack;
  127851. private _draw;
  127852. private _drawCamera;
  127853. private _drawRenderingGroup;
  127854. }
  127855. }
  127856. declare module BABYLON {
  127857. /** @hidden */
  127858. export var glowMapMergePixelShader: {
  127859. name: string;
  127860. shader: string;
  127861. };
  127862. }
  127863. declare module BABYLON {
  127864. /** @hidden */
  127865. export var glowMapMergeVertexShader: {
  127866. name: string;
  127867. shader: string;
  127868. };
  127869. }
  127870. declare module BABYLON {
  127871. interface AbstractScene {
  127872. /**
  127873. * Return a the first highlight layer of the scene with a given name.
  127874. * @param name The name of the highlight layer to look for.
  127875. * @return The highlight layer if found otherwise null.
  127876. */
  127877. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127878. }
  127879. /**
  127880. * Glow layer options. This helps customizing the behaviour
  127881. * of the glow layer.
  127882. */
  127883. export interface IGlowLayerOptions {
  127884. /**
  127885. * Multiplication factor apply to the canvas size to compute the render target size
  127886. * used to generated the glowing objects (the smaller the faster).
  127887. */
  127888. mainTextureRatio: number;
  127889. /**
  127890. * Enforces a fixed size texture to ensure resize independant blur.
  127891. */
  127892. mainTextureFixedSize?: number;
  127893. /**
  127894. * How big is the kernel of the blur texture.
  127895. */
  127896. blurKernelSize: number;
  127897. /**
  127898. * The camera attached to the layer.
  127899. */
  127900. camera: Nullable<Camera>;
  127901. /**
  127902. * Enable MSAA by chosing the number of samples.
  127903. */
  127904. mainTextureSamples?: number;
  127905. /**
  127906. * The rendering group to draw the layer in.
  127907. */
  127908. renderingGroupId: number;
  127909. }
  127910. /**
  127911. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127912. *
  127913. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127914. *
  127915. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127916. */
  127917. export class GlowLayer extends EffectLayer {
  127918. /**
  127919. * Effect Name of the layer.
  127920. */
  127921. static readonly EffectName: string;
  127922. /**
  127923. * The default blur kernel size used for the glow.
  127924. */
  127925. static DefaultBlurKernelSize: number;
  127926. /**
  127927. * The default texture size ratio used for the glow.
  127928. */
  127929. static DefaultTextureRatio: number;
  127930. /**
  127931. * Sets the kernel size of the blur.
  127932. */
  127933. set blurKernelSize(value: number);
  127934. /**
  127935. * Gets the kernel size of the blur.
  127936. */
  127937. get blurKernelSize(): number;
  127938. /**
  127939. * Sets the glow intensity.
  127940. */
  127941. set intensity(value: number);
  127942. /**
  127943. * Gets the glow intensity.
  127944. */
  127945. get intensity(): number;
  127946. private _options;
  127947. private _intensity;
  127948. private _horizontalBlurPostprocess1;
  127949. private _verticalBlurPostprocess1;
  127950. private _horizontalBlurPostprocess2;
  127951. private _verticalBlurPostprocess2;
  127952. private _blurTexture1;
  127953. private _blurTexture2;
  127954. private _postProcesses1;
  127955. private _postProcesses2;
  127956. private _includedOnlyMeshes;
  127957. private _excludedMeshes;
  127958. private _meshesUsingTheirOwnMaterials;
  127959. /**
  127960. * Callback used to let the user override the color selection on a per mesh basis
  127961. */
  127962. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127963. /**
  127964. * Callback used to let the user override the texture selection on a per mesh basis
  127965. */
  127966. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127967. /**
  127968. * Instantiates a new glow Layer and references it to the scene.
  127969. * @param name The name of the layer
  127970. * @param scene The scene to use the layer in
  127971. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127972. */
  127973. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127974. /**
  127975. * Get the effect name of the layer.
  127976. * @return The effect name
  127977. */
  127978. getEffectName(): string;
  127979. /**
  127980. * Create the merge effect. This is the shader use to blit the information back
  127981. * to the main canvas at the end of the scene rendering.
  127982. */
  127983. protected _createMergeEffect(): Effect;
  127984. /**
  127985. * Creates the render target textures and post processes used in the glow layer.
  127986. */
  127987. protected _createTextureAndPostProcesses(): void;
  127988. /**
  127989. * Checks for the readiness of the element composing the layer.
  127990. * @param subMesh the mesh to check for
  127991. * @param useInstances specify wether or not to use instances to render the mesh
  127992. * @param emissiveTexture the associated emissive texture used to generate the glow
  127993. * @return true if ready otherwise, false
  127994. */
  127995. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127996. /**
  127997. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127998. */
  127999. needStencil(): boolean;
  128000. /**
  128001. * Returns true if the mesh can be rendered, otherwise false.
  128002. * @param mesh The mesh to render
  128003. * @param material The material used on the mesh
  128004. * @returns true if it can be rendered otherwise false
  128005. */
  128006. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128007. /**
  128008. * Implementation specific of rendering the generating effect on the main canvas.
  128009. * @param effect The effect used to render through
  128010. */
  128011. protected _internalRender(effect: Effect): void;
  128012. /**
  128013. * Sets the required values for both the emissive texture and and the main color.
  128014. */
  128015. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128016. /**
  128017. * Returns true if the mesh should render, otherwise false.
  128018. * @param mesh The mesh to render
  128019. * @returns true if it should render otherwise false
  128020. */
  128021. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128022. /**
  128023. * Adds specific effects defines.
  128024. * @param defines The defines to add specifics to.
  128025. */
  128026. protected _addCustomEffectDefines(defines: string[]): void;
  128027. /**
  128028. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128029. * @param mesh The mesh to exclude from the glow layer
  128030. */
  128031. addExcludedMesh(mesh: Mesh): void;
  128032. /**
  128033. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128034. * @param mesh The mesh to remove
  128035. */
  128036. removeExcludedMesh(mesh: Mesh): void;
  128037. /**
  128038. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128039. * @param mesh The mesh to include in the glow layer
  128040. */
  128041. addIncludedOnlyMesh(mesh: Mesh): void;
  128042. /**
  128043. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128044. * @param mesh The mesh to remove
  128045. */
  128046. removeIncludedOnlyMesh(mesh: Mesh): void;
  128047. /**
  128048. * Determine if a given mesh will be used in the glow layer
  128049. * @param mesh The mesh to test
  128050. * @returns true if the mesh will be highlighted by the current glow layer
  128051. */
  128052. hasMesh(mesh: AbstractMesh): boolean;
  128053. /**
  128054. * Defines whether the current material of the mesh should be use to render the effect.
  128055. * @param mesh defines the current mesh to render
  128056. */
  128057. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128058. /**
  128059. * Add a mesh to be rendered through its own material and not with emissive only.
  128060. * @param mesh The mesh for which we need to use its material
  128061. */
  128062. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128063. /**
  128064. * Remove a mesh from being rendered through its own material and not with emissive only.
  128065. * @param mesh The mesh for which we need to not use its material
  128066. */
  128067. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128068. /**
  128069. * Free any resources and references associated to a mesh.
  128070. * Internal use
  128071. * @param mesh The mesh to free.
  128072. * @hidden
  128073. */
  128074. _disposeMesh(mesh: Mesh): void;
  128075. /**
  128076. * Gets the class name of the effect layer
  128077. * @returns the string with the class name of the effect layer
  128078. */
  128079. getClassName(): string;
  128080. /**
  128081. * Serializes this glow layer
  128082. * @returns a serialized glow layer object
  128083. */
  128084. serialize(): any;
  128085. /**
  128086. * Creates a Glow Layer from parsed glow layer data
  128087. * @param parsedGlowLayer defines glow layer data
  128088. * @param scene defines the current scene
  128089. * @param rootUrl defines the root URL containing the glow layer information
  128090. * @returns a parsed Glow Layer
  128091. */
  128092. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128093. }
  128094. }
  128095. declare module BABYLON {
  128096. /** @hidden */
  128097. export var glowBlurPostProcessPixelShader: {
  128098. name: string;
  128099. shader: string;
  128100. };
  128101. }
  128102. declare module BABYLON {
  128103. interface AbstractScene {
  128104. /**
  128105. * Return a the first highlight layer of the scene with a given name.
  128106. * @param name The name of the highlight layer to look for.
  128107. * @return The highlight layer if found otherwise null.
  128108. */
  128109. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128110. }
  128111. /**
  128112. * Highlight layer options. This helps customizing the behaviour
  128113. * of the highlight layer.
  128114. */
  128115. export interface IHighlightLayerOptions {
  128116. /**
  128117. * Multiplication factor apply to the canvas size to compute the render target size
  128118. * used to generated the glowing objects (the smaller the faster).
  128119. */
  128120. mainTextureRatio: number;
  128121. /**
  128122. * Enforces a fixed size texture to ensure resize independant blur.
  128123. */
  128124. mainTextureFixedSize?: number;
  128125. /**
  128126. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128127. * of the picture to blur (the smaller the faster).
  128128. */
  128129. blurTextureSizeRatio: number;
  128130. /**
  128131. * How big in texel of the blur texture is the vertical blur.
  128132. */
  128133. blurVerticalSize: number;
  128134. /**
  128135. * How big in texel of the blur texture is the horizontal blur.
  128136. */
  128137. blurHorizontalSize: number;
  128138. /**
  128139. * Alpha blending mode used to apply the blur. Default is combine.
  128140. */
  128141. alphaBlendingMode: number;
  128142. /**
  128143. * The camera attached to the layer.
  128144. */
  128145. camera: Nullable<Camera>;
  128146. /**
  128147. * Should we display highlight as a solid stroke?
  128148. */
  128149. isStroke?: boolean;
  128150. /**
  128151. * The rendering group to draw the layer in.
  128152. */
  128153. renderingGroupId: number;
  128154. }
  128155. /**
  128156. * The highlight layer Helps adding a glow effect around a mesh.
  128157. *
  128158. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128159. * glowy meshes to your scene.
  128160. *
  128161. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128162. */
  128163. export class HighlightLayer extends EffectLayer {
  128164. name: string;
  128165. /**
  128166. * Effect Name of the highlight layer.
  128167. */
  128168. static readonly EffectName: string;
  128169. /**
  128170. * The neutral color used during the preparation of the glow effect.
  128171. * This is black by default as the blend operation is a blend operation.
  128172. */
  128173. static NeutralColor: Color4;
  128174. /**
  128175. * Stencil value used for glowing meshes.
  128176. */
  128177. static GlowingMeshStencilReference: number;
  128178. /**
  128179. * Stencil value used for the other meshes in the scene.
  128180. */
  128181. static NormalMeshStencilReference: number;
  128182. /**
  128183. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128184. */
  128185. innerGlow: boolean;
  128186. /**
  128187. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128188. */
  128189. outerGlow: boolean;
  128190. /**
  128191. * Specifies the horizontal size of the blur.
  128192. */
  128193. set blurHorizontalSize(value: number);
  128194. /**
  128195. * Specifies the vertical size of the blur.
  128196. */
  128197. set blurVerticalSize(value: number);
  128198. /**
  128199. * Gets the horizontal size of the blur.
  128200. */
  128201. get blurHorizontalSize(): number;
  128202. /**
  128203. * Gets the vertical size of the blur.
  128204. */
  128205. get blurVerticalSize(): number;
  128206. /**
  128207. * An event triggered when the highlight layer is being blurred.
  128208. */
  128209. onBeforeBlurObservable: Observable<HighlightLayer>;
  128210. /**
  128211. * An event triggered when the highlight layer has been blurred.
  128212. */
  128213. onAfterBlurObservable: Observable<HighlightLayer>;
  128214. private _instanceGlowingMeshStencilReference;
  128215. private _options;
  128216. private _downSamplePostprocess;
  128217. private _horizontalBlurPostprocess;
  128218. private _verticalBlurPostprocess;
  128219. private _blurTexture;
  128220. private _meshes;
  128221. private _excludedMeshes;
  128222. /**
  128223. * Instantiates a new highlight Layer and references it to the scene..
  128224. * @param name The name of the layer
  128225. * @param scene The scene to use the layer in
  128226. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128227. */
  128228. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128229. /**
  128230. * Get the effect name of the layer.
  128231. * @return The effect name
  128232. */
  128233. getEffectName(): string;
  128234. /**
  128235. * Create the merge effect. This is the shader use to blit the information back
  128236. * to the main canvas at the end of the scene rendering.
  128237. */
  128238. protected _createMergeEffect(): Effect;
  128239. /**
  128240. * Creates the render target textures and post processes used in the highlight layer.
  128241. */
  128242. protected _createTextureAndPostProcesses(): void;
  128243. /**
  128244. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128245. */
  128246. needStencil(): boolean;
  128247. /**
  128248. * Checks for the readiness of the element composing the layer.
  128249. * @param subMesh the mesh to check for
  128250. * @param useInstances specify wether or not to use instances to render the mesh
  128251. * @param emissiveTexture the associated emissive texture used to generate the glow
  128252. * @return true if ready otherwise, false
  128253. */
  128254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128255. /**
  128256. * Implementation specific of rendering the generating effect on the main canvas.
  128257. * @param effect The effect used to render through
  128258. */
  128259. protected _internalRender(effect: Effect): void;
  128260. /**
  128261. * Returns true if the layer contains information to display, otherwise false.
  128262. */
  128263. shouldRender(): boolean;
  128264. /**
  128265. * Returns true if the mesh should render, otherwise false.
  128266. * @param mesh The mesh to render
  128267. * @returns true if it should render otherwise false
  128268. */
  128269. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128270. /**
  128271. * Adds specific effects defines.
  128272. * @param defines The defines to add specifics to.
  128273. */
  128274. protected _addCustomEffectDefines(defines: string[]): void;
  128275. /**
  128276. * Sets the required values for both the emissive texture and and the main color.
  128277. */
  128278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128279. /**
  128280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128281. * @param mesh The mesh to exclude from the highlight layer
  128282. */
  128283. addExcludedMesh(mesh: Mesh): void;
  128284. /**
  128285. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128286. * @param mesh The mesh to highlight
  128287. */
  128288. removeExcludedMesh(mesh: Mesh): void;
  128289. /**
  128290. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128291. * @param mesh mesh to test
  128292. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128293. */
  128294. hasMesh(mesh: AbstractMesh): boolean;
  128295. /**
  128296. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128297. * @param mesh The mesh to highlight
  128298. * @param color The color of the highlight
  128299. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128300. */
  128301. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128302. /**
  128303. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128304. * @param mesh The mesh to highlight
  128305. */
  128306. removeMesh(mesh: Mesh): void;
  128307. /**
  128308. * Remove all the meshes currently referenced in the highlight layer
  128309. */
  128310. removeAllMeshes(): void;
  128311. /**
  128312. * Force the stencil to the normal expected value for none glowing parts
  128313. */
  128314. private _defaultStencilReference;
  128315. /**
  128316. * Free any resources and references associated to a mesh.
  128317. * Internal use
  128318. * @param mesh The mesh to free.
  128319. * @hidden
  128320. */
  128321. _disposeMesh(mesh: Mesh): void;
  128322. /**
  128323. * Dispose the highlight layer and free resources.
  128324. */
  128325. dispose(): void;
  128326. /**
  128327. * Gets the class name of the effect layer
  128328. * @returns the string with the class name of the effect layer
  128329. */
  128330. getClassName(): string;
  128331. /**
  128332. * Serializes this Highlight layer
  128333. * @returns a serialized Highlight layer object
  128334. */
  128335. serialize(): any;
  128336. /**
  128337. * Creates a Highlight layer from parsed Highlight layer data
  128338. * @param parsedHightlightLayer defines the Highlight layer data
  128339. * @param scene defines the current scene
  128340. * @param rootUrl defines the root URL containing the Highlight layer information
  128341. * @returns a parsed Highlight layer
  128342. */
  128343. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128344. }
  128345. }
  128346. declare module BABYLON {
  128347. interface AbstractScene {
  128348. /**
  128349. * The list of layers (background and foreground) of the scene
  128350. */
  128351. layers: Array<Layer>;
  128352. }
  128353. /**
  128354. * Defines the layer scene component responsible to manage any layers
  128355. * in a given scene.
  128356. */
  128357. export class LayerSceneComponent implements ISceneComponent {
  128358. /**
  128359. * The component name helpfull to identify the component in the list of scene components.
  128360. */
  128361. readonly name: string;
  128362. /**
  128363. * The scene the component belongs to.
  128364. */
  128365. scene: Scene;
  128366. private _engine;
  128367. /**
  128368. * Creates a new instance of the component for the given scene
  128369. * @param scene Defines the scene to register the component in
  128370. */
  128371. constructor(scene: Scene);
  128372. /**
  128373. * Registers the component in a given scene
  128374. */
  128375. register(): void;
  128376. /**
  128377. * Rebuilds the elements related to this component in case of
  128378. * context lost for instance.
  128379. */
  128380. rebuild(): void;
  128381. /**
  128382. * Disposes the component and the associated ressources.
  128383. */
  128384. dispose(): void;
  128385. private _draw;
  128386. private _drawCameraPredicate;
  128387. private _drawCameraBackground;
  128388. private _drawCameraForeground;
  128389. private _drawRenderTargetPredicate;
  128390. private _drawRenderTargetBackground;
  128391. private _drawRenderTargetForeground;
  128392. /**
  128393. * Adds all the elements from the container to the scene
  128394. * @param container the container holding the elements
  128395. */
  128396. addFromContainer(container: AbstractScene): void;
  128397. /**
  128398. * Removes all the elements in the container from the scene
  128399. * @param container contains the elements to remove
  128400. * @param dispose if the removed element should be disposed (default: false)
  128401. */
  128402. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128403. }
  128404. }
  128405. declare module BABYLON {
  128406. /** @hidden */
  128407. export var layerPixelShader: {
  128408. name: string;
  128409. shader: string;
  128410. };
  128411. }
  128412. declare module BABYLON {
  128413. /** @hidden */
  128414. export var layerVertexShader: {
  128415. name: string;
  128416. shader: string;
  128417. };
  128418. }
  128419. declare module BABYLON {
  128420. /**
  128421. * This represents a full screen 2d layer.
  128422. * This can be useful to display a picture in the background of your scene for instance.
  128423. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128424. */
  128425. export class Layer {
  128426. /**
  128427. * Define the name of the layer.
  128428. */
  128429. name: string;
  128430. /**
  128431. * Define the texture the layer should display.
  128432. */
  128433. texture: Nullable<Texture>;
  128434. /**
  128435. * Is the layer in background or foreground.
  128436. */
  128437. isBackground: boolean;
  128438. /**
  128439. * Define the color of the layer (instead of texture).
  128440. */
  128441. color: Color4;
  128442. /**
  128443. * Define the scale of the layer in order to zoom in out of the texture.
  128444. */
  128445. scale: Vector2;
  128446. /**
  128447. * Define an offset for the layer in order to shift the texture.
  128448. */
  128449. offset: Vector2;
  128450. /**
  128451. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128452. */
  128453. alphaBlendingMode: number;
  128454. /**
  128455. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128456. * Alpha test will not mix with the background color in case of transparency.
  128457. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128458. */
  128459. alphaTest: boolean;
  128460. /**
  128461. * Define a mask to restrict the layer to only some of the scene cameras.
  128462. */
  128463. layerMask: number;
  128464. /**
  128465. * Define the list of render target the layer is visible into.
  128466. */
  128467. renderTargetTextures: RenderTargetTexture[];
  128468. /**
  128469. * Define if the layer is only used in renderTarget or if it also
  128470. * renders in the main frame buffer of the canvas.
  128471. */
  128472. renderOnlyInRenderTargetTextures: boolean;
  128473. private _scene;
  128474. private _vertexBuffers;
  128475. private _indexBuffer;
  128476. private _effect;
  128477. private _previousDefines;
  128478. /**
  128479. * An event triggered when the layer is disposed.
  128480. */
  128481. onDisposeObservable: Observable<Layer>;
  128482. private _onDisposeObserver;
  128483. /**
  128484. * Back compatibility with callback before the onDisposeObservable existed.
  128485. * The set callback will be triggered when the layer has been disposed.
  128486. */
  128487. set onDispose(callback: () => void);
  128488. /**
  128489. * An event triggered before rendering the scene
  128490. */
  128491. onBeforeRenderObservable: Observable<Layer>;
  128492. private _onBeforeRenderObserver;
  128493. /**
  128494. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128495. * The set callback will be triggered just before rendering the layer.
  128496. */
  128497. set onBeforeRender(callback: () => void);
  128498. /**
  128499. * An event triggered after rendering the scene
  128500. */
  128501. onAfterRenderObservable: Observable<Layer>;
  128502. private _onAfterRenderObserver;
  128503. /**
  128504. * Back compatibility with callback before the onAfterRenderObservable existed.
  128505. * The set callback will be triggered just after rendering the layer.
  128506. */
  128507. set onAfterRender(callback: () => void);
  128508. /**
  128509. * Instantiates a new layer.
  128510. * This represents a full screen 2d layer.
  128511. * This can be useful to display a picture in the background of your scene for instance.
  128512. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128513. * @param name Define the name of the layer in the scene
  128514. * @param imgUrl Define the url of the texture to display in the layer
  128515. * @param scene Define the scene the layer belongs to
  128516. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128517. * @param color Defines a color for the layer
  128518. */
  128519. constructor(
  128520. /**
  128521. * Define the name of the layer.
  128522. */
  128523. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128524. private _createIndexBuffer;
  128525. /** @hidden */
  128526. _rebuild(): void;
  128527. /**
  128528. * Renders the layer in the scene.
  128529. */
  128530. render(): void;
  128531. /**
  128532. * Disposes and releases the associated ressources.
  128533. */
  128534. dispose(): void;
  128535. }
  128536. }
  128537. declare module BABYLON {
  128538. /** @hidden */
  128539. export var lensFlarePixelShader: {
  128540. name: string;
  128541. shader: string;
  128542. };
  128543. }
  128544. declare module BABYLON {
  128545. /** @hidden */
  128546. export var lensFlareVertexShader: {
  128547. name: string;
  128548. shader: string;
  128549. };
  128550. }
  128551. declare module BABYLON {
  128552. /**
  128553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128554. * It is usually composed of several `lensFlare`.
  128555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128556. */
  128557. export class LensFlareSystem {
  128558. /**
  128559. * Define the name of the lens flare system
  128560. */
  128561. name: string;
  128562. /**
  128563. * List of lens flares used in this system.
  128564. */
  128565. lensFlares: LensFlare[];
  128566. /**
  128567. * Define a limit from the border the lens flare can be visible.
  128568. */
  128569. borderLimit: number;
  128570. /**
  128571. * Define a viewport border we do not want to see the lens flare in.
  128572. */
  128573. viewportBorder: number;
  128574. /**
  128575. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128576. */
  128577. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128578. /**
  128579. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128580. */
  128581. layerMask: number;
  128582. /**
  128583. * Define the id of the lens flare system in the scene.
  128584. * (equal to name by default)
  128585. */
  128586. id: string;
  128587. private _scene;
  128588. private _emitter;
  128589. private _vertexBuffers;
  128590. private _indexBuffer;
  128591. private _effect;
  128592. private _positionX;
  128593. private _positionY;
  128594. private _isEnabled;
  128595. /** @hidden */
  128596. static _SceneComponentInitialization: (scene: Scene) => void;
  128597. /**
  128598. * Instantiates a lens flare system.
  128599. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128600. * It is usually composed of several `lensFlare`.
  128601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128602. * @param name Define the name of the lens flare system in the scene
  128603. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128604. * @param scene Define the scene the lens flare system belongs to
  128605. */
  128606. constructor(
  128607. /**
  128608. * Define the name of the lens flare system
  128609. */
  128610. name: string, emitter: any, scene: Scene);
  128611. /**
  128612. * Define if the lens flare system is enabled.
  128613. */
  128614. get isEnabled(): boolean;
  128615. set isEnabled(value: boolean);
  128616. /**
  128617. * Get the scene the effects belongs to.
  128618. * @returns the scene holding the lens flare system
  128619. */
  128620. getScene(): Scene;
  128621. /**
  128622. * Get the emitter of the lens flare system.
  128623. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128624. * @returns the emitter of the lens flare system
  128625. */
  128626. getEmitter(): any;
  128627. /**
  128628. * Set the emitter of the lens flare system.
  128629. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128630. * @param newEmitter Define the new emitter of the system
  128631. */
  128632. setEmitter(newEmitter: any): void;
  128633. /**
  128634. * Get the lens flare system emitter position.
  128635. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128636. * @returns the position
  128637. */
  128638. getEmitterPosition(): Vector3;
  128639. /**
  128640. * @hidden
  128641. */
  128642. computeEffectivePosition(globalViewport: Viewport): boolean;
  128643. /** @hidden */
  128644. _isVisible(): boolean;
  128645. /**
  128646. * @hidden
  128647. */
  128648. render(): boolean;
  128649. /**
  128650. * Dispose and release the lens flare with its associated resources.
  128651. */
  128652. dispose(): void;
  128653. /**
  128654. * Parse a lens flare system from a JSON repressentation
  128655. * @param parsedLensFlareSystem Define the JSON to parse
  128656. * @param scene Define the scene the parsed system should be instantiated in
  128657. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128658. * @returns the parsed system
  128659. */
  128660. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128661. /**
  128662. * Serialize the current Lens Flare System into a JSON representation.
  128663. * @returns the serialized JSON
  128664. */
  128665. serialize(): any;
  128666. }
  128667. }
  128668. declare module BABYLON {
  128669. /**
  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. */
  128674. export class LensFlare {
  128675. /**
  128676. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128677. */
  128678. size: number;
  128679. /**
  128680. * 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.
  128681. */
  128682. position: number;
  128683. /**
  128684. * Define the lens color.
  128685. */
  128686. color: Color3;
  128687. /**
  128688. * Define the lens texture.
  128689. */
  128690. texture: Nullable<Texture>;
  128691. /**
  128692. * Define the alpha mode to render this particular lens.
  128693. */
  128694. alphaMode: number;
  128695. private _system;
  128696. /**
  128697. * Creates a new Lens Flare.
  128698. * This represents one of the lens effect in a `lensFlareSystem`.
  128699. * It controls one of the indiviual texture used in the effect.
  128700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128701. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128702. * @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.
  128703. * @param color Define the lens color
  128704. * @param imgUrl Define the lens texture url
  128705. * @param system Define the `lensFlareSystem` this flare is part of
  128706. * @returns The newly created Lens Flare
  128707. */
  128708. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128709. /**
  128710. * Instantiates a new Lens Flare.
  128711. * This represents one of the lens effect in a `lensFlareSystem`.
  128712. * It controls one of the indiviual texture used in the effect.
  128713. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128714. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128715. * @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.
  128716. * @param color Define the lens color
  128717. * @param imgUrl Define the lens texture url
  128718. * @param system Define the `lensFlareSystem` this flare is part of
  128719. */
  128720. constructor(
  128721. /**
  128722. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128723. */
  128724. size: number,
  128725. /**
  128726. * 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.
  128727. */
  128728. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128729. /**
  128730. * Dispose and release the lens flare with its associated resources.
  128731. */
  128732. dispose(): void;
  128733. }
  128734. }
  128735. declare module BABYLON {
  128736. interface AbstractScene {
  128737. /**
  128738. * The list of lens flare system added to the scene
  128739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128740. */
  128741. lensFlareSystems: Array<LensFlareSystem>;
  128742. /**
  128743. * Removes the given lens flare system from this scene.
  128744. * @param toRemove The lens flare system to remove
  128745. * @returns The index of the removed lens flare system
  128746. */
  128747. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128748. /**
  128749. * Adds the given lens flare system to this scene
  128750. * @param newLensFlareSystem The lens flare system to add
  128751. */
  128752. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128753. /**
  128754. * Gets a lens flare system using its name
  128755. * @param name defines the name to look for
  128756. * @returns the lens flare system or null if not found
  128757. */
  128758. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128759. /**
  128760. * Gets a lens flare system using its id
  128761. * @param id defines the id to look for
  128762. * @returns the lens flare system or null if not found
  128763. */
  128764. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128765. }
  128766. /**
  128767. * Defines the lens flare scene component responsible to manage any lens flares
  128768. * in a given scene.
  128769. */
  128770. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128771. /**
  128772. * The component name helpfull to identify the component in the list of scene components.
  128773. */
  128774. readonly name: string;
  128775. /**
  128776. * The scene the component belongs to.
  128777. */
  128778. scene: Scene;
  128779. /**
  128780. * Creates a new instance of the component for the given scene
  128781. * @param scene Defines the scene to register the component in
  128782. */
  128783. constructor(scene: Scene);
  128784. /**
  128785. * Registers the component in a given scene
  128786. */
  128787. register(): void;
  128788. /**
  128789. * Rebuilds the elements related to this component in case of
  128790. * context lost for instance.
  128791. */
  128792. rebuild(): void;
  128793. /**
  128794. * Adds all the elements from the container to the scene
  128795. * @param container the container holding the elements
  128796. */
  128797. addFromContainer(container: AbstractScene): void;
  128798. /**
  128799. * Removes all the elements in the container from the scene
  128800. * @param container contains the elements to remove
  128801. * @param dispose if the removed element should be disposed (default: false)
  128802. */
  128803. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128804. /**
  128805. * Serializes the component data to the specified json object
  128806. * @param serializationObject The object to serialize to
  128807. */
  128808. serialize(serializationObject: any): void;
  128809. /**
  128810. * Disposes the component and the associated ressources.
  128811. */
  128812. dispose(): void;
  128813. private _draw;
  128814. }
  128815. }
  128816. declare module BABYLON {
  128817. /** @hidden */
  128818. export var depthPixelShader: {
  128819. name: string;
  128820. shader: string;
  128821. };
  128822. }
  128823. declare module BABYLON {
  128824. /** @hidden */
  128825. export var depthVertexShader: {
  128826. name: string;
  128827. shader: string;
  128828. };
  128829. }
  128830. declare module BABYLON {
  128831. /**
  128832. * This represents a depth renderer in Babylon.
  128833. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128834. */
  128835. export class DepthRenderer {
  128836. private _scene;
  128837. private _depthMap;
  128838. private _effect;
  128839. private readonly _storeNonLinearDepth;
  128840. private readonly _clearColor;
  128841. /** Get if the depth renderer is using packed depth or not */
  128842. readonly isPacked: boolean;
  128843. private _cachedDefines;
  128844. private _camera;
  128845. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128846. enabled: boolean;
  128847. /**
  128848. * Specifiess that the depth renderer will only be used within
  128849. * the camera it is created for.
  128850. * This can help forcing its rendering during the camera processing.
  128851. */
  128852. useOnlyInActiveCamera: boolean;
  128853. /** @hidden */
  128854. static _SceneComponentInitialization: (scene: Scene) => void;
  128855. /**
  128856. * Instantiates a depth renderer
  128857. * @param scene The scene the renderer belongs to
  128858. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128859. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128860. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128861. */
  128862. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128863. /**
  128864. * Creates the depth rendering effect and checks if the effect is ready.
  128865. * @param subMesh The submesh to be used to render the depth map of
  128866. * @param useInstances If multiple world instances should be used
  128867. * @returns if the depth renderer is ready to render the depth map
  128868. */
  128869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128870. /**
  128871. * Gets the texture which the depth map will be written to.
  128872. * @returns The depth map texture
  128873. */
  128874. getDepthMap(): RenderTargetTexture;
  128875. /**
  128876. * Disposes of the depth renderer.
  128877. */
  128878. dispose(): void;
  128879. }
  128880. }
  128881. declare module BABYLON {
  128882. /** @hidden */
  128883. export var minmaxReduxPixelShader: {
  128884. name: string;
  128885. shader: string;
  128886. };
  128887. }
  128888. declare module BABYLON {
  128889. /**
  128890. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128891. * and maximum values from all values of the texture.
  128892. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128893. * The source values are read from the red channel of the texture.
  128894. */
  128895. export class MinMaxReducer {
  128896. /**
  128897. * Observable triggered when the computation has been performed
  128898. */
  128899. onAfterReductionPerformed: Observable<{
  128900. min: number;
  128901. max: number;
  128902. }>;
  128903. protected _camera: Camera;
  128904. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128905. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128906. protected _postProcessManager: PostProcessManager;
  128907. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128908. protected _forceFullscreenViewport: boolean;
  128909. /**
  128910. * Creates a min/max reducer
  128911. * @param camera The camera to use for the post processes
  128912. */
  128913. constructor(camera: Camera);
  128914. /**
  128915. * Gets the texture used to read the values from.
  128916. */
  128917. get sourceTexture(): Nullable<RenderTargetTexture>;
  128918. /**
  128919. * Sets the source texture to read the values from.
  128920. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128921. * because in such textures '1' value must not be taken into account to compute the maximum
  128922. * as this value is used to clear the texture.
  128923. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128924. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128925. * @param depthRedux Indicates if the texture is a depth texture or not
  128926. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128927. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128928. */
  128929. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128930. /**
  128931. * Defines the refresh rate of the computation.
  128932. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128933. */
  128934. get refreshRate(): number;
  128935. set refreshRate(value: number);
  128936. protected _activated: boolean;
  128937. /**
  128938. * Gets the activation status of the reducer
  128939. */
  128940. get activated(): boolean;
  128941. /**
  128942. * Activates the reduction computation.
  128943. * When activated, the observers registered in onAfterReductionPerformed are
  128944. * called after the compuation is performed
  128945. */
  128946. activate(): void;
  128947. /**
  128948. * Deactivates the reduction computation.
  128949. */
  128950. deactivate(): void;
  128951. /**
  128952. * Disposes the min/max reducer
  128953. * @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.
  128954. */
  128955. dispose(disposeAll?: boolean): void;
  128956. }
  128957. }
  128958. declare module BABYLON {
  128959. /**
  128960. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128961. */
  128962. export class DepthReducer extends MinMaxReducer {
  128963. private _depthRenderer;
  128964. private _depthRendererId;
  128965. /**
  128966. * Gets the depth renderer used for the computation.
  128967. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128968. */
  128969. get depthRenderer(): Nullable<DepthRenderer>;
  128970. /**
  128971. * Creates a depth reducer
  128972. * @param camera The camera used to render the depth texture
  128973. */
  128974. constructor(camera: Camera);
  128975. /**
  128976. * Sets the depth renderer to use to generate the depth map
  128977. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128978. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128979. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128980. */
  128981. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128982. /** @hidden */
  128983. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128984. /**
  128985. * Activates the reduction computation.
  128986. * When activated, the observers registered in onAfterReductionPerformed are
  128987. * called after the compuation is performed
  128988. */
  128989. activate(): void;
  128990. /**
  128991. * Deactivates the reduction computation.
  128992. */
  128993. deactivate(): void;
  128994. /**
  128995. * Disposes the depth reducer
  128996. * @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.
  128997. */
  128998. dispose(disposeAll?: boolean): void;
  128999. }
  129000. }
  129001. declare module BABYLON {
  129002. /**
  129003. * A CSM implementation allowing casting shadows on large scenes.
  129004. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129005. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  129006. */
  129007. export class CascadedShadowGenerator extends ShadowGenerator {
  129008. private static readonly frustumCornersNDCSpace;
  129009. /**
  129010. * Name of the CSM class
  129011. */
  129012. static CLASSNAME: string;
  129013. /**
  129014. * Defines the default number of cascades used by the CSM.
  129015. */
  129016. static readonly DEFAULT_CASCADES_COUNT: number;
  129017. /**
  129018. * Defines the minimum number of cascades used by the CSM.
  129019. */
  129020. static readonly MIN_CASCADES_COUNT: number;
  129021. /**
  129022. * Defines the maximum number of cascades used by the CSM.
  129023. */
  129024. static readonly MAX_CASCADES_COUNT: number;
  129025. protected _validateFilter(filter: number): number;
  129026. /**
  129027. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129028. */
  129029. penumbraDarkness: number;
  129030. private _numCascades;
  129031. /**
  129032. * Gets or set the number of cascades used by the CSM.
  129033. */
  129034. get numCascades(): number;
  129035. set numCascades(value: number);
  129036. /**
  129037. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129038. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129039. */
  129040. stabilizeCascades: boolean;
  129041. private _freezeShadowCastersBoundingInfo;
  129042. private _freezeShadowCastersBoundingInfoObservable;
  129043. /**
  129044. * Enables or disables the shadow casters bounding info computation.
  129045. * If your shadow casters don't move, you can disable this feature.
  129046. * If it is enabled, the bounding box computation is done every frame.
  129047. */
  129048. get freezeShadowCastersBoundingInfo(): boolean;
  129049. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129050. private _scbiMin;
  129051. private _scbiMax;
  129052. protected _computeShadowCastersBoundingInfo(): void;
  129053. protected _shadowCastersBoundingInfo: BoundingInfo;
  129054. /**
  129055. * Gets or sets the shadow casters bounding info.
  129056. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129057. * so that the system won't overwrite the bounds you provide
  129058. */
  129059. get shadowCastersBoundingInfo(): BoundingInfo;
  129060. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129061. protected _breaksAreDirty: boolean;
  129062. protected _minDistance: number;
  129063. protected _maxDistance: number;
  129064. /**
  129065. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129066. *
  129067. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129068. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129069. * @param min minimal distance for the breaks (default to 0.)
  129070. * @param max maximal distance for the breaks (default to 1.)
  129071. */
  129072. setMinMaxDistance(min: number, max: number): void;
  129073. /** Gets the minimal distance used in the cascade break computation */
  129074. get minDistance(): number;
  129075. /** Gets the maximal distance used in the cascade break computation */
  129076. get maxDistance(): number;
  129077. /**
  129078. * Gets the class name of that object
  129079. * @returns "CascadedShadowGenerator"
  129080. */
  129081. getClassName(): string;
  129082. private _cascadeMinExtents;
  129083. private _cascadeMaxExtents;
  129084. /**
  129085. * Gets a cascade minimum extents
  129086. * @param cascadeIndex index of the cascade
  129087. * @returns the minimum cascade extents
  129088. */
  129089. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129090. /**
  129091. * Gets a cascade maximum extents
  129092. * @param cascadeIndex index of the cascade
  129093. * @returns the maximum cascade extents
  129094. */
  129095. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129096. private _cascades;
  129097. private _currentLayer;
  129098. private _viewSpaceFrustumsZ;
  129099. private _viewMatrices;
  129100. private _projectionMatrices;
  129101. private _transformMatrices;
  129102. private _transformMatricesAsArray;
  129103. private _frustumLengths;
  129104. private _lightSizeUVCorrection;
  129105. private _depthCorrection;
  129106. private _frustumCornersWorldSpace;
  129107. private _frustumCenter;
  129108. private _shadowCameraPos;
  129109. private _shadowMaxZ;
  129110. /**
  129111. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129112. * It defaults to camera.maxZ
  129113. */
  129114. get shadowMaxZ(): number;
  129115. /**
  129116. * Sets the shadow max z distance.
  129117. */
  129118. set shadowMaxZ(value: number);
  129119. protected _debug: boolean;
  129120. /**
  129121. * Gets or sets the debug flag.
  129122. * When enabled, the cascades are materialized by different colors on the screen.
  129123. */
  129124. get debug(): boolean;
  129125. set debug(dbg: boolean);
  129126. private _depthClamp;
  129127. /**
  129128. * Gets or sets the depth clamping value.
  129129. *
  129130. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129131. * to account for the shadow casters far away.
  129132. *
  129133. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129134. */
  129135. get depthClamp(): boolean;
  129136. set depthClamp(value: boolean);
  129137. private _cascadeBlendPercentage;
  129138. /**
  129139. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129140. * It defaults to 0.1 (10% blending).
  129141. */
  129142. get cascadeBlendPercentage(): number;
  129143. set cascadeBlendPercentage(value: number);
  129144. private _lambda;
  129145. /**
  129146. * Gets or set the lambda parameter.
  129147. * This parameter is used to split the camera frustum and create the cascades.
  129148. * 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.
  129149. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129150. */
  129151. get lambda(): number;
  129152. set lambda(value: number);
  129153. /**
  129154. * Gets the view matrix corresponding to a given cascade
  129155. * @param cascadeNum cascade to retrieve the view matrix from
  129156. * @returns the cascade view matrix
  129157. */
  129158. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129159. /**
  129160. * Gets the projection matrix corresponding to a given cascade
  129161. * @param cascadeNum cascade to retrieve the projection matrix from
  129162. * @returns the cascade projection matrix
  129163. */
  129164. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129165. /**
  129166. * Gets the transformation matrix corresponding to a given cascade
  129167. * @param cascadeNum cascade to retrieve the transformation matrix from
  129168. * @returns the cascade transformation matrix
  129169. */
  129170. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129171. private _depthRenderer;
  129172. /**
  129173. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129174. *
  129175. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129176. *
  129177. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129178. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129179. * @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
  129180. */
  129181. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129182. private _depthReducer;
  129183. private _autoCalcDepthBounds;
  129184. /**
  129185. * Gets or sets the autoCalcDepthBounds property.
  129186. *
  129187. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129188. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129189. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129190. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129191. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129192. */
  129193. get autoCalcDepthBounds(): boolean;
  129194. set autoCalcDepthBounds(value: boolean);
  129195. /**
  129196. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129197. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129198. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129199. * for setting the refresh rate on the renderer yourself!
  129200. */
  129201. get autoCalcDepthBoundsRefreshRate(): number;
  129202. set autoCalcDepthBoundsRefreshRate(value: number);
  129203. /**
  129204. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129205. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129206. * you change the camera near/far planes!
  129207. */
  129208. splitFrustum(): void;
  129209. private _splitFrustum;
  129210. private _computeMatrices;
  129211. private _computeFrustumInWorldSpace;
  129212. private _computeCascadeFrustum;
  129213. /**
  129214. * Support test.
  129215. */
  129216. static get IsSupported(): boolean;
  129217. /** @hidden */
  129218. static _SceneComponentInitialization: (scene: Scene) => void;
  129219. /**
  129220. * Creates a Cascaded Shadow Generator object.
  129221. * A ShadowGenerator is the required tool to use the shadows.
  129222. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129223. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129224. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129225. * @param light The directional light object generating the shadows.
  129226. * @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.
  129227. */
  129228. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129229. protected _initializeGenerator(): void;
  129230. protected _createTargetRenderTexture(): void;
  129231. protected _initializeShadowMap(): void;
  129232. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129233. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129234. /**
  129235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129236. * @param defines Defines of the material we want to update
  129237. * @param lightIndex Index of the light in the enabled light list of the material
  129238. */
  129239. prepareDefines(defines: any, lightIndex: number): void;
  129240. /**
  129241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129242. * defined in the generator but impacting the effect).
  129243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129244. * @param effect The effect we are binfing the information for
  129245. */
  129246. bindShadowLight(lightIndex: string, effect: Effect): void;
  129247. /**
  129248. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129249. * (eq to view projection * shadow projection matrices)
  129250. * @returns The transform matrix used to create the shadow map
  129251. */
  129252. getTransformMatrix(): Matrix;
  129253. /**
  129254. * Disposes the ShadowGenerator.
  129255. * Returns nothing.
  129256. */
  129257. dispose(): void;
  129258. /**
  129259. * Serializes the shadow generator setup to a json object.
  129260. * @returns The serialized JSON object
  129261. */
  129262. serialize(): any;
  129263. /**
  129264. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129265. * @param parsedShadowGenerator The JSON object to parse
  129266. * @param scene The scene to create the shadow map for
  129267. * @returns The parsed shadow generator
  129268. */
  129269. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129270. }
  129271. }
  129272. declare module BABYLON {
  129273. /**
  129274. * Defines the shadow generator component responsible to manage any shadow generators
  129275. * in a given scene.
  129276. */
  129277. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129278. /**
  129279. * The component name helpfull to identify the component in the list of scene components.
  129280. */
  129281. readonly name: string;
  129282. /**
  129283. * The scene the component belongs to.
  129284. */
  129285. scene: Scene;
  129286. /**
  129287. * Creates a new instance of the component for the given scene
  129288. * @param scene Defines the scene to register the component in
  129289. */
  129290. constructor(scene: Scene);
  129291. /**
  129292. * Registers the component in a given scene
  129293. */
  129294. register(): void;
  129295. /**
  129296. * Rebuilds the elements related to this component in case of
  129297. * context lost for instance.
  129298. */
  129299. rebuild(): void;
  129300. /**
  129301. * Serializes the component data to the specified json object
  129302. * @param serializationObject The object to serialize to
  129303. */
  129304. serialize(serializationObject: any): void;
  129305. /**
  129306. * Adds all the elements from the container to the scene
  129307. * @param container the container holding the elements
  129308. */
  129309. addFromContainer(container: AbstractScene): void;
  129310. /**
  129311. * Removes all the elements in the container from the scene
  129312. * @param container contains the elements to remove
  129313. * @param dispose if the removed element should be disposed (default: false)
  129314. */
  129315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129316. /**
  129317. * Rebuilds the elements related to this component in case of
  129318. * context lost for instance.
  129319. */
  129320. dispose(): void;
  129321. private _gatherRenderTargets;
  129322. }
  129323. }
  129324. declare module BABYLON {
  129325. /**
  129326. * A point light is a light defined by an unique point in world space.
  129327. * The light is emitted in every direction from this point.
  129328. * A good example of a point light is a standard light bulb.
  129329. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129330. */
  129331. export class PointLight extends ShadowLight {
  129332. private _shadowAngle;
  129333. /**
  129334. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129335. * This specifies what angle the shadow will use to be created.
  129336. *
  129337. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129338. */
  129339. get shadowAngle(): number;
  129340. /**
  129341. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129342. * This specifies what angle the shadow will use to be created.
  129343. *
  129344. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129345. */
  129346. set shadowAngle(value: number);
  129347. /**
  129348. * Gets the direction if it has been set.
  129349. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129350. */
  129351. get direction(): Vector3;
  129352. /**
  129353. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129354. */
  129355. set direction(value: Vector3);
  129356. /**
  129357. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129358. * A PointLight emits the light in every direction.
  129359. * It can cast shadows.
  129360. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129361. * ```javascript
  129362. * var pointLight = new PointLight("pl", camera.position, scene);
  129363. * ```
  129364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129365. * @param name The light friendly name
  129366. * @param position The position of the point light in the scene
  129367. * @param scene The scene the lights belongs to
  129368. */
  129369. constructor(name: string, position: Vector3, scene: Scene);
  129370. /**
  129371. * Returns the string "PointLight"
  129372. * @returns the class name
  129373. */
  129374. getClassName(): string;
  129375. /**
  129376. * Returns the integer 0.
  129377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129378. */
  129379. getTypeID(): number;
  129380. /**
  129381. * Specifies wether or not the shadowmap should be a cube texture.
  129382. * @returns true if the shadowmap needs to be a cube texture.
  129383. */
  129384. needCube(): boolean;
  129385. /**
  129386. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129387. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129388. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129389. */
  129390. getShadowDirection(faceIndex?: number): Vector3;
  129391. /**
  129392. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129393. * - fov = PI / 2
  129394. * - aspect ratio : 1.0
  129395. * - z-near and far equal to the active camera minZ and maxZ.
  129396. * Returns the PointLight.
  129397. */
  129398. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129399. protected _buildUniformLayout(): void;
  129400. /**
  129401. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129402. * @param effect The effect to update
  129403. * @param lightIndex The index of the light in the effect to update
  129404. * @returns The point light
  129405. */
  129406. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129407. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129408. /**
  129409. * Prepares the list of defines specific to the light type.
  129410. * @param defines the list of defines
  129411. * @param lightIndex defines the index of the light for the effect
  129412. */
  129413. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129414. }
  129415. }
  129416. declare module BABYLON {
  129417. /**
  129418. * Header information of HDR texture files.
  129419. */
  129420. export interface HDRInfo {
  129421. /**
  129422. * The height of the texture in pixels.
  129423. */
  129424. height: number;
  129425. /**
  129426. * The width of the texture in pixels.
  129427. */
  129428. width: number;
  129429. /**
  129430. * The index of the beginning of the data in the binary file.
  129431. */
  129432. dataPosition: number;
  129433. }
  129434. /**
  129435. * This groups tools to convert HDR texture to native colors array.
  129436. */
  129437. export class HDRTools {
  129438. private static Ldexp;
  129439. private static Rgbe2float;
  129440. private static readStringLine;
  129441. /**
  129442. * Reads header information from an RGBE texture stored in a native array.
  129443. * More information on this format are available here:
  129444. * https://en.wikipedia.org/wiki/RGBE_image_format
  129445. *
  129446. * @param uint8array The binary file stored in native array.
  129447. * @return The header information.
  129448. */
  129449. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129450. /**
  129451. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129452. * This RGBE texture needs to store the information as a panorama.
  129453. *
  129454. * More information on this format are available here:
  129455. * https://en.wikipedia.org/wiki/RGBE_image_format
  129456. *
  129457. * @param buffer The binary file stored in an array buffer.
  129458. * @param size The expected size of the extracted cubemap.
  129459. * @return The Cube Map information.
  129460. */
  129461. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129462. /**
  129463. * Returns the pixels data extracted from an RGBE texture.
  129464. * This pixels will be stored left to right up to down in the R G B order in one array.
  129465. *
  129466. * More information on this format are available here:
  129467. * https://en.wikipedia.org/wiki/RGBE_image_format
  129468. *
  129469. * @param uint8array The binary file stored in an array buffer.
  129470. * @param hdrInfo The header information of the file.
  129471. * @return The pixels data in RGB right to left up to down order.
  129472. */
  129473. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129474. private static RGBE_ReadPixels_RLE;
  129475. }
  129476. }
  129477. declare module BABYLON {
  129478. /**
  129479. * This represents a texture coming from an HDR input.
  129480. *
  129481. * The only supported format is currently panorama picture stored in RGBE format.
  129482. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129483. */
  129484. export class HDRCubeTexture extends BaseTexture {
  129485. private static _facesMapping;
  129486. private _generateHarmonics;
  129487. private _noMipmap;
  129488. private _textureMatrix;
  129489. private _size;
  129490. private _onLoad;
  129491. private _onError;
  129492. /**
  129493. * The texture URL.
  129494. */
  129495. url: string;
  129496. /**
  129497. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129498. */
  129499. coordinatesMode: number;
  129500. protected _isBlocking: boolean;
  129501. /**
  129502. * Sets wether or not the texture is blocking during loading.
  129503. */
  129504. set isBlocking(value: boolean);
  129505. /**
  129506. * Gets wether or not the texture is blocking during loading.
  129507. */
  129508. get isBlocking(): boolean;
  129509. protected _rotationY: number;
  129510. /**
  129511. * Sets texture matrix rotation angle around Y axis in radians.
  129512. */
  129513. set rotationY(value: number);
  129514. /**
  129515. * Gets texture matrix rotation angle around Y axis radians.
  129516. */
  129517. get rotationY(): number;
  129518. /**
  129519. * Gets or sets the center of the bounding box associated with the cube texture
  129520. * It must define where the camera used to render the texture was set
  129521. */
  129522. boundingBoxPosition: Vector3;
  129523. private _boundingBoxSize;
  129524. /**
  129525. * Gets or sets the size of the bounding box associated with the cube texture
  129526. * When defined, the cubemap will switch to local mode
  129527. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129528. * @example https://www.babylonjs-playground.com/#RNASML
  129529. */
  129530. set boundingBoxSize(value: Vector3);
  129531. get boundingBoxSize(): Vector3;
  129532. /**
  129533. * Instantiates an HDRTexture from the following parameters.
  129534. *
  129535. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129536. * @param scene The scene the texture will be used in
  129537. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129538. * @param noMipmap Forces to not generate the mipmap if true
  129539. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129540. * @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)
  129541. * @param reserved Reserved flag for internal use.
  129542. */
  129543. 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>);
  129544. /**
  129545. * Get the current class name of the texture useful for serialization or dynamic coding.
  129546. * @returns "HDRCubeTexture"
  129547. */
  129548. getClassName(): string;
  129549. /**
  129550. * Occurs when the file is raw .hdr file.
  129551. */
  129552. private loadTexture;
  129553. clone(): HDRCubeTexture;
  129554. delayLoad(): void;
  129555. /**
  129556. * Get the texture reflection matrix used to rotate/transform the reflection.
  129557. * @returns the reflection matrix
  129558. */
  129559. getReflectionTextureMatrix(): Matrix;
  129560. /**
  129561. * Set the texture reflection matrix used to rotate/transform the reflection.
  129562. * @param value Define the reflection matrix to set
  129563. */
  129564. setReflectionTextureMatrix(value: Matrix): void;
  129565. /**
  129566. * Parses a JSON representation of an HDR Texture in order to create the texture
  129567. * @param parsedTexture Define the JSON representation
  129568. * @param scene Define the scene the texture should be created in
  129569. * @param rootUrl Define the root url in case we need to load relative dependencies
  129570. * @returns the newly created texture after parsing
  129571. */
  129572. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129573. serialize(): any;
  129574. }
  129575. }
  129576. declare module BABYLON {
  129577. /**
  129578. * Class used to control physics engine
  129579. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129580. */
  129581. export class PhysicsEngine implements IPhysicsEngine {
  129582. private _physicsPlugin;
  129583. /**
  129584. * Global value used to control the smallest number supported by the simulation
  129585. */
  129586. static Epsilon: number;
  129587. private _impostors;
  129588. private _joints;
  129589. private _subTimeStep;
  129590. /**
  129591. * Gets the gravity vector used by the simulation
  129592. */
  129593. gravity: Vector3;
  129594. /**
  129595. * Factory used to create the default physics plugin.
  129596. * @returns The default physics plugin
  129597. */
  129598. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129599. /**
  129600. * Creates a new Physics Engine
  129601. * @param gravity defines the gravity vector used by the simulation
  129602. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129603. */
  129604. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129605. /**
  129606. * Sets the gravity vector used by the simulation
  129607. * @param gravity defines the gravity vector to use
  129608. */
  129609. setGravity(gravity: Vector3): void;
  129610. /**
  129611. * Set the time step of the physics engine.
  129612. * Default is 1/60.
  129613. * To slow it down, enter 1/600 for example.
  129614. * To speed it up, 1/30
  129615. * @param newTimeStep defines the new timestep to apply to this world.
  129616. */
  129617. setTimeStep(newTimeStep?: number): void;
  129618. /**
  129619. * Get the time step of the physics engine.
  129620. * @returns the current time step
  129621. */
  129622. getTimeStep(): number;
  129623. /**
  129624. * Set the sub time step of the physics engine.
  129625. * Default is 0 meaning there is no sub steps
  129626. * To increase physics resolution precision, set a small value (like 1 ms)
  129627. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129628. */
  129629. setSubTimeStep(subTimeStep?: number): void;
  129630. /**
  129631. * Get the sub time step of the physics engine.
  129632. * @returns the current sub time step
  129633. */
  129634. getSubTimeStep(): number;
  129635. /**
  129636. * Release all resources
  129637. */
  129638. dispose(): void;
  129639. /**
  129640. * Gets the name of the current physics plugin
  129641. * @returns the name of the plugin
  129642. */
  129643. getPhysicsPluginName(): string;
  129644. /**
  129645. * Adding a new impostor for the impostor tracking.
  129646. * This will be done by the impostor itself.
  129647. * @param impostor the impostor to add
  129648. */
  129649. addImpostor(impostor: PhysicsImpostor): void;
  129650. /**
  129651. * Remove an impostor from the engine.
  129652. * This impostor and its mesh will not longer be updated by the physics engine.
  129653. * @param impostor the impostor to remove
  129654. */
  129655. removeImpostor(impostor: PhysicsImpostor): void;
  129656. /**
  129657. * Add a joint to the physics engine
  129658. * @param mainImpostor defines the main impostor to which the joint is added.
  129659. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129660. * @param joint defines the joint that will connect both impostors.
  129661. */
  129662. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129663. /**
  129664. * Removes a joint from the simulation
  129665. * @param mainImpostor defines the impostor used with the joint
  129666. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129667. * @param joint defines the joint to remove
  129668. */
  129669. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129670. /**
  129671. * Called by the scene. No need to call it.
  129672. * @param delta defines the timespam between frames
  129673. */
  129674. _step(delta: number): void;
  129675. /**
  129676. * Gets the current plugin used to run the simulation
  129677. * @returns current plugin
  129678. */
  129679. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129680. /**
  129681. * Gets the list of physic impostors
  129682. * @returns an array of PhysicsImpostor
  129683. */
  129684. getImpostors(): Array<PhysicsImpostor>;
  129685. /**
  129686. * Gets the impostor for a physics enabled object
  129687. * @param object defines the object impersonated by the impostor
  129688. * @returns the PhysicsImpostor or null if not found
  129689. */
  129690. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129691. /**
  129692. * Gets the impostor for a physics body object
  129693. * @param body defines physics body used by the impostor
  129694. * @returns the PhysicsImpostor or null if not found
  129695. */
  129696. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129697. /**
  129698. * Does a raycast in the physics world
  129699. * @param from when should the ray start?
  129700. * @param to when should the ray end?
  129701. * @returns PhysicsRaycastResult
  129702. */
  129703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129704. }
  129705. }
  129706. declare module BABYLON {
  129707. /** @hidden */
  129708. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129709. private _useDeltaForWorldStep;
  129710. world: any;
  129711. name: string;
  129712. private _physicsMaterials;
  129713. private _fixedTimeStep;
  129714. private _cannonRaycastResult;
  129715. private _raycastResult;
  129716. private _physicsBodysToRemoveAfterStep;
  129717. BJSCANNON: any;
  129718. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129719. setGravity(gravity: Vector3): void;
  129720. setTimeStep(timeStep: number): void;
  129721. getTimeStep(): number;
  129722. executeStep(delta: number): void;
  129723. private _removeMarkedPhysicsBodiesFromWorld;
  129724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129727. private _processChildMeshes;
  129728. removePhysicsBody(impostor: PhysicsImpostor): void;
  129729. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129730. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129731. private _addMaterial;
  129732. private _checkWithEpsilon;
  129733. private _createShape;
  129734. private _createHeightmap;
  129735. private _minus90X;
  129736. private _plus90X;
  129737. private _tmpPosition;
  129738. private _tmpDeltaPosition;
  129739. private _tmpUnityRotation;
  129740. private _updatePhysicsBodyTransformation;
  129741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129743. isSupported(): boolean;
  129744. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129745. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129746. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129747. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129748. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129749. getBodyMass(impostor: PhysicsImpostor): number;
  129750. getBodyFriction(impostor: PhysicsImpostor): number;
  129751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129752. getBodyRestitution(impostor: PhysicsImpostor): number;
  129753. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129754. sleepBody(impostor: PhysicsImpostor): void;
  129755. wakeUpBody(impostor: PhysicsImpostor): void;
  129756. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129757. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129758. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129759. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129760. getRadius(impostor: PhysicsImpostor): number;
  129761. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129762. dispose(): void;
  129763. private _extendNamespace;
  129764. /**
  129765. * Does a raycast in the physics world
  129766. * @param from when should the ray start?
  129767. * @param to when should the ray end?
  129768. * @returns PhysicsRaycastResult
  129769. */
  129770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129771. }
  129772. }
  129773. declare module BABYLON {
  129774. /** @hidden */
  129775. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129776. world: any;
  129777. name: string;
  129778. BJSOIMO: any;
  129779. private _raycastResult;
  129780. constructor(iterations?: number, oimoInjection?: any);
  129781. setGravity(gravity: Vector3): void;
  129782. setTimeStep(timeStep: number): void;
  129783. getTimeStep(): number;
  129784. private _tmpImpostorsArray;
  129785. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129788. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129789. private _tmpPositionVector;
  129790. removePhysicsBody(impostor: PhysicsImpostor): void;
  129791. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129792. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129793. isSupported(): boolean;
  129794. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129795. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129796. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129797. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129798. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129799. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129800. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129801. getBodyMass(impostor: PhysicsImpostor): number;
  129802. getBodyFriction(impostor: PhysicsImpostor): number;
  129803. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129804. getBodyRestitution(impostor: PhysicsImpostor): number;
  129805. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129806. sleepBody(impostor: PhysicsImpostor): void;
  129807. wakeUpBody(impostor: PhysicsImpostor): void;
  129808. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129809. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129810. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129811. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129812. getRadius(impostor: PhysicsImpostor): number;
  129813. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129814. dispose(): void;
  129815. /**
  129816. * Does a raycast in the physics world
  129817. * @param from when should the ray start?
  129818. * @param to when should the ray end?
  129819. * @returns PhysicsRaycastResult
  129820. */
  129821. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129822. }
  129823. }
  129824. declare module BABYLON {
  129825. /**
  129826. * Class containing static functions to help procedurally build meshes
  129827. */
  129828. export class RibbonBuilder {
  129829. /**
  129830. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129831. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129832. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129833. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129834. * * 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
  129835. * * 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
  129836. * * 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
  129837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129840. * * 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
  129841. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129842. * * 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
  129843. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129845. * @param name defines the name of the mesh
  129846. * @param options defines the options used to create the mesh
  129847. * @param scene defines the hosting scene
  129848. * @returns the ribbon mesh
  129849. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129851. */
  129852. static CreateRibbon(name: string, options: {
  129853. pathArray: Vector3[][];
  129854. closeArray?: boolean;
  129855. closePath?: boolean;
  129856. offset?: number;
  129857. updatable?: boolean;
  129858. sideOrientation?: number;
  129859. frontUVs?: Vector4;
  129860. backUVs?: Vector4;
  129861. instance?: Mesh;
  129862. invertUV?: boolean;
  129863. uvs?: Vector2[];
  129864. colors?: Color4[];
  129865. }, scene?: Nullable<Scene>): Mesh;
  129866. }
  129867. }
  129868. declare module BABYLON {
  129869. /**
  129870. * Class containing static functions to help procedurally build meshes
  129871. */
  129872. export class ShapeBuilder {
  129873. /**
  129874. * 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.
  129875. * * 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.
  129876. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129877. * * 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.
  129878. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129879. * * 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
  129880. * * 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
  129881. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129886. * @param name defines the name of the mesh
  129887. * @param options defines the options used to create the mesh
  129888. * @param scene defines the hosting scene
  129889. * @returns the extruded shape mesh
  129890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129892. */
  129893. static ExtrudeShape(name: string, options: {
  129894. shape: Vector3[];
  129895. path: Vector3[];
  129896. scale?: number;
  129897. rotation?: number;
  129898. cap?: number;
  129899. updatable?: boolean;
  129900. sideOrientation?: number;
  129901. frontUVs?: Vector4;
  129902. backUVs?: Vector4;
  129903. instance?: Mesh;
  129904. invertUV?: boolean;
  129905. }, scene?: Nullable<Scene>): Mesh;
  129906. /**
  129907. * Creates an custom extruded shape mesh.
  129908. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129909. * * 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.
  129910. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129911. * * 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
  129912. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129913. * * 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
  129914. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129915. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129916. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129917. * * 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
  129918. * * 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
  129919. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129924. * @param name defines the name of the mesh
  129925. * @param options defines the options used to create the mesh
  129926. * @param scene defines the hosting scene
  129927. * @returns the custom extruded shape mesh
  129928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129931. */
  129932. static ExtrudeShapeCustom(name: string, options: {
  129933. shape: Vector3[];
  129934. path: Vector3[];
  129935. scaleFunction?: any;
  129936. rotationFunction?: any;
  129937. ribbonCloseArray?: boolean;
  129938. ribbonClosePath?: boolean;
  129939. cap?: number;
  129940. updatable?: boolean;
  129941. sideOrientation?: number;
  129942. frontUVs?: Vector4;
  129943. backUVs?: Vector4;
  129944. instance?: Mesh;
  129945. invertUV?: boolean;
  129946. }, scene?: Nullable<Scene>): Mesh;
  129947. private static _ExtrudeShapeGeneric;
  129948. }
  129949. }
  129950. declare module BABYLON {
  129951. /**
  129952. * AmmoJS Physics plugin
  129953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129954. * @see https://github.com/kripken/ammo.js/
  129955. */
  129956. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129957. private _useDeltaForWorldStep;
  129958. /**
  129959. * Reference to the Ammo library
  129960. */
  129961. bjsAMMO: any;
  129962. /**
  129963. * Created ammoJS world which physics bodies are added to
  129964. */
  129965. world: any;
  129966. /**
  129967. * Name of the plugin
  129968. */
  129969. name: string;
  129970. private _timeStep;
  129971. private _fixedTimeStep;
  129972. private _maxSteps;
  129973. private _tmpQuaternion;
  129974. private _tmpAmmoTransform;
  129975. private _tmpAmmoQuaternion;
  129976. private _tmpAmmoConcreteContactResultCallback;
  129977. private _collisionConfiguration;
  129978. private _dispatcher;
  129979. private _overlappingPairCache;
  129980. private _solver;
  129981. private _softBodySolver;
  129982. private _tmpAmmoVectorA;
  129983. private _tmpAmmoVectorB;
  129984. private _tmpAmmoVectorC;
  129985. private _tmpAmmoVectorD;
  129986. private _tmpContactCallbackResult;
  129987. private _tmpAmmoVectorRCA;
  129988. private _tmpAmmoVectorRCB;
  129989. private _raycastResult;
  129990. private static readonly DISABLE_COLLISION_FLAG;
  129991. private static readonly KINEMATIC_FLAG;
  129992. private static readonly DISABLE_DEACTIVATION_FLAG;
  129993. /**
  129994. * Initializes the ammoJS plugin
  129995. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129996. * @param ammoInjection can be used to inject your own ammo reference
  129997. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129998. */
  129999. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  130000. /**
  130001. * Sets the gravity of the physics world (m/(s^2))
  130002. * @param gravity Gravity to set
  130003. */
  130004. setGravity(gravity: Vector3): void;
  130005. /**
  130006. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  130007. * @param timeStep timestep to use in seconds
  130008. */
  130009. setTimeStep(timeStep: number): void;
  130010. /**
  130011. * 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)
  130012. * @param fixedTimeStep fixedTimeStep to use in seconds
  130013. */
  130014. setFixedTimeStep(fixedTimeStep: number): void;
  130015. /**
  130016. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130017. * @param maxSteps the maximum number of steps by the physics engine per frame
  130018. */
  130019. setMaxSteps(maxSteps: number): void;
  130020. /**
  130021. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130022. * @returns the current timestep in seconds
  130023. */
  130024. getTimeStep(): number;
  130025. /**
  130026. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130027. */
  130028. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130029. private _isImpostorInContact;
  130030. private _isImpostorPairInContact;
  130031. private _stepSimulation;
  130032. /**
  130033. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130034. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130035. * After the step the babylon meshes are set to the position of the physics imposters
  130036. * @param delta amount of time to step forward
  130037. * @param impostors array of imposters to update before/after the step
  130038. */
  130039. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130040. /**
  130041. * Update babylon mesh to match physics world object
  130042. * @param impostor imposter to match
  130043. */
  130044. private _afterSoftStep;
  130045. /**
  130046. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130047. * @param impostor imposter to match
  130048. */
  130049. private _ropeStep;
  130050. /**
  130051. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130052. * @param impostor imposter to match
  130053. */
  130054. private _softbodyOrClothStep;
  130055. private _tmpMatrix;
  130056. /**
  130057. * Applies an impulse on the imposter
  130058. * @param impostor imposter to apply impulse to
  130059. * @param force amount of force to be applied to the imposter
  130060. * @param contactPoint the location to apply the impulse on the imposter
  130061. */
  130062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130063. /**
  130064. * Applies a force on the imposter
  130065. * @param impostor imposter to apply force
  130066. * @param force amount of force to be applied to the imposter
  130067. * @param contactPoint the location to apply the force on the imposter
  130068. */
  130069. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130070. /**
  130071. * Creates a physics body using the plugin
  130072. * @param impostor the imposter to create the physics body on
  130073. */
  130074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130075. /**
  130076. * Removes the physics body from the imposter and disposes of the body's memory
  130077. * @param impostor imposter to remove the physics body from
  130078. */
  130079. removePhysicsBody(impostor: PhysicsImpostor): void;
  130080. /**
  130081. * Generates a joint
  130082. * @param impostorJoint the imposter joint to create the joint with
  130083. */
  130084. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130085. /**
  130086. * Removes a joint
  130087. * @param impostorJoint the imposter joint to remove the joint from
  130088. */
  130089. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130090. private _addMeshVerts;
  130091. /**
  130092. * Initialise the soft body vertices to match its object's (mesh) vertices
  130093. * Softbody vertices (nodes) are in world space and to match this
  130094. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130095. * @param impostor to create the softbody for
  130096. */
  130097. private _softVertexData;
  130098. /**
  130099. * Create an impostor's soft body
  130100. * @param impostor to create the softbody for
  130101. */
  130102. private _createSoftbody;
  130103. /**
  130104. * Create cloth for an impostor
  130105. * @param impostor to create the softbody for
  130106. */
  130107. private _createCloth;
  130108. /**
  130109. * Create rope for an impostor
  130110. * @param impostor to create the softbody for
  130111. */
  130112. private _createRope;
  130113. /**
  130114. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130115. * @param impostor to create the custom physics shape for
  130116. */
  130117. private _createCustom;
  130118. private _addHullVerts;
  130119. private _createShape;
  130120. /**
  130121. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130122. * @param impostor imposter containing the physics body and babylon object
  130123. */
  130124. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130125. /**
  130126. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130127. * @param impostor imposter containing the physics body and babylon object
  130128. * @param newPosition new position
  130129. * @param newRotation new rotation
  130130. */
  130131. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130132. /**
  130133. * If this plugin is supported
  130134. * @returns true if its supported
  130135. */
  130136. isSupported(): boolean;
  130137. /**
  130138. * Sets the linear velocity of the physics body
  130139. * @param impostor imposter to set the velocity on
  130140. * @param velocity velocity to set
  130141. */
  130142. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130143. /**
  130144. * Sets the angular velocity of the physics body
  130145. * @param impostor imposter to set the velocity on
  130146. * @param velocity velocity to set
  130147. */
  130148. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130149. /**
  130150. * gets the linear velocity
  130151. * @param impostor imposter to get linear velocity from
  130152. * @returns linear velocity
  130153. */
  130154. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130155. /**
  130156. * gets the angular velocity
  130157. * @param impostor imposter to get angular velocity from
  130158. * @returns angular velocity
  130159. */
  130160. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130161. /**
  130162. * Sets the mass of physics body
  130163. * @param impostor imposter to set the mass on
  130164. * @param mass mass to set
  130165. */
  130166. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130167. /**
  130168. * Gets the mass of the physics body
  130169. * @param impostor imposter to get the mass from
  130170. * @returns mass
  130171. */
  130172. getBodyMass(impostor: PhysicsImpostor): number;
  130173. /**
  130174. * Gets friction of the impostor
  130175. * @param impostor impostor to get friction from
  130176. * @returns friction value
  130177. */
  130178. getBodyFriction(impostor: PhysicsImpostor): number;
  130179. /**
  130180. * Sets friction of the impostor
  130181. * @param impostor impostor to set friction on
  130182. * @param friction friction value
  130183. */
  130184. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130185. /**
  130186. * Gets restitution of the impostor
  130187. * @param impostor impostor to get restitution from
  130188. * @returns restitution value
  130189. */
  130190. getBodyRestitution(impostor: PhysicsImpostor): number;
  130191. /**
  130192. * Sets resitution of the impostor
  130193. * @param impostor impostor to set resitution on
  130194. * @param restitution resitution value
  130195. */
  130196. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130197. /**
  130198. * Gets pressure inside the impostor
  130199. * @param impostor impostor to get pressure from
  130200. * @returns pressure value
  130201. */
  130202. getBodyPressure(impostor: PhysicsImpostor): number;
  130203. /**
  130204. * Sets pressure inside a soft body impostor
  130205. * Cloth and rope must remain 0 pressure
  130206. * @param impostor impostor to set pressure on
  130207. * @param pressure pressure value
  130208. */
  130209. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130210. /**
  130211. * Gets stiffness of the impostor
  130212. * @param impostor impostor to get stiffness from
  130213. * @returns pressure value
  130214. */
  130215. getBodyStiffness(impostor: PhysicsImpostor): number;
  130216. /**
  130217. * Sets stiffness of the impostor
  130218. * @param impostor impostor to set stiffness on
  130219. * @param stiffness stiffness value from 0 to 1
  130220. */
  130221. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130222. /**
  130223. * Gets velocityIterations of the impostor
  130224. * @param impostor impostor to get velocity iterations from
  130225. * @returns velocityIterations value
  130226. */
  130227. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130228. /**
  130229. * Sets velocityIterations of the impostor
  130230. * @param impostor impostor to set velocity iterations on
  130231. * @param velocityIterations velocityIterations value
  130232. */
  130233. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130234. /**
  130235. * Gets positionIterations of the impostor
  130236. * @param impostor impostor to get position iterations from
  130237. * @returns positionIterations value
  130238. */
  130239. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130240. /**
  130241. * Sets positionIterations of the impostor
  130242. * @param impostor impostor to set position on
  130243. * @param positionIterations positionIterations value
  130244. */
  130245. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130246. /**
  130247. * Append an anchor to a cloth object
  130248. * @param impostor is the cloth impostor to add anchor to
  130249. * @param otherImpostor is the rigid impostor to anchor to
  130250. * @param width ratio across width from 0 to 1
  130251. * @param height ratio up height from 0 to 1
  130252. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130253. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130254. */
  130255. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130256. /**
  130257. * Append an hook to a rope object
  130258. * @param impostor is the rope impostor to add hook to
  130259. * @param otherImpostor is the rigid impostor to hook to
  130260. * @param length ratio along the rope from 0 to 1
  130261. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130262. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130263. */
  130264. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130265. /**
  130266. * Sleeps the physics body and stops it from being active
  130267. * @param impostor impostor to sleep
  130268. */
  130269. sleepBody(impostor: PhysicsImpostor): void;
  130270. /**
  130271. * Activates the physics body
  130272. * @param impostor impostor to activate
  130273. */
  130274. wakeUpBody(impostor: PhysicsImpostor): void;
  130275. /**
  130276. * Updates the distance parameters of the joint
  130277. * @param joint joint to update
  130278. * @param maxDistance maximum distance of the joint
  130279. * @param minDistance minimum distance of the joint
  130280. */
  130281. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130282. /**
  130283. * Sets a motor on the joint
  130284. * @param joint joint to set motor on
  130285. * @param speed speed of the motor
  130286. * @param maxForce maximum force of the motor
  130287. * @param motorIndex index of the motor
  130288. */
  130289. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130290. /**
  130291. * Sets the motors limit
  130292. * @param joint joint to set limit on
  130293. * @param upperLimit upper limit
  130294. * @param lowerLimit lower limit
  130295. */
  130296. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130297. /**
  130298. * Syncs the position and rotation of a mesh with the impostor
  130299. * @param mesh mesh to sync
  130300. * @param impostor impostor to update the mesh with
  130301. */
  130302. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130303. /**
  130304. * Gets the radius of the impostor
  130305. * @param impostor impostor to get radius from
  130306. * @returns the radius
  130307. */
  130308. getRadius(impostor: PhysicsImpostor): number;
  130309. /**
  130310. * Gets the box size of the impostor
  130311. * @param impostor impostor to get box size from
  130312. * @param result the resulting box size
  130313. */
  130314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130315. /**
  130316. * Disposes of the impostor
  130317. */
  130318. dispose(): void;
  130319. /**
  130320. * Does a raycast in the physics world
  130321. * @param from when should the ray start?
  130322. * @param to when should the ray end?
  130323. * @returns PhysicsRaycastResult
  130324. */
  130325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130326. }
  130327. }
  130328. declare module BABYLON {
  130329. interface AbstractScene {
  130330. /**
  130331. * The list of reflection probes added to the scene
  130332. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130333. */
  130334. reflectionProbes: Array<ReflectionProbe>;
  130335. /**
  130336. * Removes the given reflection probe from this scene.
  130337. * @param toRemove The reflection probe to remove
  130338. * @returns The index of the removed reflection probe
  130339. */
  130340. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130341. /**
  130342. * Adds the given reflection probe to this scene.
  130343. * @param newReflectionProbe The reflection probe to add
  130344. */
  130345. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130346. }
  130347. /**
  130348. * Class used to generate realtime reflection / refraction cube textures
  130349. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130350. */
  130351. export class ReflectionProbe {
  130352. /** defines the name of the probe */
  130353. name: string;
  130354. private _scene;
  130355. private _renderTargetTexture;
  130356. private _projectionMatrix;
  130357. private _viewMatrix;
  130358. private _target;
  130359. private _add;
  130360. private _attachedMesh;
  130361. private _invertYAxis;
  130362. /** Gets or sets probe position (center of the cube map) */
  130363. position: Vector3;
  130364. /**
  130365. * Creates a new reflection probe
  130366. * @param name defines the name of the probe
  130367. * @param size defines the texture resolution (for each face)
  130368. * @param scene defines the hosting scene
  130369. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130370. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130371. */
  130372. constructor(
  130373. /** defines the name of the probe */
  130374. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130375. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130376. get samples(): number;
  130377. set samples(value: number);
  130378. /** Gets or sets the refresh rate to use (on every frame by default) */
  130379. get refreshRate(): number;
  130380. set refreshRate(value: number);
  130381. /**
  130382. * Gets the hosting scene
  130383. * @returns a Scene
  130384. */
  130385. getScene(): Scene;
  130386. /** Gets the internal CubeTexture used to render to */
  130387. get cubeTexture(): RenderTargetTexture;
  130388. /** Gets the list of meshes to render */
  130389. get renderList(): Nullable<AbstractMesh[]>;
  130390. /**
  130391. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130392. * @param mesh defines the mesh to attach to
  130393. */
  130394. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130395. /**
  130396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130397. * @param renderingGroupId The rendering group id corresponding to its index
  130398. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130399. */
  130400. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130401. /**
  130402. * Clean all associated resources
  130403. */
  130404. dispose(): void;
  130405. /**
  130406. * Converts the reflection probe information to a readable string for debug purpose.
  130407. * @param fullDetails Supports for multiple levels of logging within scene loading
  130408. * @returns the human readable reflection probe info
  130409. */
  130410. toString(fullDetails?: boolean): string;
  130411. /**
  130412. * Get the class name of the relfection probe.
  130413. * @returns "ReflectionProbe"
  130414. */
  130415. getClassName(): string;
  130416. /**
  130417. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130418. * @returns The JSON representation of the texture
  130419. */
  130420. serialize(): any;
  130421. /**
  130422. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130423. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130424. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130425. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130426. * @returns The parsed reflection probe if successful
  130427. */
  130428. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130429. }
  130430. }
  130431. declare module BABYLON {
  130432. /** @hidden */
  130433. export var _BabylonLoaderRegistered: boolean;
  130434. /**
  130435. * Helps setting up some configuration for the babylon file loader.
  130436. */
  130437. export class BabylonFileLoaderConfiguration {
  130438. /**
  130439. * The loader does not allow injecting custom physix engine into the plugins.
  130440. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130441. * So you could set this variable to your engine import to make it work.
  130442. */
  130443. static LoaderInjectedPhysicsEngine: any;
  130444. }
  130445. }
  130446. declare module BABYLON {
  130447. /**
  130448. * The Physically based simple base material of BJS.
  130449. *
  130450. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130451. * It is used as the base class for both the specGloss and metalRough conventions.
  130452. */
  130453. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130454. /**
  130455. * Number of Simultaneous lights allowed on the material.
  130456. */
  130457. maxSimultaneousLights: number;
  130458. /**
  130459. * If sets to true, disables all the lights affecting the material.
  130460. */
  130461. disableLighting: boolean;
  130462. /**
  130463. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130464. */
  130465. environmentTexture: BaseTexture;
  130466. /**
  130467. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130468. */
  130469. invertNormalMapX: boolean;
  130470. /**
  130471. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130472. */
  130473. invertNormalMapY: boolean;
  130474. /**
  130475. * Normal map used in the model.
  130476. */
  130477. normalTexture: BaseTexture;
  130478. /**
  130479. * Emissivie color used to self-illuminate the model.
  130480. */
  130481. emissiveColor: Color3;
  130482. /**
  130483. * Emissivie texture used to self-illuminate the model.
  130484. */
  130485. emissiveTexture: BaseTexture;
  130486. /**
  130487. * Occlusion Channel Strenght.
  130488. */
  130489. occlusionStrength: number;
  130490. /**
  130491. * Occlusion Texture of the material (adding extra occlusion effects).
  130492. */
  130493. occlusionTexture: BaseTexture;
  130494. /**
  130495. * Defines the alpha limits in alpha test mode.
  130496. */
  130497. alphaCutOff: number;
  130498. /**
  130499. * Gets the current double sided mode.
  130500. */
  130501. get doubleSided(): boolean;
  130502. /**
  130503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130504. */
  130505. set doubleSided(value: boolean);
  130506. /**
  130507. * Stores the pre-calculated light information of a mesh in a texture.
  130508. */
  130509. lightmapTexture: BaseTexture;
  130510. /**
  130511. * If true, the light map contains occlusion information instead of lighting info.
  130512. */
  130513. useLightmapAsShadowmap: boolean;
  130514. /**
  130515. * Instantiates a new PBRMaterial instance.
  130516. *
  130517. * @param name The material name
  130518. * @param scene The scene the material will be use in.
  130519. */
  130520. constructor(name: string, scene: Scene);
  130521. getClassName(): string;
  130522. }
  130523. }
  130524. declare module BABYLON {
  130525. /**
  130526. * The PBR material of BJS following the metal roughness convention.
  130527. *
  130528. * This fits to the PBR convention in the GLTF definition:
  130529. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130530. */
  130531. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130532. /**
  130533. * The base color has two different interpretations depending on the value of metalness.
  130534. * When the material is a metal, the base color is the specific measured reflectance value
  130535. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130536. * of the material.
  130537. */
  130538. baseColor: Color3;
  130539. /**
  130540. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130541. * well as opacity information in the alpha channel.
  130542. */
  130543. baseTexture: BaseTexture;
  130544. /**
  130545. * Specifies the metallic scalar value of the material.
  130546. * Can also be used to scale the metalness values of the metallic texture.
  130547. */
  130548. metallic: number;
  130549. /**
  130550. * Specifies the roughness scalar value of the material.
  130551. * Can also be used to scale the roughness values of the metallic texture.
  130552. */
  130553. roughness: number;
  130554. /**
  130555. * Texture containing both the metallic value in the B channel and the
  130556. * roughness value in the G channel to keep better precision.
  130557. */
  130558. metallicRoughnessTexture: BaseTexture;
  130559. /**
  130560. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130561. *
  130562. * @param name The material name
  130563. * @param scene The scene the material will be use in.
  130564. */
  130565. constructor(name: string, scene: Scene);
  130566. /**
  130567. * Return the currrent class name of the material.
  130568. */
  130569. getClassName(): string;
  130570. /**
  130571. * Makes a duplicate of the current material.
  130572. * @param name - name to use for the new material.
  130573. */
  130574. clone(name: string): PBRMetallicRoughnessMaterial;
  130575. /**
  130576. * Serialize the material to a parsable JSON object.
  130577. */
  130578. serialize(): any;
  130579. /**
  130580. * Parses a JSON object correponding to the serialize function.
  130581. */
  130582. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130583. }
  130584. }
  130585. declare module BABYLON {
  130586. /**
  130587. * The PBR material of BJS following the specular glossiness convention.
  130588. *
  130589. * This fits to the PBR convention in the GLTF definition:
  130590. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130591. */
  130592. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130593. /**
  130594. * Specifies the diffuse color of the material.
  130595. */
  130596. diffuseColor: Color3;
  130597. /**
  130598. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130599. * channel.
  130600. */
  130601. diffuseTexture: BaseTexture;
  130602. /**
  130603. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130604. */
  130605. specularColor: Color3;
  130606. /**
  130607. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130608. */
  130609. glossiness: number;
  130610. /**
  130611. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130612. */
  130613. specularGlossinessTexture: BaseTexture;
  130614. /**
  130615. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130616. *
  130617. * @param name The material name
  130618. * @param scene The scene the material will be use in.
  130619. */
  130620. constructor(name: string, scene: Scene);
  130621. /**
  130622. * Return the currrent class name of the material.
  130623. */
  130624. getClassName(): string;
  130625. /**
  130626. * Makes a duplicate of the current material.
  130627. * @param name - name to use for the new material.
  130628. */
  130629. clone(name: string): PBRSpecularGlossinessMaterial;
  130630. /**
  130631. * Serialize the material to a parsable JSON object.
  130632. */
  130633. serialize(): any;
  130634. /**
  130635. * Parses a JSON object correponding to the serialize function.
  130636. */
  130637. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130638. }
  130639. }
  130640. declare module BABYLON {
  130641. /**
  130642. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130643. * It can help converting any input color in a desired output one. This can then be used to create effects
  130644. * from sepia, black and white to sixties or futuristic rendering...
  130645. *
  130646. * The only supported format is currently 3dl.
  130647. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130648. */
  130649. export class ColorGradingTexture extends BaseTexture {
  130650. /**
  130651. * The current texture matrix. (will always be identity in color grading texture)
  130652. */
  130653. private _textureMatrix;
  130654. /**
  130655. * The texture URL.
  130656. */
  130657. url: string;
  130658. /**
  130659. * Empty line regex stored for GC.
  130660. */
  130661. private static _noneEmptyLineRegex;
  130662. private _engine;
  130663. /**
  130664. * Instantiates a ColorGradingTexture from the following parameters.
  130665. *
  130666. * @param url The location of the color gradind data (currently only supporting 3dl)
  130667. * @param scene The scene the texture will be used in
  130668. */
  130669. constructor(url: string, scene: Scene);
  130670. /**
  130671. * Returns the texture matrix used in most of the material.
  130672. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130673. */
  130674. getTextureMatrix(): Matrix;
  130675. /**
  130676. * Occurs when the file being loaded is a .3dl LUT file.
  130677. */
  130678. private load3dlTexture;
  130679. /**
  130680. * Starts the loading process of the texture.
  130681. */
  130682. private loadTexture;
  130683. /**
  130684. * Clones the color gradind texture.
  130685. */
  130686. clone(): ColorGradingTexture;
  130687. /**
  130688. * Called during delayed load for textures.
  130689. */
  130690. delayLoad(): void;
  130691. /**
  130692. * Parses a color grading texture serialized by Babylon.
  130693. * @param parsedTexture The texture information being parsedTexture
  130694. * @param scene The scene to load the texture in
  130695. * @param rootUrl The root url of the data assets to load
  130696. * @return A color gradind texture
  130697. */
  130698. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130699. /**
  130700. * Serializes the LUT texture to json format.
  130701. */
  130702. serialize(): any;
  130703. }
  130704. }
  130705. declare module BABYLON {
  130706. /**
  130707. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130708. */
  130709. export class EquiRectangularCubeTexture extends BaseTexture {
  130710. /** The six faces of the cube. */
  130711. private static _FacesMapping;
  130712. private _noMipmap;
  130713. private _onLoad;
  130714. private _onError;
  130715. /** The size of the cubemap. */
  130716. private _size;
  130717. /** The buffer of the image. */
  130718. private _buffer;
  130719. /** The width of the input image. */
  130720. private _width;
  130721. /** The height of the input image. */
  130722. private _height;
  130723. /** The URL to the image. */
  130724. url: string;
  130725. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130726. coordinatesMode: number;
  130727. /**
  130728. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130729. * @param url The location of the image
  130730. * @param scene The scene the texture will be used in
  130731. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130732. * @param noMipmap Forces to not generate the mipmap if true
  130733. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130734. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130735. * @param onLoad — defines a callback called when texture is loaded
  130736. * @param onError — defines a callback called if there is an error
  130737. */
  130738. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130739. /**
  130740. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130741. */
  130742. private loadImage;
  130743. /**
  130744. * Convert the image buffer into a cubemap and create a CubeTexture.
  130745. */
  130746. private loadTexture;
  130747. /**
  130748. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130749. * @param buffer The ArrayBuffer that should be converted.
  130750. * @returns The buffer as Float32Array.
  130751. */
  130752. private getFloat32ArrayFromArrayBuffer;
  130753. /**
  130754. * Get the current class name of the texture useful for serialization or dynamic coding.
  130755. * @returns "EquiRectangularCubeTexture"
  130756. */
  130757. getClassName(): string;
  130758. /**
  130759. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130760. * @returns A clone of the current EquiRectangularCubeTexture.
  130761. */
  130762. clone(): EquiRectangularCubeTexture;
  130763. }
  130764. }
  130765. declare module BABYLON {
  130766. /**
  130767. * Based on jsTGALoader - Javascript loader for TGA file
  130768. * By Vincent Thibault
  130769. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130770. */
  130771. export class TGATools {
  130772. private static _TYPE_INDEXED;
  130773. private static _TYPE_RGB;
  130774. private static _TYPE_GREY;
  130775. private static _TYPE_RLE_INDEXED;
  130776. private static _TYPE_RLE_RGB;
  130777. private static _TYPE_RLE_GREY;
  130778. private static _ORIGIN_MASK;
  130779. private static _ORIGIN_SHIFT;
  130780. private static _ORIGIN_BL;
  130781. private static _ORIGIN_BR;
  130782. private static _ORIGIN_UL;
  130783. private static _ORIGIN_UR;
  130784. /**
  130785. * Gets the header of a TGA file
  130786. * @param data defines the TGA data
  130787. * @returns the header
  130788. */
  130789. static GetTGAHeader(data: Uint8Array): any;
  130790. /**
  130791. * Uploads TGA content to a Babylon Texture
  130792. * @hidden
  130793. */
  130794. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130795. /** @hidden */
  130796. 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;
  130797. /** @hidden */
  130798. 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;
  130799. /** @hidden */
  130800. 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;
  130801. /** @hidden */
  130802. 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;
  130803. /** @hidden */
  130804. 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;
  130805. /** @hidden */
  130806. 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;
  130807. }
  130808. }
  130809. declare module BABYLON {
  130810. /**
  130811. * Implementation of the TGA Texture Loader.
  130812. * @hidden
  130813. */
  130814. export class _TGATextureLoader implements IInternalTextureLoader {
  130815. /**
  130816. * Defines wether the loader supports cascade loading the different faces.
  130817. */
  130818. readonly supportCascades: boolean;
  130819. /**
  130820. * This returns if the loader support the current file information.
  130821. * @param extension defines the file extension of the file being loaded
  130822. * @returns true if the loader can load the specified file
  130823. */
  130824. canLoad(extension: string): boolean;
  130825. /**
  130826. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130827. * @param data contains the texture data
  130828. * @param texture defines the BabylonJS internal texture
  130829. * @param createPolynomials will be true if polynomials have been requested
  130830. * @param onLoad defines the callback to trigger once the texture is ready
  130831. * @param onError defines the callback to trigger in case of error
  130832. */
  130833. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130834. /**
  130835. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130836. * @param data contains the texture data
  130837. * @param texture defines the BabylonJS internal texture
  130838. * @param callback defines the method to call once ready to upload
  130839. */
  130840. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130841. }
  130842. }
  130843. declare module BABYLON {
  130844. /**
  130845. * Info about the .basis files
  130846. */
  130847. class BasisFileInfo {
  130848. /**
  130849. * If the file has alpha
  130850. */
  130851. hasAlpha: boolean;
  130852. /**
  130853. * Info about each image of the basis file
  130854. */
  130855. images: Array<{
  130856. levels: Array<{
  130857. width: number;
  130858. height: number;
  130859. transcodedPixels: ArrayBufferView;
  130860. }>;
  130861. }>;
  130862. }
  130863. /**
  130864. * Result of transcoding a basis file
  130865. */
  130866. class TranscodeResult {
  130867. /**
  130868. * Info about the .basis file
  130869. */
  130870. fileInfo: BasisFileInfo;
  130871. /**
  130872. * Format to use when loading the file
  130873. */
  130874. format: number;
  130875. }
  130876. /**
  130877. * Configuration options for the Basis transcoder
  130878. */
  130879. export class BasisTranscodeConfiguration {
  130880. /**
  130881. * Supported compression formats used to determine the supported output format of the transcoder
  130882. */
  130883. supportedCompressionFormats?: {
  130884. /**
  130885. * etc1 compression format
  130886. */
  130887. etc1?: boolean;
  130888. /**
  130889. * s3tc compression format
  130890. */
  130891. s3tc?: boolean;
  130892. /**
  130893. * pvrtc compression format
  130894. */
  130895. pvrtc?: boolean;
  130896. /**
  130897. * etc2 compression format
  130898. */
  130899. etc2?: boolean;
  130900. };
  130901. /**
  130902. * If mipmap levels should be loaded for transcoded images (Default: true)
  130903. */
  130904. loadMipmapLevels?: boolean;
  130905. /**
  130906. * Index of a single image to load (Default: all images)
  130907. */
  130908. loadSingleImage?: number;
  130909. }
  130910. /**
  130911. * Used to load .Basis files
  130912. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130913. */
  130914. export class BasisTools {
  130915. private static _IgnoreSupportedFormats;
  130916. /**
  130917. * URL to use when loading the basis transcoder
  130918. */
  130919. static JSModuleURL: string;
  130920. /**
  130921. * URL to use when loading the wasm module for the transcoder
  130922. */
  130923. static WasmModuleURL: string;
  130924. /**
  130925. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130926. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130927. * @returns internal format corresponding to the Basis format
  130928. */
  130929. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130930. private static _WorkerPromise;
  130931. private static _Worker;
  130932. private static _actionId;
  130933. private static _CreateWorkerAsync;
  130934. /**
  130935. * Transcodes a loaded image file to compressed pixel data
  130936. * @param data image data to transcode
  130937. * @param config configuration options for the transcoding
  130938. * @returns a promise resulting in the transcoded image
  130939. */
  130940. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130941. /**
  130942. * Loads a texture from the transcode result
  130943. * @param texture texture load to
  130944. * @param transcodeResult the result of transcoding the basis file to load from
  130945. */
  130946. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130947. }
  130948. }
  130949. declare module BABYLON {
  130950. /**
  130951. * Loader for .basis file format
  130952. */
  130953. export class _BasisTextureLoader implements IInternalTextureLoader {
  130954. /**
  130955. * Defines whether the loader supports cascade loading the different faces.
  130956. */
  130957. readonly supportCascades: boolean;
  130958. /**
  130959. * This returns if the loader support the current file information.
  130960. * @param extension defines the file extension of the file being loaded
  130961. * @returns true if the loader can load the specified file
  130962. */
  130963. canLoad(extension: string): boolean;
  130964. /**
  130965. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130966. * @param data contains the texture data
  130967. * @param texture defines the BabylonJS internal texture
  130968. * @param createPolynomials will be true if polynomials have been requested
  130969. * @param onLoad defines the callback to trigger once the texture is ready
  130970. * @param onError defines the callback to trigger in case of error
  130971. */
  130972. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130973. /**
  130974. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130975. * @param data contains the texture data
  130976. * @param texture defines the BabylonJS internal texture
  130977. * @param callback defines the method to call once ready to upload
  130978. */
  130979. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130980. }
  130981. }
  130982. declare module BABYLON {
  130983. /**
  130984. * 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.
  130985. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130986. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130987. */
  130988. export class CustomProceduralTexture extends ProceduralTexture {
  130989. private _animate;
  130990. private _time;
  130991. private _config;
  130992. private _texturePath;
  130993. /**
  130994. * Instantiates a new Custom Procedural Texture.
  130995. * 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.
  130996. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130997. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130998. * @param name Define the name of the texture
  130999. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  131000. * @param size Define the size of the texture to create
  131001. * @param scene Define the scene the texture belongs to
  131002. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  131003. * @param generateMipMaps Define if the texture should creates mip maps or not
  131004. */
  131005. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131006. private _loadJson;
  131007. /**
  131008. * Is the texture ready to be used ? (rendered at least once)
  131009. * @returns true if ready, otherwise, false.
  131010. */
  131011. isReady(): boolean;
  131012. /**
  131013. * Render the texture to its associated render target.
  131014. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  131015. */
  131016. render(useCameraPostProcess?: boolean): void;
  131017. /**
  131018. * Update the list of dependant textures samplers in the shader.
  131019. */
  131020. updateTextures(): void;
  131021. /**
  131022. * Update the uniform values of the procedural texture in the shader.
  131023. */
  131024. updateShaderUniforms(): void;
  131025. /**
  131026. * Define if the texture animates or not.
  131027. */
  131028. get animate(): boolean;
  131029. set animate(value: boolean);
  131030. }
  131031. }
  131032. declare module BABYLON {
  131033. /** @hidden */
  131034. export var noisePixelShader: {
  131035. name: string;
  131036. shader: string;
  131037. };
  131038. }
  131039. declare module BABYLON {
  131040. /**
  131041. * Class used to generate noise procedural textures
  131042. */
  131043. export class NoiseProceduralTexture extends ProceduralTexture {
  131044. private _time;
  131045. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131046. brightness: number;
  131047. /** Defines the number of octaves to process */
  131048. octaves: number;
  131049. /** Defines the level of persistence (0.8 by default) */
  131050. persistence: number;
  131051. /** Gets or sets animation speed factor (default is 1) */
  131052. animationSpeedFactor: number;
  131053. /**
  131054. * Creates a new NoiseProceduralTexture
  131055. * @param name defines the name fo the texture
  131056. * @param size defines the size of the texture (default is 256)
  131057. * @param scene defines the hosting scene
  131058. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131059. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131060. */
  131061. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131062. private _updateShaderUniforms;
  131063. protected _getDefines(): string;
  131064. /** Generate the current state of the procedural texture */
  131065. render(useCameraPostProcess?: boolean): void;
  131066. /**
  131067. * Serializes this noise procedural texture
  131068. * @returns a serialized noise procedural texture object
  131069. */
  131070. serialize(): any;
  131071. /**
  131072. * Clone the texture.
  131073. * @returns the cloned texture
  131074. */
  131075. clone(): NoiseProceduralTexture;
  131076. /**
  131077. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131078. * @param parsedTexture defines parsed texture data
  131079. * @param scene defines the current scene
  131080. * @param rootUrl defines the root URL containing noise procedural texture information
  131081. * @returns a parsed NoiseProceduralTexture
  131082. */
  131083. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131084. }
  131085. }
  131086. declare module BABYLON {
  131087. /**
  131088. * Raw cube texture where the raw buffers are passed in
  131089. */
  131090. export class RawCubeTexture extends CubeTexture {
  131091. /**
  131092. * Creates a cube texture where the raw buffers are passed in.
  131093. * @param scene defines the scene the texture is attached to
  131094. * @param data defines the array of data to use to create each face
  131095. * @param size defines the size of the textures
  131096. * @param format defines the format of the data
  131097. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131098. * @param generateMipMaps defines if the engine should generate the mip levels
  131099. * @param invertY defines if data must be stored with Y axis inverted
  131100. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131101. * @param compression defines the compression used (null by default)
  131102. */
  131103. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131104. /**
  131105. * Updates the raw cube texture.
  131106. * @param data defines the data to store
  131107. * @param format defines the data format
  131108. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131109. * @param invertY defines if data must be stored with Y axis inverted
  131110. * @param compression defines the compression used (null by default)
  131111. * @param level defines which level of the texture to update
  131112. */
  131113. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131114. /**
  131115. * Updates a raw cube texture with RGBD encoded data.
  131116. * @param data defines the array of data [mipmap][face] to use to create each face
  131117. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131118. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131119. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131120. * @returns a promsie that resolves when the operation is complete
  131121. */
  131122. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131123. /**
  131124. * Clones the raw cube texture.
  131125. * @return a new cube texture
  131126. */
  131127. clone(): CubeTexture;
  131128. /** @hidden */
  131129. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131130. }
  131131. }
  131132. declare module BABYLON {
  131133. /**
  131134. * Class used to store 3D textures containing user data
  131135. */
  131136. export class RawTexture3D extends Texture {
  131137. /** Gets or sets the texture format to use */
  131138. format: number;
  131139. private _engine;
  131140. /**
  131141. * Create a new RawTexture3D
  131142. * @param data defines the data of the texture
  131143. * @param width defines the width of the texture
  131144. * @param height defines the height of the texture
  131145. * @param depth defines the depth of the texture
  131146. * @param format defines the texture format to use
  131147. * @param scene defines the hosting scene
  131148. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131149. * @param invertY defines if texture must be stored with Y axis inverted
  131150. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131151. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131152. */
  131153. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131154. /** Gets or sets the texture format to use */
  131155. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131156. /**
  131157. * Update the texture with new data
  131158. * @param data defines the data to store in the texture
  131159. */
  131160. update(data: ArrayBufferView): void;
  131161. }
  131162. }
  131163. declare module BABYLON {
  131164. /**
  131165. * Class used to store 2D array textures containing user data
  131166. */
  131167. export class RawTexture2DArray extends Texture {
  131168. /** Gets or sets the texture format to use */
  131169. format: number;
  131170. private _engine;
  131171. /**
  131172. * Create a new RawTexture2DArray
  131173. * @param data defines the data of the texture
  131174. * @param width defines the width of the texture
  131175. * @param height defines the height of the texture
  131176. * @param depth defines the number of layers of the texture
  131177. * @param format defines the texture format to use
  131178. * @param scene defines the hosting scene
  131179. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131180. * @param invertY defines if texture must be stored with Y axis inverted
  131181. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131182. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131183. */
  131184. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131185. /** Gets or sets the texture format to use */
  131186. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131187. /**
  131188. * Update the texture with new data
  131189. * @param data defines the data to store in the texture
  131190. */
  131191. update(data: ArrayBufferView): void;
  131192. }
  131193. }
  131194. declare module BABYLON {
  131195. /**
  131196. * Creates a refraction texture used by refraction channel of the standard material.
  131197. * It is like a mirror but to see through a material.
  131198. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131199. */
  131200. export class RefractionTexture extends RenderTargetTexture {
  131201. /**
  131202. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131203. * 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.
  131204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131205. */
  131206. refractionPlane: Plane;
  131207. /**
  131208. * Define how deep under the surface we should see.
  131209. */
  131210. depth: number;
  131211. /**
  131212. * Creates a refraction texture used by refraction channel of the standard material.
  131213. * It is like a mirror but to see through a material.
  131214. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131215. * @param name Define the texture name
  131216. * @param size Define the size of the underlying texture
  131217. * @param scene Define the scene the refraction belongs to
  131218. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131219. */
  131220. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131221. /**
  131222. * Clone the refraction texture.
  131223. * @returns the cloned texture
  131224. */
  131225. clone(): RefractionTexture;
  131226. /**
  131227. * Serialize the texture to a JSON representation you could use in Parse later on
  131228. * @returns the serialized JSON representation
  131229. */
  131230. serialize(): any;
  131231. }
  131232. }
  131233. declare module BABYLON {
  131234. /**
  131235. * Defines the options related to the creation of an HtmlElementTexture
  131236. */
  131237. export interface IHtmlElementTextureOptions {
  131238. /**
  131239. * Defines wether mip maps should be created or not.
  131240. */
  131241. generateMipMaps?: boolean;
  131242. /**
  131243. * Defines the sampling mode of the texture.
  131244. */
  131245. samplingMode?: number;
  131246. /**
  131247. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131248. */
  131249. engine: Nullable<ThinEngine>;
  131250. /**
  131251. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131252. */
  131253. scene: Nullable<Scene>;
  131254. }
  131255. /**
  131256. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131257. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131258. * is automatically managed.
  131259. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131260. * in your application.
  131261. *
  131262. * As the update is not automatic, you need to call them manually.
  131263. */
  131264. export class HtmlElementTexture extends BaseTexture {
  131265. /**
  131266. * The texture URL.
  131267. */
  131268. element: HTMLVideoElement | HTMLCanvasElement;
  131269. private static readonly DefaultOptions;
  131270. private _textureMatrix;
  131271. private _engine;
  131272. private _isVideo;
  131273. private _generateMipMaps;
  131274. private _samplingMode;
  131275. /**
  131276. * Instantiates a HtmlElementTexture from the following parameters.
  131277. *
  131278. * @param name Defines the name of the texture
  131279. * @param element Defines the video or canvas the texture is filled with
  131280. * @param options Defines the other none mandatory texture creation options
  131281. */
  131282. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131283. private _createInternalTexture;
  131284. /**
  131285. * Returns the texture matrix used in most of the material.
  131286. */
  131287. getTextureMatrix(): Matrix;
  131288. /**
  131289. * Updates the content of the texture.
  131290. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131291. */
  131292. update(invertY?: Nullable<boolean>): void;
  131293. }
  131294. }
  131295. declare module BABYLON {
  131296. /**
  131297. * Defines the basic options interface of a TexturePacker Frame
  131298. */
  131299. export interface ITexturePackerFrame {
  131300. /**
  131301. * The frame ID
  131302. */
  131303. id: number;
  131304. /**
  131305. * The frames Scale
  131306. */
  131307. scale: Vector2;
  131308. /**
  131309. * The Frames offset
  131310. */
  131311. offset: Vector2;
  131312. }
  131313. /**
  131314. * This is a support class for frame Data on texture packer sets.
  131315. */
  131316. export class TexturePackerFrame implements ITexturePackerFrame {
  131317. /**
  131318. * The frame ID
  131319. */
  131320. id: number;
  131321. /**
  131322. * The frames Scale
  131323. */
  131324. scale: Vector2;
  131325. /**
  131326. * The Frames offset
  131327. */
  131328. offset: Vector2;
  131329. /**
  131330. * Initializes a texture package frame.
  131331. * @param id The numerical frame identifier
  131332. * @param scale Scalar Vector2 for UV frame
  131333. * @param offset Vector2 for the frame position in UV units.
  131334. * @returns TexturePackerFrame
  131335. */
  131336. constructor(id: number, scale: Vector2, offset: Vector2);
  131337. }
  131338. }
  131339. declare module BABYLON {
  131340. /**
  131341. * Defines the basic options interface of a TexturePacker
  131342. */
  131343. export interface ITexturePackerOptions {
  131344. /**
  131345. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131346. */
  131347. map?: string[];
  131348. /**
  131349. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131350. */
  131351. uvsIn?: string;
  131352. /**
  131353. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131354. */
  131355. uvsOut?: string;
  131356. /**
  131357. * number representing the layout style. Defaults to LAYOUT_STRIP
  131358. */
  131359. layout?: number;
  131360. /**
  131361. * number of columns if using custom column count layout(2). This defaults to 4.
  131362. */
  131363. colnum?: number;
  131364. /**
  131365. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131366. */
  131367. updateInputMeshes?: boolean;
  131368. /**
  131369. * boolean flag to dispose all the source textures. Defaults to true.
  131370. */
  131371. disposeSources?: boolean;
  131372. /**
  131373. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131374. */
  131375. fillBlanks?: boolean;
  131376. /**
  131377. * string value representing the context fill style color. Defaults to 'black'.
  131378. */
  131379. customFillColor?: string;
  131380. /**
  131381. * Width and Height Value of each Frame in the TexturePacker Sets
  131382. */
  131383. frameSize?: number;
  131384. /**
  131385. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131386. */
  131387. paddingRatio?: number;
  131388. /**
  131389. * Number that declares the fill method for the padding gutter.
  131390. */
  131391. paddingMode?: number;
  131392. /**
  131393. * If in SUBUV_COLOR padding mode what color to use.
  131394. */
  131395. paddingColor?: Color3 | Color4;
  131396. }
  131397. /**
  131398. * Defines the basic interface of a TexturePacker JSON File
  131399. */
  131400. export interface ITexturePackerJSON {
  131401. /**
  131402. * The frame ID
  131403. */
  131404. name: string;
  131405. /**
  131406. * The base64 channel data
  131407. */
  131408. sets: any;
  131409. /**
  131410. * The options of the Packer
  131411. */
  131412. options: ITexturePackerOptions;
  131413. /**
  131414. * The frame data of the Packer
  131415. */
  131416. frames: Array<number>;
  131417. }
  131418. /**
  131419. * This is a support class that generates a series of packed texture sets.
  131420. * @see https://doc.babylonjs.com/babylon101/materials
  131421. */
  131422. export class TexturePacker {
  131423. /** Packer Layout Constant 0 */
  131424. static readonly LAYOUT_STRIP: number;
  131425. /** Packer Layout Constant 1 */
  131426. static readonly LAYOUT_POWER2: number;
  131427. /** Packer Layout Constant 2 */
  131428. static readonly LAYOUT_COLNUM: number;
  131429. /** Packer Layout Constant 0 */
  131430. static readonly SUBUV_WRAP: number;
  131431. /** Packer Layout Constant 1 */
  131432. static readonly SUBUV_EXTEND: number;
  131433. /** Packer Layout Constant 2 */
  131434. static readonly SUBUV_COLOR: number;
  131435. /** The Name of the Texture Package */
  131436. name: string;
  131437. /** The scene scope of the TexturePacker */
  131438. scene: Scene;
  131439. /** The Meshes to target */
  131440. meshes: AbstractMesh[];
  131441. /** Arguments passed with the Constructor */
  131442. options: ITexturePackerOptions;
  131443. /** The promise that is started upon initialization */
  131444. promise: Nullable<Promise<TexturePacker | string>>;
  131445. /** The Container object for the channel sets that are generated */
  131446. sets: object;
  131447. /** The Container array for the frames that are generated */
  131448. frames: TexturePackerFrame[];
  131449. /** The expected number of textures the system is parsing. */
  131450. private _expecting;
  131451. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131452. private _paddingValue;
  131453. /**
  131454. * Initializes a texture package series from an array of meshes or a single mesh.
  131455. * @param name The name of the package
  131456. * @param meshes The target meshes to compose the package from
  131457. * @param options The arguments that texture packer should follow while building.
  131458. * @param scene The scene which the textures are scoped to.
  131459. * @returns TexturePacker
  131460. */
  131461. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131462. /**
  131463. * Starts the package process
  131464. * @param resolve The promises resolution function
  131465. * @returns TexturePacker
  131466. */
  131467. private _createFrames;
  131468. /**
  131469. * Calculates the Size of the Channel Sets
  131470. * @returns Vector2
  131471. */
  131472. private _calculateSize;
  131473. /**
  131474. * Calculates the UV data for the frames.
  131475. * @param baseSize the base frameSize
  131476. * @param padding the base frame padding
  131477. * @param dtSize size of the Dynamic Texture for that channel
  131478. * @param dtUnits is 1/dtSize
  131479. * @param update flag to update the input meshes
  131480. */
  131481. private _calculateMeshUVFrames;
  131482. /**
  131483. * Calculates the frames Offset.
  131484. * @param index of the frame
  131485. * @returns Vector2
  131486. */
  131487. private _getFrameOffset;
  131488. /**
  131489. * Updates a Mesh to the frame data
  131490. * @param mesh that is the target
  131491. * @param frameID or the frame index
  131492. */
  131493. private _updateMeshUV;
  131494. /**
  131495. * Updates a Meshes materials to use the texture packer channels
  131496. * @param m is the mesh to target
  131497. * @param force all channels on the packer to be set.
  131498. */
  131499. private _updateTextureReferences;
  131500. /**
  131501. * Public method to set a Mesh to a frame
  131502. * @param m that is the target
  131503. * @param frameID or the frame index
  131504. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131505. */
  131506. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131507. /**
  131508. * Starts the async promise to compile the texture packer.
  131509. * @returns Promise<void>
  131510. */
  131511. processAsync(): Promise<void>;
  131512. /**
  131513. * Disposes all textures associated with this packer
  131514. */
  131515. dispose(): void;
  131516. /**
  131517. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131518. * @param imageType is the image type to use.
  131519. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131520. */
  131521. download(imageType?: string, quality?: number): void;
  131522. /**
  131523. * Public method to load a texturePacker JSON file.
  131524. * @param data of the JSON file in string format.
  131525. */
  131526. updateFromJSON(data: string): void;
  131527. }
  131528. }
  131529. declare module BABYLON {
  131530. /**
  131531. * Enum used to define the target of a block
  131532. */
  131533. export enum NodeMaterialBlockTargets {
  131534. /** Vertex shader */
  131535. Vertex = 1,
  131536. /** Fragment shader */
  131537. Fragment = 2,
  131538. /** Neutral */
  131539. Neutral = 4,
  131540. /** Vertex and Fragment */
  131541. VertexAndFragment = 3
  131542. }
  131543. }
  131544. declare module BABYLON {
  131545. /**
  131546. * Defines the kind of connection point for node based material
  131547. */
  131548. export enum NodeMaterialBlockConnectionPointTypes {
  131549. /** Float */
  131550. Float = 1,
  131551. /** Int */
  131552. Int = 2,
  131553. /** Vector2 */
  131554. Vector2 = 4,
  131555. /** Vector3 */
  131556. Vector3 = 8,
  131557. /** Vector4 */
  131558. Vector4 = 16,
  131559. /** Color3 */
  131560. Color3 = 32,
  131561. /** Color4 */
  131562. Color4 = 64,
  131563. /** Matrix */
  131564. Matrix = 128,
  131565. /** Detect type based on connection */
  131566. AutoDetect = 1024,
  131567. /** Output type that will be defined by input type */
  131568. BasedOnInput = 2048
  131569. }
  131570. }
  131571. declare module BABYLON {
  131572. /**
  131573. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131574. */
  131575. export enum NodeMaterialBlockConnectionPointMode {
  131576. /** Value is an uniform */
  131577. Uniform = 0,
  131578. /** Value is a mesh attribute */
  131579. Attribute = 1,
  131580. /** Value is a varying between vertex and fragment shaders */
  131581. Varying = 2,
  131582. /** Mode is undefined */
  131583. Undefined = 3
  131584. }
  131585. }
  131586. declare module BABYLON {
  131587. /**
  131588. * Enum used to define system values e.g. values automatically provided by the system
  131589. */
  131590. export enum NodeMaterialSystemValues {
  131591. /** World */
  131592. World = 1,
  131593. /** View */
  131594. View = 2,
  131595. /** Projection */
  131596. Projection = 3,
  131597. /** ViewProjection */
  131598. ViewProjection = 4,
  131599. /** WorldView */
  131600. WorldView = 5,
  131601. /** WorldViewProjection */
  131602. WorldViewProjection = 6,
  131603. /** CameraPosition */
  131604. CameraPosition = 7,
  131605. /** Fog Color */
  131606. FogColor = 8,
  131607. /** Delta time */
  131608. DeltaTime = 9
  131609. }
  131610. }
  131611. declare module BABYLON {
  131612. /**
  131613. * Root class for all node material optimizers
  131614. */
  131615. export class NodeMaterialOptimizer {
  131616. /**
  131617. * Function used to optimize a NodeMaterial graph
  131618. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131619. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131620. */
  131621. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131622. }
  131623. }
  131624. declare module BABYLON {
  131625. /**
  131626. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131627. */
  131628. export class TransformBlock extends NodeMaterialBlock {
  131629. /**
  131630. * Defines the value to use to complement W value to transform it to a Vector4
  131631. */
  131632. complementW: number;
  131633. /**
  131634. * Defines the value to use to complement z value to transform it to a Vector4
  131635. */
  131636. complementZ: number;
  131637. /**
  131638. * Creates a new TransformBlock
  131639. * @param name defines the block name
  131640. */
  131641. constructor(name: string);
  131642. /**
  131643. * Gets the current class name
  131644. * @returns the class name
  131645. */
  131646. getClassName(): string;
  131647. /**
  131648. * Gets the vector input
  131649. */
  131650. get vector(): NodeMaterialConnectionPoint;
  131651. /**
  131652. * Gets the output component
  131653. */
  131654. get output(): NodeMaterialConnectionPoint;
  131655. /**
  131656. * Gets the xyz output component
  131657. */
  131658. get xyz(): NodeMaterialConnectionPoint;
  131659. /**
  131660. * Gets the matrix transform input
  131661. */
  131662. get transform(): NodeMaterialConnectionPoint;
  131663. protected _buildBlock(state: NodeMaterialBuildState): this;
  131664. serialize(): any;
  131665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131666. protected _dumpPropertiesCode(): string;
  131667. }
  131668. }
  131669. declare module BABYLON {
  131670. /**
  131671. * Block used to output the vertex position
  131672. */
  131673. export class VertexOutputBlock extends NodeMaterialBlock {
  131674. /**
  131675. * Creates a new VertexOutputBlock
  131676. * @param name defines the block name
  131677. */
  131678. constructor(name: string);
  131679. /**
  131680. * Gets the current class name
  131681. * @returns the class name
  131682. */
  131683. getClassName(): string;
  131684. /**
  131685. * Gets the vector input component
  131686. */
  131687. get vector(): NodeMaterialConnectionPoint;
  131688. protected _buildBlock(state: NodeMaterialBuildState): this;
  131689. }
  131690. }
  131691. declare module BABYLON {
  131692. /**
  131693. * Block used to output the final color
  131694. */
  131695. export class FragmentOutputBlock extends NodeMaterialBlock {
  131696. /**
  131697. * Create a new FragmentOutputBlock
  131698. * @param name defines the block name
  131699. */
  131700. constructor(name: string);
  131701. /**
  131702. * Gets the current class name
  131703. * @returns the class name
  131704. */
  131705. getClassName(): string;
  131706. /**
  131707. * Gets the rgba input component
  131708. */
  131709. get rgba(): NodeMaterialConnectionPoint;
  131710. /**
  131711. * Gets the rgb input component
  131712. */
  131713. get rgb(): NodeMaterialConnectionPoint;
  131714. /**
  131715. * Gets the a input component
  131716. */
  131717. get a(): NodeMaterialConnectionPoint;
  131718. protected _buildBlock(state: NodeMaterialBuildState): this;
  131719. }
  131720. }
  131721. declare module BABYLON {
  131722. /**
  131723. * Block used to read a reflection texture from a sampler
  131724. */
  131725. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131726. private _define3DName;
  131727. private _defineCubicName;
  131728. private _defineExplicitName;
  131729. private _defineProjectionName;
  131730. private _defineLocalCubicName;
  131731. private _defineSphericalName;
  131732. private _definePlanarName;
  131733. private _defineEquirectangularName;
  131734. private _defineMirroredEquirectangularFixedName;
  131735. private _defineEquirectangularFixedName;
  131736. private _defineSkyboxName;
  131737. private _cubeSamplerName;
  131738. private _2DSamplerName;
  131739. private _positionUVWName;
  131740. private _directionWName;
  131741. private _reflectionCoordsName;
  131742. private _reflection2DCoordsName;
  131743. private _reflectionColorName;
  131744. private _reflectionMatrixName;
  131745. /**
  131746. * Gets or sets the texture associated with the node
  131747. */
  131748. texture: Nullable<BaseTexture>;
  131749. /**
  131750. * Create a new TextureBlock
  131751. * @param name defines the block name
  131752. */
  131753. constructor(name: string);
  131754. /**
  131755. * Gets the current class name
  131756. * @returns the class name
  131757. */
  131758. getClassName(): string;
  131759. /**
  131760. * Gets the world position input component
  131761. */
  131762. get position(): NodeMaterialConnectionPoint;
  131763. /**
  131764. * Gets the world position input component
  131765. */
  131766. get worldPosition(): NodeMaterialConnectionPoint;
  131767. /**
  131768. * Gets the world normal input component
  131769. */
  131770. get worldNormal(): NodeMaterialConnectionPoint;
  131771. /**
  131772. * Gets the world input component
  131773. */
  131774. get world(): NodeMaterialConnectionPoint;
  131775. /**
  131776. * Gets the camera (or eye) position component
  131777. */
  131778. get cameraPosition(): NodeMaterialConnectionPoint;
  131779. /**
  131780. * Gets the view input component
  131781. */
  131782. get view(): NodeMaterialConnectionPoint;
  131783. /**
  131784. * Gets the rgb output component
  131785. */
  131786. get rgb(): NodeMaterialConnectionPoint;
  131787. /**
  131788. * Gets the r output component
  131789. */
  131790. get r(): NodeMaterialConnectionPoint;
  131791. /**
  131792. * Gets the g output component
  131793. */
  131794. get g(): NodeMaterialConnectionPoint;
  131795. /**
  131796. * Gets the b output component
  131797. */
  131798. get b(): NodeMaterialConnectionPoint;
  131799. autoConfigure(material: NodeMaterial): void;
  131800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131801. isReady(): boolean;
  131802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131803. private _injectVertexCode;
  131804. private _writeOutput;
  131805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131806. protected _dumpPropertiesCode(): string;
  131807. serialize(): any;
  131808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131809. }
  131810. }
  131811. declare module BABYLON {
  131812. /**
  131813. * Interface used to configure the node material editor
  131814. */
  131815. export interface INodeMaterialEditorOptions {
  131816. /** Define the URl to load node editor script */
  131817. editorURL?: string;
  131818. }
  131819. /** @hidden */
  131820. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131821. NORMAL: boolean;
  131822. TANGENT: boolean;
  131823. UV1: boolean;
  131824. /** BONES */
  131825. NUM_BONE_INFLUENCERS: number;
  131826. BonesPerMesh: number;
  131827. BONETEXTURE: boolean;
  131828. /** MORPH TARGETS */
  131829. MORPHTARGETS: boolean;
  131830. MORPHTARGETS_NORMAL: boolean;
  131831. MORPHTARGETS_TANGENT: boolean;
  131832. MORPHTARGETS_UV: boolean;
  131833. NUM_MORPH_INFLUENCERS: number;
  131834. /** IMAGE PROCESSING */
  131835. IMAGEPROCESSING: boolean;
  131836. VIGNETTE: boolean;
  131837. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131838. VIGNETTEBLENDMODEOPAQUE: boolean;
  131839. TONEMAPPING: boolean;
  131840. TONEMAPPING_ACES: boolean;
  131841. CONTRAST: boolean;
  131842. EXPOSURE: boolean;
  131843. COLORCURVES: boolean;
  131844. COLORGRADING: boolean;
  131845. COLORGRADING3D: boolean;
  131846. SAMPLER3DGREENDEPTH: boolean;
  131847. SAMPLER3DBGRMAP: boolean;
  131848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131849. /** MISC. */
  131850. BUMPDIRECTUV: number;
  131851. constructor();
  131852. setValue(name: string, value: boolean): void;
  131853. }
  131854. /**
  131855. * Class used to configure NodeMaterial
  131856. */
  131857. export interface INodeMaterialOptions {
  131858. /**
  131859. * Defines if blocks should emit comments
  131860. */
  131861. emitComments: boolean;
  131862. }
  131863. /**
  131864. * Class used to create a node based material built by assembling shader blocks
  131865. */
  131866. export class NodeMaterial extends PushMaterial {
  131867. private static _BuildIdGenerator;
  131868. private _options;
  131869. private _vertexCompilationState;
  131870. private _fragmentCompilationState;
  131871. private _sharedData;
  131872. private _buildId;
  131873. private _buildWasSuccessful;
  131874. private _cachedWorldViewMatrix;
  131875. private _cachedWorldViewProjectionMatrix;
  131876. private _optimizers;
  131877. private _animationFrame;
  131878. /** Define the Url to load node editor script */
  131879. static EditorURL: string;
  131880. /** Define the Url to load snippets */
  131881. static SnippetUrl: string;
  131882. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  131883. static IgnoreTexturesAtLoadTime: boolean;
  131884. private BJSNODEMATERIALEDITOR;
  131885. /** Get the inspector from bundle or global */
  131886. private _getGlobalNodeMaterialEditor;
  131887. /**
  131888. * Snippet ID if the material was created from the snippet server
  131889. */
  131890. snippetId: string;
  131891. /**
  131892. * Gets or sets data used by visual editor
  131893. * @see https://nme.babylonjs.com
  131894. */
  131895. editorData: any;
  131896. /**
  131897. * 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)
  131898. */
  131899. ignoreAlpha: boolean;
  131900. /**
  131901. * Defines the maximum number of lights that can be used in the material
  131902. */
  131903. maxSimultaneousLights: number;
  131904. /**
  131905. * Observable raised when the material is built
  131906. */
  131907. onBuildObservable: Observable<NodeMaterial>;
  131908. /**
  131909. * Gets or sets the root nodes of the material vertex shader
  131910. */
  131911. _vertexOutputNodes: NodeMaterialBlock[];
  131912. /**
  131913. * Gets or sets the root nodes of the material fragment (pixel) shader
  131914. */
  131915. _fragmentOutputNodes: NodeMaterialBlock[];
  131916. /** Gets or sets options to control the node material overall behavior */
  131917. get options(): INodeMaterialOptions;
  131918. set options(options: INodeMaterialOptions);
  131919. /**
  131920. * Default configuration related to image processing available in the standard Material.
  131921. */
  131922. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131923. /**
  131924. * Gets the image processing configuration used either in this material.
  131925. */
  131926. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131927. /**
  131928. * Sets the Default image processing configuration used either in the this material.
  131929. *
  131930. * If sets to null, the scene one is in use.
  131931. */
  131932. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131933. /**
  131934. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131935. */
  131936. attachedBlocks: NodeMaterialBlock[];
  131937. /**
  131938. * Create a new node based material
  131939. * @param name defines the material name
  131940. * @param scene defines the hosting scene
  131941. * @param options defines creation option
  131942. */
  131943. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131944. /**
  131945. * Gets the current class name of the material e.g. "NodeMaterial"
  131946. * @returns the class name
  131947. */
  131948. getClassName(): string;
  131949. /**
  131950. * Keep track of the image processing observer to allow dispose and replace.
  131951. */
  131952. private _imageProcessingObserver;
  131953. /**
  131954. * Attaches a new image processing configuration to the Standard Material.
  131955. * @param configuration
  131956. */
  131957. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131958. /**
  131959. * Get a block by its name
  131960. * @param name defines the name of the block to retrieve
  131961. * @returns the required block or null if not found
  131962. */
  131963. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131964. /**
  131965. * Get a block by its name
  131966. * @param predicate defines the predicate used to find the good candidate
  131967. * @returns the required block or null if not found
  131968. */
  131969. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131970. /**
  131971. * Get an input block by its name
  131972. * @param predicate defines the predicate used to find the good candidate
  131973. * @returns the required input block or null if not found
  131974. */
  131975. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131976. /**
  131977. * Gets the list of input blocks attached to this material
  131978. * @returns an array of InputBlocks
  131979. */
  131980. getInputBlocks(): InputBlock[];
  131981. /**
  131982. * Adds a new optimizer to the list of optimizers
  131983. * @param optimizer defines the optimizers to add
  131984. * @returns the current material
  131985. */
  131986. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131987. /**
  131988. * Remove an optimizer from the list of optimizers
  131989. * @param optimizer defines the optimizers to remove
  131990. * @returns the current material
  131991. */
  131992. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131993. /**
  131994. * Add a new block to the list of output nodes
  131995. * @param node defines the node to add
  131996. * @returns the current material
  131997. */
  131998. addOutputNode(node: NodeMaterialBlock): this;
  131999. /**
  132000. * Remove a block from the list of root nodes
  132001. * @param node defines the node to remove
  132002. * @returns the current material
  132003. */
  132004. removeOutputNode(node: NodeMaterialBlock): this;
  132005. private _addVertexOutputNode;
  132006. private _removeVertexOutputNode;
  132007. private _addFragmentOutputNode;
  132008. private _removeFragmentOutputNode;
  132009. /**
  132010. * Specifies if the material will require alpha blending
  132011. * @returns a boolean specifying if alpha blending is needed
  132012. */
  132013. needAlphaBlending(): boolean;
  132014. /**
  132015. * Specifies if this material should be rendered in alpha test mode
  132016. * @returns a boolean specifying if an alpha test is needed.
  132017. */
  132018. needAlphaTesting(): boolean;
  132019. private _initializeBlock;
  132020. private _resetDualBlocks;
  132021. /**
  132022. * Remove a block from the current node material
  132023. * @param block defines the block to remove
  132024. */
  132025. removeBlock(block: NodeMaterialBlock): void;
  132026. /**
  132027. * Build the material and generates the inner effect
  132028. * @param verbose defines if the build should log activity
  132029. */
  132030. build(verbose?: boolean): void;
  132031. /**
  132032. * Runs an otpimization phase to try to improve the shader code
  132033. */
  132034. optimize(): void;
  132035. private _prepareDefinesForAttributes;
  132036. /**
  132037. * Get if the submesh is ready to be used and all its information available.
  132038. * Child classes can use it to update shaders
  132039. * @param mesh defines the mesh to check
  132040. * @param subMesh defines which submesh to check
  132041. * @param useInstances specifies that instances should be used
  132042. * @returns a boolean indicating that the submesh is ready or not
  132043. */
  132044. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132045. /**
  132046. * Get a string representing the shaders built by the current node graph
  132047. */
  132048. get compiledShaders(): string;
  132049. /**
  132050. * Binds the world matrix to the material
  132051. * @param world defines the world transformation matrix
  132052. */
  132053. bindOnlyWorldMatrix(world: Matrix): void;
  132054. /**
  132055. * Binds the submesh to this material by preparing the effect and shader to draw
  132056. * @param world defines the world transformation matrix
  132057. * @param mesh defines the mesh containing the submesh
  132058. * @param subMesh defines the submesh to bind the material to
  132059. */
  132060. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132061. /**
  132062. * Gets the active textures from the material
  132063. * @returns an array of textures
  132064. */
  132065. getActiveTextures(): BaseTexture[];
  132066. /**
  132067. * Gets the list of texture blocks
  132068. * @returns an array of texture blocks
  132069. */
  132070. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132071. /**
  132072. * Specifies if the material uses a texture
  132073. * @param texture defines the texture to check against the material
  132074. * @returns a boolean specifying if the material uses the texture
  132075. */
  132076. hasTexture(texture: BaseTexture): boolean;
  132077. /**
  132078. * Disposes the material
  132079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132080. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132081. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132082. */
  132083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132084. /** Creates the node editor window. */
  132085. private _createNodeEditor;
  132086. /**
  132087. * Launch the node material editor
  132088. * @param config Define the configuration of the editor
  132089. * @return a promise fulfilled when the node editor is visible
  132090. */
  132091. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132092. /**
  132093. * Clear the current material
  132094. */
  132095. clear(): void;
  132096. /**
  132097. * Clear the current material and set it to a default state
  132098. */
  132099. setToDefault(): void;
  132100. /**
  132101. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132102. * @param url defines the url to load from
  132103. * @returns a promise that will fullfil when the material is fully loaded
  132104. */
  132105. loadAsync(url: string): Promise<void>;
  132106. private _gatherBlocks;
  132107. /**
  132108. * Generate a string containing the code declaration required to create an equivalent of this material
  132109. * @returns a string
  132110. */
  132111. generateCode(): string;
  132112. /**
  132113. * Serializes this material in a JSON representation
  132114. * @returns the serialized material object
  132115. */
  132116. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132117. private _restoreConnections;
  132118. /**
  132119. * Clear the current graph and load a new one from a serialization object
  132120. * @param source defines the JSON representation of the material
  132121. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132122. */
  132123. loadFromSerialization(source: any, rootUrl?: string): void;
  132124. /**
  132125. * Makes a duplicate of the current material.
  132126. * @param name - name to use for the new material.
  132127. */
  132128. clone(name: string): NodeMaterial;
  132129. /**
  132130. * Creates a node material from parsed material data
  132131. * @param source defines the JSON representation of the material
  132132. * @param scene defines the hosting scene
  132133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132134. * @returns a new node material
  132135. */
  132136. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132137. /**
  132138. * Creates a node material from a snippet saved in a remote file
  132139. * @param name defines the name of the material to create
  132140. * @param url defines the url to load from
  132141. * @param scene defines the hosting scene
  132142. * @returns a promise that will resolve to the new node material
  132143. */
  132144. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132145. /**
  132146. * Creates a node material from a snippet saved by the node material editor
  132147. * @param snippetId defines the snippet to load
  132148. * @param scene defines the hosting scene
  132149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132150. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132151. * @returns a promise that will resolve to the new node material
  132152. */
  132153. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132154. /**
  132155. * Creates a new node material set to default basic configuration
  132156. * @param name defines the name of the material
  132157. * @param scene defines the hosting scene
  132158. * @returns a new NodeMaterial
  132159. */
  132160. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132161. }
  132162. }
  132163. declare module BABYLON {
  132164. /**
  132165. * Block used to read a texture from a sampler
  132166. */
  132167. export class TextureBlock extends NodeMaterialBlock {
  132168. private _defineName;
  132169. private _linearDefineName;
  132170. private _tempTextureRead;
  132171. private _samplerName;
  132172. private _transformedUVName;
  132173. private _textureTransformName;
  132174. private _textureInfoName;
  132175. private _mainUVName;
  132176. private _mainUVDefineName;
  132177. /**
  132178. * Gets or sets the texture associated with the node
  132179. */
  132180. texture: Nullable<Texture>;
  132181. /**
  132182. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132183. */
  132184. convertToGammaSpace: boolean;
  132185. /**
  132186. * Create a new TextureBlock
  132187. * @param name defines the block name
  132188. */
  132189. constructor(name: string);
  132190. /**
  132191. * Gets the current class name
  132192. * @returns the class name
  132193. */
  132194. getClassName(): string;
  132195. /**
  132196. * Gets the uv input component
  132197. */
  132198. get uv(): NodeMaterialConnectionPoint;
  132199. /**
  132200. * Gets the rgba output component
  132201. */
  132202. get rgba(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the rgb output component
  132205. */
  132206. get rgb(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the r output component
  132209. */
  132210. get r(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the g output component
  132213. */
  132214. get g(): NodeMaterialConnectionPoint;
  132215. /**
  132216. * Gets the b output component
  132217. */
  132218. get b(): NodeMaterialConnectionPoint;
  132219. /**
  132220. * Gets the a output component
  132221. */
  132222. get a(): NodeMaterialConnectionPoint;
  132223. get target(): NodeMaterialBlockTargets;
  132224. autoConfigure(material: NodeMaterial): void;
  132225. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132227. isReady(): boolean;
  132228. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132229. private get _isMixed();
  132230. private _injectVertexCode;
  132231. private _writeTextureRead;
  132232. private _writeOutput;
  132233. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132234. protected _dumpPropertiesCode(): string;
  132235. serialize(): any;
  132236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132237. }
  132238. }
  132239. declare module BABYLON {
  132240. /**
  132241. * Class used to store shared data between 2 NodeMaterialBuildState
  132242. */
  132243. export class NodeMaterialBuildStateSharedData {
  132244. /**
  132245. * Gets the list of emitted varyings
  132246. */
  132247. temps: string[];
  132248. /**
  132249. * Gets the list of emitted varyings
  132250. */
  132251. varyings: string[];
  132252. /**
  132253. * Gets the varying declaration string
  132254. */
  132255. varyingDeclaration: string;
  132256. /**
  132257. * Input blocks
  132258. */
  132259. inputBlocks: InputBlock[];
  132260. /**
  132261. * Input blocks
  132262. */
  132263. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132264. /**
  132265. * Bindable blocks (Blocks that need to set data to the effect)
  132266. */
  132267. bindableBlocks: NodeMaterialBlock[];
  132268. /**
  132269. * List of blocks that can provide a compilation fallback
  132270. */
  132271. blocksWithFallbacks: NodeMaterialBlock[];
  132272. /**
  132273. * List of blocks that can provide a define update
  132274. */
  132275. blocksWithDefines: NodeMaterialBlock[];
  132276. /**
  132277. * List of blocks that can provide a repeatable content
  132278. */
  132279. repeatableContentBlocks: NodeMaterialBlock[];
  132280. /**
  132281. * List of blocks that can provide a dynamic list of uniforms
  132282. */
  132283. dynamicUniformBlocks: NodeMaterialBlock[];
  132284. /**
  132285. * List of blocks that can block the isReady function for the material
  132286. */
  132287. blockingBlocks: NodeMaterialBlock[];
  132288. /**
  132289. * Gets the list of animated inputs
  132290. */
  132291. animatedInputs: InputBlock[];
  132292. /**
  132293. * Build Id used to avoid multiple recompilations
  132294. */
  132295. buildId: number;
  132296. /** List of emitted variables */
  132297. variableNames: {
  132298. [key: string]: number;
  132299. };
  132300. /** List of emitted defines */
  132301. defineNames: {
  132302. [key: string]: number;
  132303. };
  132304. /** Should emit comments? */
  132305. emitComments: boolean;
  132306. /** Emit build activity */
  132307. verbose: boolean;
  132308. /** Gets or sets the hosting scene */
  132309. scene: Scene;
  132310. /**
  132311. * Gets the compilation hints emitted at compilation time
  132312. */
  132313. hints: {
  132314. needWorldViewMatrix: boolean;
  132315. needWorldViewProjectionMatrix: boolean;
  132316. needAlphaBlending: boolean;
  132317. needAlphaTesting: boolean;
  132318. };
  132319. /**
  132320. * List of compilation checks
  132321. */
  132322. checks: {
  132323. emitVertex: boolean;
  132324. emitFragment: boolean;
  132325. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132326. };
  132327. /** Creates a new shared data */
  132328. constructor();
  132329. /**
  132330. * Emits console errors and exceptions if there is a failing check
  132331. */
  132332. emitErrors(): void;
  132333. }
  132334. }
  132335. declare module BABYLON {
  132336. /**
  132337. * Class used to store node based material build state
  132338. */
  132339. export class NodeMaterialBuildState {
  132340. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132341. supportUniformBuffers: boolean;
  132342. /**
  132343. * Gets the list of emitted attributes
  132344. */
  132345. attributes: string[];
  132346. /**
  132347. * Gets the list of emitted uniforms
  132348. */
  132349. uniforms: string[];
  132350. /**
  132351. * Gets the list of emitted constants
  132352. */
  132353. constants: string[];
  132354. /**
  132355. * Gets the list of emitted samplers
  132356. */
  132357. samplers: string[];
  132358. /**
  132359. * Gets the list of emitted functions
  132360. */
  132361. functions: {
  132362. [key: string]: string;
  132363. };
  132364. /**
  132365. * Gets the list of emitted extensions
  132366. */
  132367. extensions: {
  132368. [key: string]: string;
  132369. };
  132370. /**
  132371. * Gets the target of the compilation state
  132372. */
  132373. target: NodeMaterialBlockTargets;
  132374. /**
  132375. * Gets the list of emitted counters
  132376. */
  132377. counters: {
  132378. [key: string]: number;
  132379. };
  132380. /**
  132381. * Shared data between multiple NodeMaterialBuildState instances
  132382. */
  132383. sharedData: NodeMaterialBuildStateSharedData;
  132384. /** @hidden */
  132385. _vertexState: NodeMaterialBuildState;
  132386. /** @hidden */
  132387. _attributeDeclaration: string;
  132388. /** @hidden */
  132389. _uniformDeclaration: string;
  132390. /** @hidden */
  132391. _constantDeclaration: string;
  132392. /** @hidden */
  132393. _samplerDeclaration: string;
  132394. /** @hidden */
  132395. _varyingTransfer: string;
  132396. private _repeatableContentAnchorIndex;
  132397. /** @hidden */
  132398. _builtCompilationString: string;
  132399. /**
  132400. * Gets the emitted compilation strings
  132401. */
  132402. compilationString: string;
  132403. /**
  132404. * Finalize the compilation strings
  132405. * @param state defines the current compilation state
  132406. */
  132407. finalize(state: NodeMaterialBuildState): void;
  132408. /** @hidden */
  132409. get _repeatableContentAnchor(): string;
  132410. /** @hidden */
  132411. _getFreeVariableName(prefix: string): string;
  132412. /** @hidden */
  132413. _getFreeDefineName(prefix: string): string;
  132414. /** @hidden */
  132415. _excludeVariableName(name: string): void;
  132416. /** @hidden */
  132417. _emit2DSampler(name: string): void;
  132418. /** @hidden */
  132419. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132420. /** @hidden */
  132421. _emitExtension(name: string, extension: string): void;
  132422. /** @hidden */
  132423. _emitFunction(name: string, code: string, comments: string): void;
  132424. /** @hidden */
  132425. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132426. replaceStrings?: {
  132427. search: RegExp;
  132428. replace: string;
  132429. }[];
  132430. repeatKey?: string;
  132431. }): string;
  132432. /** @hidden */
  132433. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132434. repeatKey?: string;
  132435. removeAttributes?: boolean;
  132436. removeUniforms?: boolean;
  132437. removeVaryings?: boolean;
  132438. removeIfDef?: boolean;
  132439. replaceStrings?: {
  132440. search: RegExp;
  132441. replace: string;
  132442. }[];
  132443. }, storeKey?: string): void;
  132444. /** @hidden */
  132445. _registerTempVariable(name: string): boolean;
  132446. /** @hidden */
  132447. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132448. /** @hidden */
  132449. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132450. /** @hidden */
  132451. _emitFloat(value: number): string;
  132452. }
  132453. }
  132454. declare module BABYLON {
  132455. /**
  132456. * Defines a block that can be used inside a node based material
  132457. */
  132458. export class NodeMaterialBlock {
  132459. private _buildId;
  132460. private _buildTarget;
  132461. private _target;
  132462. private _isFinalMerger;
  132463. private _isInput;
  132464. protected _isUnique: boolean;
  132465. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132466. inputsAreExclusive: boolean;
  132467. /** @hidden */
  132468. _codeVariableName: string;
  132469. /** @hidden */
  132470. _inputs: NodeMaterialConnectionPoint[];
  132471. /** @hidden */
  132472. _outputs: NodeMaterialConnectionPoint[];
  132473. /** @hidden */
  132474. _preparationId: number;
  132475. /**
  132476. * Gets or sets the name of the block
  132477. */
  132478. name: string;
  132479. /**
  132480. * Gets or sets the unique id of the node
  132481. */
  132482. uniqueId: number;
  132483. /**
  132484. * Gets or sets the comments associated with this block
  132485. */
  132486. comments: string;
  132487. /**
  132488. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132489. */
  132490. get isUnique(): boolean;
  132491. /**
  132492. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132493. */
  132494. get isFinalMerger(): boolean;
  132495. /**
  132496. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132497. */
  132498. get isInput(): boolean;
  132499. /**
  132500. * Gets or sets the build Id
  132501. */
  132502. get buildId(): number;
  132503. set buildId(value: number);
  132504. /**
  132505. * Gets or sets the target of the block
  132506. */
  132507. get target(): NodeMaterialBlockTargets;
  132508. set target(value: NodeMaterialBlockTargets);
  132509. /**
  132510. * Gets the list of input points
  132511. */
  132512. get inputs(): NodeMaterialConnectionPoint[];
  132513. /** Gets the list of output points */
  132514. get outputs(): NodeMaterialConnectionPoint[];
  132515. /**
  132516. * Find an input by its name
  132517. * @param name defines the name of the input to look for
  132518. * @returns the input or null if not found
  132519. */
  132520. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132521. /**
  132522. * Find an output by its name
  132523. * @param name defines the name of the outputto look for
  132524. * @returns the output or null if not found
  132525. */
  132526. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132527. /**
  132528. * Creates a new NodeMaterialBlock
  132529. * @param name defines the block name
  132530. * @param target defines the target of that block (Vertex by default)
  132531. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132532. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132533. */
  132534. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132535. /**
  132536. * Initialize the block and prepare the context for build
  132537. * @param state defines the state that will be used for the build
  132538. */
  132539. initialize(state: NodeMaterialBuildState): void;
  132540. /**
  132541. * Bind data to effect. Will only be called for blocks with isBindable === true
  132542. * @param effect defines the effect to bind data to
  132543. * @param nodeMaterial defines the hosting NodeMaterial
  132544. * @param mesh defines the mesh that will be rendered
  132545. */
  132546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132547. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132548. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132549. protected _writeFloat(value: number): string;
  132550. /**
  132551. * Gets the current class name e.g. "NodeMaterialBlock"
  132552. * @returns the class name
  132553. */
  132554. getClassName(): string;
  132555. /**
  132556. * Register a new input. Must be called inside a block constructor
  132557. * @param name defines the connection point name
  132558. * @param type defines the connection point type
  132559. * @param isOptional defines a boolean indicating that this input can be omitted
  132560. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132561. * @returns the current block
  132562. */
  132563. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132564. /**
  132565. * Register a new output. Must be called inside a block constructor
  132566. * @param name defines the connection point name
  132567. * @param type defines the connection point type
  132568. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132569. * @returns the current block
  132570. */
  132571. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132572. /**
  132573. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132574. * @param forOutput defines an optional connection point to check compatibility with
  132575. * @returns the first available input or null
  132576. */
  132577. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132578. /**
  132579. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132580. * @param forBlock defines an optional block to check compatibility with
  132581. * @returns the first available input or null
  132582. */
  132583. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132584. /**
  132585. * Gets the sibling of the given output
  132586. * @param current defines the current output
  132587. * @returns the next output in the list or null
  132588. */
  132589. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132590. /**
  132591. * Connect current block with another block
  132592. * @param other defines the block to connect with
  132593. * @param options define the various options to help pick the right connections
  132594. * @returns the current block
  132595. */
  132596. connectTo(other: NodeMaterialBlock, options?: {
  132597. input?: string;
  132598. output?: string;
  132599. outputSwizzle?: string;
  132600. }): this | undefined;
  132601. protected _buildBlock(state: NodeMaterialBuildState): void;
  132602. /**
  132603. * Add uniforms, samplers and uniform buffers at compilation time
  132604. * @param state defines the state to update
  132605. * @param nodeMaterial defines the node material requesting the update
  132606. * @param defines defines the material defines to update
  132607. * @param uniformBuffers defines the list of uniform buffer names
  132608. */
  132609. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132610. /**
  132611. * Add potential fallbacks if shader compilation fails
  132612. * @param mesh defines the mesh to be rendered
  132613. * @param fallbacks defines the current prioritized list of fallbacks
  132614. */
  132615. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132616. /**
  132617. * Initialize defines for shader compilation
  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. */
  132623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132624. /**
  132625. * Update defines for shader compilation
  132626. * @param mesh defines the mesh to be rendered
  132627. * @param nodeMaterial defines the node material requesting the update
  132628. * @param defines defines the material defines to update
  132629. * @param useInstances specifies that instances should be used
  132630. */
  132631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132632. /**
  132633. * Lets the block try to connect some inputs automatically
  132634. * @param material defines the hosting NodeMaterial
  132635. */
  132636. autoConfigure(material: NodeMaterial): void;
  132637. /**
  132638. * Function called when a block is declared as repeatable content generator
  132639. * @param vertexShaderState defines the current compilation state for the vertex shader
  132640. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132641. * @param mesh defines the mesh to be rendered
  132642. * @param defines defines the material defines to update
  132643. */
  132644. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132645. /**
  132646. * Checks if the block is ready
  132647. * @param mesh defines the mesh to be rendered
  132648. * @param nodeMaterial defines the node material requesting the update
  132649. * @param defines defines the material defines to update
  132650. * @param useInstances specifies that instances should be used
  132651. * @returns true if the block is ready
  132652. */
  132653. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132654. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132655. private _processBuild;
  132656. /**
  132657. * Compile the current node and generate the shader code
  132658. * @param state defines the current compilation state (uniforms, samplers, current string)
  132659. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132660. * @returns true if already built
  132661. */
  132662. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132663. protected _inputRename(name: string): string;
  132664. protected _outputRename(name: string): string;
  132665. protected _dumpPropertiesCode(): string;
  132666. /** @hidden */
  132667. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132668. /** @hidden */
  132669. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132670. /**
  132671. * Clone the current block to a new identical block
  132672. * @param scene defines the hosting scene
  132673. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132674. * @returns a copy of the current block
  132675. */
  132676. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132677. /**
  132678. * Serializes this block in a JSON representation
  132679. * @returns the serialized block object
  132680. */
  132681. serialize(): any;
  132682. /** @hidden */
  132683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132684. /**
  132685. * Release resources
  132686. */
  132687. dispose(): void;
  132688. }
  132689. }
  132690. declare module BABYLON {
  132691. /**
  132692. * Enum defining the type of animations supported by InputBlock
  132693. */
  132694. export enum AnimatedInputBlockTypes {
  132695. /** No animation */
  132696. None = 0,
  132697. /** Time based animation. Will only work for floats */
  132698. Time = 1
  132699. }
  132700. }
  132701. declare module BABYLON {
  132702. /**
  132703. * Block used to expose an input value
  132704. */
  132705. export class InputBlock extends NodeMaterialBlock {
  132706. private _mode;
  132707. private _associatedVariableName;
  132708. private _storedValue;
  132709. private _valueCallback;
  132710. private _type;
  132711. private _animationType;
  132712. /** Gets or set a value used to limit the range of float values */
  132713. min: number;
  132714. /** Gets or set a value used to limit the range of float values */
  132715. max: number;
  132716. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132717. isBoolean: boolean;
  132718. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132719. matrixMode: number;
  132720. /** @hidden */
  132721. _systemValue: Nullable<NodeMaterialSystemValues>;
  132722. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132723. visibleInInspector: boolean;
  132724. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132725. isConstant: boolean;
  132726. /** Gets or sets the group to use to display this block in the Inspector */
  132727. groupInInspector: string;
  132728. /** Gets an observable raised when the value is changed */
  132729. onValueChangedObservable: Observable<InputBlock>;
  132730. /**
  132731. * Gets or sets the connection point type (default is float)
  132732. */
  132733. get type(): NodeMaterialBlockConnectionPointTypes;
  132734. /**
  132735. * Creates a new InputBlock
  132736. * @param name defines the block name
  132737. * @param target defines the target of that block (Vertex by default)
  132738. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132739. */
  132740. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132741. /**
  132742. * Gets the output component
  132743. */
  132744. get output(): NodeMaterialConnectionPoint;
  132745. /**
  132746. * Set the source of this connection point to a vertex attribute
  132747. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132748. * @returns the current connection point
  132749. */
  132750. setAsAttribute(attributeName?: string): InputBlock;
  132751. /**
  132752. * Set the source of this connection point to a system value
  132753. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132754. * @returns the current connection point
  132755. */
  132756. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132757. /**
  132758. * Gets or sets the value of that point.
  132759. * Please note that this value will be ignored if valueCallback is defined
  132760. */
  132761. get value(): any;
  132762. set value(value: any);
  132763. /**
  132764. * Gets or sets a callback used to get the value of that point.
  132765. * Please note that setting this value will force the connection point to ignore the value property
  132766. */
  132767. get valueCallback(): () => any;
  132768. set valueCallback(value: () => any);
  132769. /**
  132770. * Gets or sets the associated variable name in the shader
  132771. */
  132772. get associatedVariableName(): string;
  132773. set associatedVariableName(value: string);
  132774. /** Gets or sets the type of animation applied to the input */
  132775. get animationType(): AnimatedInputBlockTypes;
  132776. set animationType(value: AnimatedInputBlockTypes);
  132777. /**
  132778. * Gets a boolean indicating that this connection point not defined yet
  132779. */
  132780. get isUndefined(): boolean;
  132781. /**
  132782. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132783. * In this case the connection point name must be the name of the uniform to use.
  132784. * Can only be set on inputs
  132785. */
  132786. get isUniform(): boolean;
  132787. set isUniform(value: boolean);
  132788. /**
  132789. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132790. * In this case the connection point name must be the name of the attribute to use
  132791. * Can only be set on inputs
  132792. */
  132793. get isAttribute(): boolean;
  132794. set isAttribute(value: boolean);
  132795. /**
  132796. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132797. * Can only be set on exit points
  132798. */
  132799. get isVarying(): boolean;
  132800. set isVarying(value: boolean);
  132801. /**
  132802. * Gets a boolean indicating that the current connection point is a system value
  132803. */
  132804. get isSystemValue(): boolean;
  132805. /**
  132806. * Gets or sets the current well known value or null if not defined as a system value
  132807. */
  132808. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132809. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132810. /**
  132811. * Gets the current class name
  132812. * @returns the class name
  132813. */
  132814. getClassName(): string;
  132815. /**
  132816. * Animate the input if animationType !== None
  132817. * @param scene defines the rendering scene
  132818. */
  132819. animate(scene: Scene): void;
  132820. private _emitDefine;
  132821. initialize(state: NodeMaterialBuildState): void;
  132822. /**
  132823. * Set the input block to its default value (based on its type)
  132824. */
  132825. setDefaultValue(): void;
  132826. private _emitConstant;
  132827. private _emit;
  132828. /** @hidden */
  132829. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132830. /** @hidden */
  132831. _transmit(effect: Effect, scene: Scene): void;
  132832. protected _buildBlock(state: NodeMaterialBuildState): void;
  132833. protected _dumpPropertiesCode(): string;
  132834. dispose(): void;
  132835. serialize(): any;
  132836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132837. }
  132838. }
  132839. declare module BABYLON {
  132840. /**
  132841. * Enum used to define the compatibility state between two connection points
  132842. */
  132843. export enum NodeMaterialConnectionPointCompatibilityStates {
  132844. /** Points are compatibles */
  132845. Compatible = 0,
  132846. /** Points are incompatible because of their types */
  132847. TypeIncompatible = 1,
  132848. /** Points are incompatible because of their targets (vertex vs fragment) */
  132849. TargetIncompatible = 2
  132850. }
  132851. /**
  132852. * Defines the direction of a connection point
  132853. */
  132854. export enum NodeMaterialConnectionPointDirection {
  132855. /** Input */
  132856. Input = 0,
  132857. /** Output */
  132858. Output = 1
  132859. }
  132860. /**
  132861. * Defines a connection point for a block
  132862. */
  132863. export class NodeMaterialConnectionPoint {
  132864. /** @hidden */
  132865. _ownerBlock: NodeMaterialBlock;
  132866. /** @hidden */
  132867. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132868. private _endpoints;
  132869. private _associatedVariableName;
  132870. private _direction;
  132871. /** @hidden */
  132872. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132873. /** @hidden */
  132874. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132875. private _type;
  132876. /** @hidden */
  132877. _enforceAssociatedVariableName: boolean;
  132878. /** Gets the direction of the point */
  132879. get direction(): NodeMaterialConnectionPointDirection;
  132880. /**
  132881. * Gets or sets the additional types supported by this connection point
  132882. */
  132883. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132884. /**
  132885. * Gets or sets the additional types excluded by this connection point
  132886. */
  132887. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132888. /**
  132889. * Observable triggered when this point is connected
  132890. */
  132891. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132892. /**
  132893. * Gets or sets the associated variable name in the shader
  132894. */
  132895. get associatedVariableName(): string;
  132896. set associatedVariableName(value: string);
  132897. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132898. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132899. /**
  132900. * Gets or sets the connection point type (default is float)
  132901. */
  132902. get type(): NodeMaterialBlockConnectionPointTypes;
  132903. set type(value: NodeMaterialBlockConnectionPointTypes);
  132904. /**
  132905. * Gets or sets the connection point name
  132906. */
  132907. name: string;
  132908. /**
  132909. * Gets or sets a boolean indicating that this connection point can be omitted
  132910. */
  132911. isOptional: boolean;
  132912. /**
  132913. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132914. */
  132915. define: string;
  132916. /** @hidden */
  132917. _prioritizeVertex: boolean;
  132918. private _target;
  132919. /** Gets or sets the target of that connection point */
  132920. get target(): NodeMaterialBlockTargets;
  132921. set target(value: NodeMaterialBlockTargets);
  132922. /**
  132923. * Gets a boolean indicating that the current point is connected
  132924. */
  132925. get isConnected(): boolean;
  132926. /**
  132927. * Gets a boolean indicating that the current point is connected to an input block
  132928. */
  132929. get isConnectedToInputBlock(): boolean;
  132930. /**
  132931. * Gets a the connected input block (if any)
  132932. */
  132933. get connectInputBlock(): Nullable<InputBlock>;
  132934. /** Get the other side of the connection (if any) */
  132935. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132936. /** Get the block that owns this connection point */
  132937. get ownerBlock(): NodeMaterialBlock;
  132938. /** Get the block connected on the other side of this connection (if any) */
  132939. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132940. /** Get the block connected on the endpoints of this connection (if any) */
  132941. get connectedBlocks(): Array<NodeMaterialBlock>;
  132942. /** Gets the list of connected endpoints */
  132943. get endpoints(): NodeMaterialConnectionPoint[];
  132944. /** Gets a boolean indicating if that output point is connected to at least one input */
  132945. get hasEndpoints(): boolean;
  132946. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132947. get isConnectedInVertexShader(): boolean;
  132948. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132949. get isConnectedInFragmentShader(): boolean;
  132950. /**
  132951. * Creates a new connection point
  132952. * @param name defines the connection point name
  132953. * @param ownerBlock defines the block hosting this connection point
  132954. * @param direction defines the direction of the connection point
  132955. */
  132956. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132957. /**
  132958. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132959. * @returns the class name
  132960. */
  132961. getClassName(): string;
  132962. /**
  132963. * Gets a boolean indicating if the current point can be connected to another point
  132964. * @param connectionPoint defines the other connection point
  132965. * @returns a boolean
  132966. */
  132967. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132968. /**
  132969. * Gets a number indicating if the current point can be connected to another point
  132970. * @param connectionPoint defines the other connection point
  132971. * @returns a number defining the compatibility state
  132972. */
  132973. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132974. /**
  132975. * Connect this point to another connection point
  132976. * @param connectionPoint defines the other connection point
  132977. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132978. * @returns the current connection point
  132979. */
  132980. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132981. /**
  132982. * Disconnect this point from one of his endpoint
  132983. * @param endpoint defines the other connection point
  132984. * @returns the current connection point
  132985. */
  132986. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132987. /**
  132988. * Serializes this point in a JSON representation
  132989. * @returns the serialized point object
  132990. */
  132991. serialize(): any;
  132992. /**
  132993. * Release resources
  132994. */
  132995. dispose(): void;
  132996. }
  132997. }
  132998. declare module BABYLON {
  132999. /**
  133000. * Block used to add support for vertex skinning (bones)
  133001. */
  133002. export class BonesBlock extends NodeMaterialBlock {
  133003. /**
  133004. * Creates a new BonesBlock
  133005. * @param name defines the block name
  133006. */
  133007. constructor(name: string);
  133008. /**
  133009. * Initialize the block and prepare the context for build
  133010. * @param state defines the state that will be used for the build
  133011. */
  133012. initialize(state: NodeMaterialBuildState): void;
  133013. /**
  133014. * Gets the current class name
  133015. * @returns the class name
  133016. */
  133017. getClassName(): string;
  133018. /**
  133019. * Gets the matrix indices input component
  133020. */
  133021. get matricesIndices(): NodeMaterialConnectionPoint;
  133022. /**
  133023. * Gets the matrix weights input component
  133024. */
  133025. get matricesWeights(): NodeMaterialConnectionPoint;
  133026. /**
  133027. * Gets the extra matrix indices input component
  133028. */
  133029. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133030. /**
  133031. * Gets the extra matrix weights input component
  133032. */
  133033. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the world input component
  133036. */
  133037. get world(): NodeMaterialConnectionPoint;
  133038. /**
  133039. * Gets the output component
  133040. */
  133041. get output(): NodeMaterialConnectionPoint;
  133042. autoConfigure(material: NodeMaterial): void;
  133043. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133046. protected _buildBlock(state: NodeMaterialBuildState): this;
  133047. }
  133048. }
  133049. declare module BABYLON {
  133050. /**
  133051. * Block used to add support for instances
  133052. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133053. */
  133054. export class InstancesBlock extends NodeMaterialBlock {
  133055. /**
  133056. * Creates a new InstancesBlock
  133057. * @param name defines the block name
  133058. */
  133059. constructor(name: string);
  133060. /**
  133061. * Gets the current class name
  133062. * @returns the class name
  133063. */
  133064. getClassName(): string;
  133065. /**
  133066. * Gets the first world row input component
  133067. */
  133068. get world0(): NodeMaterialConnectionPoint;
  133069. /**
  133070. * Gets the second world row input component
  133071. */
  133072. get world1(): NodeMaterialConnectionPoint;
  133073. /**
  133074. * Gets the third world row input component
  133075. */
  133076. get world2(): NodeMaterialConnectionPoint;
  133077. /**
  133078. * Gets the forth world row input component
  133079. */
  133080. get world3(): NodeMaterialConnectionPoint;
  133081. /**
  133082. * Gets the world input component
  133083. */
  133084. get world(): NodeMaterialConnectionPoint;
  133085. /**
  133086. * Gets the output component
  133087. */
  133088. get output(): NodeMaterialConnectionPoint;
  133089. /**
  133090. * Gets the isntanceID component
  133091. */
  133092. get instanceID(): NodeMaterialConnectionPoint;
  133093. autoConfigure(material: NodeMaterial): void;
  133094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133095. protected _buildBlock(state: NodeMaterialBuildState): this;
  133096. }
  133097. }
  133098. declare module BABYLON {
  133099. /**
  133100. * Block used to add morph targets support to vertex shader
  133101. */
  133102. export class MorphTargetsBlock extends NodeMaterialBlock {
  133103. private _repeatableContentAnchor;
  133104. /**
  133105. * Create a new MorphTargetsBlock
  133106. * @param name defines the block name
  133107. */
  133108. constructor(name: string);
  133109. /**
  133110. * Gets the current class name
  133111. * @returns the class name
  133112. */
  133113. getClassName(): string;
  133114. /**
  133115. * Gets the position input component
  133116. */
  133117. get position(): NodeMaterialConnectionPoint;
  133118. /**
  133119. * Gets the normal input component
  133120. */
  133121. get normal(): NodeMaterialConnectionPoint;
  133122. /**
  133123. * Gets the tangent input component
  133124. */
  133125. get tangent(): NodeMaterialConnectionPoint;
  133126. /**
  133127. * Gets the tangent input component
  133128. */
  133129. get uv(): NodeMaterialConnectionPoint;
  133130. /**
  133131. * Gets the position output component
  133132. */
  133133. get positionOutput(): NodeMaterialConnectionPoint;
  133134. /**
  133135. * Gets the normal output component
  133136. */
  133137. get normalOutput(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the tangent output component
  133140. */
  133141. get tangentOutput(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the tangent output component
  133144. */
  133145. get uvOutput(): NodeMaterialConnectionPoint;
  133146. initialize(state: NodeMaterialBuildState): void;
  133147. autoConfigure(material: NodeMaterial): void;
  133148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133149. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133150. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133151. protected _buildBlock(state: NodeMaterialBuildState): this;
  133152. }
  133153. }
  133154. declare module BABYLON {
  133155. /**
  133156. * Block used to get data information from a light
  133157. */
  133158. export class LightInformationBlock extends NodeMaterialBlock {
  133159. private _lightDataUniformName;
  133160. private _lightColorUniformName;
  133161. private _lightTypeDefineName;
  133162. /**
  133163. * Gets or sets the light associated with this block
  133164. */
  133165. light: Nullable<Light>;
  133166. /**
  133167. * Creates a new LightInformationBlock
  133168. * @param name defines the block name
  133169. */
  133170. constructor(name: string);
  133171. /**
  133172. * Gets the current class name
  133173. * @returns the class name
  133174. */
  133175. getClassName(): string;
  133176. /**
  133177. * Gets the world position input component
  133178. */
  133179. get worldPosition(): NodeMaterialConnectionPoint;
  133180. /**
  133181. * Gets the direction output component
  133182. */
  133183. get direction(): NodeMaterialConnectionPoint;
  133184. /**
  133185. * Gets the direction output component
  133186. */
  133187. get color(): NodeMaterialConnectionPoint;
  133188. /**
  133189. * Gets the direction output component
  133190. */
  133191. get intensity(): NodeMaterialConnectionPoint;
  133192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133194. protected _buildBlock(state: NodeMaterialBuildState): this;
  133195. serialize(): any;
  133196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133197. }
  133198. }
  133199. declare module BABYLON {
  133200. /**
  133201. * Block used to add image processing support to fragment shader
  133202. */
  133203. export class ImageProcessingBlock extends NodeMaterialBlock {
  133204. /**
  133205. * Create a new ImageProcessingBlock
  133206. * @param name defines the block name
  133207. */
  133208. constructor(name: string);
  133209. /**
  133210. * Gets the current class name
  133211. * @returns the class name
  133212. */
  133213. getClassName(): string;
  133214. /**
  133215. * Gets the color input component
  133216. */
  133217. get color(): NodeMaterialConnectionPoint;
  133218. /**
  133219. * Gets the output component
  133220. */
  133221. get output(): NodeMaterialConnectionPoint;
  133222. /**
  133223. * Initialize the block and prepare the context for build
  133224. * @param state defines the state that will be used for the build
  133225. */
  133226. initialize(state: NodeMaterialBuildState): void;
  133227. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133230. protected _buildBlock(state: NodeMaterialBuildState): this;
  133231. }
  133232. }
  133233. declare module BABYLON {
  133234. /**
  133235. * Block used to pertub normals based on a normal map
  133236. */
  133237. export class PerturbNormalBlock extends NodeMaterialBlock {
  133238. private _tangentSpaceParameterName;
  133239. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133240. invertX: boolean;
  133241. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133242. invertY: boolean;
  133243. /**
  133244. * Create a new PerturbNormalBlock
  133245. * @param name defines the block name
  133246. */
  133247. constructor(name: string);
  133248. /**
  133249. * Gets the current class name
  133250. * @returns the class name
  133251. */
  133252. getClassName(): string;
  133253. /**
  133254. * Gets the world position input component
  133255. */
  133256. get worldPosition(): NodeMaterialConnectionPoint;
  133257. /**
  133258. * Gets the world normal input component
  133259. */
  133260. get worldNormal(): NodeMaterialConnectionPoint;
  133261. /**
  133262. * Gets the world tangent input component
  133263. */
  133264. get worldTangent(): NodeMaterialConnectionPoint;
  133265. /**
  133266. * Gets the uv input component
  133267. */
  133268. get uv(): NodeMaterialConnectionPoint;
  133269. /**
  133270. * Gets the normal map color input component
  133271. */
  133272. get normalMapColor(): NodeMaterialConnectionPoint;
  133273. /**
  133274. * Gets the strength input component
  133275. */
  133276. get strength(): NodeMaterialConnectionPoint;
  133277. /**
  133278. * Gets the output component
  133279. */
  133280. get output(): NodeMaterialConnectionPoint;
  133281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133283. autoConfigure(material: NodeMaterial): void;
  133284. protected _buildBlock(state: NodeMaterialBuildState): this;
  133285. protected _dumpPropertiesCode(): string;
  133286. serialize(): any;
  133287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133288. }
  133289. }
  133290. declare module BABYLON {
  133291. /**
  133292. * Block used to discard a pixel if a value is smaller than a cutoff
  133293. */
  133294. export class DiscardBlock extends NodeMaterialBlock {
  133295. /**
  133296. * Create a new DiscardBlock
  133297. * @param name defines the block name
  133298. */
  133299. constructor(name: string);
  133300. /**
  133301. * Gets the current class name
  133302. * @returns the class name
  133303. */
  133304. getClassName(): string;
  133305. /**
  133306. * Gets the color input component
  133307. */
  133308. get value(): NodeMaterialConnectionPoint;
  133309. /**
  133310. * Gets the cutoff input component
  133311. */
  133312. get cutoff(): NodeMaterialConnectionPoint;
  133313. protected _buildBlock(state: NodeMaterialBuildState): this;
  133314. }
  133315. }
  133316. declare module BABYLON {
  133317. /**
  133318. * Block used to test if the fragment shader is front facing
  133319. */
  133320. export class FrontFacingBlock extends NodeMaterialBlock {
  133321. /**
  133322. * Creates a new FrontFacingBlock
  133323. * @param name defines the block name
  133324. */
  133325. constructor(name: string);
  133326. /**
  133327. * Gets the current class name
  133328. * @returns the class name
  133329. */
  133330. getClassName(): string;
  133331. /**
  133332. * Gets the output component
  133333. */
  133334. get output(): NodeMaterialConnectionPoint;
  133335. protected _buildBlock(state: NodeMaterialBuildState): this;
  133336. }
  133337. }
  133338. declare module BABYLON {
  133339. /**
  133340. * Block used to get the derivative value on x and y of a given input
  133341. */
  133342. export class DerivativeBlock extends NodeMaterialBlock {
  133343. /**
  133344. * Create a new DerivativeBlock
  133345. * @param name defines the block name
  133346. */
  133347. constructor(name: string);
  133348. /**
  133349. * Gets the current class name
  133350. * @returns the class name
  133351. */
  133352. getClassName(): string;
  133353. /**
  133354. * Gets the input component
  133355. */
  133356. get input(): NodeMaterialConnectionPoint;
  133357. /**
  133358. * Gets the derivative output on x
  133359. */
  133360. get dx(): NodeMaterialConnectionPoint;
  133361. /**
  133362. * Gets the derivative output on y
  133363. */
  133364. get dy(): NodeMaterialConnectionPoint;
  133365. protected _buildBlock(state: NodeMaterialBuildState): this;
  133366. }
  133367. }
  133368. declare module BABYLON {
  133369. /**
  133370. * Block used to add support for scene fog
  133371. */
  133372. export class FogBlock extends NodeMaterialBlock {
  133373. private _fogDistanceName;
  133374. private _fogParameters;
  133375. /**
  133376. * Create a new FogBlock
  133377. * @param name defines the block name
  133378. */
  133379. constructor(name: string);
  133380. /**
  133381. * Gets the current class name
  133382. * @returns the class name
  133383. */
  133384. getClassName(): string;
  133385. /**
  133386. * Gets the world position input component
  133387. */
  133388. get worldPosition(): NodeMaterialConnectionPoint;
  133389. /**
  133390. * Gets the view input component
  133391. */
  133392. get view(): NodeMaterialConnectionPoint;
  133393. /**
  133394. * Gets the color input component
  133395. */
  133396. get input(): NodeMaterialConnectionPoint;
  133397. /**
  133398. * Gets the fog color input component
  133399. */
  133400. get fogColor(): NodeMaterialConnectionPoint;
  133401. /**
  133402. * Gets the output component
  133403. */
  133404. get output(): NodeMaterialConnectionPoint;
  133405. autoConfigure(material: NodeMaterial): void;
  133406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133408. protected _buildBlock(state: NodeMaterialBuildState): this;
  133409. }
  133410. }
  133411. declare module BABYLON {
  133412. /**
  133413. * Block used to add light in the fragment shader
  133414. */
  133415. export class LightBlock extends NodeMaterialBlock {
  133416. private _lightId;
  133417. /**
  133418. * Gets or sets the light associated with this block
  133419. */
  133420. light: Nullable<Light>;
  133421. /**
  133422. * Create a new LightBlock
  133423. * @param name defines the block name
  133424. */
  133425. constructor(name: string);
  133426. /**
  133427. * Gets the current class name
  133428. * @returns the class name
  133429. */
  133430. getClassName(): string;
  133431. /**
  133432. * Gets the world position input component
  133433. */
  133434. get worldPosition(): NodeMaterialConnectionPoint;
  133435. /**
  133436. * Gets the world normal input component
  133437. */
  133438. get worldNormal(): NodeMaterialConnectionPoint;
  133439. /**
  133440. * Gets the camera (or eye) position component
  133441. */
  133442. get cameraPosition(): NodeMaterialConnectionPoint;
  133443. /**
  133444. * Gets the glossiness component
  133445. */
  133446. get glossiness(): NodeMaterialConnectionPoint;
  133447. /**
  133448. * Gets the glossinness power component
  133449. */
  133450. get glossPower(): NodeMaterialConnectionPoint;
  133451. /**
  133452. * Gets the diffuse color component
  133453. */
  133454. get diffuseColor(): NodeMaterialConnectionPoint;
  133455. /**
  133456. * Gets the specular color component
  133457. */
  133458. get specularColor(): NodeMaterialConnectionPoint;
  133459. /**
  133460. * Gets the diffuse output component
  133461. */
  133462. get diffuseOutput(): NodeMaterialConnectionPoint;
  133463. /**
  133464. * Gets the specular output component
  133465. */
  133466. get specularOutput(): NodeMaterialConnectionPoint;
  133467. /**
  133468. * Gets the shadow output component
  133469. */
  133470. get shadow(): NodeMaterialConnectionPoint;
  133471. autoConfigure(material: NodeMaterial): void;
  133472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133473. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133475. private _injectVertexCode;
  133476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133477. serialize(): any;
  133478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133479. }
  133480. }
  133481. declare module BABYLON {
  133482. /**
  133483. * Block used to multiply 2 values
  133484. */
  133485. export class MultiplyBlock extends NodeMaterialBlock {
  133486. /**
  133487. * Creates a new MultiplyBlock
  133488. * @param name defines the block name
  133489. */
  133490. constructor(name: string);
  133491. /**
  133492. * Gets the current class name
  133493. * @returns the class name
  133494. */
  133495. getClassName(): string;
  133496. /**
  133497. * Gets the left operand input component
  133498. */
  133499. get left(): NodeMaterialConnectionPoint;
  133500. /**
  133501. * Gets the right operand input component
  133502. */
  133503. get right(): NodeMaterialConnectionPoint;
  133504. /**
  133505. * Gets the output component
  133506. */
  133507. get output(): NodeMaterialConnectionPoint;
  133508. protected _buildBlock(state: NodeMaterialBuildState): this;
  133509. }
  133510. }
  133511. declare module BABYLON {
  133512. /**
  133513. * Block used to add 2 vectors
  133514. */
  133515. export class AddBlock extends NodeMaterialBlock {
  133516. /**
  133517. * Creates a new AddBlock
  133518. * @param name defines the block name
  133519. */
  133520. constructor(name: string);
  133521. /**
  133522. * Gets the current class name
  133523. * @returns the class name
  133524. */
  133525. getClassName(): string;
  133526. /**
  133527. * Gets the left operand input component
  133528. */
  133529. get left(): NodeMaterialConnectionPoint;
  133530. /**
  133531. * Gets the right operand input component
  133532. */
  133533. get right(): NodeMaterialConnectionPoint;
  133534. /**
  133535. * Gets the output component
  133536. */
  133537. get output(): NodeMaterialConnectionPoint;
  133538. protected _buildBlock(state: NodeMaterialBuildState): this;
  133539. }
  133540. }
  133541. declare module BABYLON {
  133542. /**
  133543. * Block used to scale a vector by a float
  133544. */
  133545. export class ScaleBlock extends NodeMaterialBlock {
  133546. /**
  133547. * Creates a new ScaleBlock
  133548. * @param name defines the block name
  133549. */
  133550. constructor(name: string);
  133551. /**
  133552. * Gets the current class name
  133553. * @returns the class name
  133554. */
  133555. getClassName(): string;
  133556. /**
  133557. * Gets the input component
  133558. */
  133559. get input(): NodeMaterialConnectionPoint;
  133560. /**
  133561. * Gets the factor input component
  133562. */
  133563. get factor(): NodeMaterialConnectionPoint;
  133564. /**
  133565. * Gets the output component
  133566. */
  133567. get output(): NodeMaterialConnectionPoint;
  133568. protected _buildBlock(state: NodeMaterialBuildState): this;
  133569. }
  133570. }
  133571. declare module BABYLON {
  133572. /**
  133573. * Block used to clamp a float
  133574. */
  133575. export class ClampBlock extends NodeMaterialBlock {
  133576. /** Gets or sets the minimum range */
  133577. minimum: number;
  133578. /** Gets or sets the maximum range */
  133579. maximum: number;
  133580. /**
  133581. * Creates a new ClampBlock
  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 value input component
  133592. */
  133593. get value(): NodeMaterialConnectionPoint;
  133594. /**
  133595. * Gets the output component
  133596. */
  133597. get output(): NodeMaterialConnectionPoint;
  133598. protected _buildBlock(state: NodeMaterialBuildState): this;
  133599. protected _dumpPropertiesCode(): string;
  133600. serialize(): any;
  133601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133602. }
  133603. }
  133604. declare module BABYLON {
  133605. /**
  133606. * Block used to apply a cross product between 2 vectors
  133607. */
  133608. export class CrossBlock extends NodeMaterialBlock {
  133609. /**
  133610. * Creates a new CrossBlock
  133611. * @param name defines the block name
  133612. */
  133613. constructor(name: string);
  133614. /**
  133615. * Gets the current class name
  133616. * @returns the class name
  133617. */
  133618. getClassName(): string;
  133619. /**
  133620. * Gets the left operand input component
  133621. */
  133622. get left(): NodeMaterialConnectionPoint;
  133623. /**
  133624. * Gets the right operand input component
  133625. */
  133626. get right(): NodeMaterialConnectionPoint;
  133627. /**
  133628. * Gets the output component
  133629. */
  133630. get output(): NodeMaterialConnectionPoint;
  133631. protected _buildBlock(state: NodeMaterialBuildState): this;
  133632. }
  133633. }
  133634. declare module BABYLON {
  133635. /**
  133636. * Block used to apply a dot product between 2 vectors
  133637. */
  133638. export class DotBlock extends NodeMaterialBlock {
  133639. /**
  133640. * Creates a new DotBlock
  133641. * @param name defines the block name
  133642. */
  133643. constructor(name: string);
  133644. /**
  133645. * Gets the current class name
  133646. * @returns the class name
  133647. */
  133648. getClassName(): string;
  133649. /**
  133650. * Gets the left operand input component
  133651. */
  133652. get left(): NodeMaterialConnectionPoint;
  133653. /**
  133654. * Gets the right operand input component
  133655. */
  133656. get right(): NodeMaterialConnectionPoint;
  133657. /**
  133658. * Gets the output component
  133659. */
  133660. get output(): NodeMaterialConnectionPoint;
  133661. protected _buildBlock(state: NodeMaterialBuildState): this;
  133662. }
  133663. }
  133664. declare module BABYLON {
  133665. /**
  133666. * Block used to remap a float from a range to a new one
  133667. */
  133668. export class RemapBlock extends NodeMaterialBlock {
  133669. /**
  133670. * Gets or sets the source range
  133671. */
  133672. sourceRange: Vector2;
  133673. /**
  133674. * Gets or sets the target range
  133675. */
  133676. targetRange: Vector2;
  133677. /**
  133678. * Creates a new RemapBlock
  133679. * @param name defines the block name
  133680. */
  133681. constructor(name: string);
  133682. /**
  133683. * Gets the current class name
  133684. * @returns the class name
  133685. */
  133686. getClassName(): string;
  133687. /**
  133688. * Gets the input component
  133689. */
  133690. get input(): NodeMaterialConnectionPoint;
  133691. /**
  133692. * Gets the source min input component
  133693. */
  133694. get sourceMin(): NodeMaterialConnectionPoint;
  133695. /**
  133696. * Gets the source max input component
  133697. */
  133698. get sourceMax(): NodeMaterialConnectionPoint;
  133699. /**
  133700. * Gets the target min input component
  133701. */
  133702. get targetMin(): NodeMaterialConnectionPoint;
  133703. /**
  133704. * Gets the target max input component
  133705. */
  133706. get targetMax(): NodeMaterialConnectionPoint;
  133707. /**
  133708. * Gets the output component
  133709. */
  133710. get output(): NodeMaterialConnectionPoint;
  133711. protected _buildBlock(state: NodeMaterialBuildState): this;
  133712. protected _dumpPropertiesCode(): string;
  133713. serialize(): any;
  133714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133715. }
  133716. }
  133717. declare module BABYLON {
  133718. /**
  133719. * Block used to normalize a vector
  133720. */
  133721. export class NormalizeBlock extends NodeMaterialBlock {
  133722. /**
  133723. * Creates a new NormalizeBlock
  133724. * @param name defines the block name
  133725. */
  133726. constructor(name: string);
  133727. /**
  133728. * Gets the current class name
  133729. * @returns the class name
  133730. */
  133731. getClassName(): string;
  133732. /**
  133733. * Gets the input component
  133734. */
  133735. get input(): NodeMaterialConnectionPoint;
  133736. /**
  133737. * Gets the output component
  133738. */
  133739. get output(): NodeMaterialConnectionPoint;
  133740. protected _buildBlock(state: NodeMaterialBuildState): this;
  133741. }
  133742. }
  133743. declare module BABYLON {
  133744. /**
  133745. * Operations supported by the Trigonometry block
  133746. */
  133747. export enum TrigonometryBlockOperations {
  133748. /** Cos */
  133749. Cos = 0,
  133750. /** Sin */
  133751. Sin = 1,
  133752. /** Abs */
  133753. Abs = 2,
  133754. /** Exp */
  133755. Exp = 3,
  133756. /** Exp2 */
  133757. Exp2 = 4,
  133758. /** Round */
  133759. Round = 5,
  133760. /** Floor */
  133761. Floor = 6,
  133762. /** Ceiling */
  133763. Ceiling = 7,
  133764. /** Square root */
  133765. Sqrt = 8,
  133766. /** Log */
  133767. Log = 9,
  133768. /** Tangent */
  133769. Tan = 10,
  133770. /** Arc tangent */
  133771. ArcTan = 11,
  133772. /** Arc cosinus */
  133773. ArcCos = 12,
  133774. /** Arc sinus */
  133775. ArcSin = 13,
  133776. /** Fraction */
  133777. Fract = 14,
  133778. /** Sign */
  133779. Sign = 15,
  133780. /** To radians (from degrees) */
  133781. Radians = 16,
  133782. /** To degrees (from radians) */
  133783. Degrees = 17
  133784. }
  133785. /**
  133786. * Block used to apply trigonometry operation to floats
  133787. */
  133788. export class TrigonometryBlock extends NodeMaterialBlock {
  133789. /**
  133790. * Gets or sets the operation applied by the block
  133791. */
  133792. operation: TrigonometryBlockOperations;
  133793. /**
  133794. * Creates a new TrigonometryBlock
  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 input component
  133805. */
  133806. get input(): NodeMaterialConnectionPoint;
  133807. /**
  133808. * Gets the output component
  133809. */
  133810. get output(): NodeMaterialConnectionPoint;
  133811. protected _buildBlock(state: NodeMaterialBuildState): this;
  133812. serialize(): any;
  133813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133814. protected _dumpPropertiesCode(): string;
  133815. }
  133816. }
  133817. declare module BABYLON {
  133818. /**
  133819. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133820. */
  133821. export class ColorMergerBlock extends NodeMaterialBlock {
  133822. /**
  133823. * Create a new ColorMergerBlock
  133824. * @param name defines the block name
  133825. */
  133826. constructor(name: string);
  133827. /**
  133828. * Gets the current class name
  133829. * @returns the class name
  133830. */
  133831. getClassName(): string;
  133832. /**
  133833. * Gets the rgb component (input)
  133834. */
  133835. get rgbIn(): NodeMaterialConnectionPoint;
  133836. /**
  133837. * Gets the r component (input)
  133838. */
  133839. get r(): NodeMaterialConnectionPoint;
  133840. /**
  133841. * Gets the g component (input)
  133842. */
  133843. get g(): NodeMaterialConnectionPoint;
  133844. /**
  133845. * Gets the b component (input)
  133846. */
  133847. get b(): NodeMaterialConnectionPoint;
  133848. /**
  133849. * Gets the a component (input)
  133850. */
  133851. get a(): NodeMaterialConnectionPoint;
  133852. /**
  133853. * Gets the rgba component (output)
  133854. */
  133855. get rgba(): NodeMaterialConnectionPoint;
  133856. /**
  133857. * Gets the rgb component (output)
  133858. */
  133859. get rgbOut(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the rgb component (output)
  133862. * @deprecated Please use rgbOut instead.
  133863. */
  133864. get rgb(): NodeMaterialConnectionPoint;
  133865. protected _buildBlock(state: NodeMaterialBuildState): this;
  133866. }
  133867. }
  133868. declare module BABYLON {
  133869. /**
  133870. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133871. */
  133872. export class VectorMergerBlock extends NodeMaterialBlock {
  133873. /**
  133874. * Create a new VectorMergerBlock
  133875. * @param name defines the block name
  133876. */
  133877. constructor(name: string);
  133878. /**
  133879. * Gets the current class name
  133880. * @returns the class name
  133881. */
  133882. getClassName(): string;
  133883. /**
  133884. * Gets the xyz component (input)
  133885. */
  133886. get xyzIn(): NodeMaterialConnectionPoint;
  133887. /**
  133888. * Gets the xy component (input)
  133889. */
  133890. get xyIn(): NodeMaterialConnectionPoint;
  133891. /**
  133892. * Gets the x component (input)
  133893. */
  133894. get x(): NodeMaterialConnectionPoint;
  133895. /**
  133896. * Gets the y component (input)
  133897. */
  133898. get y(): NodeMaterialConnectionPoint;
  133899. /**
  133900. * Gets the z component (input)
  133901. */
  133902. get z(): NodeMaterialConnectionPoint;
  133903. /**
  133904. * Gets the w component (input)
  133905. */
  133906. get w(): NodeMaterialConnectionPoint;
  133907. /**
  133908. * Gets the xyzw component (output)
  133909. */
  133910. get xyzw(): NodeMaterialConnectionPoint;
  133911. /**
  133912. * Gets the xyz component (output)
  133913. */
  133914. get xyzOut(): NodeMaterialConnectionPoint;
  133915. /**
  133916. * Gets the xy component (output)
  133917. */
  133918. get xyOut(): NodeMaterialConnectionPoint;
  133919. /**
  133920. * Gets the xy component (output)
  133921. * @deprecated Please use xyOut instead.
  133922. */
  133923. get xy(): NodeMaterialConnectionPoint;
  133924. /**
  133925. * Gets the xyz component (output)
  133926. * @deprecated Please use xyzOut instead.
  133927. */
  133928. get xyz(): NodeMaterialConnectionPoint;
  133929. protected _buildBlock(state: NodeMaterialBuildState): this;
  133930. }
  133931. }
  133932. declare module BABYLON {
  133933. /**
  133934. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133935. */
  133936. export class ColorSplitterBlock extends NodeMaterialBlock {
  133937. /**
  133938. * Create a new ColorSplitterBlock
  133939. * @param name defines the block name
  133940. */
  133941. constructor(name: string);
  133942. /**
  133943. * Gets the current class name
  133944. * @returns the class name
  133945. */
  133946. getClassName(): string;
  133947. /**
  133948. * Gets the rgba component (input)
  133949. */
  133950. get rgba(): NodeMaterialConnectionPoint;
  133951. /**
  133952. * Gets the rgb component (input)
  133953. */
  133954. get rgbIn(): NodeMaterialConnectionPoint;
  133955. /**
  133956. * Gets the rgb component (output)
  133957. */
  133958. get rgbOut(): NodeMaterialConnectionPoint;
  133959. /**
  133960. * Gets the r component (output)
  133961. */
  133962. get r(): NodeMaterialConnectionPoint;
  133963. /**
  133964. * Gets the g component (output)
  133965. */
  133966. get g(): NodeMaterialConnectionPoint;
  133967. /**
  133968. * Gets the b component (output)
  133969. */
  133970. get b(): NodeMaterialConnectionPoint;
  133971. /**
  133972. * Gets the a component (output)
  133973. */
  133974. get a(): NodeMaterialConnectionPoint;
  133975. protected _inputRename(name: string): string;
  133976. protected _outputRename(name: string): string;
  133977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133978. }
  133979. }
  133980. declare module BABYLON {
  133981. /**
  133982. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133983. */
  133984. export class VectorSplitterBlock extends NodeMaterialBlock {
  133985. /**
  133986. * Create a new VectorSplitterBlock
  133987. * @param name defines the block name
  133988. */
  133989. constructor(name: string);
  133990. /**
  133991. * Gets the current class name
  133992. * @returns the class name
  133993. */
  133994. getClassName(): string;
  133995. /**
  133996. * Gets the xyzw component (input)
  133997. */
  133998. get xyzw(): NodeMaterialConnectionPoint;
  133999. /**
  134000. * Gets the xyz component (input)
  134001. */
  134002. get xyzIn(): NodeMaterialConnectionPoint;
  134003. /**
  134004. * Gets the xy component (input)
  134005. */
  134006. get xyIn(): NodeMaterialConnectionPoint;
  134007. /**
  134008. * Gets the xyz component (output)
  134009. */
  134010. get xyzOut(): NodeMaterialConnectionPoint;
  134011. /**
  134012. * Gets the xy component (output)
  134013. */
  134014. get xyOut(): NodeMaterialConnectionPoint;
  134015. /**
  134016. * Gets the x component (output)
  134017. */
  134018. get x(): NodeMaterialConnectionPoint;
  134019. /**
  134020. * Gets the y component (output)
  134021. */
  134022. get y(): NodeMaterialConnectionPoint;
  134023. /**
  134024. * Gets the z component (output)
  134025. */
  134026. get z(): NodeMaterialConnectionPoint;
  134027. /**
  134028. * Gets the w component (output)
  134029. */
  134030. get w(): NodeMaterialConnectionPoint;
  134031. protected _inputRename(name: string): string;
  134032. protected _outputRename(name: string): string;
  134033. protected _buildBlock(state: NodeMaterialBuildState): this;
  134034. }
  134035. }
  134036. declare module BABYLON {
  134037. /**
  134038. * Block used to lerp between 2 values
  134039. */
  134040. export class LerpBlock extends NodeMaterialBlock {
  134041. /**
  134042. * Creates a new LerpBlock
  134043. * @param name defines the block name
  134044. */
  134045. constructor(name: string);
  134046. /**
  134047. * Gets the current class name
  134048. * @returns the class name
  134049. */
  134050. getClassName(): string;
  134051. /**
  134052. * Gets the left operand input component
  134053. */
  134054. get left(): NodeMaterialConnectionPoint;
  134055. /**
  134056. * Gets the right operand input component
  134057. */
  134058. get right(): NodeMaterialConnectionPoint;
  134059. /**
  134060. * Gets the gradient operand input component
  134061. */
  134062. get gradient(): NodeMaterialConnectionPoint;
  134063. /**
  134064. * Gets the output component
  134065. */
  134066. get output(): NodeMaterialConnectionPoint;
  134067. protected _buildBlock(state: NodeMaterialBuildState): this;
  134068. }
  134069. }
  134070. declare module BABYLON {
  134071. /**
  134072. * Block used to divide 2 vectors
  134073. */
  134074. export class DivideBlock extends NodeMaterialBlock {
  134075. /**
  134076. * Creates a new DivideBlock
  134077. * @param name defines the block name
  134078. */
  134079. constructor(name: string);
  134080. /**
  134081. * Gets the current class name
  134082. * @returns the class name
  134083. */
  134084. getClassName(): string;
  134085. /**
  134086. * Gets the left operand input component
  134087. */
  134088. get left(): NodeMaterialConnectionPoint;
  134089. /**
  134090. * Gets the right operand input component
  134091. */
  134092. get right(): NodeMaterialConnectionPoint;
  134093. /**
  134094. * Gets the output component
  134095. */
  134096. get output(): NodeMaterialConnectionPoint;
  134097. protected _buildBlock(state: NodeMaterialBuildState): this;
  134098. }
  134099. }
  134100. declare module BABYLON {
  134101. /**
  134102. * Block used to subtract 2 vectors
  134103. */
  134104. export class SubtractBlock extends NodeMaterialBlock {
  134105. /**
  134106. * Creates a new SubtractBlock
  134107. * @param name defines the block name
  134108. */
  134109. constructor(name: string);
  134110. /**
  134111. * Gets the current class name
  134112. * @returns the class name
  134113. */
  134114. getClassName(): string;
  134115. /**
  134116. * Gets the left operand input component
  134117. */
  134118. get left(): NodeMaterialConnectionPoint;
  134119. /**
  134120. * Gets the right operand input component
  134121. */
  134122. get right(): NodeMaterialConnectionPoint;
  134123. /**
  134124. * Gets the output component
  134125. */
  134126. get output(): NodeMaterialConnectionPoint;
  134127. protected _buildBlock(state: NodeMaterialBuildState): this;
  134128. }
  134129. }
  134130. declare module BABYLON {
  134131. /**
  134132. * Block used to step a value
  134133. */
  134134. export class StepBlock extends NodeMaterialBlock {
  134135. /**
  134136. * Creates a new StepBlock
  134137. * @param name defines the block name
  134138. */
  134139. constructor(name: string);
  134140. /**
  134141. * Gets the current class name
  134142. * @returns the class name
  134143. */
  134144. getClassName(): string;
  134145. /**
  134146. * Gets the value operand input component
  134147. */
  134148. get value(): NodeMaterialConnectionPoint;
  134149. /**
  134150. * Gets the edge operand input component
  134151. */
  134152. get edge(): NodeMaterialConnectionPoint;
  134153. /**
  134154. * Gets the output component
  134155. */
  134156. get output(): NodeMaterialConnectionPoint;
  134157. protected _buildBlock(state: NodeMaterialBuildState): this;
  134158. }
  134159. }
  134160. declare module BABYLON {
  134161. /**
  134162. * Block used to get the opposite (1 - x) of a value
  134163. */
  134164. export class OneMinusBlock extends NodeMaterialBlock {
  134165. /**
  134166. * Creates a new OneMinusBlock
  134167. * @param name defines the block name
  134168. */
  134169. constructor(name: string);
  134170. /**
  134171. * Gets the current class name
  134172. * @returns the class name
  134173. */
  134174. getClassName(): string;
  134175. /**
  134176. * Gets the input component
  134177. */
  134178. get input(): NodeMaterialConnectionPoint;
  134179. /**
  134180. * Gets the output component
  134181. */
  134182. get output(): NodeMaterialConnectionPoint;
  134183. protected _buildBlock(state: NodeMaterialBuildState): this;
  134184. }
  134185. }
  134186. declare module BABYLON {
  134187. /**
  134188. * Block used to get the view direction
  134189. */
  134190. export class ViewDirectionBlock extends NodeMaterialBlock {
  134191. /**
  134192. * Creates a new ViewDirectionBlock
  134193. * @param name defines the block name
  134194. */
  134195. constructor(name: string);
  134196. /**
  134197. * Gets the current class name
  134198. * @returns the class name
  134199. */
  134200. getClassName(): string;
  134201. /**
  134202. * Gets the world position component
  134203. */
  134204. get worldPosition(): NodeMaterialConnectionPoint;
  134205. /**
  134206. * Gets the camera position component
  134207. */
  134208. get cameraPosition(): NodeMaterialConnectionPoint;
  134209. /**
  134210. * Gets the output component
  134211. */
  134212. get output(): NodeMaterialConnectionPoint;
  134213. autoConfigure(material: NodeMaterial): void;
  134214. protected _buildBlock(state: NodeMaterialBuildState): this;
  134215. }
  134216. }
  134217. declare module BABYLON {
  134218. /**
  134219. * Block used to compute fresnel value
  134220. */
  134221. export class FresnelBlock extends NodeMaterialBlock {
  134222. /**
  134223. * Create a new FresnelBlock
  134224. * @param name defines the block name
  134225. */
  134226. constructor(name: string);
  134227. /**
  134228. * Gets the current class name
  134229. * @returns the class name
  134230. */
  134231. getClassName(): string;
  134232. /**
  134233. * Gets the world normal input component
  134234. */
  134235. get worldNormal(): NodeMaterialConnectionPoint;
  134236. /**
  134237. * Gets the view direction input component
  134238. */
  134239. get viewDirection(): NodeMaterialConnectionPoint;
  134240. /**
  134241. * Gets the bias input component
  134242. */
  134243. get bias(): NodeMaterialConnectionPoint;
  134244. /**
  134245. * Gets the camera (or eye) position component
  134246. */
  134247. get power(): NodeMaterialConnectionPoint;
  134248. /**
  134249. * Gets the fresnel output component
  134250. */
  134251. get fresnel(): NodeMaterialConnectionPoint;
  134252. autoConfigure(material: NodeMaterial): void;
  134253. protected _buildBlock(state: NodeMaterialBuildState): this;
  134254. }
  134255. }
  134256. declare module BABYLON {
  134257. /**
  134258. * Block used to get the max of 2 values
  134259. */
  134260. export class MaxBlock extends NodeMaterialBlock {
  134261. /**
  134262. * Creates a new MaxBlock
  134263. * @param name defines the block name
  134264. */
  134265. constructor(name: string);
  134266. /**
  134267. * Gets the current class name
  134268. * @returns the class name
  134269. */
  134270. getClassName(): string;
  134271. /**
  134272. * Gets the left operand input component
  134273. */
  134274. get left(): NodeMaterialConnectionPoint;
  134275. /**
  134276. * Gets the right operand input component
  134277. */
  134278. get right(): NodeMaterialConnectionPoint;
  134279. /**
  134280. * Gets the output component
  134281. */
  134282. get output(): NodeMaterialConnectionPoint;
  134283. protected _buildBlock(state: NodeMaterialBuildState): this;
  134284. }
  134285. }
  134286. declare module BABYLON {
  134287. /**
  134288. * Block used to get the min of 2 values
  134289. */
  134290. export class MinBlock extends NodeMaterialBlock {
  134291. /**
  134292. * Creates a new MinBlock
  134293. * @param name defines the block name
  134294. */
  134295. constructor(name: string);
  134296. /**
  134297. * Gets the current class name
  134298. * @returns the class name
  134299. */
  134300. getClassName(): string;
  134301. /**
  134302. * Gets the left operand input component
  134303. */
  134304. get left(): NodeMaterialConnectionPoint;
  134305. /**
  134306. * Gets the right operand input component
  134307. */
  134308. get right(): NodeMaterialConnectionPoint;
  134309. /**
  134310. * Gets the output component
  134311. */
  134312. get output(): NodeMaterialConnectionPoint;
  134313. protected _buildBlock(state: NodeMaterialBuildState): this;
  134314. }
  134315. }
  134316. declare module BABYLON {
  134317. /**
  134318. * Block used to get the distance between 2 values
  134319. */
  134320. export class DistanceBlock extends NodeMaterialBlock {
  134321. /**
  134322. * Creates a new DistanceBlock
  134323. * @param name defines the block name
  134324. */
  134325. constructor(name: string);
  134326. /**
  134327. * Gets the current class name
  134328. * @returns the class name
  134329. */
  134330. getClassName(): string;
  134331. /**
  134332. * Gets the left operand input component
  134333. */
  134334. get left(): NodeMaterialConnectionPoint;
  134335. /**
  134336. * Gets the right operand input component
  134337. */
  134338. get right(): NodeMaterialConnectionPoint;
  134339. /**
  134340. * Gets the output component
  134341. */
  134342. get output(): NodeMaterialConnectionPoint;
  134343. protected _buildBlock(state: NodeMaterialBuildState): this;
  134344. }
  134345. }
  134346. declare module BABYLON {
  134347. /**
  134348. * Block used to get the length of a vector
  134349. */
  134350. export class LengthBlock extends NodeMaterialBlock {
  134351. /**
  134352. * Creates a new LengthBlock
  134353. * @param name defines the block name
  134354. */
  134355. constructor(name: string);
  134356. /**
  134357. * Gets the current class name
  134358. * @returns the class name
  134359. */
  134360. getClassName(): string;
  134361. /**
  134362. * Gets the value input component
  134363. */
  134364. get value(): NodeMaterialConnectionPoint;
  134365. /**
  134366. * Gets the output component
  134367. */
  134368. get output(): NodeMaterialConnectionPoint;
  134369. protected _buildBlock(state: NodeMaterialBuildState): this;
  134370. }
  134371. }
  134372. declare module BABYLON {
  134373. /**
  134374. * Block used to get negative version of a value (i.e. x * -1)
  134375. */
  134376. export class NegateBlock extends NodeMaterialBlock {
  134377. /**
  134378. * Creates a new NegateBlock
  134379. * @param name defines the block name
  134380. */
  134381. constructor(name: string);
  134382. /**
  134383. * Gets the current class name
  134384. * @returns the class name
  134385. */
  134386. getClassName(): string;
  134387. /**
  134388. * Gets the value input component
  134389. */
  134390. get value(): NodeMaterialConnectionPoint;
  134391. /**
  134392. * Gets the output component
  134393. */
  134394. get output(): NodeMaterialConnectionPoint;
  134395. protected _buildBlock(state: NodeMaterialBuildState): this;
  134396. }
  134397. }
  134398. declare module BABYLON {
  134399. /**
  134400. * Block used to get the value of the first parameter raised to the power of the second
  134401. */
  134402. export class PowBlock extends NodeMaterialBlock {
  134403. /**
  134404. * Creates a new PowBlock
  134405. * @param name defines the block name
  134406. */
  134407. constructor(name: string);
  134408. /**
  134409. * Gets the current class name
  134410. * @returns the class name
  134411. */
  134412. getClassName(): string;
  134413. /**
  134414. * Gets the value operand input component
  134415. */
  134416. get value(): NodeMaterialConnectionPoint;
  134417. /**
  134418. * Gets the power operand input component
  134419. */
  134420. get power(): NodeMaterialConnectionPoint;
  134421. /**
  134422. * Gets the output component
  134423. */
  134424. get output(): NodeMaterialConnectionPoint;
  134425. protected _buildBlock(state: NodeMaterialBuildState): this;
  134426. }
  134427. }
  134428. declare module BABYLON {
  134429. /**
  134430. * Block used to get a random number
  134431. */
  134432. export class RandomNumberBlock extends NodeMaterialBlock {
  134433. /**
  134434. * Creates a new RandomNumberBlock
  134435. * @param name defines the block name
  134436. */
  134437. constructor(name: string);
  134438. /**
  134439. * Gets the current class name
  134440. * @returns the class name
  134441. */
  134442. getClassName(): string;
  134443. /**
  134444. * Gets the seed input component
  134445. */
  134446. get seed(): NodeMaterialConnectionPoint;
  134447. /**
  134448. * Gets the output component
  134449. */
  134450. get output(): NodeMaterialConnectionPoint;
  134451. protected _buildBlock(state: NodeMaterialBuildState): this;
  134452. }
  134453. }
  134454. declare module BABYLON {
  134455. /**
  134456. * Block used to compute arc tangent of 2 values
  134457. */
  134458. export class ArcTan2Block extends NodeMaterialBlock {
  134459. /**
  134460. * Creates a new ArcTan2Block
  134461. * @param name defines the block name
  134462. */
  134463. constructor(name: string);
  134464. /**
  134465. * Gets the current class name
  134466. * @returns the class name
  134467. */
  134468. getClassName(): string;
  134469. /**
  134470. * Gets the x operand input component
  134471. */
  134472. get x(): NodeMaterialConnectionPoint;
  134473. /**
  134474. * Gets the y operand input component
  134475. */
  134476. get y(): NodeMaterialConnectionPoint;
  134477. /**
  134478. * Gets the output component
  134479. */
  134480. get output(): NodeMaterialConnectionPoint;
  134481. protected _buildBlock(state: NodeMaterialBuildState): this;
  134482. }
  134483. }
  134484. declare module BABYLON {
  134485. /**
  134486. * Block used to smooth step a value
  134487. */
  134488. export class SmoothStepBlock extends NodeMaterialBlock {
  134489. /**
  134490. * Creates a new SmoothStepBlock
  134491. * @param name defines the block name
  134492. */
  134493. constructor(name: string);
  134494. /**
  134495. * Gets the current class name
  134496. * @returns the class name
  134497. */
  134498. getClassName(): string;
  134499. /**
  134500. * Gets the value operand input component
  134501. */
  134502. get value(): NodeMaterialConnectionPoint;
  134503. /**
  134504. * Gets the first edge operand input component
  134505. */
  134506. get edge0(): NodeMaterialConnectionPoint;
  134507. /**
  134508. * Gets the second edge operand input component
  134509. */
  134510. get edge1(): NodeMaterialConnectionPoint;
  134511. /**
  134512. * Gets the output component
  134513. */
  134514. get output(): NodeMaterialConnectionPoint;
  134515. protected _buildBlock(state: NodeMaterialBuildState): this;
  134516. }
  134517. }
  134518. declare module BABYLON {
  134519. /**
  134520. * Block used to get the reciprocal (1 / x) of a value
  134521. */
  134522. export class ReciprocalBlock extends NodeMaterialBlock {
  134523. /**
  134524. * Creates a new ReciprocalBlock
  134525. * @param name defines the block name
  134526. */
  134527. constructor(name: string);
  134528. /**
  134529. * Gets the current class name
  134530. * @returns the class name
  134531. */
  134532. getClassName(): string;
  134533. /**
  134534. * Gets the input component
  134535. */
  134536. get input(): NodeMaterialConnectionPoint;
  134537. /**
  134538. * Gets the output component
  134539. */
  134540. get output(): NodeMaterialConnectionPoint;
  134541. protected _buildBlock(state: NodeMaterialBuildState): this;
  134542. }
  134543. }
  134544. declare module BABYLON {
  134545. /**
  134546. * Block used to replace a color by another one
  134547. */
  134548. export class ReplaceColorBlock extends NodeMaterialBlock {
  134549. /**
  134550. * Creates a new ReplaceColorBlock
  134551. * @param name defines the block name
  134552. */
  134553. constructor(name: string);
  134554. /**
  134555. * Gets the current class name
  134556. * @returns the class name
  134557. */
  134558. getClassName(): string;
  134559. /**
  134560. * Gets the value input component
  134561. */
  134562. get value(): NodeMaterialConnectionPoint;
  134563. /**
  134564. * Gets the reference input component
  134565. */
  134566. get reference(): NodeMaterialConnectionPoint;
  134567. /**
  134568. * Gets the distance input component
  134569. */
  134570. get distance(): NodeMaterialConnectionPoint;
  134571. /**
  134572. * Gets the replacement input component
  134573. */
  134574. get replacement(): NodeMaterialConnectionPoint;
  134575. /**
  134576. * Gets the output component
  134577. */
  134578. get output(): NodeMaterialConnectionPoint;
  134579. protected _buildBlock(state: NodeMaterialBuildState): this;
  134580. }
  134581. }
  134582. declare module BABYLON {
  134583. /**
  134584. * Block used to posterize a value
  134585. * @see https://en.wikipedia.org/wiki/Posterization
  134586. */
  134587. export class PosterizeBlock extends NodeMaterialBlock {
  134588. /**
  134589. * Creates a new PosterizeBlock
  134590. * @param name defines the block name
  134591. */
  134592. constructor(name: string);
  134593. /**
  134594. * Gets the current class name
  134595. * @returns the class name
  134596. */
  134597. getClassName(): string;
  134598. /**
  134599. * Gets the value input component
  134600. */
  134601. get value(): NodeMaterialConnectionPoint;
  134602. /**
  134603. * Gets the steps input component
  134604. */
  134605. get steps(): NodeMaterialConnectionPoint;
  134606. /**
  134607. * Gets the output component
  134608. */
  134609. get output(): NodeMaterialConnectionPoint;
  134610. protected _buildBlock(state: NodeMaterialBuildState): this;
  134611. }
  134612. }
  134613. declare module BABYLON {
  134614. /**
  134615. * Operations supported by the Wave block
  134616. */
  134617. export enum WaveBlockKind {
  134618. /** SawTooth */
  134619. SawTooth = 0,
  134620. /** Square */
  134621. Square = 1,
  134622. /** Triangle */
  134623. Triangle = 2
  134624. }
  134625. /**
  134626. * Block used to apply wave operation to floats
  134627. */
  134628. export class WaveBlock extends NodeMaterialBlock {
  134629. /**
  134630. * Gets or sets the kibnd of wave to be applied by the block
  134631. */
  134632. kind: WaveBlockKind;
  134633. /**
  134634. * Creates a new WaveBlock
  134635. * @param name defines the block name
  134636. */
  134637. constructor(name: string);
  134638. /**
  134639. * Gets the current class name
  134640. * @returns the class name
  134641. */
  134642. getClassName(): string;
  134643. /**
  134644. * Gets the input component
  134645. */
  134646. get input(): NodeMaterialConnectionPoint;
  134647. /**
  134648. * Gets the output component
  134649. */
  134650. get output(): NodeMaterialConnectionPoint;
  134651. protected _buildBlock(state: NodeMaterialBuildState): this;
  134652. serialize(): any;
  134653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134654. }
  134655. }
  134656. declare module BABYLON {
  134657. /**
  134658. * Class used to store a color step for the GradientBlock
  134659. */
  134660. export class GradientBlockColorStep {
  134661. /**
  134662. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134663. */
  134664. step: number;
  134665. /**
  134666. * Gets or sets the color associated with this step
  134667. */
  134668. color: Color3;
  134669. /**
  134670. * Creates a new GradientBlockColorStep
  134671. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134672. * @param color defines the color associated with this step
  134673. */
  134674. constructor(
  134675. /**
  134676. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134677. */
  134678. step: number,
  134679. /**
  134680. * Gets or sets the color associated with this step
  134681. */
  134682. color: Color3);
  134683. }
  134684. /**
  134685. * Block used to return a color from a gradient based on an input value between 0 and 1
  134686. */
  134687. export class GradientBlock extends NodeMaterialBlock {
  134688. /**
  134689. * Gets or sets the list of color steps
  134690. */
  134691. colorSteps: GradientBlockColorStep[];
  134692. /**
  134693. * Creates a new GradientBlock
  134694. * @param name defines the block name
  134695. */
  134696. constructor(name: string);
  134697. /**
  134698. * Gets the current class name
  134699. * @returns the class name
  134700. */
  134701. getClassName(): string;
  134702. /**
  134703. * Gets the gradient input component
  134704. */
  134705. get gradient(): NodeMaterialConnectionPoint;
  134706. /**
  134707. * Gets the output component
  134708. */
  134709. get output(): NodeMaterialConnectionPoint;
  134710. private _writeColorConstant;
  134711. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134712. serialize(): any;
  134713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134714. protected _dumpPropertiesCode(): string;
  134715. }
  134716. }
  134717. declare module BABYLON {
  134718. /**
  134719. * Block used to normalize lerp between 2 values
  134720. */
  134721. export class NLerpBlock extends NodeMaterialBlock {
  134722. /**
  134723. * Creates a new NLerpBlock
  134724. * @param name defines the block name
  134725. */
  134726. constructor(name: string);
  134727. /**
  134728. * Gets the current class name
  134729. * @returns the class name
  134730. */
  134731. getClassName(): string;
  134732. /**
  134733. * Gets the left operand input component
  134734. */
  134735. get left(): NodeMaterialConnectionPoint;
  134736. /**
  134737. * Gets the right operand input component
  134738. */
  134739. get right(): NodeMaterialConnectionPoint;
  134740. /**
  134741. * Gets the gradient operand input component
  134742. */
  134743. get gradient(): NodeMaterialConnectionPoint;
  134744. /**
  134745. * Gets the output component
  134746. */
  134747. get output(): NodeMaterialConnectionPoint;
  134748. protected _buildBlock(state: NodeMaterialBuildState): this;
  134749. }
  134750. }
  134751. declare module BABYLON {
  134752. /**
  134753. * block used to Generate a Worley Noise 3D Noise Pattern
  134754. */
  134755. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134756. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134757. manhattanDistance: boolean;
  134758. /**
  134759. * Creates a new WorleyNoise3DBlock
  134760. * @param name defines the block name
  134761. */
  134762. constructor(name: string);
  134763. /**
  134764. * Gets the current class name
  134765. * @returns the class name
  134766. */
  134767. getClassName(): string;
  134768. /**
  134769. * Gets the seed input component
  134770. */
  134771. get seed(): NodeMaterialConnectionPoint;
  134772. /**
  134773. * Gets the jitter input component
  134774. */
  134775. get jitter(): NodeMaterialConnectionPoint;
  134776. /**
  134777. * Gets the output component
  134778. */
  134779. get output(): NodeMaterialConnectionPoint;
  134780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134781. /**
  134782. * Exposes the properties to the UI?
  134783. */
  134784. protected _dumpPropertiesCode(): string;
  134785. /**
  134786. * Exposes the properties to the Seralize?
  134787. */
  134788. serialize(): any;
  134789. /**
  134790. * Exposes the properties to the deseralize?
  134791. */
  134792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134793. }
  134794. }
  134795. declare module BABYLON {
  134796. /**
  134797. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134798. */
  134799. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134800. /**
  134801. * Creates a new SimplexPerlin3DBlock
  134802. * @param name defines the block name
  134803. */
  134804. constructor(name: string);
  134805. /**
  134806. * Gets the current class name
  134807. * @returns the class name
  134808. */
  134809. getClassName(): string;
  134810. /**
  134811. * Gets the seed operand input component
  134812. */
  134813. get seed(): NodeMaterialConnectionPoint;
  134814. /**
  134815. * Gets the output component
  134816. */
  134817. get output(): NodeMaterialConnectionPoint;
  134818. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134819. }
  134820. }
  134821. declare module BABYLON {
  134822. /**
  134823. * Block used to blend normals
  134824. */
  134825. export class NormalBlendBlock extends NodeMaterialBlock {
  134826. /**
  134827. * Creates a new NormalBlendBlock
  134828. * @param name defines the block name
  134829. */
  134830. constructor(name: string);
  134831. /**
  134832. * Gets the current class name
  134833. * @returns the class name
  134834. */
  134835. getClassName(): string;
  134836. /**
  134837. * Gets the first input component
  134838. */
  134839. get normalMap0(): NodeMaterialConnectionPoint;
  134840. /**
  134841. * Gets the second input component
  134842. */
  134843. get normalMap1(): NodeMaterialConnectionPoint;
  134844. /**
  134845. * Gets the output component
  134846. */
  134847. get output(): NodeMaterialConnectionPoint;
  134848. protected _buildBlock(state: NodeMaterialBuildState): this;
  134849. }
  134850. }
  134851. declare module BABYLON {
  134852. /**
  134853. * Block used to rotate a 2d vector by a given angle
  134854. */
  134855. export class Rotate2dBlock extends NodeMaterialBlock {
  134856. /**
  134857. * Creates a new Rotate2dBlock
  134858. * @param name defines the block name
  134859. */
  134860. constructor(name: string);
  134861. /**
  134862. * Gets the current class name
  134863. * @returns the class name
  134864. */
  134865. getClassName(): string;
  134866. /**
  134867. * Gets the input vector
  134868. */
  134869. get input(): NodeMaterialConnectionPoint;
  134870. /**
  134871. * Gets the input angle
  134872. */
  134873. get angle(): NodeMaterialConnectionPoint;
  134874. /**
  134875. * Gets the output component
  134876. */
  134877. get output(): NodeMaterialConnectionPoint;
  134878. autoConfigure(material: NodeMaterial): void;
  134879. protected _buildBlock(state: NodeMaterialBuildState): this;
  134880. }
  134881. }
  134882. declare module BABYLON {
  134883. /**
  134884. * Block used to get the reflected vector from a direction and a normal
  134885. */
  134886. export class ReflectBlock extends NodeMaterialBlock {
  134887. /**
  134888. * Creates a new ReflectBlock
  134889. * @param name defines the block name
  134890. */
  134891. constructor(name: string);
  134892. /**
  134893. * Gets the current class name
  134894. * @returns the class name
  134895. */
  134896. getClassName(): string;
  134897. /**
  134898. * Gets the incident component
  134899. */
  134900. get incident(): NodeMaterialConnectionPoint;
  134901. /**
  134902. * Gets the normal component
  134903. */
  134904. get normal(): NodeMaterialConnectionPoint;
  134905. /**
  134906. * Gets the output component
  134907. */
  134908. get output(): NodeMaterialConnectionPoint;
  134909. protected _buildBlock(state: NodeMaterialBuildState): this;
  134910. }
  134911. }
  134912. declare module BABYLON {
  134913. /**
  134914. * Block used to get the refracted vector from a direction and a normal
  134915. */
  134916. export class RefractBlock extends NodeMaterialBlock {
  134917. /**
  134918. * Creates a new RefractBlock
  134919. * @param name defines the block name
  134920. */
  134921. constructor(name: string);
  134922. /**
  134923. * Gets the current class name
  134924. * @returns the class name
  134925. */
  134926. getClassName(): string;
  134927. /**
  134928. * Gets the incident component
  134929. */
  134930. get incident(): NodeMaterialConnectionPoint;
  134931. /**
  134932. * Gets the normal component
  134933. */
  134934. get normal(): NodeMaterialConnectionPoint;
  134935. /**
  134936. * Gets the index of refraction component
  134937. */
  134938. get ior(): NodeMaterialConnectionPoint;
  134939. /**
  134940. * Gets the output component
  134941. */
  134942. get output(): NodeMaterialConnectionPoint;
  134943. protected _buildBlock(state: NodeMaterialBuildState): this;
  134944. }
  134945. }
  134946. declare module BABYLON {
  134947. /**
  134948. * Block used to desaturate a color
  134949. */
  134950. export class DesaturateBlock extends NodeMaterialBlock {
  134951. /**
  134952. * Creates a new DesaturateBlock
  134953. * @param name defines the block name
  134954. */
  134955. constructor(name: string);
  134956. /**
  134957. * Gets the current class name
  134958. * @returns the class name
  134959. */
  134960. getClassName(): string;
  134961. /**
  134962. * Gets the color operand input component
  134963. */
  134964. get color(): NodeMaterialConnectionPoint;
  134965. /**
  134966. * Gets the level operand input component
  134967. */
  134968. get level(): NodeMaterialConnectionPoint;
  134969. /**
  134970. * Gets the output component
  134971. */
  134972. get output(): NodeMaterialConnectionPoint;
  134973. protected _buildBlock(state: NodeMaterialBuildState): this;
  134974. }
  134975. }
  134976. declare module BABYLON {
  134977. /**
  134978. * Effect Render Options
  134979. */
  134980. export interface IEffectRendererOptions {
  134981. /**
  134982. * Defines the vertices positions.
  134983. */
  134984. positions?: number[];
  134985. /**
  134986. * Defines the indices.
  134987. */
  134988. indices?: number[];
  134989. }
  134990. /**
  134991. * Helper class to render one or more effects.
  134992. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  134993. */
  134994. export class EffectRenderer {
  134995. private engine;
  134996. private static _DefaultOptions;
  134997. private _vertexBuffers;
  134998. private _indexBuffer;
  134999. private _fullscreenViewport;
  135000. /**
  135001. * Creates an effect renderer
  135002. * @param engine the engine to use for rendering
  135003. * @param options defines the options of the effect renderer
  135004. */
  135005. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135006. /**
  135007. * Sets the current viewport in normalized coordinates 0-1
  135008. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135009. */
  135010. setViewport(viewport?: Viewport): void;
  135011. /**
  135012. * Binds the embedded attributes buffer to the effect.
  135013. * @param effect Defines the effect to bind the attributes for
  135014. */
  135015. bindBuffers(effect: Effect): void;
  135016. /**
  135017. * Sets the current effect wrapper to use during draw.
  135018. * The effect needs to be ready before calling this api.
  135019. * This also sets the default full screen position attribute.
  135020. * @param effectWrapper Defines the effect to draw with
  135021. */
  135022. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135023. /**
  135024. * Draws a full screen quad.
  135025. */
  135026. draw(): void;
  135027. private isRenderTargetTexture;
  135028. /**
  135029. * renders one or more effects to a specified texture
  135030. * @param effectWrapper the effect to renderer
  135031. * @param outputTexture texture to draw to, if null it will render to the screen.
  135032. */
  135033. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135034. /**
  135035. * Disposes of the effect renderer
  135036. */
  135037. dispose(): void;
  135038. }
  135039. /**
  135040. * Options to create an EffectWrapper
  135041. */
  135042. interface EffectWrapperCreationOptions {
  135043. /**
  135044. * Engine to use to create the effect
  135045. */
  135046. engine: ThinEngine;
  135047. /**
  135048. * Fragment shader for the effect
  135049. */
  135050. fragmentShader: string;
  135051. /**
  135052. * Vertex shader for the effect
  135053. */
  135054. vertexShader?: string;
  135055. /**
  135056. * Attributes to use in the shader
  135057. */
  135058. attributeNames?: Array<string>;
  135059. /**
  135060. * Uniforms to use in the shader
  135061. */
  135062. uniformNames?: Array<string>;
  135063. /**
  135064. * Texture sampler names to use in the shader
  135065. */
  135066. samplerNames?: Array<string>;
  135067. /**
  135068. * The friendly name of the effect displayed in Spector.
  135069. */
  135070. name?: string;
  135071. }
  135072. /**
  135073. * Wraps an effect to be used for rendering
  135074. */
  135075. export class EffectWrapper {
  135076. /**
  135077. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135078. */
  135079. onApplyObservable: Observable<{}>;
  135080. /**
  135081. * The underlying effect
  135082. */
  135083. effect: Effect;
  135084. /**
  135085. * Creates an effect to be renderer
  135086. * @param creationOptions options to create the effect
  135087. */
  135088. constructor(creationOptions: EffectWrapperCreationOptions);
  135089. /**
  135090. * Disposes of the effect wrapper
  135091. */
  135092. dispose(): void;
  135093. }
  135094. }
  135095. declare module BABYLON {
  135096. /**
  135097. * Helper class to push actions to a pool of workers.
  135098. */
  135099. export class WorkerPool implements IDisposable {
  135100. private _workerInfos;
  135101. private _pendingActions;
  135102. /**
  135103. * Constructor
  135104. * @param workers Array of workers to use for actions
  135105. */
  135106. constructor(workers: Array<Worker>);
  135107. /**
  135108. * Terminates all workers and clears any pending actions.
  135109. */
  135110. dispose(): void;
  135111. /**
  135112. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135113. * pended until a worker has completed its action.
  135114. * @param action The action to perform. Call onComplete when the action is complete.
  135115. */
  135116. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135117. private _execute;
  135118. }
  135119. }
  135120. declare module BABYLON {
  135121. /**
  135122. * Configuration for Draco compression
  135123. */
  135124. export interface IDracoCompressionConfiguration {
  135125. /**
  135126. * Configuration for the decoder.
  135127. */
  135128. decoder: {
  135129. /**
  135130. * The url to the WebAssembly module.
  135131. */
  135132. wasmUrl?: string;
  135133. /**
  135134. * The url to the WebAssembly binary.
  135135. */
  135136. wasmBinaryUrl?: string;
  135137. /**
  135138. * The url to the fallback JavaScript module.
  135139. */
  135140. fallbackUrl?: string;
  135141. };
  135142. }
  135143. /**
  135144. * Draco compression (https://google.github.io/draco/)
  135145. *
  135146. * This class wraps the Draco module.
  135147. *
  135148. * **Encoder**
  135149. *
  135150. * The encoder is not currently implemented.
  135151. *
  135152. * **Decoder**
  135153. *
  135154. * 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.
  135155. *
  135156. * To update the configuration, use the following code:
  135157. * ```javascript
  135158. * DracoCompression.Configuration = {
  135159. * decoder: {
  135160. * wasmUrl: "<url to the WebAssembly library>",
  135161. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135162. * fallbackUrl: "<url to the fallback JavaScript library>",
  135163. * }
  135164. * };
  135165. * ```
  135166. *
  135167. * 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.
  135168. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135169. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135170. *
  135171. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135172. * ```javascript
  135173. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135174. * ```
  135175. *
  135176. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135177. */
  135178. export class DracoCompression implements IDisposable {
  135179. private _workerPoolPromise?;
  135180. private _decoderModulePromise?;
  135181. /**
  135182. * The configuration. Defaults to the following urls:
  135183. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135184. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135185. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135186. */
  135187. static Configuration: IDracoCompressionConfiguration;
  135188. /**
  135189. * Returns true if the decoder configuration is available.
  135190. */
  135191. static get DecoderAvailable(): boolean;
  135192. /**
  135193. * Default number of workers to create when creating the draco compression object.
  135194. */
  135195. static DefaultNumWorkers: number;
  135196. private static GetDefaultNumWorkers;
  135197. private static _Default;
  135198. /**
  135199. * Default instance for the draco compression object.
  135200. */
  135201. static get Default(): DracoCompression;
  135202. /**
  135203. * Constructor
  135204. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135205. */
  135206. constructor(numWorkers?: number);
  135207. /**
  135208. * Stop all async operations and release resources.
  135209. */
  135210. dispose(): void;
  135211. /**
  135212. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135213. * @returns a promise that resolves when ready
  135214. */
  135215. whenReadyAsync(): Promise<void>;
  135216. /**
  135217. * Decode Draco compressed mesh data to vertex data.
  135218. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135219. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135220. * @returns A promise that resolves with the decoded vertex data
  135221. */
  135222. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135223. [kind: string]: number;
  135224. }): Promise<VertexData>;
  135225. }
  135226. }
  135227. declare module BABYLON {
  135228. /**
  135229. * Class for building Constructive Solid Geometry
  135230. */
  135231. export class CSG {
  135232. private polygons;
  135233. /**
  135234. * The world matrix
  135235. */
  135236. matrix: Matrix;
  135237. /**
  135238. * Stores the position
  135239. */
  135240. position: Vector3;
  135241. /**
  135242. * Stores the rotation
  135243. */
  135244. rotation: Vector3;
  135245. /**
  135246. * Stores the rotation quaternion
  135247. */
  135248. rotationQuaternion: Nullable<Quaternion>;
  135249. /**
  135250. * Stores the scaling vector
  135251. */
  135252. scaling: Vector3;
  135253. /**
  135254. * Convert the Mesh to CSG
  135255. * @param mesh The Mesh to convert to CSG
  135256. * @returns A new CSG from the Mesh
  135257. */
  135258. static FromMesh(mesh: Mesh): CSG;
  135259. /**
  135260. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135261. * @param polygons Polygons used to construct a CSG solid
  135262. */
  135263. private static FromPolygons;
  135264. /**
  135265. * Clones, or makes a deep copy, of the CSG
  135266. * @returns A new CSG
  135267. */
  135268. clone(): CSG;
  135269. /**
  135270. * Unions this CSG with another CSG
  135271. * @param csg The CSG to union against this CSG
  135272. * @returns The unioned CSG
  135273. */
  135274. union(csg: CSG): CSG;
  135275. /**
  135276. * Unions this CSG with another CSG in place
  135277. * @param csg The CSG to union against this CSG
  135278. */
  135279. unionInPlace(csg: CSG): void;
  135280. /**
  135281. * Subtracts this CSG with another CSG
  135282. * @param csg The CSG to subtract against this CSG
  135283. * @returns A new CSG
  135284. */
  135285. subtract(csg: CSG): CSG;
  135286. /**
  135287. * Subtracts this CSG with another CSG in place
  135288. * @param csg The CSG to subtact against this CSG
  135289. */
  135290. subtractInPlace(csg: CSG): void;
  135291. /**
  135292. * Intersect this CSG with another CSG
  135293. * @param csg The CSG to intersect against this CSG
  135294. * @returns A new CSG
  135295. */
  135296. intersect(csg: CSG): CSG;
  135297. /**
  135298. * Intersects this CSG with another CSG in place
  135299. * @param csg The CSG to intersect against this CSG
  135300. */
  135301. intersectInPlace(csg: CSG): void;
  135302. /**
  135303. * Return a new CSG solid with solid and empty space switched. This solid is
  135304. * not modified.
  135305. * @returns A new CSG solid with solid and empty space switched
  135306. */
  135307. inverse(): CSG;
  135308. /**
  135309. * Inverses the CSG in place
  135310. */
  135311. inverseInPlace(): void;
  135312. /**
  135313. * This is used to keep meshes transformations so they can be restored
  135314. * when we build back a Babylon Mesh
  135315. * NB : All CSG operations are performed in world coordinates
  135316. * @param csg The CSG to copy the transform attributes from
  135317. * @returns This CSG
  135318. */
  135319. copyTransformAttributes(csg: CSG): CSG;
  135320. /**
  135321. * Build Raw mesh from CSG
  135322. * Coordinates here are in world space
  135323. * @param name The name of the mesh geometry
  135324. * @param scene The Scene
  135325. * @param keepSubMeshes Specifies if the submeshes should be kept
  135326. * @returns A new Mesh
  135327. */
  135328. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135329. /**
  135330. * Build Mesh from CSG taking material and transforms into account
  135331. * @param name The name of the Mesh
  135332. * @param material The material of the Mesh
  135333. * @param scene The Scene
  135334. * @param keepSubMeshes Specifies if submeshes should be kept
  135335. * @returns The new Mesh
  135336. */
  135337. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135338. }
  135339. }
  135340. declare module BABYLON {
  135341. /**
  135342. * Class used to create a trail following a mesh
  135343. */
  135344. export class TrailMesh extends Mesh {
  135345. private _generator;
  135346. private _autoStart;
  135347. private _running;
  135348. private _diameter;
  135349. private _length;
  135350. private _sectionPolygonPointsCount;
  135351. private _sectionVectors;
  135352. private _sectionNormalVectors;
  135353. private _beforeRenderObserver;
  135354. /**
  135355. * @constructor
  135356. * @param name The value used by scene.getMeshByName() to do a lookup.
  135357. * @param generator The mesh or transform node to generate a trail.
  135358. * @param scene The scene to add this mesh to.
  135359. * @param diameter Diameter of trailing mesh. Default is 1.
  135360. * @param length Length of trailing mesh. Default is 60.
  135361. * @param autoStart Automatically start trailing mesh. Default true.
  135362. */
  135363. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135364. /**
  135365. * "TrailMesh"
  135366. * @returns "TrailMesh"
  135367. */
  135368. getClassName(): string;
  135369. private _createMesh;
  135370. /**
  135371. * Start trailing mesh.
  135372. */
  135373. start(): void;
  135374. /**
  135375. * Stop trailing mesh.
  135376. */
  135377. stop(): void;
  135378. /**
  135379. * Update trailing mesh geometry.
  135380. */
  135381. update(): void;
  135382. /**
  135383. * Returns a new TrailMesh object.
  135384. * @param name is a string, the name given to the new mesh
  135385. * @param newGenerator use new generator object for cloned trail mesh
  135386. * @returns a new mesh
  135387. */
  135388. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135389. /**
  135390. * Serializes this trail mesh
  135391. * @param serializationObject object to write serialization to
  135392. */
  135393. serialize(serializationObject: any): void;
  135394. /**
  135395. * Parses a serialized trail mesh
  135396. * @param parsedMesh the serialized mesh
  135397. * @param scene the scene to create the trail mesh in
  135398. * @returns the created trail mesh
  135399. */
  135400. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135401. }
  135402. }
  135403. declare module BABYLON {
  135404. /**
  135405. * Class containing static functions to help procedurally build meshes
  135406. */
  135407. export class TiledBoxBuilder {
  135408. /**
  135409. * Creates a box mesh
  135410. * 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)
  135411. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135415. * @param name defines the name of the mesh
  135416. * @param options defines the options used to create the mesh
  135417. * @param scene defines the hosting scene
  135418. * @returns the box mesh
  135419. */
  135420. static CreateTiledBox(name: string, options: {
  135421. pattern?: number;
  135422. width?: number;
  135423. height?: number;
  135424. depth?: number;
  135425. tileSize?: number;
  135426. tileWidth?: number;
  135427. tileHeight?: number;
  135428. alignHorizontal?: number;
  135429. alignVertical?: number;
  135430. faceUV?: Vector4[];
  135431. faceColors?: Color4[];
  135432. sideOrientation?: number;
  135433. updatable?: boolean;
  135434. }, scene?: Nullable<Scene>): Mesh;
  135435. }
  135436. }
  135437. declare module BABYLON {
  135438. /**
  135439. * Class containing static functions to help procedurally build meshes
  135440. */
  135441. export class TorusKnotBuilder {
  135442. /**
  135443. * Creates a torus knot mesh
  135444. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135445. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135446. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135447. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135451. * @param name defines the name of the mesh
  135452. * @param options defines the options used to create the mesh
  135453. * @param scene defines the hosting scene
  135454. * @returns the torus knot mesh
  135455. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135456. */
  135457. static CreateTorusKnot(name: string, options: {
  135458. radius?: number;
  135459. tube?: number;
  135460. radialSegments?: number;
  135461. tubularSegments?: number;
  135462. p?: number;
  135463. q?: number;
  135464. updatable?: boolean;
  135465. sideOrientation?: number;
  135466. frontUVs?: Vector4;
  135467. backUVs?: Vector4;
  135468. }, scene: any): Mesh;
  135469. }
  135470. }
  135471. declare module BABYLON {
  135472. /**
  135473. * Polygon
  135474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135475. */
  135476. export class Polygon {
  135477. /**
  135478. * Creates a rectangle
  135479. * @param xmin bottom X coord
  135480. * @param ymin bottom Y coord
  135481. * @param xmax top X coord
  135482. * @param ymax top Y coord
  135483. * @returns points that make the resulting rectation
  135484. */
  135485. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135486. /**
  135487. * Creates a circle
  135488. * @param radius radius of circle
  135489. * @param cx scale in x
  135490. * @param cy scale in y
  135491. * @param numberOfSides number of sides that make up the circle
  135492. * @returns points that make the resulting circle
  135493. */
  135494. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135495. /**
  135496. * Creates a polygon from input string
  135497. * @param input Input polygon data
  135498. * @returns the parsed points
  135499. */
  135500. static Parse(input: string): Vector2[];
  135501. /**
  135502. * Starts building a polygon from x and y coordinates
  135503. * @param x x coordinate
  135504. * @param y y coordinate
  135505. * @returns the started path2
  135506. */
  135507. static StartingAt(x: number, y: number): Path2;
  135508. }
  135509. /**
  135510. * Builds a polygon
  135511. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135512. */
  135513. export class PolygonMeshBuilder {
  135514. private _points;
  135515. private _outlinepoints;
  135516. private _holes;
  135517. private _name;
  135518. private _scene;
  135519. private _epoints;
  135520. private _eholes;
  135521. private _addToepoint;
  135522. /**
  135523. * Babylon reference to the earcut plugin.
  135524. */
  135525. bjsEarcut: any;
  135526. /**
  135527. * Creates a PolygonMeshBuilder
  135528. * @param name name of the builder
  135529. * @param contours Path of the polygon
  135530. * @param scene scene to add to when creating the mesh
  135531. * @param earcutInjection can be used to inject your own earcut reference
  135532. */
  135533. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135534. /**
  135535. * Adds a whole within the polygon
  135536. * @param hole Array of points defining the hole
  135537. * @returns this
  135538. */
  135539. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135540. /**
  135541. * Creates the polygon
  135542. * @param updatable If the mesh should be updatable
  135543. * @param depth The depth of the mesh created
  135544. * @returns the created mesh
  135545. */
  135546. build(updatable?: boolean, depth?: number): Mesh;
  135547. /**
  135548. * Creates the polygon
  135549. * @param depth The depth of the mesh created
  135550. * @returns the created VertexData
  135551. */
  135552. buildVertexData(depth?: number): VertexData;
  135553. /**
  135554. * Adds a side to the polygon
  135555. * @param positions points that make the polygon
  135556. * @param normals normals of the polygon
  135557. * @param uvs uvs of the polygon
  135558. * @param indices indices of the polygon
  135559. * @param bounds bounds of the polygon
  135560. * @param points points of the polygon
  135561. * @param depth depth of the polygon
  135562. * @param flip flip of the polygon
  135563. */
  135564. private addSide;
  135565. }
  135566. }
  135567. declare module BABYLON {
  135568. /**
  135569. * Class containing static functions to help procedurally build meshes
  135570. */
  135571. export class PolygonBuilder {
  135572. /**
  135573. * Creates a polygon mesh
  135574. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135575. * * 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
  135576. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135579. * * Remember you can only change the shape positions, not their number when updating a polygon
  135580. * @param name defines the name of the mesh
  135581. * @param options defines the options used to create the mesh
  135582. * @param scene defines the hosting scene
  135583. * @param earcutInjection can be used to inject your own earcut reference
  135584. * @returns the polygon mesh
  135585. */
  135586. static CreatePolygon(name: string, options: {
  135587. shape: Vector3[];
  135588. holes?: Vector3[][];
  135589. depth?: number;
  135590. faceUV?: Vector4[];
  135591. faceColors?: Color4[];
  135592. updatable?: boolean;
  135593. sideOrientation?: number;
  135594. frontUVs?: Vector4;
  135595. backUVs?: Vector4;
  135596. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135597. /**
  135598. * Creates an extruded polygon mesh, with depth in the Y direction.
  135599. * * 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)
  135600. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135601. * @param name defines the name of the mesh
  135602. * @param options defines the options used to create the mesh
  135603. * @param scene defines the hosting scene
  135604. * @param earcutInjection can be used to inject your own earcut reference
  135605. * @returns the polygon mesh
  135606. */
  135607. static ExtrudePolygon(name: string, options: {
  135608. shape: Vector3[];
  135609. holes?: Vector3[][];
  135610. depth?: number;
  135611. faceUV?: Vector4[];
  135612. faceColors?: Color4[];
  135613. updatable?: boolean;
  135614. sideOrientation?: number;
  135615. frontUVs?: Vector4;
  135616. backUVs?: Vector4;
  135617. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135618. }
  135619. }
  135620. declare module BABYLON {
  135621. /**
  135622. * Class containing static functions to help procedurally build meshes
  135623. */
  135624. export class LatheBuilder {
  135625. /**
  135626. * Creates lathe mesh.
  135627. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135628. * * 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
  135629. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135630. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135631. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135632. * * 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
  135633. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135634. * * 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
  135635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135637. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135639. * @param name defines the name of the mesh
  135640. * @param options defines the options used to create the mesh
  135641. * @param scene defines the hosting scene
  135642. * @returns the lathe mesh
  135643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135644. */
  135645. static CreateLathe(name: string, options: {
  135646. shape: Vector3[];
  135647. radius?: number;
  135648. tessellation?: number;
  135649. clip?: number;
  135650. arc?: number;
  135651. closed?: boolean;
  135652. updatable?: boolean;
  135653. sideOrientation?: number;
  135654. frontUVs?: Vector4;
  135655. backUVs?: Vector4;
  135656. cap?: number;
  135657. invertUV?: boolean;
  135658. }, scene?: Nullable<Scene>): Mesh;
  135659. }
  135660. }
  135661. declare module BABYLON {
  135662. /**
  135663. * Class containing static functions to help procedurally build meshes
  135664. */
  135665. export class TiledPlaneBuilder {
  135666. /**
  135667. * Creates a tiled plane mesh
  135668. * * The parameter `pattern` will, depending on value, do nothing or
  135669. * * * flip (reflect about central vertical) alternate tiles across and up
  135670. * * * flip every tile on alternate rows
  135671. * * * rotate (180 degs) alternate tiles across and up
  135672. * * * rotate every tile on alternate rows
  135673. * * * flip and rotate alternate tiles across and up
  135674. * * * flip and rotate every tile on alternate rows
  135675. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135676. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135679. * * 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)
  135680. * * 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)
  135681. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135682. * @param name defines the name of the mesh
  135683. * @param options defines the options used to create the mesh
  135684. * @param scene defines the hosting scene
  135685. * @returns the box mesh
  135686. */
  135687. static CreateTiledPlane(name: string, options: {
  135688. pattern?: number;
  135689. tileSize?: number;
  135690. tileWidth?: number;
  135691. tileHeight?: number;
  135692. size?: number;
  135693. width?: number;
  135694. height?: number;
  135695. alignHorizontal?: number;
  135696. alignVertical?: number;
  135697. sideOrientation?: number;
  135698. frontUVs?: Vector4;
  135699. backUVs?: Vector4;
  135700. updatable?: boolean;
  135701. }, scene?: Nullable<Scene>): Mesh;
  135702. }
  135703. }
  135704. declare module BABYLON {
  135705. /**
  135706. * Class containing static functions to help procedurally build meshes
  135707. */
  135708. export class TubeBuilder {
  135709. /**
  135710. * Creates a tube mesh.
  135711. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135712. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135713. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135714. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135715. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135716. * * 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)
  135717. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135718. * * 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
  135719. * * 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
  135720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135722. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135724. * @param name defines the name of the mesh
  135725. * @param options defines the options used to create the mesh
  135726. * @param scene defines the hosting scene
  135727. * @returns the tube mesh
  135728. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135729. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135730. */
  135731. static CreateTube(name: string, options: {
  135732. path: Vector3[];
  135733. radius?: number;
  135734. tessellation?: number;
  135735. radiusFunction?: {
  135736. (i: number, distance: number): number;
  135737. };
  135738. cap?: number;
  135739. arc?: number;
  135740. updatable?: boolean;
  135741. sideOrientation?: number;
  135742. frontUVs?: Vector4;
  135743. backUVs?: Vector4;
  135744. instance?: Mesh;
  135745. invertUV?: boolean;
  135746. }, scene?: Nullable<Scene>): Mesh;
  135747. }
  135748. }
  135749. declare module BABYLON {
  135750. /**
  135751. * Class containing static functions to help procedurally build meshes
  135752. */
  135753. export class IcoSphereBuilder {
  135754. /**
  135755. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135756. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135757. * * 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`)
  135758. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135759. * * 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
  135760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135763. * @param name defines the name of the mesh
  135764. * @param options defines the options used to create the mesh
  135765. * @param scene defines the hosting scene
  135766. * @returns the icosahedron mesh
  135767. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135768. */
  135769. static CreateIcoSphere(name: string, options: {
  135770. radius?: number;
  135771. radiusX?: number;
  135772. radiusY?: number;
  135773. radiusZ?: number;
  135774. flat?: boolean;
  135775. subdivisions?: number;
  135776. sideOrientation?: number;
  135777. frontUVs?: Vector4;
  135778. backUVs?: Vector4;
  135779. updatable?: boolean;
  135780. }, scene?: Nullable<Scene>): Mesh;
  135781. }
  135782. }
  135783. declare module BABYLON {
  135784. /**
  135785. * Class containing static functions to help procedurally build meshes
  135786. */
  135787. export class DecalBuilder {
  135788. /**
  135789. * Creates a decal mesh.
  135790. * 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
  135791. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135792. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135793. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135794. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135795. * @param name defines the name of the mesh
  135796. * @param sourceMesh defines the mesh where the decal must be applied
  135797. * @param options defines the options used to create the mesh
  135798. * @param scene defines the hosting scene
  135799. * @returns the decal mesh
  135800. * @see https://doc.babylonjs.com/how_to/decals
  135801. */
  135802. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135803. position?: Vector3;
  135804. normal?: Vector3;
  135805. size?: Vector3;
  135806. angle?: number;
  135807. }): Mesh;
  135808. }
  135809. }
  135810. declare module BABYLON {
  135811. /**
  135812. * Class containing static functions to help procedurally build meshes
  135813. */
  135814. export class MeshBuilder {
  135815. /**
  135816. * Creates a box mesh
  135817. * * The parameter `size` sets the size (float) of each box side (default 1)
  135818. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135819. * * 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)
  135820. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135824. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135825. * @param name defines the name of the mesh
  135826. * @param options defines the options used to create the mesh
  135827. * @param scene defines the hosting scene
  135828. * @returns the box mesh
  135829. */
  135830. static CreateBox(name: string, options: {
  135831. size?: number;
  135832. width?: number;
  135833. height?: number;
  135834. depth?: number;
  135835. faceUV?: Vector4[];
  135836. faceColors?: Color4[];
  135837. sideOrientation?: number;
  135838. frontUVs?: Vector4;
  135839. backUVs?: Vector4;
  135840. wrap?: boolean;
  135841. topBaseAt?: number;
  135842. bottomBaseAt?: number;
  135843. updatable?: boolean;
  135844. }, scene?: Nullable<Scene>): Mesh;
  135845. /**
  135846. * Creates a tiled box mesh
  135847. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135849. * @param name defines the name of the mesh
  135850. * @param options defines the options used to create the mesh
  135851. * @param scene defines the hosting scene
  135852. * @returns the tiled box mesh
  135853. */
  135854. static CreateTiledBox(name: string, options: {
  135855. pattern?: number;
  135856. size?: number;
  135857. width?: number;
  135858. height?: number;
  135859. depth: number;
  135860. tileSize?: number;
  135861. tileWidth?: number;
  135862. tileHeight?: number;
  135863. faceUV?: Vector4[];
  135864. faceColors?: Color4[];
  135865. alignHorizontal?: number;
  135866. alignVertical?: number;
  135867. sideOrientation?: number;
  135868. updatable?: boolean;
  135869. }, scene?: Nullable<Scene>): Mesh;
  135870. /**
  135871. * Creates a sphere mesh
  135872. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135873. * * 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`)
  135874. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135875. * * 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
  135876. * * 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)
  135877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135880. * @param name defines the name of the mesh
  135881. * @param options defines the options used to create the mesh
  135882. * @param scene defines the hosting scene
  135883. * @returns the sphere mesh
  135884. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135885. */
  135886. static CreateSphere(name: string, options: {
  135887. segments?: number;
  135888. diameter?: number;
  135889. diameterX?: number;
  135890. diameterY?: number;
  135891. diameterZ?: number;
  135892. arc?: number;
  135893. slice?: number;
  135894. sideOrientation?: number;
  135895. frontUVs?: Vector4;
  135896. backUVs?: Vector4;
  135897. updatable?: boolean;
  135898. }, scene?: Nullable<Scene>): Mesh;
  135899. /**
  135900. * Creates a plane polygonal mesh. By default, this is a disc
  135901. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135902. * * 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
  135903. * * 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
  135904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135907. * @param name defines the name of the mesh
  135908. * @param options defines the options used to create the mesh
  135909. * @param scene defines the hosting scene
  135910. * @returns the plane polygonal mesh
  135911. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135912. */
  135913. static CreateDisc(name: string, options: {
  135914. radius?: number;
  135915. tessellation?: number;
  135916. arc?: number;
  135917. updatable?: boolean;
  135918. sideOrientation?: number;
  135919. frontUVs?: Vector4;
  135920. backUVs?: Vector4;
  135921. }, scene?: Nullable<Scene>): Mesh;
  135922. /**
  135923. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135924. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135925. * * 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`)
  135926. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135927. * * 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
  135928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135931. * @param name defines the name of the mesh
  135932. * @param options defines the options used to create the mesh
  135933. * @param scene defines the hosting scene
  135934. * @returns the icosahedron mesh
  135935. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135936. */
  135937. static CreateIcoSphere(name: string, options: {
  135938. radius?: number;
  135939. radiusX?: number;
  135940. radiusY?: number;
  135941. radiusZ?: number;
  135942. flat?: boolean;
  135943. subdivisions?: number;
  135944. sideOrientation?: number;
  135945. frontUVs?: Vector4;
  135946. backUVs?: Vector4;
  135947. updatable?: boolean;
  135948. }, scene?: Nullable<Scene>): Mesh;
  135949. /**
  135950. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135951. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135952. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135953. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135954. * * 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
  135955. * * 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
  135956. * * 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
  135957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135960. * * 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
  135961. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135962. * * 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
  135963. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135965. * @param name defines the name of the mesh
  135966. * @param options defines the options used to create the mesh
  135967. * @param scene defines the hosting scene
  135968. * @returns the ribbon mesh
  135969. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135970. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135971. */
  135972. static CreateRibbon(name: string, options: {
  135973. pathArray: Vector3[][];
  135974. closeArray?: boolean;
  135975. closePath?: boolean;
  135976. offset?: number;
  135977. updatable?: boolean;
  135978. sideOrientation?: number;
  135979. frontUVs?: Vector4;
  135980. backUVs?: Vector4;
  135981. instance?: Mesh;
  135982. invertUV?: boolean;
  135983. uvs?: Vector2[];
  135984. colors?: Color4[];
  135985. }, scene?: Nullable<Scene>): Mesh;
  135986. /**
  135987. * Creates a cylinder or a cone mesh
  135988. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135989. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135990. * * 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.
  135991. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135992. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135993. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135994. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135995. * * 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).
  135996. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135997. * * 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).
  135998. * * 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
  135999. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  136000. * * 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
  136001. * * 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.
  136002. * * If `enclose` is false, a ring surface is one element.
  136003. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  136004. * * 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
  136005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136008. * @param name defines the name of the mesh
  136009. * @param options defines the options used to create the mesh
  136010. * @param scene defines the hosting scene
  136011. * @returns the cylinder mesh
  136012. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  136013. */
  136014. static CreateCylinder(name: string, options: {
  136015. height?: number;
  136016. diameterTop?: number;
  136017. diameterBottom?: number;
  136018. diameter?: number;
  136019. tessellation?: number;
  136020. subdivisions?: number;
  136021. arc?: number;
  136022. faceColors?: Color4[];
  136023. faceUV?: Vector4[];
  136024. updatable?: boolean;
  136025. hasRings?: boolean;
  136026. enclose?: boolean;
  136027. cap?: number;
  136028. sideOrientation?: number;
  136029. frontUVs?: Vector4;
  136030. backUVs?: Vector4;
  136031. }, scene?: Nullable<Scene>): Mesh;
  136032. /**
  136033. * Creates a torus mesh
  136034. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136035. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136036. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136040. * @param name defines the name of the mesh
  136041. * @param options defines the options used to create the mesh
  136042. * @param scene defines the hosting scene
  136043. * @returns the torus mesh
  136044. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136045. */
  136046. static CreateTorus(name: string, options: {
  136047. diameter?: number;
  136048. thickness?: number;
  136049. tessellation?: number;
  136050. updatable?: boolean;
  136051. sideOrientation?: number;
  136052. frontUVs?: Vector4;
  136053. backUVs?: Vector4;
  136054. }, scene?: Nullable<Scene>): Mesh;
  136055. /**
  136056. * Creates a torus knot mesh
  136057. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136058. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136059. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136060. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136064. * @param name defines the name of the mesh
  136065. * @param options defines the options used to create the mesh
  136066. * @param scene defines the hosting scene
  136067. * @returns the torus knot mesh
  136068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136069. */
  136070. static CreateTorusKnot(name: string, options: {
  136071. radius?: number;
  136072. tube?: number;
  136073. radialSegments?: number;
  136074. tubularSegments?: number;
  136075. p?: number;
  136076. q?: number;
  136077. updatable?: boolean;
  136078. sideOrientation?: number;
  136079. frontUVs?: Vector4;
  136080. backUVs?: Vector4;
  136081. }, scene?: Nullable<Scene>): Mesh;
  136082. /**
  136083. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136084. * * 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
  136085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136086. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136087. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136088. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136090. * * 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
  136091. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136094. * @param name defines the name of the new line system
  136095. * @param options defines the options used to create the line system
  136096. * @param scene defines the hosting scene
  136097. * @returns a new line system mesh
  136098. */
  136099. static CreateLineSystem(name: string, options: {
  136100. lines: Vector3[][];
  136101. updatable?: boolean;
  136102. instance?: Nullable<LinesMesh>;
  136103. colors?: Nullable<Color4[][]>;
  136104. useVertexAlpha?: boolean;
  136105. }, scene: Nullable<Scene>): LinesMesh;
  136106. /**
  136107. * Creates a line mesh
  136108. * 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
  136109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136110. * * The parameter `points` is an array successive Vector3
  136111. * * 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
  136112. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136113. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136114. * * When updating an instance, remember that only point positions can change, not the number of points
  136115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136117. * @param name defines the name of the new line system
  136118. * @param options defines the options used to create the line system
  136119. * @param scene defines the hosting scene
  136120. * @returns a new line mesh
  136121. */
  136122. static CreateLines(name: string, options: {
  136123. points: Vector3[];
  136124. updatable?: boolean;
  136125. instance?: Nullable<LinesMesh>;
  136126. colors?: Color4[];
  136127. useVertexAlpha?: boolean;
  136128. }, scene?: Nullable<Scene>): LinesMesh;
  136129. /**
  136130. * Creates a dashed line mesh
  136131. * * 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
  136132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136133. * * The parameter `points` is an array successive Vector3
  136134. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136135. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136136. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136137. * * 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
  136138. * * When updating an instance, remember that only point positions can change, not the number of points
  136139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136140. * @param name defines the name of the mesh
  136141. * @param options defines the options used to create the mesh
  136142. * @param scene defines the hosting scene
  136143. * @returns the dashed line mesh
  136144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136145. */
  136146. static CreateDashedLines(name: string, options: {
  136147. points: Vector3[];
  136148. dashSize?: number;
  136149. gapSize?: number;
  136150. dashNb?: number;
  136151. updatable?: boolean;
  136152. instance?: LinesMesh;
  136153. }, scene?: Nullable<Scene>): LinesMesh;
  136154. /**
  136155. * 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.
  136156. * * 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.
  136157. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136158. * * 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.
  136159. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136160. * * 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
  136161. * * 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
  136162. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136167. * @param name defines the name of the mesh
  136168. * @param options defines the options used to create the mesh
  136169. * @param scene defines the hosting scene
  136170. * @returns the extruded shape mesh
  136171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136173. */
  136174. static ExtrudeShape(name: string, options: {
  136175. shape: Vector3[];
  136176. path: Vector3[];
  136177. scale?: number;
  136178. rotation?: number;
  136179. cap?: number;
  136180. updatable?: boolean;
  136181. sideOrientation?: number;
  136182. frontUVs?: Vector4;
  136183. backUVs?: Vector4;
  136184. instance?: Mesh;
  136185. invertUV?: boolean;
  136186. }, scene?: Nullable<Scene>): Mesh;
  136187. /**
  136188. * Creates an custom extruded shape mesh.
  136189. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136190. * * 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.
  136191. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136192. * * 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
  136193. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136194. * * 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
  136195. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136196. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136197. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136198. * * 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
  136199. * * 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
  136200. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136205. * @param name defines the name of the mesh
  136206. * @param options defines the options used to create the mesh
  136207. * @param scene defines the hosting scene
  136208. * @returns the custom extruded shape mesh
  136209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136212. */
  136213. static ExtrudeShapeCustom(name: string, options: {
  136214. shape: Vector3[];
  136215. path: Vector3[];
  136216. scaleFunction?: any;
  136217. rotationFunction?: any;
  136218. ribbonCloseArray?: boolean;
  136219. ribbonClosePath?: boolean;
  136220. cap?: number;
  136221. updatable?: boolean;
  136222. sideOrientation?: number;
  136223. frontUVs?: Vector4;
  136224. backUVs?: Vector4;
  136225. instance?: Mesh;
  136226. invertUV?: boolean;
  136227. }, scene?: Nullable<Scene>): Mesh;
  136228. /**
  136229. * Creates lathe mesh.
  136230. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136231. * * 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
  136232. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136233. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136234. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136235. * * 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
  136236. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136237. * * 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
  136238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136242. * @param name defines the name of the mesh
  136243. * @param options defines the options used to create the mesh
  136244. * @param scene defines the hosting scene
  136245. * @returns the lathe mesh
  136246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136247. */
  136248. static CreateLathe(name: string, options: {
  136249. shape: Vector3[];
  136250. radius?: number;
  136251. tessellation?: number;
  136252. clip?: number;
  136253. arc?: number;
  136254. closed?: boolean;
  136255. updatable?: boolean;
  136256. sideOrientation?: number;
  136257. frontUVs?: Vector4;
  136258. backUVs?: Vector4;
  136259. cap?: number;
  136260. invertUV?: boolean;
  136261. }, scene?: Nullable<Scene>): Mesh;
  136262. /**
  136263. * Creates a tiled plane mesh
  136264. * * You can set a limited pattern arrangement with the tiles
  136265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136268. * @param name defines the name of the mesh
  136269. * @param options defines the options used to create the mesh
  136270. * @param scene defines the hosting scene
  136271. * @returns the plane mesh
  136272. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136273. */
  136274. static CreateTiledPlane(name: string, options: {
  136275. pattern?: number;
  136276. tileSize?: number;
  136277. tileWidth?: number;
  136278. tileHeight?: number;
  136279. size?: number;
  136280. width?: number;
  136281. height?: number;
  136282. alignHorizontal?: number;
  136283. alignVertical?: number;
  136284. sideOrientation?: number;
  136285. frontUVs?: Vector4;
  136286. backUVs?: Vector4;
  136287. updatable?: boolean;
  136288. }, scene?: Nullable<Scene>): Mesh;
  136289. /**
  136290. * Creates a plane mesh
  136291. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136292. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136293. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136297. * @param name defines the name of the mesh
  136298. * @param options defines the options used to create the mesh
  136299. * @param scene defines the hosting scene
  136300. * @returns the plane mesh
  136301. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136302. */
  136303. static CreatePlane(name: string, options: {
  136304. size?: number;
  136305. width?: number;
  136306. height?: number;
  136307. sideOrientation?: number;
  136308. frontUVs?: Vector4;
  136309. backUVs?: Vector4;
  136310. updatable?: boolean;
  136311. sourcePlane?: Plane;
  136312. }, scene?: Nullable<Scene>): Mesh;
  136313. /**
  136314. * Creates a ground mesh
  136315. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136316. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136318. * @param name defines the name of the mesh
  136319. * @param options defines the options used to create the mesh
  136320. * @param scene defines the hosting scene
  136321. * @returns the ground mesh
  136322. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136323. */
  136324. static CreateGround(name: string, options: {
  136325. width?: number;
  136326. height?: number;
  136327. subdivisions?: number;
  136328. subdivisionsX?: number;
  136329. subdivisionsY?: number;
  136330. updatable?: boolean;
  136331. }, scene?: Nullable<Scene>): Mesh;
  136332. /**
  136333. * Creates a tiled ground mesh
  136334. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136335. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136336. * * 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
  136337. * * 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
  136338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136339. * @param name defines the name of the mesh
  136340. * @param options defines the options used to create the mesh
  136341. * @param scene defines the hosting scene
  136342. * @returns the tiled ground mesh
  136343. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136344. */
  136345. static CreateTiledGround(name: string, options: {
  136346. xmin: number;
  136347. zmin: number;
  136348. xmax: number;
  136349. zmax: number;
  136350. subdivisions?: {
  136351. w: number;
  136352. h: number;
  136353. };
  136354. precision?: {
  136355. w: number;
  136356. h: number;
  136357. };
  136358. updatable?: boolean;
  136359. }, scene?: Nullable<Scene>): Mesh;
  136360. /**
  136361. * Creates a ground mesh from a height map
  136362. * * The parameter `url` sets the URL of the height map image resource.
  136363. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136364. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136365. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136366. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136367. * * 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.
  136368. * * 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).
  136369. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136371. * @param name defines the name of the mesh
  136372. * @param url defines the url to the height map
  136373. * @param options defines the options used to create the mesh
  136374. * @param scene defines the hosting scene
  136375. * @returns the ground mesh
  136376. * @see https://doc.babylonjs.com/babylon101/height_map
  136377. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136378. */
  136379. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136380. width?: number;
  136381. height?: number;
  136382. subdivisions?: number;
  136383. minHeight?: number;
  136384. maxHeight?: number;
  136385. colorFilter?: Color3;
  136386. alphaFilter?: number;
  136387. updatable?: boolean;
  136388. onReady?: (mesh: GroundMesh) => void;
  136389. }, scene?: Nullable<Scene>): GroundMesh;
  136390. /**
  136391. * Creates a polygon mesh
  136392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136393. * * 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
  136394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136397. * * Remember you can only change the shape positions, not their number when updating a polygon
  136398. * @param name defines the name of the mesh
  136399. * @param options defines the options used to create the mesh
  136400. * @param scene defines the hosting scene
  136401. * @param earcutInjection can be used to inject your own earcut reference
  136402. * @returns the polygon mesh
  136403. */
  136404. static CreatePolygon(name: string, options: {
  136405. shape: Vector3[];
  136406. holes?: Vector3[][];
  136407. depth?: number;
  136408. faceUV?: Vector4[];
  136409. faceColors?: Color4[];
  136410. updatable?: boolean;
  136411. sideOrientation?: number;
  136412. frontUVs?: Vector4;
  136413. backUVs?: Vector4;
  136414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136415. /**
  136416. * Creates an extruded polygon mesh, with depth in the Y direction.
  136417. * * 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)
  136418. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136419. * @param name defines the name of the mesh
  136420. * @param options defines the options used to create the mesh
  136421. * @param scene defines the hosting scene
  136422. * @param earcutInjection can be used to inject your own earcut reference
  136423. * @returns the polygon mesh
  136424. */
  136425. static ExtrudePolygon(name: string, options: {
  136426. shape: Vector3[];
  136427. holes?: Vector3[][];
  136428. depth?: number;
  136429. faceUV?: Vector4[];
  136430. faceColors?: Color4[];
  136431. updatable?: boolean;
  136432. sideOrientation?: number;
  136433. frontUVs?: Vector4;
  136434. backUVs?: Vector4;
  136435. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136436. /**
  136437. * Creates a tube mesh.
  136438. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136439. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136440. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136441. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136442. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136443. * * 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)
  136444. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136445. * * 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
  136446. * * 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
  136447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136451. * @param name defines the name of the mesh
  136452. * @param options defines the options used to create the mesh
  136453. * @param scene defines the hosting scene
  136454. * @returns the tube mesh
  136455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136456. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136457. */
  136458. static CreateTube(name: string, options: {
  136459. path: Vector3[];
  136460. radius?: number;
  136461. tessellation?: number;
  136462. radiusFunction?: {
  136463. (i: number, distance: number): number;
  136464. };
  136465. cap?: number;
  136466. arc?: number;
  136467. updatable?: boolean;
  136468. sideOrientation?: number;
  136469. frontUVs?: Vector4;
  136470. backUVs?: Vector4;
  136471. instance?: Mesh;
  136472. invertUV?: boolean;
  136473. }, scene?: Nullable<Scene>): Mesh;
  136474. /**
  136475. * Creates a polyhedron mesh
  136476. * * 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
  136477. * * The parameter `size` (positive float, default 1) sets the polygon size
  136478. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136479. * * 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`
  136480. * * 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
  136481. * * 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)`)
  136482. * * 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
  136483. * * 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
  136484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136487. * @param name defines the name of the mesh
  136488. * @param options defines the options used to create the mesh
  136489. * @param scene defines the hosting scene
  136490. * @returns the polyhedron mesh
  136491. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136492. */
  136493. static CreatePolyhedron(name: string, options: {
  136494. type?: number;
  136495. size?: number;
  136496. sizeX?: number;
  136497. sizeY?: number;
  136498. sizeZ?: number;
  136499. custom?: any;
  136500. faceUV?: Vector4[];
  136501. faceColors?: Color4[];
  136502. flat?: boolean;
  136503. updatable?: boolean;
  136504. sideOrientation?: number;
  136505. frontUVs?: Vector4;
  136506. backUVs?: Vector4;
  136507. }, scene?: Nullable<Scene>): Mesh;
  136508. /**
  136509. * Creates a decal mesh.
  136510. * 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
  136511. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136512. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136513. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136514. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136515. * @param name defines the name of the mesh
  136516. * @param sourceMesh defines the mesh where the decal must be applied
  136517. * @param options defines the options used to create the mesh
  136518. * @param scene defines the hosting scene
  136519. * @returns the decal mesh
  136520. * @see https://doc.babylonjs.com/how_to/decals
  136521. */
  136522. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136523. position?: Vector3;
  136524. normal?: Vector3;
  136525. size?: Vector3;
  136526. angle?: number;
  136527. }): Mesh;
  136528. }
  136529. }
  136530. declare module BABYLON {
  136531. /**
  136532. * A simplifier interface for future simplification implementations
  136533. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136534. */
  136535. export interface ISimplifier {
  136536. /**
  136537. * Simplification of a given mesh according to the given settings.
  136538. * Since this requires computation, it is assumed that the function runs async.
  136539. * @param settings The settings of the simplification, including quality and distance
  136540. * @param successCallback A callback that will be called after the mesh was simplified.
  136541. * @param errorCallback in case of an error, this callback will be called. optional.
  136542. */
  136543. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136544. }
  136545. /**
  136546. * Expected simplification settings.
  136547. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136548. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136549. */
  136550. export interface ISimplificationSettings {
  136551. /**
  136552. * Gets or sets the expected quality
  136553. */
  136554. quality: number;
  136555. /**
  136556. * Gets or sets the distance when this optimized version should be used
  136557. */
  136558. distance: number;
  136559. /**
  136560. * Gets an already optimized mesh
  136561. */
  136562. optimizeMesh?: boolean;
  136563. }
  136564. /**
  136565. * Class used to specify simplification options
  136566. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136567. */
  136568. export class SimplificationSettings implements ISimplificationSettings {
  136569. /** expected quality */
  136570. quality: number;
  136571. /** distance when this optimized version should be used */
  136572. distance: number;
  136573. /** already optimized mesh */
  136574. optimizeMesh?: boolean | undefined;
  136575. /**
  136576. * Creates a SimplificationSettings
  136577. * @param quality expected quality
  136578. * @param distance distance when this optimized version should be used
  136579. * @param optimizeMesh already optimized mesh
  136580. */
  136581. constructor(
  136582. /** expected quality */
  136583. quality: number,
  136584. /** distance when this optimized version should be used */
  136585. distance: number,
  136586. /** already optimized mesh */
  136587. optimizeMesh?: boolean | undefined);
  136588. }
  136589. /**
  136590. * Interface used to define a simplification task
  136591. */
  136592. export interface ISimplificationTask {
  136593. /**
  136594. * Array of settings
  136595. */
  136596. settings: Array<ISimplificationSettings>;
  136597. /**
  136598. * Simplification type
  136599. */
  136600. simplificationType: SimplificationType;
  136601. /**
  136602. * Mesh to simplify
  136603. */
  136604. mesh: Mesh;
  136605. /**
  136606. * Callback called on success
  136607. */
  136608. successCallback?: () => void;
  136609. /**
  136610. * Defines if parallel processing can be used
  136611. */
  136612. parallelProcessing: boolean;
  136613. }
  136614. /**
  136615. * Queue used to order the simplification tasks
  136616. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136617. */
  136618. export class SimplificationQueue {
  136619. private _simplificationArray;
  136620. /**
  136621. * Gets a boolean indicating that the process is still running
  136622. */
  136623. running: boolean;
  136624. /**
  136625. * Creates a new queue
  136626. */
  136627. constructor();
  136628. /**
  136629. * Adds a new simplification task
  136630. * @param task defines a task to add
  136631. */
  136632. addTask(task: ISimplificationTask): void;
  136633. /**
  136634. * Execute next task
  136635. */
  136636. executeNext(): void;
  136637. /**
  136638. * Execute a simplification task
  136639. * @param task defines the task to run
  136640. */
  136641. runSimplification(task: ISimplificationTask): void;
  136642. private getSimplifier;
  136643. }
  136644. /**
  136645. * The implemented types of simplification
  136646. * At the moment only Quadratic Error Decimation is implemented
  136647. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136648. */
  136649. export enum SimplificationType {
  136650. /** Quadratic error decimation */
  136651. QUADRATIC = 0
  136652. }
  136653. /**
  136654. * An implementation of the Quadratic Error simplification algorithm.
  136655. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136656. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136657. * @author RaananW
  136658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136659. */
  136660. export class QuadraticErrorSimplification implements ISimplifier {
  136661. private _mesh;
  136662. private triangles;
  136663. private vertices;
  136664. private references;
  136665. private _reconstructedMesh;
  136666. /** Gets or sets the number pf sync interations */
  136667. syncIterations: number;
  136668. /** Gets or sets the aggressiveness of the simplifier */
  136669. aggressiveness: number;
  136670. /** Gets or sets the number of allowed iterations for decimation */
  136671. decimationIterations: number;
  136672. /** Gets or sets the espilon to use for bounding box computation */
  136673. boundingBoxEpsilon: number;
  136674. /**
  136675. * Creates a new QuadraticErrorSimplification
  136676. * @param _mesh defines the target mesh
  136677. */
  136678. constructor(_mesh: Mesh);
  136679. /**
  136680. * Simplification of a given mesh according to the given settings.
  136681. * Since this requires computation, it is assumed that the function runs async.
  136682. * @param settings The settings of the simplification, including quality and distance
  136683. * @param successCallback A callback that will be called after the mesh was simplified.
  136684. */
  136685. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136686. private runDecimation;
  136687. private initWithMesh;
  136688. private init;
  136689. private reconstructMesh;
  136690. private initDecimatedMesh;
  136691. private isFlipped;
  136692. private updateTriangles;
  136693. private identifyBorder;
  136694. private updateMesh;
  136695. private vertexError;
  136696. private calculateError;
  136697. }
  136698. }
  136699. declare module BABYLON {
  136700. interface Scene {
  136701. /** @hidden (Backing field) */
  136702. _simplificationQueue: SimplificationQueue;
  136703. /**
  136704. * Gets or sets the simplification queue attached to the scene
  136705. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136706. */
  136707. simplificationQueue: SimplificationQueue;
  136708. }
  136709. interface Mesh {
  136710. /**
  136711. * Simplify the mesh according to the given array of settings.
  136712. * Function will return immediately and will simplify async
  136713. * @param settings a collection of simplification settings
  136714. * @param parallelProcessing should all levels calculate parallel or one after the other
  136715. * @param simplificationType the type of simplification to run
  136716. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136717. * @returns the current mesh
  136718. */
  136719. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136720. }
  136721. /**
  136722. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136723. * created in a scene
  136724. */
  136725. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136726. /**
  136727. * The component name helpfull to identify the component in the list of scene components.
  136728. */
  136729. readonly name: string;
  136730. /**
  136731. * The scene the component belongs to.
  136732. */
  136733. scene: Scene;
  136734. /**
  136735. * Creates a new instance of the component for the given scene
  136736. * @param scene Defines the scene to register the component in
  136737. */
  136738. constructor(scene: Scene);
  136739. /**
  136740. * Registers the component in a given scene
  136741. */
  136742. register(): void;
  136743. /**
  136744. * Rebuilds the elements related to this component in case of
  136745. * context lost for instance.
  136746. */
  136747. rebuild(): void;
  136748. /**
  136749. * Disposes the component and the associated ressources
  136750. */
  136751. dispose(): void;
  136752. private _beforeCameraUpdate;
  136753. }
  136754. }
  136755. declare module BABYLON {
  136756. /**
  136757. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136758. */
  136759. export interface INavigationEnginePlugin {
  136760. /**
  136761. * plugin name
  136762. */
  136763. name: string;
  136764. /**
  136765. * Creates a navigation mesh
  136766. * @param meshes array of all the geometry used to compute the navigatio mesh
  136767. * @param parameters bunch of parameters used to filter geometry
  136768. */
  136769. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136770. /**
  136771. * Create a navigation mesh debug mesh
  136772. * @param scene is where the mesh will be added
  136773. * @returns debug display mesh
  136774. */
  136775. createDebugNavMesh(scene: Scene): Mesh;
  136776. /**
  136777. * Get a navigation mesh constrained position, closest to the parameter position
  136778. * @param position world position
  136779. * @returns the closest point to position constrained by the navigation mesh
  136780. */
  136781. getClosestPoint(position: Vector3): Vector3;
  136782. /**
  136783. * Get a navigation mesh constrained position, closest to the parameter position
  136784. * @param position world position
  136785. * @param result output the closest point to position constrained by the navigation mesh
  136786. */
  136787. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136788. /**
  136789. * Get a navigation mesh constrained position, within a particular radius
  136790. * @param position world position
  136791. * @param maxRadius the maximum distance to the constrained world position
  136792. * @returns the closest point to position constrained by the navigation mesh
  136793. */
  136794. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136795. /**
  136796. * Get a navigation mesh constrained position, within a particular radius
  136797. * @param position world position
  136798. * @param maxRadius the maximum distance to the constrained world position
  136799. * @param result output the closest point to position constrained by the navigation mesh
  136800. */
  136801. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136802. /**
  136803. * Compute the final position from a segment made of destination-position
  136804. * @param position world position
  136805. * @param destination world position
  136806. * @returns the resulting point along the navmesh
  136807. */
  136808. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136809. /**
  136810. * Compute the final position from a segment made of destination-position
  136811. * @param position world position
  136812. * @param destination world position
  136813. * @param result output the resulting point along the navmesh
  136814. */
  136815. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136816. /**
  136817. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136818. * @param start world position
  136819. * @param end world position
  136820. * @returns array containing world position composing the path
  136821. */
  136822. computePath(start: Vector3, end: Vector3): Vector3[];
  136823. /**
  136824. * If this plugin is supported
  136825. * @returns true if plugin is supported
  136826. */
  136827. isSupported(): boolean;
  136828. /**
  136829. * Create a new Crowd so you can add agents
  136830. * @param maxAgents the maximum agent count in the crowd
  136831. * @param maxAgentRadius the maximum radius an agent can have
  136832. * @param scene to attach the crowd to
  136833. * @returns the crowd you can add agents to
  136834. */
  136835. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136836. /**
  136837. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136838. * The queries will try to find a solution within those bounds
  136839. * default is (1,1,1)
  136840. * @param extent x,y,z value that define the extent around the queries point of reference
  136841. */
  136842. setDefaultQueryExtent(extent: Vector3): void;
  136843. /**
  136844. * Get the Bounding box extent specified by setDefaultQueryExtent
  136845. * @returns the box extent values
  136846. */
  136847. getDefaultQueryExtent(): Vector3;
  136848. /**
  136849. * build the navmesh from a previously saved state using getNavmeshData
  136850. * @param data the Uint8Array returned by getNavmeshData
  136851. */
  136852. buildFromNavmeshData(data: Uint8Array): void;
  136853. /**
  136854. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136855. * @returns data the Uint8Array that can be saved and reused
  136856. */
  136857. getNavmeshData(): Uint8Array;
  136858. /**
  136859. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136860. * @param result output the box extent values
  136861. */
  136862. getDefaultQueryExtentToRef(result: Vector3): void;
  136863. /**
  136864. * Release all resources
  136865. */
  136866. dispose(): void;
  136867. }
  136868. /**
  136869. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136870. */
  136871. export interface ICrowd {
  136872. /**
  136873. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136874. * You can attach anything to that node. The node position is updated in the scene update tick.
  136875. * @param pos world position that will be constrained by the navigation mesh
  136876. * @param parameters agent parameters
  136877. * @param transform hooked to the agent that will be update by the scene
  136878. * @returns agent index
  136879. */
  136880. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136881. /**
  136882. * Returns the agent position in world space
  136883. * @param index agent index returned by addAgent
  136884. * @returns world space position
  136885. */
  136886. getAgentPosition(index: number): Vector3;
  136887. /**
  136888. * Gets the agent position result in world space
  136889. * @param index agent index returned by addAgent
  136890. * @param result output world space position
  136891. */
  136892. getAgentPositionToRef(index: number, result: Vector3): void;
  136893. /**
  136894. * Gets the agent velocity in world space
  136895. * @param index agent index returned by addAgent
  136896. * @returns world space velocity
  136897. */
  136898. getAgentVelocity(index: number): Vector3;
  136899. /**
  136900. * Gets the agent velocity result in world space
  136901. * @param index agent index returned by addAgent
  136902. * @param result output world space velocity
  136903. */
  136904. getAgentVelocityToRef(index: number, result: Vector3): void;
  136905. /**
  136906. * remove a particular agent previously created
  136907. * @param index agent index returned by addAgent
  136908. */
  136909. removeAgent(index: number): void;
  136910. /**
  136911. * get the list of all agents attached to this crowd
  136912. * @returns list of agent indices
  136913. */
  136914. getAgents(): number[];
  136915. /**
  136916. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136917. * @param deltaTime in seconds
  136918. */
  136919. update(deltaTime: number): void;
  136920. /**
  136921. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136922. * @param index agent index returned by addAgent
  136923. * @param destination targeted world position
  136924. */
  136925. agentGoto(index: number, destination: Vector3): void;
  136926. /**
  136927. * Teleport the agent to a new position
  136928. * @param index agent index returned by addAgent
  136929. * @param destination targeted world position
  136930. */
  136931. agentTeleport(index: number, destination: Vector3): void;
  136932. /**
  136933. * Update agent parameters
  136934. * @param index agent index returned by addAgent
  136935. * @param parameters agent parameters
  136936. */
  136937. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136938. /**
  136939. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136940. * The queries will try to find a solution within those bounds
  136941. * default is (1,1,1)
  136942. * @param extent x,y,z value that define the extent around the queries point of reference
  136943. */
  136944. setDefaultQueryExtent(extent: Vector3): void;
  136945. /**
  136946. * Get the Bounding box extent specified by setDefaultQueryExtent
  136947. * @returns the box extent values
  136948. */
  136949. getDefaultQueryExtent(): Vector3;
  136950. /**
  136951. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136952. * @param result output the box extent values
  136953. */
  136954. getDefaultQueryExtentToRef(result: Vector3): void;
  136955. /**
  136956. * Release all resources
  136957. */
  136958. dispose(): void;
  136959. }
  136960. /**
  136961. * Configures an agent
  136962. */
  136963. export interface IAgentParameters {
  136964. /**
  136965. * Agent radius. [Limit: >= 0]
  136966. */
  136967. radius: number;
  136968. /**
  136969. * Agent height. [Limit: > 0]
  136970. */
  136971. height: number;
  136972. /**
  136973. * Maximum allowed acceleration. [Limit: >= 0]
  136974. */
  136975. maxAcceleration: number;
  136976. /**
  136977. * Maximum allowed speed. [Limit: >= 0]
  136978. */
  136979. maxSpeed: number;
  136980. /**
  136981. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136982. */
  136983. collisionQueryRange: number;
  136984. /**
  136985. * The path visibility optimization range. [Limit: > 0]
  136986. */
  136987. pathOptimizationRange: number;
  136988. /**
  136989. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136990. */
  136991. separationWeight: number;
  136992. }
  136993. /**
  136994. * Configures the navigation mesh creation
  136995. */
  136996. export interface INavMeshParameters {
  136997. /**
  136998. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136999. */
  137000. cs: number;
  137001. /**
  137002. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  137003. */
  137004. ch: number;
  137005. /**
  137006. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  137007. */
  137008. walkableSlopeAngle: number;
  137009. /**
  137010. * Minimum floor to 'ceiling' height that will still allow the floor area to
  137011. * be considered walkable. [Limit: >= 3] [Units: vx]
  137012. */
  137013. walkableHeight: number;
  137014. /**
  137015. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  137016. */
  137017. walkableClimb: number;
  137018. /**
  137019. * The distance to erode/shrink the walkable area of the heightfield away from
  137020. * obstructions. [Limit: >=0] [Units: vx]
  137021. */
  137022. walkableRadius: number;
  137023. /**
  137024. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137025. */
  137026. maxEdgeLen: number;
  137027. /**
  137028. * The maximum distance a simplfied contour's border edges should deviate
  137029. * the original raw contour. [Limit: >=0] [Units: vx]
  137030. */
  137031. maxSimplificationError: number;
  137032. /**
  137033. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137034. */
  137035. minRegionArea: number;
  137036. /**
  137037. * Any regions with a span count smaller than this value will, if possible,
  137038. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137039. */
  137040. mergeRegionArea: number;
  137041. /**
  137042. * The maximum number of vertices allowed for polygons generated during the
  137043. * contour to polygon conversion process. [Limit: >= 3]
  137044. */
  137045. maxVertsPerPoly: number;
  137046. /**
  137047. * Sets the sampling distance to use when generating the detail mesh.
  137048. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137049. */
  137050. detailSampleDist: number;
  137051. /**
  137052. * The maximum distance the detail mesh surface should deviate from heightfield
  137053. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137054. */
  137055. detailSampleMaxError: number;
  137056. }
  137057. }
  137058. declare module BABYLON {
  137059. /**
  137060. * RecastJS navigation plugin
  137061. */
  137062. export class RecastJSPlugin implements INavigationEnginePlugin {
  137063. /**
  137064. * Reference to the Recast library
  137065. */
  137066. bjsRECAST: any;
  137067. /**
  137068. * plugin name
  137069. */
  137070. name: string;
  137071. /**
  137072. * the first navmesh created. We might extend this to support multiple navmeshes
  137073. */
  137074. navMesh: any;
  137075. /**
  137076. * Initializes the recastJS plugin
  137077. * @param recastInjection can be used to inject your own recast reference
  137078. */
  137079. constructor(recastInjection?: any);
  137080. /**
  137081. * Creates a navigation mesh
  137082. * @param meshes array of all the geometry used to compute the navigatio mesh
  137083. * @param parameters bunch of parameters used to filter geometry
  137084. */
  137085. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137086. /**
  137087. * Create a navigation mesh debug mesh
  137088. * @param scene is where the mesh will be added
  137089. * @returns debug display mesh
  137090. */
  137091. createDebugNavMesh(scene: Scene): Mesh;
  137092. /**
  137093. * Get a navigation mesh constrained position, closest to the parameter position
  137094. * @param position world position
  137095. * @returns the closest point to position constrained by the navigation mesh
  137096. */
  137097. getClosestPoint(position: Vector3): Vector3;
  137098. /**
  137099. * Get a navigation mesh constrained position, closest to the parameter position
  137100. * @param position world position
  137101. * @param result output the closest point to position constrained by the navigation mesh
  137102. */
  137103. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137104. /**
  137105. * Get a navigation mesh constrained position, within a particular radius
  137106. * @param position world position
  137107. * @param maxRadius the maximum distance to the constrained world position
  137108. * @returns the closest point to position constrained by the navigation mesh
  137109. */
  137110. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137111. /**
  137112. * Get a navigation mesh constrained position, within a particular radius
  137113. * @param position world position
  137114. * @param maxRadius the maximum distance to the constrained world position
  137115. * @param result output the closest point to position constrained by the navigation mesh
  137116. */
  137117. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137118. /**
  137119. * Compute the final position from a segment made of destination-position
  137120. * @param position world position
  137121. * @param destination world position
  137122. * @returns the resulting point along the navmesh
  137123. */
  137124. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137125. /**
  137126. * Compute the final position from a segment made of destination-position
  137127. * @param position world position
  137128. * @param destination world position
  137129. * @param result output the resulting point along the navmesh
  137130. */
  137131. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137132. /**
  137133. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137134. * @param start world position
  137135. * @param end world position
  137136. * @returns array containing world position composing the path
  137137. */
  137138. computePath(start: Vector3, end: Vector3): Vector3[];
  137139. /**
  137140. * Create a new Crowd so you can add agents
  137141. * @param maxAgents the maximum agent count in the crowd
  137142. * @param maxAgentRadius the maximum radius an agent can have
  137143. * @param scene to attach the crowd to
  137144. * @returns the crowd you can add agents to
  137145. */
  137146. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137147. /**
  137148. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137149. * The queries will try to find a solution within those bounds
  137150. * default is (1,1,1)
  137151. * @param extent x,y,z value that define the extent around the queries point of reference
  137152. */
  137153. setDefaultQueryExtent(extent: Vector3): void;
  137154. /**
  137155. * Get the Bounding box extent specified by setDefaultQueryExtent
  137156. * @returns the box extent values
  137157. */
  137158. getDefaultQueryExtent(): Vector3;
  137159. /**
  137160. * build the navmesh from a previously saved state using getNavmeshData
  137161. * @param data the Uint8Array returned by getNavmeshData
  137162. */
  137163. buildFromNavmeshData(data: Uint8Array): void;
  137164. /**
  137165. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137166. * @returns data the Uint8Array that can be saved and reused
  137167. */
  137168. getNavmeshData(): Uint8Array;
  137169. /**
  137170. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137171. * @param result output the box extent values
  137172. */
  137173. getDefaultQueryExtentToRef(result: Vector3): void;
  137174. /**
  137175. * Disposes
  137176. */
  137177. dispose(): void;
  137178. /**
  137179. * If this plugin is supported
  137180. * @returns true if plugin is supported
  137181. */
  137182. isSupported(): boolean;
  137183. }
  137184. /**
  137185. * Recast detour crowd implementation
  137186. */
  137187. export class RecastJSCrowd implements ICrowd {
  137188. /**
  137189. * Recast/detour plugin
  137190. */
  137191. bjsRECASTPlugin: RecastJSPlugin;
  137192. /**
  137193. * Link to the detour crowd
  137194. */
  137195. recastCrowd: any;
  137196. /**
  137197. * One transform per agent
  137198. */
  137199. transforms: TransformNode[];
  137200. /**
  137201. * All agents created
  137202. */
  137203. agents: number[];
  137204. /**
  137205. * Link to the scene is kept to unregister the crowd from the scene
  137206. */
  137207. private _scene;
  137208. /**
  137209. * Observer for crowd updates
  137210. */
  137211. private _onBeforeAnimationsObserver;
  137212. /**
  137213. * Constructor
  137214. * @param plugin recastJS plugin
  137215. * @param maxAgents the maximum agent count in the crowd
  137216. * @param maxAgentRadius the maximum radius an agent can have
  137217. * @param scene to attach the crowd to
  137218. * @returns the crowd you can add agents to
  137219. */
  137220. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137221. /**
  137222. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137223. * You can attach anything to that node. The node position is updated in the scene update tick.
  137224. * @param pos world position that will be constrained by the navigation mesh
  137225. * @param parameters agent parameters
  137226. * @param transform hooked to the agent that will be update by the scene
  137227. * @returns agent index
  137228. */
  137229. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137230. /**
  137231. * Returns the agent position in world space
  137232. * @param index agent index returned by addAgent
  137233. * @returns world space position
  137234. */
  137235. getAgentPosition(index: number): Vector3;
  137236. /**
  137237. * Returns the agent position result in world space
  137238. * @param index agent index returned by addAgent
  137239. * @param result output world space position
  137240. */
  137241. getAgentPositionToRef(index: number, result: Vector3): void;
  137242. /**
  137243. * Returns the agent velocity in world space
  137244. * @param index agent index returned by addAgent
  137245. * @returns world space velocity
  137246. */
  137247. getAgentVelocity(index: number): Vector3;
  137248. /**
  137249. * Returns the agent velocity result in world space
  137250. * @param index agent index returned by addAgent
  137251. * @param result output world space velocity
  137252. */
  137253. getAgentVelocityToRef(index: number, result: Vector3): void;
  137254. /**
  137255. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137256. * @param index agent index returned by addAgent
  137257. * @param destination targeted world position
  137258. */
  137259. agentGoto(index: number, destination: Vector3): void;
  137260. /**
  137261. * Teleport the agent to a new position
  137262. * @param index agent index returned by addAgent
  137263. * @param destination targeted world position
  137264. */
  137265. agentTeleport(index: number, destination: Vector3): void;
  137266. /**
  137267. * Update agent parameters
  137268. * @param index agent index returned by addAgent
  137269. * @param parameters agent parameters
  137270. */
  137271. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137272. /**
  137273. * remove a particular agent previously created
  137274. * @param index agent index returned by addAgent
  137275. */
  137276. removeAgent(index: number): void;
  137277. /**
  137278. * get the list of all agents attached to this crowd
  137279. * @returns list of agent indices
  137280. */
  137281. getAgents(): number[];
  137282. /**
  137283. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137284. * @param deltaTime in seconds
  137285. */
  137286. update(deltaTime: number): void;
  137287. /**
  137288. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137289. * The queries will try to find a solution within those bounds
  137290. * default is (1,1,1)
  137291. * @param extent x,y,z value that define the extent around the queries point of reference
  137292. */
  137293. setDefaultQueryExtent(extent: Vector3): void;
  137294. /**
  137295. * Get the Bounding box extent specified by setDefaultQueryExtent
  137296. * @returns the box extent values
  137297. */
  137298. getDefaultQueryExtent(): Vector3;
  137299. /**
  137300. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137301. * @param result output the box extent values
  137302. */
  137303. getDefaultQueryExtentToRef(result: Vector3): void;
  137304. /**
  137305. * Release all resources
  137306. */
  137307. dispose(): void;
  137308. }
  137309. }
  137310. declare module BABYLON {
  137311. /**
  137312. * Class used to enable access to IndexedDB
  137313. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137314. */
  137315. export class Database implements IOfflineProvider {
  137316. private _callbackManifestChecked;
  137317. private _currentSceneUrl;
  137318. private _db;
  137319. private _enableSceneOffline;
  137320. private _enableTexturesOffline;
  137321. private _manifestVersionFound;
  137322. private _mustUpdateRessources;
  137323. private _hasReachedQuota;
  137324. private _isSupported;
  137325. private _idbFactory;
  137326. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137327. private static IsUASupportingBlobStorage;
  137328. /**
  137329. * Gets a boolean indicating if Database storate is enabled (off by default)
  137330. */
  137331. static IDBStorageEnabled: boolean;
  137332. /**
  137333. * Gets a boolean indicating if scene must be saved in the database
  137334. */
  137335. get enableSceneOffline(): boolean;
  137336. /**
  137337. * Gets a boolean indicating if textures must be saved in the database
  137338. */
  137339. get enableTexturesOffline(): boolean;
  137340. /**
  137341. * Creates a new Database
  137342. * @param urlToScene defines the url to load the scene
  137343. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137344. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137345. */
  137346. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137347. private static _ParseURL;
  137348. private static _ReturnFullUrlLocation;
  137349. private _checkManifestFile;
  137350. /**
  137351. * Open the database and make it available
  137352. * @param successCallback defines the callback to call on success
  137353. * @param errorCallback defines the callback to call on error
  137354. */
  137355. open(successCallback: () => void, errorCallback: () => void): void;
  137356. /**
  137357. * Loads an image from the database
  137358. * @param url defines the url to load from
  137359. * @param image defines the target DOM image
  137360. */
  137361. loadImage(url: string, image: HTMLImageElement): void;
  137362. private _loadImageFromDBAsync;
  137363. private _saveImageIntoDBAsync;
  137364. private _checkVersionFromDB;
  137365. private _loadVersionFromDBAsync;
  137366. private _saveVersionIntoDBAsync;
  137367. /**
  137368. * Loads a file from database
  137369. * @param url defines the URL to load from
  137370. * @param sceneLoaded defines a callback to call on success
  137371. * @param progressCallBack defines a callback to call when progress changed
  137372. * @param errorCallback defines a callback to call on error
  137373. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137374. */
  137375. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137376. private _loadFileAsync;
  137377. private _saveFileAsync;
  137378. /**
  137379. * Validates if xhr data is correct
  137380. * @param xhr defines the request to validate
  137381. * @param dataType defines the expected data type
  137382. * @returns true if data is correct
  137383. */
  137384. private static _ValidateXHRData;
  137385. }
  137386. }
  137387. declare module BABYLON {
  137388. /** @hidden */
  137389. export var gpuUpdateParticlesPixelShader: {
  137390. name: string;
  137391. shader: string;
  137392. };
  137393. }
  137394. declare module BABYLON {
  137395. /** @hidden */
  137396. export var gpuUpdateParticlesVertexShader: {
  137397. name: string;
  137398. shader: string;
  137399. };
  137400. }
  137401. declare module BABYLON {
  137402. /** @hidden */
  137403. export var clipPlaneFragmentDeclaration2: {
  137404. name: string;
  137405. shader: string;
  137406. };
  137407. }
  137408. declare module BABYLON {
  137409. /** @hidden */
  137410. export var gpuRenderParticlesPixelShader: {
  137411. name: string;
  137412. shader: string;
  137413. };
  137414. }
  137415. declare module BABYLON {
  137416. /** @hidden */
  137417. export var clipPlaneVertexDeclaration2: {
  137418. name: string;
  137419. shader: string;
  137420. };
  137421. }
  137422. declare module BABYLON {
  137423. /** @hidden */
  137424. export var gpuRenderParticlesVertexShader: {
  137425. name: string;
  137426. shader: string;
  137427. };
  137428. }
  137429. declare module BABYLON {
  137430. /**
  137431. * This represents a GPU particle system in Babylon
  137432. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137433. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137434. */
  137435. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137436. /**
  137437. * The layer mask we are rendering the particles through.
  137438. */
  137439. layerMask: number;
  137440. private _capacity;
  137441. private _activeCount;
  137442. private _currentActiveCount;
  137443. private _accumulatedCount;
  137444. private _renderEffect;
  137445. private _updateEffect;
  137446. private _buffer0;
  137447. private _buffer1;
  137448. private _spriteBuffer;
  137449. private _updateVAO;
  137450. private _renderVAO;
  137451. private _targetIndex;
  137452. private _sourceBuffer;
  137453. private _targetBuffer;
  137454. private _engine;
  137455. private _currentRenderId;
  137456. private _started;
  137457. private _stopped;
  137458. private _timeDelta;
  137459. private _randomTexture;
  137460. private _randomTexture2;
  137461. private _attributesStrideSize;
  137462. private _updateEffectOptions;
  137463. private _randomTextureSize;
  137464. private _actualFrame;
  137465. private readonly _rawTextureWidth;
  137466. /**
  137467. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137468. */
  137469. static get IsSupported(): boolean;
  137470. /**
  137471. * An event triggered when the system is disposed.
  137472. */
  137473. onDisposeObservable: Observable<GPUParticleSystem>;
  137474. /**
  137475. * Gets the maximum number of particles active at the same time.
  137476. * @returns The max number of active particles.
  137477. */
  137478. getCapacity(): number;
  137479. /**
  137480. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137481. * to override the particles.
  137482. */
  137483. forceDepthWrite: boolean;
  137484. /**
  137485. * Gets or set the number of active particles
  137486. */
  137487. get activeParticleCount(): number;
  137488. set activeParticleCount(value: number);
  137489. private _preWarmDone;
  137490. /**
  137491. * Specifies if the particles are updated in emitter local space or world space.
  137492. * This is always false for GPU particles
  137493. */
  137494. get isLocal(): boolean;
  137495. set isLocal(value: boolean);
  137496. /**
  137497. * Is this system ready to be used/rendered
  137498. * @return true if the system is ready
  137499. */
  137500. isReady(): boolean;
  137501. /**
  137502. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137503. * @returns True if it has been started, otherwise false.
  137504. */
  137505. isStarted(): boolean;
  137506. /**
  137507. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137508. * @returns True if it has been stopped, otherwise false.
  137509. */
  137510. isStopped(): boolean;
  137511. /**
  137512. * Gets a boolean indicating that the system is stopping
  137513. * @returns true if the system is currently stopping
  137514. */
  137515. isStopping(): boolean;
  137516. /**
  137517. * Gets the number of particles active at the same time.
  137518. * @returns The number of active particles.
  137519. */
  137520. getActiveCount(): number;
  137521. /**
  137522. * Starts the particle system and begins to emit
  137523. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137524. */
  137525. start(delay?: number): void;
  137526. /**
  137527. * Stops the particle system.
  137528. */
  137529. stop(): void;
  137530. /**
  137531. * Remove all active particles
  137532. */
  137533. reset(): void;
  137534. /**
  137535. * Returns the string "GPUParticleSystem"
  137536. * @returns a string containing the class name
  137537. */
  137538. getClassName(): string;
  137539. private _colorGradientsTexture;
  137540. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137541. /**
  137542. * Adds a new color gradient
  137543. * @param gradient defines the gradient to use (between 0 and 1)
  137544. * @param color1 defines the color to affect to the specified gradient
  137545. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137546. * @returns the current particle system
  137547. */
  137548. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137549. private _refreshColorGradient;
  137550. /** Force the system to rebuild all gradients that need to be resync */
  137551. forceRefreshGradients(): void;
  137552. /**
  137553. * Remove a specific color gradient
  137554. * @param gradient defines the gradient to remove
  137555. * @returns the current particle system
  137556. */
  137557. removeColorGradient(gradient: number): GPUParticleSystem;
  137558. private _angularSpeedGradientsTexture;
  137559. private _sizeGradientsTexture;
  137560. private _velocityGradientsTexture;
  137561. private _limitVelocityGradientsTexture;
  137562. private _dragGradientsTexture;
  137563. private _addFactorGradient;
  137564. /**
  137565. * Adds a new size gradient
  137566. * @param gradient defines the gradient to use (between 0 and 1)
  137567. * @param factor defines the size factor to affect to the specified gradient
  137568. * @returns the current particle system
  137569. */
  137570. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137571. /**
  137572. * Remove a specific size gradient
  137573. * @param gradient defines the gradient to remove
  137574. * @returns the current particle system
  137575. */
  137576. removeSizeGradient(gradient: number): GPUParticleSystem;
  137577. private _refreshFactorGradient;
  137578. /**
  137579. * Adds a new angular speed gradient
  137580. * @param gradient defines the gradient to use (between 0 and 1)
  137581. * @param factor defines the angular speed to affect to the specified gradient
  137582. * @returns the current particle system
  137583. */
  137584. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137585. /**
  137586. * Remove a specific angular speed gradient
  137587. * @param gradient defines the gradient to remove
  137588. * @returns the current particle system
  137589. */
  137590. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137591. /**
  137592. * Adds a new velocity gradient
  137593. * @param gradient defines the gradient to use (between 0 and 1)
  137594. * @param factor defines the velocity to affect to the specified gradient
  137595. * @returns the current particle system
  137596. */
  137597. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137598. /**
  137599. * Remove a specific velocity gradient
  137600. * @param gradient defines the gradient to remove
  137601. * @returns the current particle system
  137602. */
  137603. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137604. /**
  137605. * Adds a new limit velocity gradient
  137606. * @param gradient defines the gradient to use (between 0 and 1)
  137607. * @param factor defines the limit velocity value to affect to the specified gradient
  137608. * @returns the current particle system
  137609. */
  137610. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137611. /**
  137612. * Remove a specific limit velocity gradient
  137613. * @param gradient defines the gradient to remove
  137614. * @returns the current particle system
  137615. */
  137616. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137617. /**
  137618. * Adds a new drag gradient
  137619. * @param gradient defines the gradient to use (between 0 and 1)
  137620. * @param factor defines the drag value to affect to the specified gradient
  137621. * @returns the current particle system
  137622. */
  137623. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137624. /**
  137625. * Remove a specific drag gradient
  137626. * @param gradient defines the gradient to remove
  137627. * @returns the current particle system
  137628. */
  137629. removeDragGradient(gradient: number): GPUParticleSystem;
  137630. /**
  137631. * Not supported by GPUParticleSystem
  137632. * @param gradient defines the gradient to use (between 0 and 1)
  137633. * @param factor defines the emit rate value to affect to the specified gradient
  137634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137635. * @returns the current particle system
  137636. */
  137637. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137638. /**
  137639. * Not supported by GPUParticleSystem
  137640. * @param gradient defines the gradient to remove
  137641. * @returns the current particle system
  137642. */
  137643. removeEmitRateGradient(gradient: number): IParticleSystem;
  137644. /**
  137645. * Not supported by GPUParticleSystem
  137646. * @param gradient defines the gradient to use (between 0 and 1)
  137647. * @param factor defines the start size value to affect to the specified gradient
  137648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137649. * @returns the current particle system
  137650. */
  137651. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137652. /**
  137653. * Not supported by GPUParticleSystem
  137654. * @param gradient defines the gradient to remove
  137655. * @returns the current particle system
  137656. */
  137657. removeStartSizeGradient(gradient: number): IParticleSystem;
  137658. /**
  137659. * Not supported by GPUParticleSystem
  137660. * @param gradient defines the gradient to use (between 0 and 1)
  137661. * @param min defines the color remap minimal range
  137662. * @param max defines the color remap maximal range
  137663. * @returns the current particle system
  137664. */
  137665. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137666. /**
  137667. * Not supported by GPUParticleSystem
  137668. * @param gradient defines the gradient to remove
  137669. * @returns the current particle system
  137670. */
  137671. removeColorRemapGradient(): IParticleSystem;
  137672. /**
  137673. * Not supported by GPUParticleSystem
  137674. * @param gradient defines the gradient to use (between 0 and 1)
  137675. * @param min defines the alpha remap minimal range
  137676. * @param max defines the alpha remap maximal range
  137677. * @returns the current particle system
  137678. */
  137679. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137680. /**
  137681. * Not supported by GPUParticleSystem
  137682. * @param gradient defines the gradient to remove
  137683. * @returns the current particle system
  137684. */
  137685. removeAlphaRemapGradient(): IParticleSystem;
  137686. /**
  137687. * Not supported by GPUParticleSystem
  137688. * @param gradient defines the gradient to use (between 0 and 1)
  137689. * @param color defines the color to affect to the specified gradient
  137690. * @returns the current particle system
  137691. */
  137692. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137693. /**
  137694. * Not supported by GPUParticleSystem
  137695. * @param gradient defines the gradient to remove
  137696. * @returns the current particle system
  137697. */
  137698. removeRampGradient(): IParticleSystem;
  137699. /**
  137700. * Not supported by GPUParticleSystem
  137701. * @returns the list of ramp gradients
  137702. */
  137703. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137704. /**
  137705. * Not supported by GPUParticleSystem
  137706. * Gets or sets a boolean indicating that ramp gradients must be used
  137707. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137708. */
  137709. get useRampGradients(): boolean;
  137710. set useRampGradients(value: boolean);
  137711. /**
  137712. * Not supported by GPUParticleSystem
  137713. * @param gradient defines the gradient to use (between 0 and 1)
  137714. * @param factor defines the life time factor to affect to the specified gradient
  137715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137716. * @returns the current particle system
  137717. */
  137718. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137719. /**
  137720. * Not supported by GPUParticleSystem
  137721. * @param gradient defines the gradient to remove
  137722. * @returns the current particle system
  137723. */
  137724. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137725. /**
  137726. * Instantiates a GPU particle system.
  137727. * 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.
  137728. * @param name The name of the particle system
  137729. * @param options The options used to create the system
  137730. * @param scene The scene the particle system belongs to
  137731. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137732. */
  137733. constructor(name: string, options: Partial<{
  137734. capacity: number;
  137735. randomTextureSize: number;
  137736. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137737. protected _reset(): void;
  137738. private _createUpdateVAO;
  137739. private _createRenderVAO;
  137740. private _initialize;
  137741. /** @hidden */
  137742. _recreateUpdateEffect(): void;
  137743. /** @hidden */
  137744. _recreateRenderEffect(): void;
  137745. /**
  137746. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137747. * @param preWarm defines if we are in the pre-warmimg phase
  137748. */
  137749. animate(preWarm?: boolean): void;
  137750. private _createFactorGradientTexture;
  137751. private _createSizeGradientTexture;
  137752. private _createAngularSpeedGradientTexture;
  137753. private _createVelocityGradientTexture;
  137754. private _createLimitVelocityGradientTexture;
  137755. private _createDragGradientTexture;
  137756. private _createColorGradientTexture;
  137757. /**
  137758. * Renders the particle system in its current state
  137759. * @param preWarm defines if the system should only update the particles but not render them
  137760. * @returns the current number of particles
  137761. */
  137762. render(preWarm?: boolean): number;
  137763. /**
  137764. * Rebuilds the particle system
  137765. */
  137766. rebuild(): void;
  137767. private _releaseBuffers;
  137768. private _releaseVAOs;
  137769. /**
  137770. * Disposes the particle system and free the associated resources
  137771. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137772. */
  137773. dispose(disposeTexture?: boolean): void;
  137774. /**
  137775. * Clones the particle system.
  137776. * @param name The name of the cloned object
  137777. * @param newEmitter The new emitter to use
  137778. * @returns the cloned particle system
  137779. */
  137780. clone(name: string, newEmitter: any): GPUParticleSystem;
  137781. /**
  137782. * Serializes the particle system to a JSON object
  137783. * @param serializeTexture defines if the texture must be serialized as well
  137784. * @returns the JSON object
  137785. */
  137786. serialize(serializeTexture?: boolean): any;
  137787. /**
  137788. * Parses a JSON object to create a GPU particle system.
  137789. * @param parsedParticleSystem The JSON object to parse
  137790. * @param scene The scene to create the particle system in
  137791. * @param rootUrl The root url to use to load external dependencies like texture
  137792. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137793. * @returns the parsed GPU particle system
  137794. */
  137795. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137796. }
  137797. }
  137798. declare module BABYLON {
  137799. /**
  137800. * Represents a set of particle systems working together to create a specific effect
  137801. */
  137802. export class ParticleSystemSet implements IDisposable {
  137803. /**
  137804. * Gets or sets base Assets URL
  137805. */
  137806. static BaseAssetsUrl: string;
  137807. private _emitterCreationOptions;
  137808. private _emitterNode;
  137809. /**
  137810. * Gets the particle system list
  137811. */
  137812. systems: IParticleSystem[];
  137813. /**
  137814. * Gets the emitter node used with this set
  137815. */
  137816. get emitterNode(): Nullable<TransformNode>;
  137817. /**
  137818. * Creates a new emitter mesh as a sphere
  137819. * @param options defines the options used to create the sphere
  137820. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137821. * @param scene defines the hosting scene
  137822. */
  137823. setEmitterAsSphere(options: {
  137824. diameter: number;
  137825. segments: number;
  137826. color: Color3;
  137827. }, renderingGroupId: number, scene: Scene): void;
  137828. /**
  137829. * Starts all particle systems of the set
  137830. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137831. */
  137832. start(emitter?: AbstractMesh): void;
  137833. /**
  137834. * Release all associated resources
  137835. */
  137836. dispose(): void;
  137837. /**
  137838. * Serialize the set into a JSON compatible object
  137839. * @param serializeTexture defines if the texture must be serialized as well
  137840. * @returns a JSON compatible representation of the set
  137841. */
  137842. serialize(serializeTexture?: boolean): any;
  137843. /**
  137844. * Parse a new ParticleSystemSet from a serialized source
  137845. * @param data defines a JSON compatible representation of the set
  137846. * @param scene defines the hosting scene
  137847. * @param gpu defines if we want GPU particles or CPU particles
  137848. * @returns a new ParticleSystemSet
  137849. */
  137850. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137851. }
  137852. }
  137853. declare module BABYLON {
  137854. /**
  137855. * This class is made for on one-liner static method to help creating particle system set.
  137856. */
  137857. export class ParticleHelper {
  137858. /**
  137859. * Gets or sets base Assets URL
  137860. */
  137861. static BaseAssetsUrl: string;
  137862. /** Define the Url to load snippets */
  137863. static SnippetUrl: string;
  137864. /**
  137865. * Create a default particle system that you can tweak
  137866. * @param emitter defines the emitter to use
  137867. * @param capacity defines the system capacity (default is 500 particles)
  137868. * @param scene defines the hosting scene
  137869. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137870. * @returns the new Particle system
  137871. */
  137872. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137873. /**
  137874. * This is the main static method (one-liner) of this helper to create different particle systems
  137875. * @param type This string represents the type to the particle system to create
  137876. * @param scene The scene where the particle system should live
  137877. * @param gpu If the system will use gpu
  137878. * @returns the ParticleSystemSet created
  137879. */
  137880. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137881. /**
  137882. * Static function used to export a particle system to a ParticleSystemSet variable.
  137883. * Please note that the emitter shape is not exported
  137884. * @param systems defines the particle systems to export
  137885. * @returns the created particle system set
  137886. */
  137887. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137888. /**
  137889. * Creates a particle system from a snippet saved in a remote file
  137890. * @param name defines the name of the particle system to create
  137891. * @param url defines the url to load from
  137892. * @param scene defines the hosting scene
  137893. * @param gpu If the system will use gpu
  137894. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137895. * @returns a promise that will resolve to the new particle system
  137896. */
  137897. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137898. /**
  137899. * Creates a particle system from a snippet saved by the particle system editor
  137900. * @param snippetId defines the snippet to load
  137901. * @param scene defines the hosting scene
  137902. * @param gpu If the system will use gpu
  137903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137904. * @returns a promise that will resolve to the new particle system
  137905. */
  137906. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137907. }
  137908. }
  137909. declare module BABYLON {
  137910. interface Engine {
  137911. /**
  137912. * Create an effect to use with particle systems.
  137913. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137914. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137915. * @param uniformsNames defines a list of attribute names
  137916. * @param samplers defines an array of string used to represent textures
  137917. * @param defines defines the string containing the defines to use to compile the shaders
  137918. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137919. * @param onCompiled defines a function to call when the effect creation is successful
  137920. * @param onError defines a function to call when the effect creation has failed
  137921. * @returns the new Effect
  137922. */
  137923. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137924. }
  137925. interface Mesh {
  137926. /**
  137927. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137928. * @returns an array of IParticleSystem
  137929. */
  137930. getEmittedParticleSystems(): IParticleSystem[];
  137931. /**
  137932. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137933. * @returns an array of IParticleSystem
  137934. */
  137935. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137936. }
  137937. /**
  137938. * @hidden
  137939. */
  137940. export var _IDoNeedToBeInTheBuild: number;
  137941. }
  137942. declare module BABYLON {
  137943. /** Defines the 4 color options */
  137944. export enum PointColor {
  137945. /** color value */
  137946. Color = 2,
  137947. /** uv value */
  137948. UV = 1,
  137949. /** random value */
  137950. Random = 0,
  137951. /** stated value */
  137952. Stated = 3
  137953. }
  137954. /**
  137955. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137956. * 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.
  137957. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137958. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137959. *
  137960. * Full documentation here : TO BE ENTERED
  137961. */
  137962. export class PointsCloudSystem implements IDisposable {
  137963. /**
  137964. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137965. * Example : var p = SPS.particles[i];
  137966. */
  137967. particles: CloudPoint[];
  137968. /**
  137969. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137970. */
  137971. nbParticles: number;
  137972. /**
  137973. * This a counter for your own usage. It's not set by any SPS functions.
  137974. */
  137975. counter: number;
  137976. /**
  137977. * The PCS name. This name is also given to the underlying mesh.
  137978. */
  137979. name: string;
  137980. /**
  137981. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137982. */
  137983. mesh: Mesh;
  137984. /**
  137985. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137986. * Please read :
  137987. */
  137988. vars: any;
  137989. /**
  137990. * @hidden
  137991. */
  137992. _size: number;
  137993. private _scene;
  137994. private _promises;
  137995. private _positions;
  137996. private _indices;
  137997. private _normals;
  137998. private _colors;
  137999. private _uvs;
  138000. private _indices32;
  138001. private _positions32;
  138002. private _colors32;
  138003. private _uvs32;
  138004. private _updatable;
  138005. private _isVisibilityBoxLocked;
  138006. private _alwaysVisible;
  138007. private _groups;
  138008. private _groupCounter;
  138009. private _computeParticleColor;
  138010. private _computeParticleTexture;
  138011. private _computeParticleRotation;
  138012. private _computeBoundingBox;
  138013. private _isReady;
  138014. /**
  138015. * Creates a PCS (Points Cloud System) object
  138016. * @param name (String) is the PCS name, this will be the underlying mesh name
  138017. * @param pointSize (number) is the size for each point
  138018. * @param scene (Scene) is the scene in which the PCS is added
  138019. * @param options defines the options of the PCS e.g.
  138020. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138021. */
  138022. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138023. updatable?: boolean;
  138024. });
  138025. /**
  138026. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138027. * If no points were added to the PCS, the returned mesh is just a single point.
  138028. * @returns a promise for the created mesh
  138029. */
  138030. buildMeshAsync(): Promise<Mesh>;
  138031. /**
  138032. * @hidden
  138033. */
  138034. private _buildMesh;
  138035. private _addParticle;
  138036. private _randomUnitVector;
  138037. private _getColorIndicesForCoord;
  138038. private _setPointsColorOrUV;
  138039. private _colorFromTexture;
  138040. private _calculateDensity;
  138041. /**
  138042. * Adds points to the PCS in random positions within a unit sphere
  138043. * @param nb (positive integer) the number of particles to be created from this model
  138044. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138045. * @returns the number of groups in the system
  138046. */
  138047. addPoints(nb: number, pointFunction?: any): number;
  138048. /**
  138049. * Adds points to the PCS from the surface of the model shape
  138050. * @param mesh is any Mesh object that will be used as a surface model for the points
  138051. * @param nb (positive integer) the number of particles to be created from this model
  138052. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138053. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138054. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138055. * @returns the number of groups in the system
  138056. */
  138057. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138058. /**
  138059. * Adds points to the PCS inside the model shape
  138060. * @param mesh is any Mesh object that will be used as a surface model for the points
  138061. * @param nb (positive integer) the number of particles to be created from this model
  138062. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138063. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138064. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138065. * @returns the number of groups in the system
  138066. */
  138067. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138068. /**
  138069. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138070. * This method calls `updateParticle()` for each particle of the SPS.
  138071. * For an animated SPS, it is usually called within the render loop.
  138072. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138073. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138074. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138075. * @returns the PCS.
  138076. */
  138077. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138078. /**
  138079. * Disposes the PCS.
  138080. */
  138081. dispose(): void;
  138082. /**
  138083. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138084. * doc :
  138085. * @returns the PCS.
  138086. */
  138087. refreshVisibleSize(): PointsCloudSystem;
  138088. /**
  138089. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138090. * @param size the size (float) of the visibility box
  138091. * note : this doesn't lock the PCS mesh bounding box.
  138092. * doc :
  138093. */
  138094. setVisibilityBox(size: number): void;
  138095. /**
  138096. * Gets whether the PCS is always visible or not
  138097. * doc :
  138098. */
  138099. get isAlwaysVisible(): boolean;
  138100. /**
  138101. * Sets the PCS as always visible or not
  138102. * doc :
  138103. */
  138104. set isAlwaysVisible(val: boolean);
  138105. /**
  138106. * Tells to `setParticles()` to compute the particle rotations or not
  138107. * Default value : false. The PCS is faster when it's set to false
  138108. * Note : particle rotations are only applied to parent particles
  138109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138110. */
  138111. set computeParticleRotation(val: boolean);
  138112. /**
  138113. * Tells to `setParticles()` to compute the particle colors or not.
  138114. * Default value : true. The PCS is faster when it's set to false.
  138115. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138116. */
  138117. set computeParticleColor(val: boolean);
  138118. set computeParticleTexture(val: boolean);
  138119. /**
  138120. * Gets if `setParticles()` computes the particle colors or not.
  138121. * Default value : false. The PCS is faster when it's set to false.
  138122. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138123. */
  138124. get computeParticleColor(): boolean;
  138125. /**
  138126. * Gets if `setParticles()` computes the particle textures or not.
  138127. * Default value : false. The PCS is faster when it's set to false.
  138128. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138129. */
  138130. get computeParticleTexture(): boolean;
  138131. /**
  138132. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138133. */
  138134. set computeBoundingBox(val: boolean);
  138135. /**
  138136. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138137. */
  138138. get computeBoundingBox(): boolean;
  138139. /**
  138140. * This function does nothing. It may be overwritten to set all the particle first values.
  138141. * The PCS doesn't call this function, you may have to call it by your own.
  138142. * doc :
  138143. */
  138144. initParticles(): void;
  138145. /**
  138146. * This function does nothing. It may be overwritten to recycle a particle
  138147. * The PCS doesn't call this function, you can to call it
  138148. * doc :
  138149. * @param particle The particle to recycle
  138150. * @returns the recycled particle
  138151. */
  138152. recycleParticle(particle: CloudPoint): CloudPoint;
  138153. /**
  138154. * Updates a particle : this function should be overwritten by the user.
  138155. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138156. * doc :
  138157. * @example : just set a particle position or velocity and recycle conditions
  138158. * @param particle The particle to update
  138159. * @returns the updated particle
  138160. */
  138161. updateParticle(particle: CloudPoint): CloudPoint;
  138162. /**
  138163. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138164. * This does nothing and may be overwritten by the user.
  138165. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138166. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138167. * @param update the boolean update value actually passed to setParticles()
  138168. */
  138169. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138170. /**
  138171. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138172. * This will be passed three parameters.
  138173. * This does nothing and may be overwritten by the user.
  138174. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138175. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138176. * @param update the boolean update value actually passed to setParticles()
  138177. */
  138178. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138179. }
  138180. }
  138181. declare module BABYLON {
  138182. /**
  138183. * Represents one particle of a points cloud system.
  138184. */
  138185. export class CloudPoint {
  138186. /**
  138187. * particle global index
  138188. */
  138189. idx: number;
  138190. /**
  138191. * The color of the particle
  138192. */
  138193. color: Nullable<Color4>;
  138194. /**
  138195. * The world space position of the particle.
  138196. */
  138197. position: Vector3;
  138198. /**
  138199. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138200. */
  138201. rotation: Vector3;
  138202. /**
  138203. * The world space rotation quaternion of the particle.
  138204. */
  138205. rotationQuaternion: Nullable<Quaternion>;
  138206. /**
  138207. * The uv of the particle.
  138208. */
  138209. uv: Nullable<Vector2>;
  138210. /**
  138211. * The current speed of the particle.
  138212. */
  138213. velocity: Vector3;
  138214. /**
  138215. * The pivot point in the particle local space.
  138216. */
  138217. pivot: Vector3;
  138218. /**
  138219. * Must the particle be translated from its pivot point in its local space ?
  138220. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138221. * Default : false
  138222. */
  138223. translateFromPivot: boolean;
  138224. /**
  138225. * Index of this particle in the global "positions" array (Internal use)
  138226. * @hidden
  138227. */
  138228. _pos: number;
  138229. /**
  138230. * @hidden Index of this particle in the global "indices" array (Internal use)
  138231. */
  138232. _ind: number;
  138233. /**
  138234. * Group this particle belongs to
  138235. */
  138236. _group: PointsGroup;
  138237. /**
  138238. * Group id of this particle
  138239. */
  138240. groupId: number;
  138241. /**
  138242. * Index of the particle in its group id (Internal use)
  138243. */
  138244. idxInGroup: number;
  138245. /**
  138246. * @hidden Particle BoundingInfo object (Internal use)
  138247. */
  138248. _boundingInfo: BoundingInfo;
  138249. /**
  138250. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138251. */
  138252. _pcs: PointsCloudSystem;
  138253. /**
  138254. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138255. */
  138256. _stillInvisible: boolean;
  138257. /**
  138258. * @hidden Last computed particle rotation matrix
  138259. */
  138260. _rotationMatrix: number[];
  138261. /**
  138262. * Parent particle Id, if any.
  138263. * Default null.
  138264. */
  138265. parentId: Nullable<number>;
  138266. /**
  138267. * @hidden Internal global position in the PCS.
  138268. */
  138269. _globalPosition: Vector3;
  138270. /**
  138271. * Creates a Point Cloud object.
  138272. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138273. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138274. * @param group (PointsGroup) is the group the particle belongs to
  138275. * @param groupId (integer) is the group identifier in the PCS.
  138276. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138277. * @param pcs defines the PCS it is associated to
  138278. */
  138279. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138280. /**
  138281. * get point size
  138282. */
  138283. get size(): Vector3;
  138284. /**
  138285. * Set point size
  138286. */
  138287. set size(scale: Vector3);
  138288. /**
  138289. * Legacy support, changed quaternion to rotationQuaternion
  138290. */
  138291. get quaternion(): Nullable<Quaternion>;
  138292. /**
  138293. * Legacy support, changed quaternion to rotationQuaternion
  138294. */
  138295. set quaternion(q: Nullable<Quaternion>);
  138296. /**
  138297. * Returns a boolean. True if the particle intersects a mesh, else false
  138298. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138299. * @param target is the object (point or mesh) what the intersection is computed against
  138300. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138301. * @returns true if it intersects
  138302. */
  138303. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138304. /**
  138305. * get the rotation matrix of the particle
  138306. * @hidden
  138307. */
  138308. getRotationMatrix(m: Matrix): void;
  138309. }
  138310. /**
  138311. * Represents a group of points in a points cloud system
  138312. * * PCS internal tool, don't use it manually.
  138313. */
  138314. export class PointsGroup {
  138315. /**
  138316. * The group id
  138317. * @hidden
  138318. */
  138319. groupID: number;
  138320. /**
  138321. * image data for group (internal use)
  138322. * @hidden
  138323. */
  138324. _groupImageData: Nullable<ArrayBufferView>;
  138325. /**
  138326. * Image Width (internal use)
  138327. * @hidden
  138328. */
  138329. _groupImgWidth: number;
  138330. /**
  138331. * Image Height (internal use)
  138332. * @hidden
  138333. */
  138334. _groupImgHeight: number;
  138335. /**
  138336. * Custom position function (internal use)
  138337. * @hidden
  138338. */
  138339. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138340. /**
  138341. * density per facet for surface points
  138342. * @hidden
  138343. */
  138344. _groupDensity: number[];
  138345. /**
  138346. * Only when points are colored by texture carries pointer to texture list array
  138347. * @hidden
  138348. */
  138349. _textureNb: number;
  138350. /**
  138351. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138352. * PCS internal tool, don't use it manually.
  138353. * @hidden
  138354. */
  138355. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138356. }
  138357. }
  138358. declare module BABYLON {
  138359. interface Scene {
  138360. /** @hidden (Backing field) */
  138361. _physicsEngine: Nullable<IPhysicsEngine>;
  138362. /** @hidden */
  138363. _physicsTimeAccumulator: number;
  138364. /**
  138365. * Gets the current physics engine
  138366. * @returns a IPhysicsEngine or null if none attached
  138367. */
  138368. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138369. /**
  138370. * Enables physics to the current scene
  138371. * @param gravity defines the scene's gravity for the physics engine
  138372. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138373. * @return a boolean indicating if the physics engine was initialized
  138374. */
  138375. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138376. /**
  138377. * Disables and disposes the physics engine associated with the scene
  138378. */
  138379. disablePhysicsEngine(): void;
  138380. /**
  138381. * Gets a boolean indicating if there is an active physics engine
  138382. * @returns a boolean indicating if there is an active physics engine
  138383. */
  138384. isPhysicsEnabled(): boolean;
  138385. /**
  138386. * Deletes a physics compound impostor
  138387. * @param compound defines the compound to delete
  138388. */
  138389. deleteCompoundImpostor(compound: any): void;
  138390. /**
  138391. * An event triggered when physic simulation is about to be run
  138392. */
  138393. onBeforePhysicsObservable: Observable<Scene>;
  138394. /**
  138395. * An event triggered when physic simulation has been done
  138396. */
  138397. onAfterPhysicsObservable: Observable<Scene>;
  138398. }
  138399. interface AbstractMesh {
  138400. /** @hidden */
  138401. _physicsImpostor: Nullable<PhysicsImpostor>;
  138402. /**
  138403. * Gets or sets impostor used for physic simulation
  138404. * @see http://doc.babylonjs.com/features/physics_engine
  138405. */
  138406. physicsImpostor: Nullable<PhysicsImpostor>;
  138407. /**
  138408. * Gets the current physics impostor
  138409. * @see http://doc.babylonjs.com/features/physics_engine
  138410. * @returns a physics impostor or null
  138411. */
  138412. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138413. /** Apply a physic impulse to the mesh
  138414. * @param force defines the force to apply
  138415. * @param contactPoint defines where to apply the force
  138416. * @returns the current mesh
  138417. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138418. */
  138419. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138420. /**
  138421. * Creates a physic joint between two meshes
  138422. * @param otherMesh defines the other mesh to use
  138423. * @param pivot1 defines the pivot to use on this mesh
  138424. * @param pivot2 defines the pivot to use on the other mesh
  138425. * @param options defines additional options (can be plugin dependent)
  138426. * @returns the current mesh
  138427. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138428. */
  138429. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138430. /** @hidden */
  138431. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138432. }
  138433. /**
  138434. * Defines the physics engine scene component responsible to manage a physics engine
  138435. */
  138436. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138437. /**
  138438. * The component name helpful to identify the component in the list of scene components.
  138439. */
  138440. readonly name: string;
  138441. /**
  138442. * The scene the component belongs to.
  138443. */
  138444. scene: Scene;
  138445. /**
  138446. * Creates a new instance of the component for the given scene
  138447. * @param scene Defines the scene to register the component in
  138448. */
  138449. constructor(scene: Scene);
  138450. /**
  138451. * Registers the component in a given scene
  138452. */
  138453. register(): void;
  138454. /**
  138455. * Rebuilds the elements related to this component in case of
  138456. * context lost for instance.
  138457. */
  138458. rebuild(): void;
  138459. /**
  138460. * Disposes the component and the associated ressources
  138461. */
  138462. dispose(): void;
  138463. }
  138464. }
  138465. declare module BABYLON {
  138466. /**
  138467. * A helper for physics simulations
  138468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138469. */
  138470. export class PhysicsHelper {
  138471. private _scene;
  138472. private _physicsEngine;
  138473. /**
  138474. * Initializes the Physics helper
  138475. * @param scene Babylon.js scene
  138476. */
  138477. constructor(scene: Scene);
  138478. /**
  138479. * Applies a radial explosion impulse
  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 radial explosion event, or null
  138485. */
  138486. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138487. /**
  138488. * Applies a radial explosion force
  138489. * @param origin the origin of the explosion
  138490. * @param radiusOrEventOptions the radius or the options of radial explosion
  138491. * @param strength the explosion strength
  138492. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138493. * @returns A physics radial explosion event, or null
  138494. */
  138495. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138496. /**
  138497. * Creates a gravitational field
  138498. * @param origin the origin of the explosion
  138499. * @param radiusOrEventOptions the radius or the options of radial explosion
  138500. * @param strength the explosion strength
  138501. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138502. * @returns A physics gravitational field event, or null
  138503. */
  138504. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138505. /**
  138506. * Creates a physics updraft event
  138507. * @param origin the origin of the updraft
  138508. * @param radiusOrEventOptions the radius or the options of the updraft
  138509. * @param strength the strength of the updraft
  138510. * @param height the height of the updraft
  138511. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138512. * @returns A physics updraft event, or null
  138513. */
  138514. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138515. /**
  138516. * Creates a physics vortex event
  138517. * @param origin the of the vortex
  138518. * @param radiusOrEventOptions the radius or the options of the vortex
  138519. * @param strength the strength of the vortex
  138520. * @param height the height of the vortex
  138521. * @returns a Physics vortex event, or null
  138522. * A physics vortex event or null
  138523. */
  138524. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138525. }
  138526. /**
  138527. * Represents a physics radial explosion event
  138528. */
  138529. class PhysicsRadialExplosionEvent {
  138530. private _scene;
  138531. private _options;
  138532. private _sphere;
  138533. private _dataFetched;
  138534. /**
  138535. * Initializes a radial explosioin event
  138536. * @param _scene BabylonJS scene
  138537. * @param _options The options for the vortex event
  138538. */
  138539. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138540. /**
  138541. * Returns the data related to the radial explosion event (sphere).
  138542. * @returns The radial explosion event data
  138543. */
  138544. getData(): PhysicsRadialExplosionEventData;
  138545. /**
  138546. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138547. * @param impostor A physics imposter
  138548. * @param origin the origin of the explosion
  138549. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138550. */
  138551. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138552. /**
  138553. * Triggers affecterd impostors callbacks
  138554. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138555. */
  138556. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138557. /**
  138558. * Disposes the sphere.
  138559. * @param force Specifies if the sphere should be disposed by force
  138560. */
  138561. dispose(force?: boolean): void;
  138562. /*** Helpers ***/
  138563. private _prepareSphere;
  138564. private _intersectsWithSphere;
  138565. }
  138566. /**
  138567. * Represents a gravitational field event
  138568. */
  138569. class PhysicsGravitationalFieldEvent {
  138570. private _physicsHelper;
  138571. private _scene;
  138572. private _origin;
  138573. private _options;
  138574. private _tickCallback;
  138575. private _sphere;
  138576. private _dataFetched;
  138577. /**
  138578. * Initializes the physics gravitational field event
  138579. * @param _physicsHelper A physics helper
  138580. * @param _scene BabylonJS scene
  138581. * @param _origin The origin position of the gravitational field event
  138582. * @param _options The options for the vortex event
  138583. */
  138584. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138585. /**
  138586. * Returns the data related to the gravitational field event (sphere).
  138587. * @returns A gravitational field event
  138588. */
  138589. getData(): PhysicsGravitationalFieldEventData;
  138590. /**
  138591. * Enables the gravitational field.
  138592. */
  138593. enable(): void;
  138594. /**
  138595. * Disables the gravitational field.
  138596. */
  138597. disable(): void;
  138598. /**
  138599. * Disposes the sphere.
  138600. * @param force The force to dispose from the gravitational field event
  138601. */
  138602. dispose(force?: boolean): void;
  138603. private _tick;
  138604. }
  138605. /**
  138606. * Represents a physics updraft event
  138607. */
  138608. class PhysicsUpdraftEvent {
  138609. private _scene;
  138610. private _origin;
  138611. private _options;
  138612. private _physicsEngine;
  138613. private _originTop;
  138614. private _originDirection;
  138615. private _tickCallback;
  138616. private _cylinder;
  138617. private _cylinderPosition;
  138618. private _dataFetched;
  138619. /**
  138620. * Initializes the physics updraft event
  138621. * @param _scene BabylonJS scene
  138622. * @param _origin The origin position of the updraft
  138623. * @param _options The options for the updraft event
  138624. */
  138625. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138626. /**
  138627. * Returns the data related to the updraft event (cylinder).
  138628. * @returns A physics updraft event
  138629. */
  138630. getData(): PhysicsUpdraftEventData;
  138631. /**
  138632. * Enables the updraft.
  138633. */
  138634. enable(): void;
  138635. /**
  138636. * Disables the updraft.
  138637. */
  138638. disable(): void;
  138639. /**
  138640. * Disposes the cylinder.
  138641. * @param force Specifies if the updraft should be disposed by force
  138642. */
  138643. dispose(force?: boolean): void;
  138644. private getImpostorHitData;
  138645. private _tick;
  138646. /*** Helpers ***/
  138647. private _prepareCylinder;
  138648. private _intersectsWithCylinder;
  138649. }
  138650. /**
  138651. * Represents a physics vortex event
  138652. */
  138653. class PhysicsVortexEvent {
  138654. private _scene;
  138655. private _origin;
  138656. private _options;
  138657. private _physicsEngine;
  138658. private _originTop;
  138659. private _tickCallback;
  138660. private _cylinder;
  138661. private _cylinderPosition;
  138662. private _dataFetched;
  138663. /**
  138664. * Initializes the physics vortex event
  138665. * @param _scene The BabylonJS scene
  138666. * @param _origin The origin position of the vortex
  138667. * @param _options The options for the vortex event
  138668. */
  138669. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138670. /**
  138671. * Returns the data related to the vortex event (cylinder).
  138672. * @returns The physics vortex event data
  138673. */
  138674. getData(): PhysicsVortexEventData;
  138675. /**
  138676. * Enables the vortex.
  138677. */
  138678. enable(): void;
  138679. /**
  138680. * Disables the cortex.
  138681. */
  138682. disable(): void;
  138683. /**
  138684. * Disposes the sphere.
  138685. * @param force
  138686. */
  138687. dispose(force?: boolean): void;
  138688. private getImpostorHitData;
  138689. private _tick;
  138690. /*** Helpers ***/
  138691. private _prepareCylinder;
  138692. private _intersectsWithCylinder;
  138693. }
  138694. /**
  138695. * Options fot the radial explosion event
  138696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138697. */
  138698. export class PhysicsRadialExplosionEventOptions {
  138699. /**
  138700. * The radius of the sphere for the radial explosion.
  138701. */
  138702. radius: number;
  138703. /**
  138704. * The strenth of the explosion.
  138705. */
  138706. strength: number;
  138707. /**
  138708. * The strenght of the force in correspondence to the distance of the affected object
  138709. */
  138710. falloff: PhysicsRadialImpulseFalloff;
  138711. /**
  138712. * Sphere options for the radial explosion.
  138713. */
  138714. sphere: {
  138715. segments: number;
  138716. diameter: number;
  138717. };
  138718. /**
  138719. * Sphere options for the radial explosion.
  138720. */
  138721. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138722. }
  138723. /**
  138724. * Options fot the updraft event
  138725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138726. */
  138727. export class PhysicsUpdraftEventOptions {
  138728. /**
  138729. * The radius of the cylinder for the vortex
  138730. */
  138731. radius: number;
  138732. /**
  138733. * The strenth of the updraft.
  138734. */
  138735. strength: number;
  138736. /**
  138737. * The height of the cylinder for the updraft.
  138738. */
  138739. height: number;
  138740. /**
  138741. * The mode for the the updraft.
  138742. */
  138743. updraftMode: PhysicsUpdraftMode;
  138744. }
  138745. /**
  138746. * Options fot the vortex event
  138747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138748. */
  138749. export class PhysicsVortexEventOptions {
  138750. /**
  138751. * The radius of the cylinder for the vortex
  138752. */
  138753. radius: number;
  138754. /**
  138755. * The strenth of the vortex.
  138756. */
  138757. strength: number;
  138758. /**
  138759. * The height of the cylinder for the vortex.
  138760. */
  138761. height: number;
  138762. /**
  138763. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138764. */
  138765. centripetalForceThreshold: number;
  138766. /**
  138767. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138768. */
  138769. centripetalForceMultiplier: number;
  138770. /**
  138771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138772. */
  138773. centrifugalForceMultiplier: number;
  138774. /**
  138775. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138776. */
  138777. updraftForceMultiplier: number;
  138778. }
  138779. /**
  138780. * The strenght of the force in correspondence to the distance of the affected object
  138781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138782. */
  138783. export enum PhysicsRadialImpulseFalloff {
  138784. /** Defines that impulse is constant in strength across it's whole radius */
  138785. Constant = 0,
  138786. /** Defines that impulse gets weaker if it's further from the origin */
  138787. Linear = 1
  138788. }
  138789. /**
  138790. * The strength of the force in correspondence to the distance of the affected object
  138791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138792. */
  138793. export enum PhysicsUpdraftMode {
  138794. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138795. Center = 0,
  138796. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138797. Perpendicular = 1
  138798. }
  138799. /**
  138800. * Interface for a physics hit data
  138801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138802. */
  138803. export interface PhysicsHitData {
  138804. /**
  138805. * The force applied at the contact point
  138806. */
  138807. force: Vector3;
  138808. /**
  138809. * The contact point
  138810. */
  138811. contactPoint: Vector3;
  138812. /**
  138813. * The distance from the origin to the contact point
  138814. */
  138815. distanceFromOrigin: number;
  138816. }
  138817. /**
  138818. * Interface for radial explosion event data
  138819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138820. */
  138821. export interface PhysicsRadialExplosionEventData {
  138822. /**
  138823. * A sphere used for the radial explosion event
  138824. */
  138825. sphere: Mesh;
  138826. }
  138827. /**
  138828. * Interface for gravitational field event data
  138829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138830. */
  138831. export interface PhysicsGravitationalFieldEventData {
  138832. /**
  138833. * A sphere mesh used for the gravitational field event
  138834. */
  138835. sphere: Mesh;
  138836. }
  138837. /**
  138838. * Interface for updraft event data
  138839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138840. */
  138841. export interface PhysicsUpdraftEventData {
  138842. /**
  138843. * A cylinder used for the updraft event
  138844. */
  138845. cylinder: Mesh;
  138846. }
  138847. /**
  138848. * Interface for vortex event data
  138849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138850. */
  138851. export interface PhysicsVortexEventData {
  138852. /**
  138853. * A cylinder used for the vortex event
  138854. */
  138855. cylinder: Mesh;
  138856. }
  138857. /**
  138858. * Interface for an affected physics impostor
  138859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138860. */
  138861. export interface PhysicsAffectedImpostorWithData {
  138862. /**
  138863. * The impostor affected by the effect
  138864. */
  138865. impostor: PhysicsImpostor;
  138866. /**
  138867. * The data about the hit/horce from the explosion
  138868. */
  138869. hitData: PhysicsHitData;
  138870. }
  138871. }
  138872. declare module BABYLON {
  138873. /** @hidden */
  138874. export var blackAndWhitePixelShader: {
  138875. name: string;
  138876. shader: string;
  138877. };
  138878. }
  138879. declare module BABYLON {
  138880. /**
  138881. * Post process used to render in black and white
  138882. */
  138883. export class BlackAndWhitePostProcess extends PostProcess {
  138884. /**
  138885. * Linear about to convert he result to black and white (default: 1)
  138886. */
  138887. degree: number;
  138888. /**
  138889. * Creates a black and white post process
  138890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138891. * @param name The name of the effect.
  138892. * @param options The required width/height ratio to downsize to before computing the render pass.
  138893. * @param camera The camera to apply the render pass to.
  138894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138895. * @param engine The engine which the post process will be applied. (default: current engine)
  138896. * @param reusable If the post process can be reused on the same frame. (default: false)
  138897. */
  138898. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138899. }
  138900. }
  138901. declare module BABYLON {
  138902. /**
  138903. * This represents a set of one or more post processes in Babylon.
  138904. * A post process can be used to apply a shader to a texture after it is rendered.
  138905. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138906. */
  138907. export class PostProcessRenderEffect {
  138908. private _postProcesses;
  138909. private _getPostProcesses;
  138910. private _singleInstance;
  138911. private _cameras;
  138912. private _indicesForCamera;
  138913. /**
  138914. * Name of the effect
  138915. * @hidden
  138916. */
  138917. _name: string;
  138918. /**
  138919. * Instantiates a post process render effect.
  138920. * A post process can be used to apply a shader to a texture after it is rendered.
  138921. * @param engine The engine the effect is tied to
  138922. * @param name The name of the effect
  138923. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138924. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138925. */
  138926. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138927. /**
  138928. * Checks if all the post processes in the effect are supported.
  138929. */
  138930. get isSupported(): boolean;
  138931. /**
  138932. * Updates the current state of the effect
  138933. * @hidden
  138934. */
  138935. _update(): void;
  138936. /**
  138937. * Attaches the effect on cameras
  138938. * @param cameras The camera to attach to.
  138939. * @hidden
  138940. */
  138941. _attachCameras(cameras: Camera): void;
  138942. /**
  138943. * Attaches the effect on cameras
  138944. * @param cameras The camera to attach to.
  138945. * @hidden
  138946. */
  138947. _attachCameras(cameras: Camera[]): void;
  138948. /**
  138949. * Detaches the effect on cameras
  138950. * @param cameras The camera to detatch from.
  138951. * @hidden
  138952. */
  138953. _detachCameras(cameras: Camera): void;
  138954. /**
  138955. * Detatches the effect on cameras
  138956. * @param cameras The camera to detatch from.
  138957. * @hidden
  138958. */
  138959. _detachCameras(cameras: Camera[]): void;
  138960. /**
  138961. * Enables the effect on given cameras
  138962. * @param cameras The camera to enable.
  138963. * @hidden
  138964. */
  138965. _enable(cameras: Camera): void;
  138966. /**
  138967. * Enables the effect on given cameras
  138968. * @param cameras The camera to enable.
  138969. * @hidden
  138970. */
  138971. _enable(cameras: Nullable<Camera[]>): void;
  138972. /**
  138973. * Disables the effect on the given cameras
  138974. * @param cameras The camera to disable.
  138975. * @hidden
  138976. */
  138977. _disable(cameras: Camera): void;
  138978. /**
  138979. * Disables the effect on the given cameras
  138980. * @param cameras The camera to disable.
  138981. * @hidden
  138982. */
  138983. _disable(cameras: Nullable<Camera[]>): void;
  138984. /**
  138985. * Gets a list of the post processes contained in the effect.
  138986. * @param camera The camera to get the post processes on.
  138987. * @returns The list of the post processes in the effect.
  138988. */
  138989. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  138990. }
  138991. }
  138992. declare module BABYLON {
  138993. /** @hidden */
  138994. export var extractHighlightsPixelShader: {
  138995. name: string;
  138996. shader: string;
  138997. };
  138998. }
  138999. declare module BABYLON {
  139000. /**
  139001. * 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.
  139002. */
  139003. export class ExtractHighlightsPostProcess extends PostProcess {
  139004. /**
  139005. * The luminance threshold, pixels below this value will be set to black.
  139006. */
  139007. threshold: number;
  139008. /** @hidden */
  139009. _exposure: number;
  139010. /**
  139011. * Post process which has the input texture to be used when performing highlight extraction
  139012. * @hidden
  139013. */
  139014. _inputPostProcess: Nullable<PostProcess>;
  139015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139016. }
  139017. }
  139018. declare module BABYLON {
  139019. /** @hidden */
  139020. export var bloomMergePixelShader: {
  139021. name: string;
  139022. shader: string;
  139023. };
  139024. }
  139025. declare module BABYLON {
  139026. /**
  139027. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139028. */
  139029. export class BloomMergePostProcess extends PostProcess {
  139030. /** Weight of the bloom to be added to the original input. */
  139031. weight: number;
  139032. /**
  139033. * Creates a new instance of @see BloomMergePostProcess
  139034. * @param name The name of the effect.
  139035. * @param originalFromInput Post process which's input will be used for the merge.
  139036. * @param blurred Blurred highlights post process which's output will be used.
  139037. * @param weight Weight of the bloom to be added to the original input.
  139038. * @param options The required width/height ratio to downsize to before computing the render pass.
  139039. * @param camera The camera to apply the render pass to.
  139040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139041. * @param engine The engine which the post process will be applied. (default: current engine)
  139042. * @param reusable If the post process can be reused on the same frame. (default: false)
  139043. * @param textureType Type of textures used when performing the post process. (default: 0)
  139044. * @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)
  139045. */
  139046. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139047. /** Weight of the bloom to be added to the original input. */
  139048. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139049. }
  139050. }
  139051. declare module BABYLON {
  139052. /**
  139053. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139054. */
  139055. export class BloomEffect extends PostProcessRenderEffect {
  139056. private bloomScale;
  139057. /**
  139058. * @hidden Internal
  139059. */
  139060. _effects: Array<PostProcess>;
  139061. /**
  139062. * @hidden Internal
  139063. */
  139064. _downscale: ExtractHighlightsPostProcess;
  139065. private _blurX;
  139066. private _blurY;
  139067. private _merge;
  139068. /**
  139069. * The luminance threshold to find bright areas of the image to bloom.
  139070. */
  139071. get threshold(): number;
  139072. set threshold(value: number);
  139073. /**
  139074. * The strength of the bloom.
  139075. */
  139076. get weight(): number;
  139077. set weight(value: number);
  139078. /**
  139079. * Specifies the size of the bloom blur kernel, relative to the final output size
  139080. */
  139081. get kernel(): number;
  139082. set kernel(value: number);
  139083. /**
  139084. * Creates a new instance of @see BloomEffect
  139085. * @param scene The scene the effect belongs to.
  139086. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139087. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139088. * @param bloomWeight The the strength of bloom.
  139089. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139090. * @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)
  139091. */
  139092. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139093. /**
  139094. * Disposes each of the internal effects for a given camera.
  139095. * @param camera The camera to dispose the effect on.
  139096. */
  139097. disposeEffects(camera: Camera): void;
  139098. /**
  139099. * @hidden Internal
  139100. */
  139101. _updateEffects(): void;
  139102. /**
  139103. * Internal
  139104. * @returns if all the contained post processes are ready.
  139105. * @hidden
  139106. */
  139107. _isReady(): boolean;
  139108. }
  139109. }
  139110. declare module BABYLON {
  139111. /** @hidden */
  139112. export var chromaticAberrationPixelShader: {
  139113. name: string;
  139114. shader: string;
  139115. };
  139116. }
  139117. declare module BABYLON {
  139118. /**
  139119. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139120. */
  139121. export class ChromaticAberrationPostProcess extends PostProcess {
  139122. /**
  139123. * The amount of seperation of rgb channels (default: 30)
  139124. */
  139125. aberrationAmount: number;
  139126. /**
  139127. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139128. */
  139129. radialIntensity: number;
  139130. /**
  139131. * 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))
  139132. */
  139133. direction: Vector2;
  139134. /**
  139135. * 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))
  139136. */
  139137. centerPosition: Vector2;
  139138. /**
  139139. * Creates a new instance ChromaticAberrationPostProcess
  139140. * @param name The name of the effect.
  139141. * @param screenWidth The width of the screen to apply the effect on.
  139142. * @param screenHeight The height of the screen to apply the effect on.
  139143. * @param options The required width/height ratio to downsize to before computing the render pass.
  139144. * @param camera The camera to apply the render pass to.
  139145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139146. * @param engine The engine which the post process will be applied. (default: current engine)
  139147. * @param reusable If the post process can be reused on the same frame. (default: false)
  139148. * @param textureType Type of textures used when performing the post process. (default: 0)
  139149. * @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)
  139150. */
  139151. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139152. }
  139153. }
  139154. declare module BABYLON {
  139155. /** @hidden */
  139156. export var circleOfConfusionPixelShader: {
  139157. name: string;
  139158. shader: string;
  139159. };
  139160. }
  139161. declare module BABYLON {
  139162. /**
  139163. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139164. */
  139165. export class CircleOfConfusionPostProcess extends PostProcess {
  139166. /**
  139167. * 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.
  139168. */
  139169. lensSize: number;
  139170. /**
  139171. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139172. */
  139173. fStop: number;
  139174. /**
  139175. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139176. */
  139177. focusDistance: number;
  139178. /**
  139179. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139180. */
  139181. focalLength: number;
  139182. private _depthTexture;
  139183. /**
  139184. * Creates a new instance CircleOfConfusionPostProcess
  139185. * @param name The name of the effect.
  139186. * @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.
  139187. * @param options The required width/height ratio to downsize to before computing the render pass.
  139188. * @param camera The camera to apply the render pass to.
  139189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139190. * @param engine The engine which the post process will be applied. (default: current engine)
  139191. * @param reusable If the post process can be reused on the same frame. (default: false)
  139192. * @param textureType Type of textures used when performing the post process. (default: 0)
  139193. * @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)
  139194. */
  139195. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139196. /**
  139197. * 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.
  139198. */
  139199. set depthTexture(value: RenderTargetTexture);
  139200. }
  139201. }
  139202. declare module BABYLON {
  139203. /** @hidden */
  139204. export var colorCorrectionPixelShader: {
  139205. name: string;
  139206. shader: string;
  139207. };
  139208. }
  139209. declare module BABYLON {
  139210. /**
  139211. *
  139212. * This post-process allows the modification of rendered colors by using
  139213. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139214. *
  139215. * The object needs to be provided an url to a texture containing the color
  139216. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139217. * Use an image editing software to tweak the LUT to match your needs.
  139218. *
  139219. * For an example of a color LUT, see here:
  139220. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139221. * For explanations on color grading, see here:
  139222. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139223. *
  139224. */
  139225. export class ColorCorrectionPostProcess extends PostProcess {
  139226. private _colorTableTexture;
  139227. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139228. }
  139229. }
  139230. declare module BABYLON {
  139231. /** @hidden */
  139232. export var convolutionPixelShader: {
  139233. name: string;
  139234. shader: string;
  139235. };
  139236. }
  139237. declare module BABYLON {
  139238. /**
  139239. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139240. * input texture to perform effects such as edge detection or sharpening
  139241. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139242. */
  139243. export class ConvolutionPostProcess extends PostProcess {
  139244. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139245. kernel: number[];
  139246. /**
  139247. * Creates a new instance ConvolutionPostProcess
  139248. * @param name The name of the effect.
  139249. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139250. * @param options The required width/height ratio to downsize to before computing the render pass.
  139251. * @param camera The camera to apply the render pass to.
  139252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139253. * @param engine The engine which the post process will be applied. (default: current engine)
  139254. * @param reusable If the post process can be reused on the same frame. (default: false)
  139255. * @param textureType Type of textures used when performing the post process. (default: 0)
  139256. */
  139257. constructor(name: string,
  139258. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139259. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139260. /**
  139261. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139262. */
  139263. static EdgeDetect0Kernel: number[];
  139264. /**
  139265. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139266. */
  139267. static EdgeDetect1Kernel: number[];
  139268. /**
  139269. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139270. */
  139271. static EdgeDetect2Kernel: number[];
  139272. /**
  139273. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139274. */
  139275. static SharpenKernel: number[];
  139276. /**
  139277. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139278. */
  139279. static EmbossKernel: number[];
  139280. /**
  139281. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139282. */
  139283. static GaussianKernel: number[];
  139284. }
  139285. }
  139286. declare module BABYLON {
  139287. /**
  139288. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139289. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139290. * based on samples that have a large difference in distance than the center pixel.
  139291. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139292. */
  139293. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139294. direction: Vector2;
  139295. /**
  139296. * Creates a new instance CircleOfConfusionPostProcess
  139297. * @param name The name of the effect.
  139298. * @param scene The scene the effect belongs to.
  139299. * @param direction The direction the blur should be applied.
  139300. * @param kernel The size of the kernel used to blur.
  139301. * @param options The required width/height ratio to downsize to before computing the render pass.
  139302. * @param camera The camera to apply the render pass to.
  139303. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139304. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139306. * @param engine The engine which the post process will be applied. (default: current engine)
  139307. * @param reusable If the post process can be reused on the same frame. (default: false)
  139308. * @param textureType Type of textures used when performing the post process. (default: 0)
  139309. * @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)
  139310. */
  139311. 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);
  139312. }
  139313. }
  139314. declare module BABYLON {
  139315. /** @hidden */
  139316. export var depthOfFieldMergePixelShader: {
  139317. name: string;
  139318. shader: string;
  139319. };
  139320. }
  139321. declare module BABYLON {
  139322. /**
  139323. * Options to be set when merging outputs from the default pipeline.
  139324. */
  139325. export class DepthOfFieldMergePostProcessOptions {
  139326. /**
  139327. * The original image to merge on top of
  139328. */
  139329. originalFromInput: PostProcess;
  139330. /**
  139331. * Parameters to perform the merge of the depth of field effect
  139332. */
  139333. depthOfField?: {
  139334. circleOfConfusion: PostProcess;
  139335. blurSteps: Array<PostProcess>;
  139336. };
  139337. /**
  139338. * Parameters to perform the merge of bloom effect
  139339. */
  139340. bloom?: {
  139341. blurred: PostProcess;
  139342. weight: number;
  139343. };
  139344. }
  139345. /**
  139346. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139347. */
  139348. export class DepthOfFieldMergePostProcess extends PostProcess {
  139349. private blurSteps;
  139350. /**
  139351. * Creates a new instance of DepthOfFieldMergePostProcess
  139352. * @param name The name of the effect.
  139353. * @param originalFromInput Post process which's input will be used for the merge.
  139354. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139355. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139356. * @param options The required width/height ratio to downsize to before computing the render pass.
  139357. * @param camera The camera to apply the render pass to.
  139358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139359. * @param engine The engine which the post process will be applied. (default: current engine)
  139360. * @param reusable If the post process can be reused on the same frame. (default: false)
  139361. * @param textureType Type of textures used when performing the post process. (default: 0)
  139362. * @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)
  139363. */
  139364. 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);
  139365. /**
  139366. * Updates the effect with the current post process compile time values and recompiles the shader.
  139367. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139368. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139369. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139370. * @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
  139371. * @param onCompiled Called when the shader has been compiled.
  139372. * @param onError Called if there is an error when compiling a shader.
  139373. */
  139374. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139375. }
  139376. }
  139377. declare module BABYLON {
  139378. /**
  139379. * Specifies the level of max blur that should be applied when using the depth of field effect
  139380. */
  139381. export enum DepthOfFieldEffectBlurLevel {
  139382. /**
  139383. * Subtle blur
  139384. */
  139385. Low = 0,
  139386. /**
  139387. * Medium blur
  139388. */
  139389. Medium = 1,
  139390. /**
  139391. * Large blur
  139392. */
  139393. High = 2
  139394. }
  139395. /**
  139396. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139397. */
  139398. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139399. private _circleOfConfusion;
  139400. /**
  139401. * @hidden Internal, blurs from high to low
  139402. */
  139403. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139404. private _depthOfFieldBlurY;
  139405. private _dofMerge;
  139406. /**
  139407. * @hidden Internal post processes in depth of field effect
  139408. */
  139409. _effects: Array<PostProcess>;
  139410. /**
  139411. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139412. */
  139413. set focalLength(value: number);
  139414. get focalLength(): number;
  139415. /**
  139416. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139417. */
  139418. set fStop(value: number);
  139419. get fStop(): number;
  139420. /**
  139421. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139422. */
  139423. set focusDistance(value: number);
  139424. get focusDistance(): number;
  139425. /**
  139426. * 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.
  139427. */
  139428. set lensSize(value: number);
  139429. get lensSize(): number;
  139430. /**
  139431. * Creates a new instance DepthOfFieldEffect
  139432. * @param scene The scene the effect belongs to.
  139433. * @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.
  139434. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139435. * @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)
  139436. */
  139437. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139438. /**
  139439. * Get the current class name of the current effet
  139440. * @returns "DepthOfFieldEffect"
  139441. */
  139442. getClassName(): string;
  139443. /**
  139444. * 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.
  139445. */
  139446. set depthTexture(value: RenderTargetTexture);
  139447. /**
  139448. * Disposes each of the internal effects for a given camera.
  139449. * @param camera The camera to dispose the effect on.
  139450. */
  139451. disposeEffects(camera: Camera): void;
  139452. /**
  139453. * @hidden Internal
  139454. */
  139455. _updateEffects(): void;
  139456. /**
  139457. * Internal
  139458. * @returns if all the contained post processes are ready.
  139459. * @hidden
  139460. */
  139461. _isReady(): boolean;
  139462. }
  139463. }
  139464. declare module BABYLON {
  139465. /** @hidden */
  139466. export var displayPassPixelShader: {
  139467. name: string;
  139468. shader: string;
  139469. };
  139470. }
  139471. declare module BABYLON {
  139472. /**
  139473. * DisplayPassPostProcess which produces an output the same as it's input
  139474. */
  139475. export class DisplayPassPostProcess extends PostProcess {
  139476. /**
  139477. * Creates the DisplayPassPostProcess
  139478. * @param name The name of the effect.
  139479. * @param options The required width/height ratio to downsize to before computing the render pass.
  139480. * @param camera The camera to apply the render pass to.
  139481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139482. * @param engine The engine which the post process will be applied. (default: current engine)
  139483. * @param reusable If the post process can be reused on the same frame. (default: false)
  139484. */
  139485. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139486. }
  139487. }
  139488. declare module BABYLON {
  139489. /** @hidden */
  139490. export var filterPixelShader: {
  139491. name: string;
  139492. shader: string;
  139493. };
  139494. }
  139495. declare module BABYLON {
  139496. /**
  139497. * Applies a kernel filter to the image
  139498. */
  139499. export class FilterPostProcess extends PostProcess {
  139500. /** The matrix to be applied to the image */
  139501. kernelMatrix: Matrix;
  139502. /**
  139503. *
  139504. * @param name The name of the effect.
  139505. * @param kernelMatrix The matrix to be applied to the image
  139506. * @param options The required width/height ratio to downsize to before computing the render pass.
  139507. * @param camera The camera to apply the render pass to.
  139508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139509. * @param engine The engine which the post process will be applied. (default: current engine)
  139510. * @param reusable If the post process can be reused on the same frame. (default: false)
  139511. */
  139512. constructor(name: string,
  139513. /** The matrix to be applied to the image */
  139514. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139515. }
  139516. }
  139517. declare module BABYLON {
  139518. /** @hidden */
  139519. export var fxaaPixelShader: {
  139520. name: string;
  139521. shader: string;
  139522. };
  139523. }
  139524. declare module BABYLON {
  139525. /** @hidden */
  139526. export var fxaaVertexShader: {
  139527. name: string;
  139528. shader: string;
  139529. };
  139530. }
  139531. declare module BABYLON {
  139532. /**
  139533. * Fxaa post process
  139534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139535. */
  139536. export class FxaaPostProcess extends PostProcess {
  139537. /** @hidden */
  139538. texelWidth: number;
  139539. /** @hidden */
  139540. texelHeight: number;
  139541. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139542. private _getDefines;
  139543. }
  139544. }
  139545. declare module BABYLON {
  139546. /** @hidden */
  139547. export var grainPixelShader: {
  139548. name: string;
  139549. shader: string;
  139550. };
  139551. }
  139552. declare module BABYLON {
  139553. /**
  139554. * The GrainPostProcess adds noise to the image at mid luminance levels
  139555. */
  139556. export class GrainPostProcess extends PostProcess {
  139557. /**
  139558. * The intensity of the grain added (default: 30)
  139559. */
  139560. intensity: number;
  139561. /**
  139562. * If the grain should be randomized on every frame
  139563. */
  139564. animated: boolean;
  139565. /**
  139566. * Creates a new instance of @see GrainPostProcess
  139567. * @param name The name of the effect.
  139568. * @param options The required width/height ratio to downsize to before computing the render pass.
  139569. * @param camera The camera to apply the render pass to.
  139570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139571. * @param engine The engine which the post process will be applied. (default: current engine)
  139572. * @param reusable If the post process can be reused on the same frame. (default: false)
  139573. * @param textureType Type of textures used when performing the post process. (default: 0)
  139574. * @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)
  139575. */
  139576. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139577. }
  139578. }
  139579. declare module BABYLON {
  139580. /** @hidden */
  139581. export var highlightsPixelShader: {
  139582. name: string;
  139583. shader: string;
  139584. };
  139585. }
  139586. declare module BABYLON {
  139587. /**
  139588. * Extracts highlights from the image
  139589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139590. */
  139591. export class HighlightsPostProcess extends PostProcess {
  139592. /**
  139593. * Extracts highlights from the image
  139594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139595. * @param name The name of the effect.
  139596. * @param options The required width/height ratio to downsize to before computing the render pass.
  139597. * @param camera The camera to apply the render pass to.
  139598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139599. * @param engine The engine which the post process will be applied. (default: current engine)
  139600. * @param reusable If the post process can be reused on the same frame. (default: false)
  139601. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139602. */
  139603. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139604. }
  139605. }
  139606. declare module BABYLON {
  139607. /** @hidden */
  139608. export var mrtFragmentDeclaration: {
  139609. name: string;
  139610. shader: string;
  139611. };
  139612. }
  139613. declare module BABYLON {
  139614. /** @hidden */
  139615. export var geometryPixelShader: {
  139616. name: string;
  139617. shader: string;
  139618. };
  139619. }
  139620. declare module BABYLON {
  139621. /** @hidden */
  139622. export var geometryVertexShader: {
  139623. name: string;
  139624. shader: string;
  139625. };
  139626. }
  139627. declare module BABYLON {
  139628. /** @hidden */
  139629. interface ISavedTransformationMatrix {
  139630. world: Matrix;
  139631. viewProjection: Matrix;
  139632. }
  139633. /**
  139634. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139635. */
  139636. export class GeometryBufferRenderer {
  139637. /**
  139638. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139639. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139640. */
  139641. static readonly POSITION_TEXTURE_TYPE: number;
  139642. /**
  139643. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139644. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139645. */
  139646. static readonly VELOCITY_TEXTURE_TYPE: number;
  139647. /**
  139648. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139649. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139650. */
  139651. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139652. /**
  139653. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139654. * in order to compute objects velocities when enableVelocity is set to "true"
  139655. * @hidden
  139656. */
  139657. _previousTransformationMatrices: {
  139658. [index: number]: ISavedTransformationMatrix;
  139659. };
  139660. /**
  139661. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139662. * in order to compute objects velocities when enableVelocity is set to "true"
  139663. * @hidden
  139664. */
  139665. _previousBonesTransformationMatrices: {
  139666. [index: number]: Float32Array;
  139667. };
  139668. /**
  139669. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139670. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139671. */
  139672. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139673. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139674. renderTransparentMeshes: boolean;
  139675. private _scene;
  139676. private _multiRenderTarget;
  139677. private _ratio;
  139678. private _enablePosition;
  139679. private _enableVelocity;
  139680. private _enableReflectivity;
  139681. private _positionIndex;
  139682. private _velocityIndex;
  139683. private _reflectivityIndex;
  139684. protected _effect: Effect;
  139685. protected _cachedDefines: string;
  139686. /**
  139687. * Set the render list (meshes to be rendered) used in the G buffer.
  139688. */
  139689. set renderList(meshes: Mesh[]);
  139690. /**
  139691. * Gets wether or not G buffer are supported by the running hardware.
  139692. * This requires draw buffer supports
  139693. */
  139694. get isSupported(): boolean;
  139695. /**
  139696. * Returns the index of the given texture type in the G-Buffer textures array
  139697. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139698. * @returns the index of the given texture type in the G-Buffer textures array
  139699. */
  139700. getTextureIndex(textureType: number): number;
  139701. /**
  139702. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139703. */
  139704. get enablePosition(): boolean;
  139705. /**
  139706. * Sets whether or not objects positions are enabled for the G buffer.
  139707. */
  139708. set enablePosition(enable: boolean);
  139709. /**
  139710. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139711. */
  139712. get enableVelocity(): boolean;
  139713. /**
  139714. * Sets wether or not objects velocities are enabled for the G buffer.
  139715. */
  139716. set enableVelocity(enable: boolean);
  139717. /**
  139718. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139719. */
  139720. get enableReflectivity(): boolean;
  139721. /**
  139722. * Sets wether or not objects roughness are enabled for the G buffer.
  139723. */
  139724. set enableReflectivity(enable: boolean);
  139725. /**
  139726. * Gets the scene associated with the buffer.
  139727. */
  139728. get scene(): Scene;
  139729. /**
  139730. * Gets the ratio used by the buffer during its creation.
  139731. * How big is the buffer related to the main canvas.
  139732. */
  139733. get ratio(): number;
  139734. /** @hidden */
  139735. static _SceneComponentInitialization: (scene: Scene) => void;
  139736. /**
  139737. * Creates a new G Buffer for the scene
  139738. * @param scene The scene the buffer belongs to
  139739. * @param ratio How big is the buffer related to the main canvas.
  139740. */
  139741. constructor(scene: Scene, ratio?: number);
  139742. /**
  139743. * Checks wether everything is ready to render a submesh to the G buffer.
  139744. * @param subMesh the submesh to check readiness for
  139745. * @param useInstances is the mesh drawn using instance or not
  139746. * @returns true if ready otherwise false
  139747. */
  139748. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139749. /**
  139750. * Gets the current underlying G Buffer.
  139751. * @returns the buffer
  139752. */
  139753. getGBuffer(): MultiRenderTarget;
  139754. /**
  139755. * Gets the number of samples used to render the buffer (anti aliasing).
  139756. */
  139757. get samples(): number;
  139758. /**
  139759. * Sets the number of samples used to render the buffer (anti aliasing).
  139760. */
  139761. set samples(value: number);
  139762. /**
  139763. * Disposes the renderer and frees up associated resources.
  139764. */
  139765. dispose(): void;
  139766. protected _createRenderTargets(): void;
  139767. private _copyBonesTransformationMatrices;
  139768. }
  139769. }
  139770. declare module BABYLON {
  139771. interface Scene {
  139772. /** @hidden (Backing field) */
  139773. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139774. /**
  139775. * Gets or Sets the current geometry buffer associated to the scene.
  139776. */
  139777. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139778. /**
  139779. * Enables a GeometryBufferRender and associates it with the scene
  139780. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139781. * @returns the GeometryBufferRenderer
  139782. */
  139783. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139784. /**
  139785. * Disables the GeometryBufferRender associated with the scene
  139786. */
  139787. disableGeometryBufferRenderer(): void;
  139788. }
  139789. /**
  139790. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139791. * in several rendering techniques.
  139792. */
  139793. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139794. /**
  139795. * The component name helpful to identify the component in the list of scene components.
  139796. */
  139797. readonly name: string;
  139798. /**
  139799. * The scene the component belongs to.
  139800. */
  139801. scene: Scene;
  139802. /**
  139803. * Creates a new instance of the component for the given scene
  139804. * @param scene Defines the scene to register the component in
  139805. */
  139806. constructor(scene: Scene);
  139807. /**
  139808. * Registers the component in a given scene
  139809. */
  139810. register(): void;
  139811. /**
  139812. * Rebuilds the elements related to this component in case of
  139813. * context lost for instance.
  139814. */
  139815. rebuild(): void;
  139816. /**
  139817. * Disposes the component and the associated ressources
  139818. */
  139819. dispose(): void;
  139820. private _gatherRenderTargets;
  139821. }
  139822. }
  139823. declare module BABYLON {
  139824. /** @hidden */
  139825. export var motionBlurPixelShader: {
  139826. name: string;
  139827. shader: string;
  139828. };
  139829. }
  139830. declare module BABYLON {
  139831. /**
  139832. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139833. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139834. * As an example, all you have to do is to create the post-process:
  139835. * var mb = new BABYLON.MotionBlurPostProcess(
  139836. * 'mb', // The name of the effect.
  139837. * scene, // The scene containing the objects to blur according to their velocity.
  139838. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139839. * camera // The camera to apply the render pass to.
  139840. * );
  139841. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139842. */
  139843. export class MotionBlurPostProcess extends PostProcess {
  139844. /**
  139845. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139846. */
  139847. motionStrength: number;
  139848. /**
  139849. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139850. */
  139851. get motionBlurSamples(): number;
  139852. /**
  139853. * Sets the number of iterations to be used for motion blur quality
  139854. */
  139855. set motionBlurSamples(samples: number);
  139856. private _motionBlurSamples;
  139857. private _geometryBufferRenderer;
  139858. /**
  139859. * Creates a new instance MotionBlurPostProcess
  139860. * @param name The name of the effect.
  139861. * @param scene The scene containing the objects to blur according to their velocity.
  139862. * @param options The required width/height ratio to downsize to before computing the render pass.
  139863. * @param camera The camera to apply the render pass to.
  139864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139865. * @param engine The engine which the post process will be applied. (default: current engine)
  139866. * @param reusable If the post process can be reused on the same frame. (default: false)
  139867. * @param textureType Type of textures used when performing the post process. (default: 0)
  139868. * @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)
  139869. */
  139870. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139871. /**
  139872. * Excludes the given skinned mesh from computing bones velocities.
  139873. * 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.
  139874. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139875. */
  139876. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139877. /**
  139878. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139879. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139880. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139881. */
  139882. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139883. /**
  139884. * Disposes the post process.
  139885. * @param camera The camera to dispose the post process on.
  139886. */
  139887. dispose(camera?: Camera): void;
  139888. }
  139889. }
  139890. declare module BABYLON {
  139891. /** @hidden */
  139892. export var refractionPixelShader: {
  139893. name: string;
  139894. shader: string;
  139895. };
  139896. }
  139897. declare module BABYLON {
  139898. /**
  139899. * Post process which applies a refractin texture
  139900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139901. */
  139902. export class RefractionPostProcess extends PostProcess {
  139903. /** the base color of the refraction (used to taint the rendering) */
  139904. color: Color3;
  139905. /** simulated refraction depth */
  139906. depth: number;
  139907. /** the coefficient of the base color (0 to remove base color tainting) */
  139908. colorLevel: number;
  139909. private _refTexture;
  139910. private _ownRefractionTexture;
  139911. /**
  139912. * Gets or sets the refraction texture
  139913. * Please note that you are responsible for disposing the texture if you set it manually
  139914. */
  139915. get refractionTexture(): Texture;
  139916. set refractionTexture(value: Texture);
  139917. /**
  139918. * Initializes the RefractionPostProcess
  139919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139920. * @param name The name of the effect.
  139921. * @param refractionTextureUrl Url of the refraction texture to use
  139922. * @param color the base color of the refraction (used to taint the rendering)
  139923. * @param depth simulated refraction depth
  139924. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139925. * @param camera The camera to apply the render pass to.
  139926. * @param options The required width/height ratio to downsize to before computing the render pass.
  139927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139928. * @param engine The engine which the post process will be applied. (default: current engine)
  139929. * @param reusable If the post process can be reused on the same frame. (default: false)
  139930. */
  139931. constructor(name: string, refractionTextureUrl: string,
  139932. /** the base color of the refraction (used to taint the rendering) */
  139933. color: Color3,
  139934. /** simulated refraction depth */
  139935. depth: number,
  139936. /** the coefficient of the base color (0 to remove base color tainting) */
  139937. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139938. /**
  139939. * Disposes of the post process
  139940. * @param camera Camera to dispose post process on
  139941. */
  139942. dispose(camera: Camera): void;
  139943. }
  139944. }
  139945. declare module BABYLON {
  139946. /** @hidden */
  139947. export var sharpenPixelShader: {
  139948. name: string;
  139949. shader: string;
  139950. };
  139951. }
  139952. declare module BABYLON {
  139953. /**
  139954. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139955. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139956. */
  139957. export class SharpenPostProcess extends PostProcess {
  139958. /**
  139959. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139960. */
  139961. colorAmount: number;
  139962. /**
  139963. * How much sharpness should be applied (default: 0.3)
  139964. */
  139965. edgeAmount: number;
  139966. /**
  139967. * Creates a new instance ConvolutionPostProcess
  139968. * @param name The name of the effect.
  139969. * @param options The required width/height ratio to downsize to before computing the render pass.
  139970. * @param camera The camera to apply the render pass to.
  139971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139972. * @param engine The engine which the post process will be applied. (default: current engine)
  139973. * @param reusable If the post process can be reused on the same frame. (default: false)
  139974. * @param textureType Type of textures used when performing the post process. (default: 0)
  139975. * @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)
  139976. */
  139977. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139978. }
  139979. }
  139980. declare module BABYLON {
  139981. /**
  139982. * PostProcessRenderPipeline
  139983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139984. */
  139985. export class PostProcessRenderPipeline {
  139986. private engine;
  139987. private _renderEffects;
  139988. private _renderEffectsForIsolatedPass;
  139989. /**
  139990. * List of inspectable custom properties (used by the Inspector)
  139991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  139992. */
  139993. inspectableCustomProperties: IInspectable[];
  139994. /**
  139995. * @hidden
  139996. */
  139997. protected _cameras: Camera[];
  139998. /** @hidden */
  139999. _name: string;
  140000. /**
  140001. * Gets pipeline name
  140002. */
  140003. get name(): string;
  140004. /** Gets the list of attached cameras */
  140005. get cameras(): Camera[];
  140006. /**
  140007. * Initializes a PostProcessRenderPipeline
  140008. * @param engine engine to add the pipeline to
  140009. * @param name name of the pipeline
  140010. */
  140011. constructor(engine: Engine, name: string);
  140012. /**
  140013. * Gets the class name
  140014. * @returns "PostProcessRenderPipeline"
  140015. */
  140016. getClassName(): string;
  140017. /**
  140018. * If all the render effects in the pipeline are supported
  140019. */
  140020. get isSupported(): boolean;
  140021. /**
  140022. * Adds an effect to the pipeline
  140023. * @param renderEffect the effect to add
  140024. */
  140025. addEffect(renderEffect: PostProcessRenderEffect): void;
  140026. /** @hidden */
  140027. _rebuild(): void;
  140028. /** @hidden */
  140029. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140030. /** @hidden */
  140031. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140032. /** @hidden */
  140033. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140034. /** @hidden */
  140035. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140036. /** @hidden */
  140037. _attachCameras(cameras: Camera, unique: boolean): void;
  140038. /** @hidden */
  140039. _attachCameras(cameras: Camera[], unique: boolean): void;
  140040. /** @hidden */
  140041. _detachCameras(cameras: Camera): void;
  140042. /** @hidden */
  140043. _detachCameras(cameras: Nullable<Camera[]>): void;
  140044. /** @hidden */
  140045. _update(): void;
  140046. /** @hidden */
  140047. _reset(): void;
  140048. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140049. /**
  140050. * Disposes of the pipeline
  140051. */
  140052. dispose(): void;
  140053. }
  140054. }
  140055. declare module BABYLON {
  140056. /**
  140057. * PostProcessRenderPipelineManager class
  140058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140059. */
  140060. export class PostProcessRenderPipelineManager {
  140061. private _renderPipelines;
  140062. /**
  140063. * Initializes a PostProcessRenderPipelineManager
  140064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140065. */
  140066. constructor();
  140067. /**
  140068. * Gets the list of supported render pipelines
  140069. */
  140070. get supportedPipelines(): PostProcessRenderPipeline[];
  140071. /**
  140072. * Adds a pipeline to the manager
  140073. * @param renderPipeline The pipeline to add
  140074. */
  140075. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140076. /**
  140077. * Attaches a camera to the pipeline
  140078. * @param renderPipelineName The name of the pipeline to attach to
  140079. * @param cameras the camera to attach
  140080. * @param unique if the camera can be attached multiple times to the pipeline
  140081. */
  140082. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140083. /**
  140084. * Detaches a camera from the pipeline
  140085. * @param renderPipelineName The name of the pipeline to detach from
  140086. * @param cameras the camera to detach
  140087. */
  140088. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140089. /**
  140090. * Enables an effect by name on a pipeline
  140091. * @param renderPipelineName the name of the pipeline to enable the effect in
  140092. * @param renderEffectName the name of the effect to enable
  140093. * @param cameras the cameras that the effect should be enabled on
  140094. */
  140095. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140096. /**
  140097. * Disables an effect by name on a pipeline
  140098. * @param renderPipelineName the name of the pipeline to disable the effect in
  140099. * @param renderEffectName the name of the effect to disable
  140100. * @param cameras the cameras that the effect should be disabled on
  140101. */
  140102. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140103. /**
  140104. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140105. */
  140106. update(): void;
  140107. /** @hidden */
  140108. _rebuild(): void;
  140109. /**
  140110. * Disposes of the manager and pipelines
  140111. */
  140112. dispose(): void;
  140113. }
  140114. }
  140115. declare module BABYLON {
  140116. interface Scene {
  140117. /** @hidden (Backing field) */
  140118. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140119. /**
  140120. * Gets the postprocess render pipeline manager
  140121. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140122. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140123. */
  140124. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140125. }
  140126. /**
  140127. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140128. */
  140129. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140130. /**
  140131. * The component name helpfull to identify the component in the list of scene components.
  140132. */
  140133. readonly name: string;
  140134. /**
  140135. * The scene the component belongs to.
  140136. */
  140137. scene: Scene;
  140138. /**
  140139. * Creates a new instance of the component for the given scene
  140140. * @param scene Defines the scene to register the component in
  140141. */
  140142. constructor(scene: Scene);
  140143. /**
  140144. * Registers the component in a given scene
  140145. */
  140146. register(): void;
  140147. /**
  140148. * Rebuilds the elements related to this component in case of
  140149. * context lost for instance.
  140150. */
  140151. rebuild(): void;
  140152. /**
  140153. * Disposes the component and the associated ressources
  140154. */
  140155. dispose(): void;
  140156. private _gatherRenderTargets;
  140157. }
  140158. }
  140159. declare module BABYLON {
  140160. /**
  140161. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140162. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140163. */
  140164. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140165. private _scene;
  140166. private _camerasToBeAttached;
  140167. /**
  140168. * ID of the sharpen post process,
  140169. */
  140170. private readonly SharpenPostProcessId;
  140171. /**
  140172. * @ignore
  140173. * ID of the image processing post process;
  140174. */
  140175. readonly ImageProcessingPostProcessId: string;
  140176. /**
  140177. * @ignore
  140178. * ID of the Fast Approximate Anti-Aliasing post process;
  140179. */
  140180. readonly FxaaPostProcessId: string;
  140181. /**
  140182. * ID of the chromatic aberration post process,
  140183. */
  140184. private readonly ChromaticAberrationPostProcessId;
  140185. /**
  140186. * ID of the grain post process
  140187. */
  140188. private readonly GrainPostProcessId;
  140189. /**
  140190. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140191. */
  140192. sharpen: SharpenPostProcess;
  140193. private _sharpenEffect;
  140194. private bloom;
  140195. /**
  140196. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140197. */
  140198. depthOfField: DepthOfFieldEffect;
  140199. /**
  140200. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140201. */
  140202. fxaa: FxaaPostProcess;
  140203. /**
  140204. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140205. */
  140206. imageProcessing: ImageProcessingPostProcess;
  140207. /**
  140208. * Chromatic aberration post process which will shift rgb colors in the image
  140209. */
  140210. chromaticAberration: ChromaticAberrationPostProcess;
  140211. private _chromaticAberrationEffect;
  140212. /**
  140213. * Grain post process which add noise to the image
  140214. */
  140215. grain: GrainPostProcess;
  140216. private _grainEffect;
  140217. /**
  140218. * Glow post process which adds a glow to emissive areas of the image
  140219. */
  140220. private _glowLayer;
  140221. /**
  140222. * Animations which can be used to tweak settings over a period of time
  140223. */
  140224. animations: Animation[];
  140225. private _imageProcessingConfigurationObserver;
  140226. private _sharpenEnabled;
  140227. private _bloomEnabled;
  140228. private _depthOfFieldEnabled;
  140229. private _depthOfFieldBlurLevel;
  140230. private _fxaaEnabled;
  140231. private _imageProcessingEnabled;
  140232. private _defaultPipelineTextureType;
  140233. private _bloomScale;
  140234. private _chromaticAberrationEnabled;
  140235. private _grainEnabled;
  140236. private _buildAllowed;
  140237. /**
  140238. * Gets active scene
  140239. */
  140240. get scene(): Scene;
  140241. /**
  140242. * Enable or disable the sharpen process from the pipeline
  140243. */
  140244. set sharpenEnabled(enabled: boolean);
  140245. get sharpenEnabled(): boolean;
  140246. private _resizeObserver;
  140247. private _hardwareScaleLevel;
  140248. private _bloomKernel;
  140249. /**
  140250. * Specifies the size of the bloom blur kernel, relative to the final output size
  140251. */
  140252. get bloomKernel(): number;
  140253. set bloomKernel(value: number);
  140254. /**
  140255. * Specifies the weight of the bloom in the final rendering
  140256. */
  140257. private _bloomWeight;
  140258. /**
  140259. * Specifies the luma threshold for the area that will be blurred by the bloom
  140260. */
  140261. private _bloomThreshold;
  140262. private _hdr;
  140263. /**
  140264. * The strength of the bloom.
  140265. */
  140266. set bloomWeight(value: number);
  140267. get bloomWeight(): number;
  140268. /**
  140269. * The strength of the bloom.
  140270. */
  140271. set bloomThreshold(value: number);
  140272. get bloomThreshold(): number;
  140273. /**
  140274. * The scale of the bloom, lower value will provide better performance.
  140275. */
  140276. set bloomScale(value: number);
  140277. get bloomScale(): number;
  140278. /**
  140279. * Enable or disable the bloom from the pipeline
  140280. */
  140281. set bloomEnabled(enabled: boolean);
  140282. get bloomEnabled(): boolean;
  140283. private _rebuildBloom;
  140284. /**
  140285. * If the depth of field is enabled.
  140286. */
  140287. get depthOfFieldEnabled(): boolean;
  140288. set depthOfFieldEnabled(enabled: boolean);
  140289. /**
  140290. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140291. */
  140292. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140293. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140294. /**
  140295. * If the anti aliasing is enabled.
  140296. */
  140297. set fxaaEnabled(enabled: boolean);
  140298. get fxaaEnabled(): boolean;
  140299. private _samples;
  140300. /**
  140301. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140302. */
  140303. set samples(sampleCount: number);
  140304. get samples(): number;
  140305. /**
  140306. * If image processing is enabled.
  140307. */
  140308. set imageProcessingEnabled(enabled: boolean);
  140309. get imageProcessingEnabled(): boolean;
  140310. /**
  140311. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140312. */
  140313. set glowLayerEnabled(enabled: boolean);
  140314. get glowLayerEnabled(): boolean;
  140315. /**
  140316. * Gets the glow layer (or null if not defined)
  140317. */
  140318. get glowLayer(): Nullable<GlowLayer>;
  140319. /**
  140320. * Enable or disable the chromaticAberration process from the pipeline
  140321. */
  140322. set chromaticAberrationEnabled(enabled: boolean);
  140323. get chromaticAberrationEnabled(): boolean;
  140324. /**
  140325. * Enable or disable the grain process from the pipeline
  140326. */
  140327. set grainEnabled(enabled: boolean);
  140328. get grainEnabled(): boolean;
  140329. /**
  140330. * @constructor
  140331. * @param name - The rendering pipeline name (default: "")
  140332. * @param hdr - If high dynamic range textures should be used (default: true)
  140333. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140334. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140335. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140336. */
  140337. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140338. /**
  140339. * Get the class name
  140340. * @returns "DefaultRenderingPipeline"
  140341. */
  140342. getClassName(): string;
  140343. /**
  140344. * Force the compilation of the entire pipeline.
  140345. */
  140346. prepare(): void;
  140347. private _hasCleared;
  140348. private _prevPostProcess;
  140349. private _prevPrevPostProcess;
  140350. private _setAutoClearAndTextureSharing;
  140351. private _depthOfFieldSceneObserver;
  140352. private _buildPipeline;
  140353. private _disposePostProcesses;
  140354. /**
  140355. * Adds a camera to the pipeline
  140356. * @param camera the camera to be added
  140357. */
  140358. addCamera(camera: Camera): void;
  140359. /**
  140360. * Removes a camera from the pipeline
  140361. * @param camera the camera to remove
  140362. */
  140363. removeCamera(camera: Camera): void;
  140364. /**
  140365. * Dispose of the pipeline and stop all post processes
  140366. */
  140367. dispose(): void;
  140368. /**
  140369. * Serialize the rendering pipeline (Used when exporting)
  140370. * @returns the serialized object
  140371. */
  140372. serialize(): any;
  140373. /**
  140374. * Parse the serialized pipeline
  140375. * @param source Source pipeline.
  140376. * @param scene The scene to load the pipeline to.
  140377. * @param rootUrl The URL of the serialized pipeline.
  140378. * @returns An instantiated pipeline from the serialized object.
  140379. */
  140380. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140381. }
  140382. }
  140383. declare module BABYLON {
  140384. /** @hidden */
  140385. export var lensHighlightsPixelShader: {
  140386. name: string;
  140387. shader: string;
  140388. };
  140389. }
  140390. declare module BABYLON {
  140391. /** @hidden */
  140392. export var depthOfFieldPixelShader: {
  140393. name: string;
  140394. shader: string;
  140395. };
  140396. }
  140397. declare module BABYLON {
  140398. /**
  140399. * BABYLON.JS Chromatic Aberration GLSL Shader
  140400. * Author: Olivier Guyot
  140401. * Separates very slightly R, G and B colors on the edges of the screen
  140402. * Inspired by Francois Tarlier & Martins Upitis
  140403. */
  140404. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140405. /**
  140406. * @ignore
  140407. * The chromatic aberration PostProcess id in the pipeline
  140408. */
  140409. LensChromaticAberrationEffect: string;
  140410. /**
  140411. * @ignore
  140412. * The highlights enhancing PostProcess id in the pipeline
  140413. */
  140414. HighlightsEnhancingEffect: string;
  140415. /**
  140416. * @ignore
  140417. * The depth-of-field PostProcess id in the pipeline
  140418. */
  140419. LensDepthOfFieldEffect: string;
  140420. private _scene;
  140421. private _depthTexture;
  140422. private _grainTexture;
  140423. private _chromaticAberrationPostProcess;
  140424. private _highlightsPostProcess;
  140425. private _depthOfFieldPostProcess;
  140426. private _edgeBlur;
  140427. private _grainAmount;
  140428. private _chromaticAberration;
  140429. private _distortion;
  140430. private _highlightsGain;
  140431. private _highlightsThreshold;
  140432. private _dofDistance;
  140433. private _dofAperture;
  140434. private _dofDarken;
  140435. private _dofPentagon;
  140436. private _blurNoise;
  140437. /**
  140438. * @constructor
  140439. *
  140440. * Effect parameters are as follow:
  140441. * {
  140442. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140443. * edge_blur: number; // from 0 to x (1 for realism)
  140444. * distortion: number; // from 0 to x (1 for realism)
  140445. * grain_amount: number; // from 0 to 1
  140446. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140447. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140448. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140449. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140450. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140451. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140452. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140453. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140454. * }
  140455. * Note: if an effect parameter is unset, effect is disabled
  140456. *
  140457. * @param name The rendering pipeline name
  140458. * @param parameters - An object containing all parameters (see above)
  140459. * @param scene The scene linked to this pipeline
  140460. * @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)
  140461. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140462. */
  140463. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140464. /**
  140465. * Get the class name
  140466. * @returns "LensRenderingPipeline"
  140467. */
  140468. getClassName(): string;
  140469. /**
  140470. * Gets associated scene
  140471. */
  140472. get scene(): Scene;
  140473. /**
  140474. * Gets or sets the edge blur
  140475. */
  140476. get edgeBlur(): number;
  140477. set edgeBlur(value: number);
  140478. /**
  140479. * Gets or sets the grain amount
  140480. */
  140481. get grainAmount(): number;
  140482. set grainAmount(value: number);
  140483. /**
  140484. * Gets or sets the chromatic aberration amount
  140485. */
  140486. get chromaticAberration(): number;
  140487. set chromaticAberration(value: number);
  140488. /**
  140489. * Gets or sets the depth of field aperture
  140490. */
  140491. get dofAperture(): number;
  140492. set dofAperture(value: number);
  140493. /**
  140494. * Gets or sets the edge distortion
  140495. */
  140496. get edgeDistortion(): number;
  140497. set edgeDistortion(value: number);
  140498. /**
  140499. * Gets or sets the depth of field distortion
  140500. */
  140501. get dofDistortion(): number;
  140502. set dofDistortion(value: number);
  140503. /**
  140504. * Gets or sets the darken out of focus amount
  140505. */
  140506. get darkenOutOfFocus(): number;
  140507. set darkenOutOfFocus(value: number);
  140508. /**
  140509. * Gets or sets a boolean indicating if blur noise is enabled
  140510. */
  140511. get blurNoise(): boolean;
  140512. set blurNoise(value: boolean);
  140513. /**
  140514. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140515. */
  140516. get pentagonBokeh(): boolean;
  140517. set pentagonBokeh(value: boolean);
  140518. /**
  140519. * Gets or sets the highlight grain amount
  140520. */
  140521. get highlightsGain(): number;
  140522. set highlightsGain(value: number);
  140523. /**
  140524. * Gets or sets the highlight threshold
  140525. */
  140526. get highlightsThreshold(): number;
  140527. set highlightsThreshold(value: number);
  140528. /**
  140529. * Sets the amount of blur at the edges
  140530. * @param amount blur amount
  140531. */
  140532. setEdgeBlur(amount: number): void;
  140533. /**
  140534. * Sets edge blur to 0
  140535. */
  140536. disableEdgeBlur(): void;
  140537. /**
  140538. * Sets the amout of grain
  140539. * @param amount Amount of grain
  140540. */
  140541. setGrainAmount(amount: number): void;
  140542. /**
  140543. * Set grain amount to 0
  140544. */
  140545. disableGrain(): void;
  140546. /**
  140547. * Sets the chromatic aberration amount
  140548. * @param amount amount of chromatic aberration
  140549. */
  140550. setChromaticAberration(amount: number): void;
  140551. /**
  140552. * Sets chromatic aberration amount to 0
  140553. */
  140554. disableChromaticAberration(): void;
  140555. /**
  140556. * Sets the EdgeDistortion amount
  140557. * @param amount amount of EdgeDistortion
  140558. */
  140559. setEdgeDistortion(amount: number): void;
  140560. /**
  140561. * Sets edge distortion to 0
  140562. */
  140563. disableEdgeDistortion(): void;
  140564. /**
  140565. * Sets the FocusDistance amount
  140566. * @param amount amount of FocusDistance
  140567. */
  140568. setFocusDistance(amount: number): void;
  140569. /**
  140570. * Disables depth of field
  140571. */
  140572. disableDepthOfField(): void;
  140573. /**
  140574. * Sets the Aperture amount
  140575. * @param amount amount of Aperture
  140576. */
  140577. setAperture(amount: number): void;
  140578. /**
  140579. * Sets the DarkenOutOfFocus amount
  140580. * @param amount amount of DarkenOutOfFocus
  140581. */
  140582. setDarkenOutOfFocus(amount: number): void;
  140583. private _pentagonBokehIsEnabled;
  140584. /**
  140585. * Creates a pentagon bokeh effect
  140586. */
  140587. enablePentagonBokeh(): void;
  140588. /**
  140589. * Disables the pentagon bokeh effect
  140590. */
  140591. disablePentagonBokeh(): void;
  140592. /**
  140593. * Enables noise blur
  140594. */
  140595. enableNoiseBlur(): void;
  140596. /**
  140597. * Disables noise blur
  140598. */
  140599. disableNoiseBlur(): void;
  140600. /**
  140601. * Sets the HighlightsGain amount
  140602. * @param amount amount of HighlightsGain
  140603. */
  140604. setHighlightsGain(amount: number): void;
  140605. /**
  140606. * Sets the HighlightsThreshold amount
  140607. * @param amount amount of HighlightsThreshold
  140608. */
  140609. setHighlightsThreshold(amount: number): void;
  140610. /**
  140611. * Disables highlights
  140612. */
  140613. disableHighlights(): void;
  140614. /**
  140615. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140616. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140617. */
  140618. dispose(disableDepthRender?: boolean): void;
  140619. private _createChromaticAberrationPostProcess;
  140620. private _createHighlightsPostProcess;
  140621. private _createDepthOfFieldPostProcess;
  140622. private _createGrainTexture;
  140623. }
  140624. }
  140625. declare module BABYLON {
  140626. /** @hidden */
  140627. export var ssao2PixelShader: {
  140628. name: string;
  140629. shader: string;
  140630. };
  140631. }
  140632. declare module BABYLON {
  140633. /** @hidden */
  140634. export var ssaoCombinePixelShader: {
  140635. name: string;
  140636. shader: string;
  140637. };
  140638. }
  140639. declare module BABYLON {
  140640. /**
  140641. * Render pipeline to produce ssao effect
  140642. */
  140643. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140644. /**
  140645. * @ignore
  140646. * The PassPostProcess id in the pipeline that contains the original scene color
  140647. */
  140648. SSAOOriginalSceneColorEffect: string;
  140649. /**
  140650. * @ignore
  140651. * The SSAO PostProcess id in the pipeline
  140652. */
  140653. SSAORenderEffect: string;
  140654. /**
  140655. * @ignore
  140656. * The horizontal blur PostProcess id in the pipeline
  140657. */
  140658. SSAOBlurHRenderEffect: string;
  140659. /**
  140660. * @ignore
  140661. * The vertical blur PostProcess id in the pipeline
  140662. */
  140663. SSAOBlurVRenderEffect: string;
  140664. /**
  140665. * @ignore
  140666. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140667. */
  140668. SSAOCombineRenderEffect: string;
  140669. /**
  140670. * The output strength of the SSAO post-process. Default value is 1.0.
  140671. */
  140672. totalStrength: number;
  140673. /**
  140674. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140675. */
  140676. maxZ: number;
  140677. /**
  140678. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140679. */
  140680. minZAspect: number;
  140681. private _samples;
  140682. /**
  140683. * Number of samples used for the SSAO calculations. Default value is 8
  140684. */
  140685. set samples(n: number);
  140686. get samples(): number;
  140687. private _textureSamples;
  140688. /**
  140689. * Number of samples to use for antialiasing
  140690. */
  140691. set textureSamples(n: number);
  140692. get textureSamples(): number;
  140693. /**
  140694. * Ratio object used for SSAO ratio and blur ratio
  140695. */
  140696. private _ratio;
  140697. /**
  140698. * Dynamically generated sphere sampler.
  140699. */
  140700. private _sampleSphere;
  140701. /**
  140702. * Blur filter offsets
  140703. */
  140704. private _samplerOffsets;
  140705. private _expensiveBlur;
  140706. /**
  140707. * If bilateral blur should be used
  140708. */
  140709. set expensiveBlur(b: boolean);
  140710. get expensiveBlur(): boolean;
  140711. /**
  140712. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140713. */
  140714. radius: number;
  140715. /**
  140716. * The base color of the SSAO post-process
  140717. * The final result is "base + ssao" between [0, 1]
  140718. */
  140719. base: number;
  140720. /**
  140721. * Support test.
  140722. */
  140723. static get IsSupported(): boolean;
  140724. private _scene;
  140725. private _depthTexture;
  140726. private _normalTexture;
  140727. private _randomTexture;
  140728. private _originalColorPostProcess;
  140729. private _ssaoPostProcess;
  140730. private _blurHPostProcess;
  140731. private _blurVPostProcess;
  140732. private _ssaoCombinePostProcess;
  140733. /**
  140734. * Gets active scene
  140735. */
  140736. get scene(): Scene;
  140737. /**
  140738. * @constructor
  140739. * @param name The rendering pipeline name
  140740. * @param scene The scene linked to this pipeline
  140741. * @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 }
  140742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140743. */
  140744. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140745. /**
  140746. * Get the class name
  140747. * @returns "SSAO2RenderingPipeline"
  140748. */
  140749. getClassName(): string;
  140750. /**
  140751. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140752. */
  140753. dispose(disableGeometryBufferRenderer?: boolean): void;
  140754. private _createBlurPostProcess;
  140755. /** @hidden */
  140756. _rebuild(): void;
  140757. private _bits;
  140758. private _radicalInverse_VdC;
  140759. private _hammersley;
  140760. private _hemisphereSample_uniform;
  140761. private _generateHemisphere;
  140762. private _createSSAOPostProcess;
  140763. private _createSSAOCombinePostProcess;
  140764. private _createRandomTexture;
  140765. /**
  140766. * Serialize the rendering pipeline (Used when exporting)
  140767. * @returns the serialized object
  140768. */
  140769. serialize(): any;
  140770. /**
  140771. * Parse the serialized pipeline
  140772. * @param source Source pipeline.
  140773. * @param scene The scene to load the pipeline to.
  140774. * @param rootUrl The URL of the serialized pipeline.
  140775. * @returns An instantiated pipeline from the serialized object.
  140776. */
  140777. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140778. }
  140779. }
  140780. declare module BABYLON {
  140781. /** @hidden */
  140782. export var ssaoPixelShader: {
  140783. name: string;
  140784. shader: string;
  140785. };
  140786. }
  140787. declare module BABYLON {
  140788. /**
  140789. * Render pipeline to produce ssao effect
  140790. */
  140791. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140792. /**
  140793. * @ignore
  140794. * The PassPostProcess id in the pipeline that contains the original scene color
  140795. */
  140796. SSAOOriginalSceneColorEffect: string;
  140797. /**
  140798. * @ignore
  140799. * The SSAO PostProcess id in the pipeline
  140800. */
  140801. SSAORenderEffect: string;
  140802. /**
  140803. * @ignore
  140804. * The horizontal blur PostProcess id in the pipeline
  140805. */
  140806. SSAOBlurHRenderEffect: string;
  140807. /**
  140808. * @ignore
  140809. * The vertical blur PostProcess id in the pipeline
  140810. */
  140811. SSAOBlurVRenderEffect: string;
  140812. /**
  140813. * @ignore
  140814. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140815. */
  140816. SSAOCombineRenderEffect: string;
  140817. /**
  140818. * The output strength of the SSAO post-process. Default value is 1.0.
  140819. */
  140820. totalStrength: number;
  140821. /**
  140822. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140823. */
  140824. radius: number;
  140825. /**
  140826. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140827. * Must not be equal to fallOff and superior to fallOff.
  140828. * Default value is 0.0075
  140829. */
  140830. area: number;
  140831. /**
  140832. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140833. * Must not be equal to area and inferior to area.
  140834. * Default value is 0.000001
  140835. */
  140836. fallOff: number;
  140837. /**
  140838. * The base color of the SSAO post-process
  140839. * The final result is "base + ssao" between [0, 1]
  140840. */
  140841. base: number;
  140842. private _scene;
  140843. private _depthTexture;
  140844. private _randomTexture;
  140845. private _originalColorPostProcess;
  140846. private _ssaoPostProcess;
  140847. private _blurHPostProcess;
  140848. private _blurVPostProcess;
  140849. private _ssaoCombinePostProcess;
  140850. private _firstUpdate;
  140851. /**
  140852. * Gets active scene
  140853. */
  140854. get scene(): Scene;
  140855. /**
  140856. * @constructor
  140857. * @param name - The rendering pipeline name
  140858. * @param scene - The scene linked to this pipeline
  140859. * @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 }
  140860. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140861. */
  140862. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140863. /**
  140864. * Get the class name
  140865. * @returns "SSAORenderingPipeline"
  140866. */
  140867. getClassName(): string;
  140868. /**
  140869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140870. */
  140871. dispose(disableDepthRender?: boolean): void;
  140872. private _createBlurPostProcess;
  140873. /** @hidden */
  140874. _rebuild(): void;
  140875. private _createSSAOPostProcess;
  140876. private _createSSAOCombinePostProcess;
  140877. private _createRandomTexture;
  140878. }
  140879. }
  140880. declare module BABYLON {
  140881. /** @hidden */
  140882. export var screenSpaceReflectionPixelShader: {
  140883. name: string;
  140884. shader: string;
  140885. };
  140886. }
  140887. declare module BABYLON {
  140888. /**
  140889. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140890. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140891. */
  140892. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140893. /**
  140894. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140895. */
  140896. threshold: number;
  140897. /**
  140898. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140899. */
  140900. strength: number;
  140901. /**
  140902. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140903. */
  140904. reflectionSpecularFalloffExponent: number;
  140905. /**
  140906. * 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]
  140907. */
  140908. step: number;
  140909. /**
  140910. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140911. */
  140912. roughnessFactor: number;
  140913. private _geometryBufferRenderer;
  140914. private _enableSmoothReflections;
  140915. private _reflectionSamples;
  140916. private _smoothSteps;
  140917. /**
  140918. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140919. * @param name The name of the effect.
  140920. * @param scene The scene containing the objects to calculate reflections.
  140921. * @param options The required width/height ratio to downsize to before computing the render pass.
  140922. * @param camera The camera to apply the render pass to.
  140923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140924. * @param engine The engine which the post process will be applied. (default: current engine)
  140925. * @param reusable If the post process can be reused on the same frame. (default: false)
  140926. * @param textureType Type of textures used when performing the post process. (default: 0)
  140927. * @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)
  140928. */
  140929. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140930. /**
  140931. * Gets wether or not smoothing reflections is enabled.
  140932. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140933. */
  140934. get enableSmoothReflections(): boolean;
  140935. /**
  140936. * Sets wether or not smoothing reflections is enabled.
  140937. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140938. */
  140939. set enableSmoothReflections(enabled: boolean);
  140940. /**
  140941. * Gets the number of samples taken while computing reflections. More samples count is high,
  140942. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140943. */
  140944. get reflectionSamples(): number;
  140945. /**
  140946. * Sets the number of samples taken while computing reflections. More samples count is high,
  140947. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140948. */
  140949. set reflectionSamples(samples: number);
  140950. /**
  140951. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140952. * more the post-process will require GPU power and can generate a drop in FPS.
  140953. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140954. */
  140955. get smoothSteps(): number;
  140956. set smoothSteps(steps: number);
  140957. private _updateEffectDefines;
  140958. }
  140959. }
  140960. declare module BABYLON {
  140961. /** @hidden */
  140962. export var standardPixelShader: {
  140963. name: string;
  140964. shader: string;
  140965. };
  140966. }
  140967. declare module BABYLON {
  140968. /**
  140969. * Standard rendering pipeline
  140970. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140971. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140972. */
  140973. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140974. /**
  140975. * Public members
  140976. */
  140977. /**
  140978. * Post-process which contains the original scene color before the pipeline applies all the effects
  140979. */
  140980. originalPostProcess: Nullable<PostProcess>;
  140981. /**
  140982. * Post-process used to down scale an image x4
  140983. */
  140984. downSampleX4PostProcess: Nullable<PostProcess>;
  140985. /**
  140986. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  140987. */
  140988. brightPassPostProcess: Nullable<PostProcess>;
  140989. /**
  140990. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  140991. */
  140992. blurHPostProcesses: PostProcess[];
  140993. /**
  140994. * Post-process array storing all the vertical blur post-processes used by the pipeline
  140995. */
  140996. blurVPostProcesses: PostProcess[];
  140997. /**
  140998. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  140999. */
  141000. textureAdderPostProcess: Nullable<PostProcess>;
  141001. /**
  141002. * Post-process used to create volumetric lighting effect
  141003. */
  141004. volumetricLightPostProcess: Nullable<PostProcess>;
  141005. /**
  141006. * Post-process used to smooth the previous volumetric light post-process on the X axis
  141007. */
  141008. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  141009. /**
  141010. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  141011. */
  141012. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  141013. /**
  141014. * Post-process used to merge the volumetric light effect and the real scene color
  141015. */
  141016. volumetricLightMergePostProces: Nullable<PostProcess>;
  141017. /**
  141018. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141019. */
  141020. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141021. /**
  141022. * Base post-process used to calculate the average luminance of the final image for HDR
  141023. */
  141024. luminancePostProcess: Nullable<PostProcess>;
  141025. /**
  141026. * Post-processes used to create down sample post-processes in order to get
  141027. * the average luminance of the final image for HDR
  141028. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141029. */
  141030. luminanceDownSamplePostProcesses: PostProcess[];
  141031. /**
  141032. * Post-process used to create a HDR effect (light adaptation)
  141033. */
  141034. hdrPostProcess: Nullable<PostProcess>;
  141035. /**
  141036. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141037. */
  141038. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141039. /**
  141040. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141041. */
  141042. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141043. /**
  141044. * Post-process used to merge the final HDR post-process and the real scene color
  141045. */
  141046. hdrFinalPostProcess: Nullable<PostProcess>;
  141047. /**
  141048. * Post-process used to create a lens flare effect
  141049. */
  141050. lensFlarePostProcess: Nullable<PostProcess>;
  141051. /**
  141052. * Post-process that merges the result of the lens flare post-process and the real scene color
  141053. */
  141054. lensFlareComposePostProcess: Nullable<PostProcess>;
  141055. /**
  141056. * Post-process used to create a motion blur effect
  141057. */
  141058. motionBlurPostProcess: Nullable<PostProcess>;
  141059. /**
  141060. * Post-process used to create a depth of field effect
  141061. */
  141062. depthOfFieldPostProcess: Nullable<PostProcess>;
  141063. /**
  141064. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141065. */
  141066. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141067. /**
  141068. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141069. */
  141070. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141071. /**
  141072. * Represents the brightness threshold in order to configure the illuminated surfaces
  141073. */
  141074. brightThreshold: number;
  141075. /**
  141076. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141077. */
  141078. blurWidth: number;
  141079. /**
  141080. * Sets if the blur for highlighted surfaces must be only horizontal
  141081. */
  141082. horizontalBlur: boolean;
  141083. /**
  141084. * Gets the overall exposure used by the pipeline
  141085. */
  141086. get exposure(): number;
  141087. /**
  141088. * Sets the overall exposure used by the pipeline
  141089. */
  141090. set exposure(value: number);
  141091. /**
  141092. * Texture used typically to simulate "dirty" on camera lens
  141093. */
  141094. lensTexture: Nullable<Texture>;
  141095. /**
  141096. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141097. */
  141098. volumetricLightCoefficient: number;
  141099. /**
  141100. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141101. */
  141102. volumetricLightPower: number;
  141103. /**
  141104. * Used the set the blur intensity to smooth the volumetric lights
  141105. */
  141106. volumetricLightBlurScale: number;
  141107. /**
  141108. * Light (spot or directional) used to generate the volumetric lights rays
  141109. * The source light must have a shadow generate so the pipeline can get its
  141110. * depth map
  141111. */
  141112. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141113. /**
  141114. * For eye adaptation, represents the minimum luminance the eye can see
  141115. */
  141116. hdrMinimumLuminance: number;
  141117. /**
  141118. * For eye adaptation, represents the decrease luminance speed
  141119. */
  141120. hdrDecreaseRate: number;
  141121. /**
  141122. * For eye adaptation, represents the increase luminance speed
  141123. */
  141124. hdrIncreaseRate: number;
  141125. /**
  141126. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141127. */
  141128. get hdrAutoExposure(): boolean;
  141129. /**
  141130. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141131. */
  141132. set hdrAutoExposure(value: boolean);
  141133. /**
  141134. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141135. */
  141136. lensColorTexture: Nullable<Texture>;
  141137. /**
  141138. * The overall strengh for the lens flare effect
  141139. */
  141140. lensFlareStrength: number;
  141141. /**
  141142. * Dispersion coefficient for lens flare ghosts
  141143. */
  141144. lensFlareGhostDispersal: number;
  141145. /**
  141146. * Main lens flare halo width
  141147. */
  141148. lensFlareHaloWidth: number;
  141149. /**
  141150. * Based on the lens distortion effect, defines how much the lens flare result
  141151. * is distorted
  141152. */
  141153. lensFlareDistortionStrength: number;
  141154. /**
  141155. * Configures the blur intensity used for for lens flare (halo)
  141156. */
  141157. lensFlareBlurWidth: number;
  141158. /**
  141159. * Lens star texture must be used to simulate rays on the flares and is available
  141160. * in the documentation
  141161. */
  141162. lensStarTexture: Nullable<Texture>;
  141163. /**
  141164. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141165. * flare effect by taking account of the dirt texture
  141166. */
  141167. lensFlareDirtTexture: Nullable<Texture>;
  141168. /**
  141169. * Represents the focal length for the depth of field effect
  141170. */
  141171. depthOfFieldDistance: number;
  141172. /**
  141173. * Represents the blur intensity for the blurred part of the depth of field effect
  141174. */
  141175. depthOfFieldBlurWidth: number;
  141176. /**
  141177. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141178. */
  141179. get motionStrength(): number;
  141180. /**
  141181. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141182. */
  141183. set motionStrength(strength: number);
  141184. /**
  141185. * Gets wether or not the motion blur post-process is object based or screen based.
  141186. */
  141187. get objectBasedMotionBlur(): boolean;
  141188. /**
  141189. * Sets wether or not the motion blur post-process should be object based or screen based
  141190. */
  141191. set objectBasedMotionBlur(value: boolean);
  141192. /**
  141193. * List of animations for the pipeline (IAnimatable implementation)
  141194. */
  141195. animations: Animation[];
  141196. /**
  141197. * Private members
  141198. */
  141199. private _scene;
  141200. private _currentDepthOfFieldSource;
  141201. private _basePostProcess;
  141202. private _fixedExposure;
  141203. private _currentExposure;
  141204. private _hdrAutoExposure;
  141205. private _hdrCurrentLuminance;
  141206. private _motionStrength;
  141207. private _isObjectBasedMotionBlur;
  141208. private _floatTextureType;
  141209. private _camerasToBeAttached;
  141210. private _ratio;
  141211. private _bloomEnabled;
  141212. private _depthOfFieldEnabled;
  141213. private _vlsEnabled;
  141214. private _lensFlareEnabled;
  141215. private _hdrEnabled;
  141216. private _motionBlurEnabled;
  141217. private _fxaaEnabled;
  141218. private _screenSpaceReflectionsEnabled;
  141219. private _motionBlurSamples;
  141220. private _volumetricLightStepsCount;
  141221. private _samples;
  141222. /**
  141223. * @ignore
  141224. * Specifies if the bloom pipeline is enabled
  141225. */
  141226. get BloomEnabled(): boolean;
  141227. set BloomEnabled(enabled: boolean);
  141228. /**
  141229. * @ignore
  141230. * Specifies if the depth of field pipeline is enabed
  141231. */
  141232. get DepthOfFieldEnabled(): boolean;
  141233. set DepthOfFieldEnabled(enabled: boolean);
  141234. /**
  141235. * @ignore
  141236. * Specifies if the lens flare pipeline is enabed
  141237. */
  141238. get LensFlareEnabled(): boolean;
  141239. set LensFlareEnabled(enabled: boolean);
  141240. /**
  141241. * @ignore
  141242. * Specifies if the HDR pipeline is enabled
  141243. */
  141244. get HDREnabled(): boolean;
  141245. set HDREnabled(enabled: boolean);
  141246. /**
  141247. * @ignore
  141248. * Specifies if the volumetric lights scattering effect is enabled
  141249. */
  141250. get VLSEnabled(): boolean;
  141251. set VLSEnabled(enabled: boolean);
  141252. /**
  141253. * @ignore
  141254. * Specifies if the motion blur effect is enabled
  141255. */
  141256. get MotionBlurEnabled(): boolean;
  141257. set MotionBlurEnabled(enabled: boolean);
  141258. /**
  141259. * Specifies if anti-aliasing is enabled
  141260. */
  141261. get fxaaEnabled(): boolean;
  141262. set fxaaEnabled(enabled: boolean);
  141263. /**
  141264. * Specifies if screen space reflections are enabled.
  141265. */
  141266. get screenSpaceReflectionsEnabled(): boolean;
  141267. set screenSpaceReflectionsEnabled(enabled: boolean);
  141268. /**
  141269. * Specifies the number of steps used to calculate the volumetric lights
  141270. * Typically in interval [50, 200]
  141271. */
  141272. get volumetricLightStepsCount(): number;
  141273. set volumetricLightStepsCount(count: number);
  141274. /**
  141275. * Specifies the number of samples used for the motion blur effect
  141276. * Typically in interval [16, 64]
  141277. */
  141278. get motionBlurSamples(): number;
  141279. set motionBlurSamples(samples: number);
  141280. /**
  141281. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141282. */
  141283. get samples(): number;
  141284. set samples(sampleCount: number);
  141285. /**
  141286. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141287. * @constructor
  141288. * @param name The rendering pipeline name
  141289. * @param scene The scene linked to this pipeline
  141290. * @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)
  141291. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141292. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141293. */
  141294. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141295. private _buildPipeline;
  141296. private _createDownSampleX4PostProcess;
  141297. private _createBrightPassPostProcess;
  141298. private _createBlurPostProcesses;
  141299. private _createTextureAdderPostProcess;
  141300. private _createVolumetricLightPostProcess;
  141301. private _createLuminancePostProcesses;
  141302. private _createHdrPostProcess;
  141303. private _createLensFlarePostProcess;
  141304. private _createDepthOfFieldPostProcess;
  141305. private _createMotionBlurPostProcess;
  141306. private _getDepthTexture;
  141307. private _disposePostProcesses;
  141308. /**
  141309. * Dispose of the pipeline and stop all post processes
  141310. */
  141311. dispose(): void;
  141312. /**
  141313. * Serialize the rendering pipeline (Used when exporting)
  141314. * @returns the serialized object
  141315. */
  141316. serialize(): any;
  141317. /**
  141318. * Parse the serialized pipeline
  141319. * @param source Source pipeline.
  141320. * @param scene The scene to load the pipeline to.
  141321. * @param rootUrl The URL of the serialized pipeline.
  141322. * @returns An instantiated pipeline from the serialized object.
  141323. */
  141324. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141325. /**
  141326. * Luminance steps
  141327. */
  141328. static LuminanceSteps: number;
  141329. }
  141330. }
  141331. declare module BABYLON {
  141332. /** @hidden */
  141333. export var tonemapPixelShader: {
  141334. name: string;
  141335. shader: string;
  141336. };
  141337. }
  141338. declare module BABYLON {
  141339. /** Defines operator used for tonemapping */
  141340. export enum TonemappingOperator {
  141341. /** Hable */
  141342. Hable = 0,
  141343. /** Reinhard */
  141344. Reinhard = 1,
  141345. /** HejiDawson */
  141346. HejiDawson = 2,
  141347. /** Photographic */
  141348. Photographic = 3
  141349. }
  141350. /**
  141351. * Defines a post process to apply tone mapping
  141352. */
  141353. export class TonemapPostProcess extends PostProcess {
  141354. private _operator;
  141355. /** Defines the required exposure adjustement */
  141356. exposureAdjustment: number;
  141357. /**
  141358. * Creates a new TonemapPostProcess
  141359. * @param name defines the name of the postprocess
  141360. * @param _operator defines the operator to use
  141361. * @param exposureAdjustment defines the required exposure adjustement
  141362. * @param camera defines the camera to use (can be null)
  141363. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141364. * @param engine defines the hosting engine (can be ignore if camera is set)
  141365. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141366. */
  141367. constructor(name: string, _operator: TonemappingOperator,
  141368. /** Defines the required exposure adjustement */
  141369. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141370. }
  141371. }
  141372. declare module BABYLON {
  141373. /** @hidden */
  141374. export var volumetricLightScatteringPixelShader: {
  141375. name: string;
  141376. shader: string;
  141377. };
  141378. }
  141379. declare module BABYLON {
  141380. /** @hidden */
  141381. export var volumetricLightScatteringPassVertexShader: {
  141382. name: string;
  141383. shader: string;
  141384. };
  141385. }
  141386. declare module BABYLON {
  141387. /** @hidden */
  141388. export var volumetricLightScatteringPassPixelShader: {
  141389. name: string;
  141390. shader: string;
  141391. };
  141392. }
  141393. declare module BABYLON {
  141394. /**
  141395. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141396. */
  141397. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141398. private _volumetricLightScatteringPass;
  141399. private _volumetricLightScatteringRTT;
  141400. private _viewPort;
  141401. private _screenCoordinates;
  141402. private _cachedDefines;
  141403. /**
  141404. * If not undefined, the mesh position is computed from the attached node position
  141405. */
  141406. attachedNode: {
  141407. position: Vector3;
  141408. };
  141409. /**
  141410. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141411. */
  141412. customMeshPosition: Vector3;
  141413. /**
  141414. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141415. */
  141416. useCustomMeshPosition: boolean;
  141417. /**
  141418. * If the post-process should inverse the light scattering direction
  141419. */
  141420. invert: boolean;
  141421. /**
  141422. * The internal mesh used by the post-process
  141423. */
  141424. mesh: Mesh;
  141425. /**
  141426. * @hidden
  141427. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141428. */
  141429. get useDiffuseColor(): boolean;
  141430. set useDiffuseColor(useDiffuseColor: boolean);
  141431. /**
  141432. * Array containing the excluded meshes not rendered in the internal pass
  141433. */
  141434. excludedMeshes: AbstractMesh[];
  141435. /**
  141436. * Controls the overall intensity of the post-process
  141437. */
  141438. exposure: number;
  141439. /**
  141440. * Dissipates each sample's contribution in range [0, 1]
  141441. */
  141442. decay: number;
  141443. /**
  141444. * Controls the overall intensity of each sample
  141445. */
  141446. weight: number;
  141447. /**
  141448. * Controls the density of each sample
  141449. */
  141450. density: number;
  141451. /**
  141452. * @constructor
  141453. * @param name The post-process name
  141454. * @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)
  141455. * @param camera The camera that the post-process will be attached to
  141456. * @param mesh The mesh used to create the light scattering
  141457. * @param samples The post-process quality, default 100
  141458. * @param samplingModeThe post-process filtering mode
  141459. * @param engine The babylon engine
  141460. * @param reusable If the post-process is reusable
  141461. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141462. */
  141463. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141464. /**
  141465. * Returns the string "VolumetricLightScatteringPostProcess"
  141466. * @returns "VolumetricLightScatteringPostProcess"
  141467. */
  141468. getClassName(): string;
  141469. private _isReady;
  141470. /**
  141471. * Sets the new light position for light scattering effect
  141472. * @param position The new custom light position
  141473. */
  141474. setCustomMeshPosition(position: Vector3): void;
  141475. /**
  141476. * Returns the light position for light scattering effect
  141477. * @return Vector3 The custom light position
  141478. */
  141479. getCustomMeshPosition(): Vector3;
  141480. /**
  141481. * Disposes the internal assets and detaches the post-process from the camera
  141482. */
  141483. dispose(camera: Camera): void;
  141484. /**
  141485. * Returns the render target texture used by the post-process
  141486. * @return the render target texture used by the post-process
  141487. */
  141488. getPass(): RenderTargetTexture;
  141489. private _meshExcluded;
  141490. private _createPass;
  141491. private _updateMeshScreenCoordinates;
  141492. /**
  141493. * Creates a default mesh for the Volumeric Light Scattering post-process
  141494. * @param name The mesh name
  141495. * @param scene The scene where to create the mesh
  141496. * @return the default mesh
  141497. */
  141498. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141499. }
  141500. }
  141501. declare module BABYLON {
  141502. interface Scene {
  141503. /** @hidden (Backing field) */
  141504. _boundingBoxRenderer: BoundingBoxRenderer;
  141505. /** @hidden (Backing field) */
  141506. _forceShowBoundingBoxes: boolean;
  141507. /**
  141508. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141509. */
  141510. forceShowBoundingBoxes: boolean;
  141511. /**
  141512. * Gets the bounding box renderer associated with the scene
  141513. * @returns a BoundingBoxRenderer
  141514. */
  141515. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141516. }
  141517. interface AbstractMesh {
  141518. /** @hidden (Backing field) */
  141519. _showBoundingBox: boolean;
  141520. /**
  141521. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141522. */
  141523. showBoundingBox: boolean;
  141524. }
  141525. /**
  141526. * Component responsible of rendering the bounding box of the meshes in a scene.
  141527. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141528. */
  141529. export class BoundingBoxRenderer implements ISceneComponent {
  141530. /**
  141531. * The component name helpfull to identify the component in the list of scene components.
  141532. */
  141533. readonly name: string;
  141534. /**
  141535. * The scene the component belongs to.
  141536. */
  141537. scene: Scene;
  141538. /**
  141539. * Color of the bounding box lines placed in front of an object
  141540. */
  141541. frontColor: Color3;
  141542. /**
  141543. * Color of the bounding box lines placed behind an object
  141544. */
  141545. backColor: Color3;
  141546. /**
  141547. * Defines if the renderer should show the back lines or not
  141548. */
  141549. showBackLines: boolean;
  141550. /**
  141551. * @hidden
  141552. */
  141553. renderList: SmartArray<BoundingBox>;
  141554. private _colorShader;
  141555. private _vertexBuffers;
  141556. private _indexBuffer;
  141557. private _fillIndexBuffer;
  141558. private _fillIndexData;
  141559. /**
  141560. * Instantiates a new bounding box renderer in a scene.
  141561. * @param scene the scene the renderer renders in
  141562. */
  141563. constructor(scene: Scene);
  141564. /**
  141565. * Registers the component in a given scene
  141566. */
  141567. register(): void;
  141568. private _evaluateSubMesh;
  141569. private _activeMesh;
  141570. private _prepareRessources;
  141571. private _createIndexBuffer;
  141572. /**
  141573. * Rebuilds the elements related to this component in case of
  141574. * context lost for instance.
  141575. */
  141576. rebuild(): void;
  141577. /**
  141578. * @hidden
  141579. */
  141580. reset(): void;
  141581. /**
  141582. * Render the bounding boxes of a specific rendering group
  141583. * @param renderingGroupId defines the rendering group to render
  141584. */
  141585. render(renderingGroupId: number): void;
  141586. /**
  141587. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141588. * @param mesh Define the mesh to render the occlusion bounding box for
  141589. */
  141590. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141591. /**
  141592. * Dispose and release the resources attached to this renderer.
  141593. */
  141594. dispose(): void;
  141595. }
  141596. }
  141597. declare module BABYLON {
  141598. interface Scene {
  141599. /** @hidden (Backing field) */
  141600. _depthRenderer: {
  141601. [id: string]: DepthRenderer;
  141602. };
  141603. /**
  141604. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141605. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141606. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141607. * @returns the created depth renderer
  141608. */
  141609. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141610. /**
  141611. * Disables a depth renderer for a given camera
  141612. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141613. */
  141614. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141615. }
  141616. /**
  141617. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141618. * in several rendering techniques.
  141619. */
  141620. export class DepthRendererSceneComponent implements ISceneComponent {
  141621. /**
  141622. * The component name helpfull to identify the component in the list of scene components.
  141623. */
  141624. readonly name: string;
  141625. /**
  141626. * The scene the component belongs to.
  141627. */
  141628. scene: Scene;
  141629. /**
  141630. * Creates a new instance of the component for the given scene
  141631. * @param scene Defines the scene to register the component in
  141632. */
  141633. constructor(scene: Scene);
  141634. /**
  141635. * Registers the component in a given scene
  141636. */
  141637. register(): void;
  141638. /**
  141639. * Rebuilds the elements related to this component in case of
  141640. * context lost for instance.
  141641. */
  141642. rebuild(): void;
  141643. /**
  141644. * Disposes the component and the associated ressources
  141645. */
  141646. dispose(): void;
  141647. private _gatherRenderTargets;
  141648. private _gatherActiveCameraRenderTargets;
  141649. }
  141650. }
  141651. declare module BABYLON {
  141652. /** @hidden */
  141653. export var outlinePixelShader: {
  141654. name: string;
  141655. shader: string;
  141656. };
  141657. }
  141658. declare module BABYLON {
  141659. /** @hidden */
  141660. export var outlineVertexShader: {
  141661. name: string;
  141662. shader: string;
  141663. };
  141664. }
  141665. declare module BABYLON {
  141666. interface Scene {
  141667. /** @hidden */
  141668. _outlineRenderer: OutlineRenderer;
  141669. /**
  141670. * Gets the outline renderer associated with the scene
  141671. * @returns a OutlineRenderer
  141672. */
  141673. getOutlineRenderer(): OutlineRenderer;
  141674. }
  141675. interface AbstractMesh {
  141676. /** @hidden (Backing field) */
  141677. _renderOutline: boolean;
  141678. /**
  141679. * Gets or sets a boolean indicating if the outline must be rendered as well
  141680. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141681. */
  141682. renderOutline: boolean;
  141683. /** @hidden (Backing field) */
  141684. _renderOverlay: boolean;
  141685. /**
  141686. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141687. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141688. */
  141689. renderOverlay: boolean;
  141690. }
  141691. /**
  141692. * This class is responsible to draw bothe outline/overlay of meshes.
  141693. * It should not be used directly but through the available method on mesh.
  141694. */
  141695. export class OutlineRenderer implements ISceneComponent {
  141696. /**
  141697. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141698. */
  141699. private static _StencilReference;
  141700. /**
  141701. * The name of the component. Each component must have a unique name.
  141702. */
  141703. name: string;
  141704. /**
  141705. * The scene the component belongs to.
  141706. */
  141707. scene: Scene;
  141708. /**
  141709. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141710. */
  141711. zOffset: number;
  141712. private _engine;
  141713. private _effect;
  141714. private _cachedDefines;
  141715. private _savedDepthWrite;
  141716. /**
  141717. * Instantiates a new outline renderer. (There could be only one per scene).
  141718. * @param scene Defines the scene it belongs to
  141719. */
  141720. constructor(scene: Scene);
  141721. /**
  141722. * Register the component to one instance of a scene.
  141723. */
  141724. register(): void;
  141725. /**
  141726. * Rebuilds the elements related to this component in case of
  141727. * context lost for instance.
  141728. */
  141729. rebuild(): void;
  141730. /**
  141731. * Disposes the component and the associated ressources.
  141732. */
  141733. dispose(): void;
  141734. /**
  141735. * Renders the outline in the canvas.
  141736. * @param subMesh Defines the sumesh to render
  141737. * @param batch Defines the batch of meshes in case of instances
  141738. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141739. */
  141740. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141741. /**
  141742. * Returns whether or not the outline renderer is ready for a given submesh.
  141743. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141744. * @param subMesh Defines the submesh to check readyness for
  141745. * @param useInstances Defines wheter wee are trying to render instances or not
  141746. * @returns true if ready otherwise false
  141747. */
  141748. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141749. private _beforeRenderingMesh;
  141750. private _afterRenderingMesh;
  141751. }
  141752. }
  141753. declare module BABYLON {
  141754. /**
  141755. * Defines the basic options interface of a Sprite Frame Source Size.
  141756. */
  141757. export interface ISpriteJSONSpriteSourceSize {
  141758. /**
  141759. * number of the original width of the Frame
  141760. */
  141761. w: number;
  141762. /**
  141763. * number of the original height of the Frame
  141764. */
  141765. h: number;
  141766. }
  141767. /**
  141768. * Defines the basic options interface of a Sprite Frame Data.
  141769. */
  141770. export interface ISpriteJSONSpriteFrameData {
  141771. /**
  141772. * number of the x offset of the Frame
  141773. */
  141774. x: number;
  141775. /**
  141776. * number of the y offset of the Frame
  141777. */
  141778. y: number;
  141779. /**
  141780. * number of the width of the Frame
  141781. */
  141782. w: number;
  141783. /**
  141784. * number of the height of the Frame
  141785. */
  141786. h: number;
  141787. }
  141788. /**
  141789. * Defines the basic options interface of a JSON Sprite.
  141790. */
  141791. export interface ISpriteJSONSprite {
  141792. /**
  141793. * string name of the Frame
  141794. */
  141795. filename: string;
  141796. /**
  141797. * ISpriteJSONSpriteFrame basic object of the frame data
  141798. */
  141799. frame: ISpriteJSONSpriteFrameData;
  141800. /**
  141801. * boolean to flag is the frame was rotated.
  141802. */
  141803. rotated: boolean;
  141804. /**
  141805. * boolean to flag is the frame was trimmed.
  141806. */
  141807. trimmed: boolean;
  141808. /**
  141809. * ISpriteJSONSpriteFrame basic object of the source data
  141810. */
  141811. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141812. /**
  141813. * ISpriteJSONSpriteFrame basic object of the source data
  141814. */
  141815. sourceSize: ISpriteJSONSpriteSourceSize;
  141816. }
  141817. /**
  141818. * Defines the basic options interface of a JSON atlas.
  141819. */
  141820. export interface ISpriteJSONAtlas {
  141821. /**
  141822. * Array of objects that contain the frame data.
  141823. */
  141824. frames: Array<ISpriteJSONSprite>;
  141825. /**
  141826. * object basic object containing the sprite meta data.
  141827. */
  141828. meta?: object;
  141829. }
  141830. }
  141831. declare module BABYLON {
  141832. /** @hidden */
  141833. export var spriteMapPixelShader: {
  141834. name: string;
  141835. shader: string;
  141836. };
  141837. }
  141838. declare module BABYLON {
  141839. /** @hidden */
  141840. export var spriteMapVertexShader: {
  141841. name: string;
  141842. shader: string;
  141843. };
  141844. }
  141845. declare module BABYLON {
  141846. /**
  141847. * Defines the basic options interface of a SpriteMap
  141848. */
  141849. export interface ISpriteMapOptions {
  141850. /**
  141851. * Vector2 of the number of cells in the grid.
  141852. */
  141853. stageSize?: Vector2;
  141854. /**
  141855. * Vector2 of the size of the output plane in World Units.
  141856. */
  141857. outputSize?: Vector2;
  141858. /**
  141859. * Vector3 of the position of the output plane in World Units.
  141860. */
  141861. outputPosition?: Vector3;
  141862. /**
  141863. * Vector3 of the rotation of the output plane.
  141864. */
  141865. outputRotation?: Vector3;
  141866. /**
  141867. * number of layers that the system will reserve in resources.
  141868. */
  141869. layerCount?: number;
  141870. /**
  141871. * number of max animation frames a single cell will reserve in resources.
  141872. */
  141873. maxAnimationFrames?: number;
  141874. /**
  141875. * number cell index of the base tile when the system compiles.
  141876. */
  141877. baseTile?: number;
  141878. /**
  141879. * boolean flip the sprite after its been repositioned by the framing data.
  141880. */
  141881. flipU?: boolean;
  141882. /**
  141883. * Vector3 scalar of the global RGB values of the SpriteMap.
  141884. */
  141885. colorMultiply?: Vector3;
  141886. }
  141887. /**
  141888. * Defines the IDisposable interface in order to be cleanable from resources.
  141889. */
  141890. export interface ISpriteMap extends IDisposable {
  141891. /**
  141892. * String name of the SpriteMap.
  141893. */
  141894. name: string;
  141895. /**
  141896. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141897. */
  141898. atlasJSON: ISpriteJSONAtlas;
  141899. /**
  141900. * Texture of the SpriteMap.
  141901. */
  141902. spriteSheet: Texture;
  141903. /**
  141904. * The parameters to initialize the SpriteMap with.
  141905. */
  141906. options: ISpriteMapOptions;
  141907. }
  141908. /**
  141909. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141910. */
  141911. export class SpriteMap implements ISpriteMap {
  141912. /** The Name of the spriteMap */
  141913. name: string;
  141914. /** The JSON file with the frame and meta data */
  141915. atlasJSON: ISpriteJSONAtlas;
  141916. /** The systems Sprite Sheet Texture */
  141917. spriteSheet: Texture;
  141918. /** Arguments passed with the Constructor */
  141919. options: ISpriteMapOptions;
  141920. /** Public Sprite Storage array, parsed from atlasJSON */
  141921. sprites: Array<ISpriteJSONSprite>;
  141922. /** Returns the Number of Sprites in the System */
  141923. get spriteCount(): number;
  141924. /** Returns the Position of Output Plane*/
  141925. get position(): Vector3;
  141926. /** Returns the Position of Output Plane*/
  141927. set position(v: Vector3);
  141928. /** Returns the Rotation of Output Plane*/
  141929. get rotation(): Vector3;
  141930. /** Returns the Rotation of Output Plane*/
  141931. set rotation(v: Vector3);
  141932. /** Sets the AnimationMap*/
  141933. get animationMap(): RawTexture;
  141934. /** Sets the AnimationMap*/
  141935. set animationMap(v: RawTexture);
  141936. /** Scene that the SpriteMap was created in */
  141937. private _scene;
  141938. /** Texture Buffer of Float32 that holds tile frame data*/
  141939. private _frameMap;
  141940. /** Texture Buffers of Float32 that holds tileMap data*/
  141941. private _tileMaps;
  141942. /** Texture Buffer of Float32 that holds Animation Data*/
  141943. private _animationMap;
  141944. /** Custom ShaderMaterial Central to the System*/
  141945. private _material;
  141946. /** Custom ShaderMaterial Central to the System*/
  141947. private _output;
  141948. /** Systems Time Ticker*/
  141949. private _time;
  141950. /**
  141951. * Creates a new SpriteMap
  141952. * @param name defines the SpriteMaps Name
  141953. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141954. * @param spriteSheet is the Texture that the Sprites are on.
  141955. * @param options a basic deployment configuration
  141956. * @param scene The Scene that the map is deployed on
  141957. */
  141958. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141959. /**
  141960. * Returns tileID location
  141961. * @returns Vector2 the cell position ID
  141962. */
  141963. getTileID(): Vector2;
  141964. /**
  141965. * Gets the UV location of the mouse over the SpriteMap.
  141966. * @returns Vector2 the UV position of the mouse interaction
  141967. */
  141968. getMousePosition(): Vector2;
  141969. /**
  141970. * Creates the "frame" texture Buffer
  141971. * -------------------------------------
  141972. * Structure of frames
  141973. * "filename": "Falling-Water-2.png",
  141974. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141975. * "rotated": true,
  141976. * "trimmed": true,
  141977. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141978. * "sourceSize": {"w":32,"h":32}
  141979. * @returns RawTexture of the frameMap
  141980. */
  141981. private _createFrameBuffer;
  141982. /**
  141983. * Creates the tileMap texture Buffer
  141984. * @param buffer normally and array of numbers, or a false to generate from scratch
  141985. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  141986. * @returns RawTexture of the tileMap
  141987. */
  141988. private _createTileBuffer;
  141989. /**
  141990. * Modifies the data of the tileMaps
  141991. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  141992. * @param pos is the iVector2 Coordinates of the Tile
  141993. * @param tile The SpriteIndex of the new Tile
  141994. */
  141995. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  141996. /**
  141997. * Creates the animationMap texture Buffer
  141998. * @param buffer normally and array of numbers, or a false to generate from scratch
  141999. * @returns RawTexture of the animationMap
  142000. */
  142001. private _createTileAnimationBuffer;
  142002. /**
  142003. * Modifies the data of the animationMap
  142004. * @param cellID is the Index of the Sprite
  142005. * @param _frame is the target Animation frame
  142006. * @param toCell is the Target Index of the next frame of the animation
  142007. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  142008. * @param speed is a global scalar of the time variable on the map.
  142009. */
  142010. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  142011. /**
  142012. * Exports the .tilemaps file
  142013. */
  142014. saveTileMaps(): void;
  142015. /**
  142016. * Imports the .tilemaps file
  142017. * @param url of the .tilemaps file
  142018. */
  142019. loadTileMaps(url: string): void;
  142020. /**
  142021. * Release associated resources
  142022. */
  142023. dispose(): void;
  142024. }
  142025. }
  142026. declare module BABYLON {
  142027. /**
  142028. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142029. * @see http://doc.babylonjs.com/babylon101/sprites
  142030. */
  142031. export class SpritePackedManager extends SpriteManager {
  142032. /** defines the packed manager's name */
  142033. name: string;
  142034. /**
  142035. * Creates a new sprite manager from a packed sprite sheet
  142036. * @param name defines the manager's name
  142037. * @param imgUrl defines the sprite sheet url
  142038. * @param capacity defines the maximum allowed number of sprites
  142039. * @param scene defines the hosting scene
  142040. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142041. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142042. * @param samplingMode defines the smapling mode to use with spritesheet
  142043. * @param fromPacked set to true; do not alter
  142044. */
  142045. constructor(
  142046. /** defines the packed manager's name */
  142047. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142048. }
  142049. }
  142050. declare module BABYLON {
  142051. /**
  142052. * Defines the list of states available for a task inside a AssetsManager
  142053. */
  142054. export enum AssetTaskState {
  142055. /**
  142056. * Initialization
  142057. */
  142058. INIT = 0,
  142059. /**
  142060. * Running
  142061. */
  142062. RUNNING = 1,
  142063. /**
  142064. * Done
  142065. */
  142066. DONE = 2,
  142067. /**
  142068. * Error
  142069. */
  142070. ERROR = 3
  142071. }
  142072. /**
  142073. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142074. */
  142075. export abstract class AbstractAssetTask {
  142076. /**
  142077. * Task name
  142078. */ name: string;
  142079. /**
  142080. * Callback called when the task is successful
  142081. */
  142082. onSuccess: (task: any) => void;
  142083. /**
  142084. * Callback called when the task is not successful
  142085. */
  142086. onError: (task: any, message?: string, exception?: any) => void;
  142087. /**
  142088. * Creates a new AssetsManager
  142089. * @param name defines the name of the task
  142090. */
  142091. constructor(
  142092. /**
  142093. * Task name
  142094. */ name: string);
  142095. private _isCompleted;
  142096. private _taskState;
  142097. private _errorObject;
  142098. /**
  142099. * Get if the task is completed
  142100. */
  142101. get isCompleted(): boolean;
  142102. /**
  142103. * Gets the current state of the task
  142104. */
  142105. get taskState(): AssetTaskState;
  142106. /**
  142107. * Gets the current error object (if task is in error)
  142108. */
  142109. get errorObject(): {
  142110. message?: string;
  142111. exception?: any;
  142112. };
  142113. /**
  142114. * Internal only
  142115. * @hidden
  142116. */
  142117. _setErrorObject(message?: string, exception?: any): void;
  142118. /**
  142119. * Execute the current task
  142120. * @param scene defines the scene where you want your assets to be loaded
  142121. * @param onSuccess is a callback called when the task is successfully executed
  142122. * @param onError is a callback called if an error occurs
  142123. */
  142124. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142125. /**
  142126. * Execute the current task
  142127. * @param scene defines the scene where you want your assets to be loaded
  142128. * @param onSuccess is a callback called when the task is successfully executed
  142129. * @param onError is a callback called if an error occurs
  142130. */
  142131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142132. /**
  142133. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142134. * This can be used with failed tasks that have the reason for failure fixed.
  142135. */
  142136. reset(): void;
  142137. private onErrorCallback;
  142138. private onDoneCallback;
  142139. }
  142140. /**
  142141. * Define the interface used by progress events raised during assets loading
  142142. */
  142143. export interface IAssetsProgressEvent {
  142144. /**
  142145. * Defines the number of remaining tasks to process
  142146. */
  142147. remainingCount: number;
  142148. /**
  142149. * Defines the total number of tasks
  142150. */
  142151. totalCount: number;
  142152. /**
  142153. * Defines the task that was just processed
  142154. */
  142155. task: AbstractAssetTask;
  142156. }
  142157. /**
  142158. * Class used to share progress information about assets loading
  142159. */
  142160. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142161. /**
  142162. * Defines the number of remaining tasks to process
  142163. */
  142164. remainingCount: number;
  142165. /**
  142166. * Defines the total number of tasks
  142167. */
  142168. totalCount: number;
  142169. /**
  142170. * Defines the task that was just processed
  142171. */
  142172. task: AbstractAssetTask;
  142173. /**
  142174. * Creates a AssetsProgressEvent
  142175. * @param remainingCount defines the number of remaining tasks to process
  142176. * @param totalCount defines the total number of tasks
  142177. * @param task defines the task that was just processed
  142178. */
  142179. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142180. }
  142181. /**
  142182. * Define a task used by AssetsManager to load meshes
  142183. */
  142184. export class MeshAssetTask extends AbstractAssetTask {
  142185. /**
  142186. * Defines the name of the task
  142187. */
  142188. name: string;
  142189. /**
  142190. * Defines the list of mesh's names you want to load
  142191. */
  142192. meshesNames: any;
  142193. /**
  142194. * Defines the root url to use as a base to load your meshes and associated resources
  142195. */
  142196. rootUrl: string;
  142197. /**
  142198. * Defines the filename of the scene to load from
  142199. */
  142200. sceneFilename: string;
  142201. /**
  142202. * Gets the list of loaded meshes
  142203. */
  142204. loadedMeshes: Array<AbstractMesh>;
  142205. /**
  142206. * Gets the list of loaded particle systems
  142207. */
  142208. loadedParticleSystems: Array<IParticleSystem>;
  142209. /**
  142210. * Gets the list of loaded skeletons
  142211. */
  142212. loadedSkeletons: Array<Skeleton>;
  142213. /**
  142214. * Gets the list of loaded animation groups
  142215. */
  142216. loadedAnimationGroups: Array<AnimationGroup>;
  142217. /**
  142218. * Callback called when the task is successful
  142219. */
  142220. onSuccess: (task: MeshAssetTask) => void;
  142221. /**
  142222. * Callback called when the task is successful
  142223. */
  142224. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142225. /**
  142226. * Creates a new MeshAssetTask
  142227. * @param name defines the name of the task
  142228. * @param meshesNames defines the list of mesh's names you want to load
  142229. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142230. * @param sceneFilename defines the filename of the scene to load from
  142231. */
  142232. constructor(
  142233. /**
  142234. * Defines the name of the task
  142235. */
  142236. name: string,
  142237. /**
  142238. * Defines the list of mesh's names you want to load
  142239. */
  142240. meshesNames: any,
  142241. /**
  142242. * Defines the root url to use as a base to load your meshes and associated resources
  142243. */
  142244. rootUrl: string,
  142245. /**
  142246. * Defines the filename of the scene to load from
  142247. */
  142248. sceneFilename: string);
  142249. /**
  142250. * Execute the current task
  142251. * @param scene defines the scene where you want your assets to be loaded
  142252. * @param onSuccess is a callback called when the task is successfully executed
  142253. * @param onError is a callback called if an error occurs
  142254. */
  142255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142256. }
  142257. /**
  142258. * Define a task used by AssetsManager to load text content
  142259. */
  142260. export class TextFileAssetTask extends AbstractAssetTask {
  142261. /**
  142262. * Defines the name of the task
  142263. */
  142264. name: string;
  142265. /**
  142266. * Defines the location of the file to load
  142267. */
  142268. url: string;
  142269. /**
  142270. * Gets the loaded text string
  142271. */
  142272. text: string;
  142273. /**
  142274. * Callback called when the task is successful
  142275. */
  142276. onSuccess: (task: TextFileAssetTask) => void;
  142277. /**
  142278. * Callback called when the task is successful
  142279. */
  142280. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142281. /**
  142282. * Creates a new TextFileAssetTask object
  142283. * @param name defines the name of the task
  142284. * @param url defines the location of the file to load
  142285. */
  142286. constructor(
  142287. /**
  142288. * Defines the name of the task
  142289. */
  142290. name: string,
  142291. /**
  142292. * Defines the location of the file to load
  142293. */
  142294. url: string);
  142295. /**
  142296. * Execute the current task
  142297. * @param scene defines the scene where you want your assets to be loaded
  142298. * @param onSuccess is a callback called when the task is successfully executed
  142299. * @param onError is a callback called if an error occurs
  142300. */
  142301. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142302. }
  142303. /**
  142304. * Define a task used by AssetsManager to load binary data
  142305. */
  142306. export class BinaryFileAssetTask extends AbstractAssetTask {
  142307. /**
  142308. * Defines the name of the task
  142309. */
  142310. name: string;
  142311. /**
  142312. * Defines the location of the file to load
  142313. */
  142314. url: string;
  142315. /**
  142316. * Gets the lodaded data (as an array buffer)
  142317. */
  142318. data: ArrayBuffer;
  142319. /**
  142320. * Callback called when the task is successful
  142321. */
  142322. onSuccess: (task: BinaryFileAssetTask) => void;
  142323. /**
  142324. * Callback called when the task is successful
  142325. */
  142326. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142327. /**
  142328. * Creates a new BinaryFileAssetTask object
  142329. * @param name defines the name of the new task
  142330. * @param url defines the location of the file to load
  142331. */
  142332. constructor(
  142333. /**
  142334. * Defines the name of the task
  142335. */
  142336. name: string,
  142337. /**
  142338. * Defines the location of the file to load
  142339. */
  142340. url: string);
  142341. /**
  142342. * Execute the current task
  142343. * @param scene defines the scene where you want your assets to be loaded
  142344. * @param onSuccess is a callback called when the task is successfully executed
  142345. * @param onError is a callback called if an error occurs
  142346. */
  142347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142348. }
  142349. /**
  142350. * Define a task used by AssetsManager to load images
  142351. */
  142352. export class ImageAssetTask extends AbstractAssetTask {
  142353. /**
  142354. * Defines the name of the task
  142355. */
  142356. name: string;
  142357. /**
  142358. * Defines the location of the image to load
  142359. */
  142360. url: string;
  142361. /**
  142362. * Gets the loaded images
  142363. */
  142364. image: HTMLImageElement;
  142365. /**
  142366. * Callback called when the task is successful
  142367. */
  142368. onSuccess: (task: ImageAssetTask) => void;
  142369. /**
  142370. * Callback called when the task is successful
  142371. */
  142372. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142373. /**
  142374. * Creates a new ImageAssetTask
  142375. * @param name defines the name of the task
  142376. * @param url defines the location of the image to load
  142377. */
  142378. constructor(
  142379. /**
  142380. * Defines the name of the task
  142381. */
  142382. name: string,
  142383. /**
  142384. * Defines the location of the image to load
  142385. */
  142386. url: string);
  142387. /**
  142388. * Execute the current task
  142389. * @param scene defines the scene where you want your assets to be loaded
  142390. * @param onSuccess is a callback called when the task is successfully executed
  142391. * @param onError is a callback called if an error occurs
  142392. */
  142393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142394. }
  142395. /**
  142396. * Defines the interface used by texture loading tasks
  142397. */
  142398. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142399. /**
  142400. * Gets the loaded texture
  142401. */
  142402. texture: TEX;
  142403. }
  142404. /**
  142405. * Define a task used by AssetsManager to load 2D textures
  142406. */
  142407. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142408. /**
  142409. * Defines the name of the task
  142410. */
  142411. name: string;
  142412. /**
  142413. * Defines the location of the file to load
  142414. */
  142415. url: string;
  142416. /**
  142417. * Defines if mipmap should not be generated (default is false)
  142418. */
  142419. noMipmap?: boolean | undefined;
  142420. /**
  142421. * Defines if texture must be inverted on Y axis (default is true)
  142422. */
  142423. invertY: boolean;
  142424. /**
  142425. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142426. */
  142427. samplingMode: number;
  142428. /**
  142429. * Gets the loaded texture
  142430. */
  142431. texture: Texture;
  142432. /**
  142433. * Callback called when the task is successful
  142434. */
  142435. onSuccess: (task: TextureAssetTask) => void;
  142436. /**
  142437. * Callback called when the task is successful
  142438. */
  142439. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142440. /**
  142441. * Creates a new TextureAssetTask object
  142442. * @param name defines the name of the task
  142443. * @param url defines the location of the file to load
  142444. * @param noMipmap defines if mipmap should not be generated (default is false)
  142445. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142446. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142447. */
  142448. constructor(
  142449. /**
  142450. * Defines the name of the task
  142451. */
  142452. name: string,
  142453. /**
  142454. * Defines the location of the file to load
  142455. */
  142456. url: string,
  142457. /**
  142458. * Defines if mipmap should not be generated (default is false)
  142459. */
  142460. noMipmap?: boolean | undefined,
  142461. /**
  142462. * Defines if texture must be inverted on Y axis (default is true)
  142463. */
  142464. invertY?: boolean,
  142465. /**
  142466. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142467. */
  142468. samplingMode?: number);
  142469. /**
  142470. * Execute the current task
  142471. * @param scene defines the scene where you want your assets to be loaded
  142472. * @param onSuccess is a callback called when the task is successfully executed
  142473. * @param onError is a callback called if an error occurs
  142474. */
  142475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142476. }
  142477. /**
  142478. * Define a task used by AssetsManager to load cube textures
  142479. */
  142480. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142481. /**
  142482. * Defines the name of the task
  142483. */
  142484. name: string;
  142485. /**
  142486. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142487. */
  142488. url: string;
  142489. /**
  142490. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142491. */
  142492. extensions?: string[] | undefined;
  142493. /**
  142494. * Defines if mipmaps should not be generated (default is false)
  142495. */
  142496. noMipmap?: boolean | undefined;
  142497. /**
  142498. * Defines the explicit list of files (undefined by default)
  142499. */
  142500. files?: string[] | undefined;
  142501. /**
  142502. * Gets the loaded texture
  142503. */
  142504. texture: CubeTexture;
  142505. /**
  142506. * Callback called when the task is successful
  142507. */
  142508. onSuccess: (task: CubeTextureAssetTask) => void;
  142509. /**
  142510. * Callback called when the task is successful
  142511. */
  142512. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142513. /**
  142514. * Creates a new CubeTextureAssetTask
  142515. * @param name defines the name of the task
  142516. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142517. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142518. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142519. * @param files defines the explicit list of files (undefined by default)
  142520. */
  142521. constructor(
  142522. /**
  142523. * Defines the name of the task
  142524. */
  142525. name: string,
  142526. /**
  142527. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142528. */
  142529. url: string,
  142530. /**
  142531. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142532. */
  142533. extensions?: string[] | undefined,
  142534. /**
  142535. * Defines if mipmaps should not be generated (default is false)
  142536. */
  142537. noMipmap?: boolean | undefined,
  142538. /**
  142539. * Defines the explicit list of files (undefined by default)
  142540. */
  142541. files?: string[] | undefined);
  142542. /**
  142543. * Execute the current task
  142544. * @param scene defines the scene where you want your assets to be loaded
  142545. * @param onSuccess is a callback called when the task is successfully executed
  142546. * @param onError is a callback called if an error occurs
  142547. */
  142548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142549. }
  142550. /**
  142551. * Define a task used by AssetsManager to load HDR cube textures
  142552. */
  142553. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142554. /**
  142555. * Defines the name of the task
  142556. */
  142557. name: string;
  142558. /**
  142559. * Defines the location of the file to load
  142560. */
  142561. url: string;
  142562. /**
  142563. * Defines the desired size (the more it increases the longer the generation will be)
  142564. */
  142565. size: number;
  142566. /**
  142567. * Defines if mipmaps should not be generated (default is false)
  142568. */
  142569. noMipmap: boolean;
  142570. /**
  142571. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142572. */
  142573. generateHarmonics: boolean;
  142574. /**
  142575. * 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)
  142576. */
  142577. gammaSpace: boolean;
  142578. /**
  142579. * Internal Use Only
  142580. */
  142581. reserved: boolean;
  142582. /**
  142583. * Gets the loaded texture
  142584. */
  142585. texture: HDRCubeTexture;
  142586. /**
  142587. * Callback called when the task is successful
  142588. */
  142589. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142590. /**
  142591. * Callback called when the task is successful
  142592. */
  142593. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142594. /**
  142595. * Creates a new HDRCubeTextureAssetTask object
  142596. * @param name defines the name of the task
  142597. * @param url defines the location of the file to load
  142598. * @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.
  142599. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142600. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142601. * @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)
  142602. * @param reserved Internal use only
  142603. */
  142604. constructor(
  142605. /**
  142606. * Defines the name of the task
  142607. */
  142608. name: string,
  142609. /**
  142610. * Defines the location of the file to load
  142611. */
  142612. url: string,
  142613. /**
  142614. * Defines the desired size (the more it increases the longer the generation will be)
  142615. */
  142616. size: number,
  142617. /**
  142618. * Defines if mipmaps should not be generated (default is false)
  142619. */
  142620. noMipmap?: boolean,
  142621. /**
  142622. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142623. */
  142624. generateHarmonics?: boolean,
  142625. /**
  142626. * 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)
  142627. */
  142628. gammaSpace?: boolean,
  142629. /**
  142630. * Internal Use Only
  142631. */
  142632. reserved?: boolean);
  142633. /**
  142634. * Execute the current task
  142635. * @param scene defines the scene where you want your assets to be loaded
  142636. * @param onSuccess is a callback called when the task is successfully executed
  142637. * @param onError is a callback called if an error occurs
  142638. */
  142639. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142640. }
  142641. /**
  142642. * Define a task used by AssetsManager to load Equirectangular cube textures
  142643. */
  142644. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142645. /**
  142646. * Defines the name of the task
  142647. */
  142648. name: string;
  142649. /**
  142650. * Defines the location of the file to load
  142651. */
  142652. url: string;
  142653. /**
  142654. * Defines the desired size (the more it increases the longer the generation will be)
  142655. */
  142656. size: number;
  142657. /**
  142658. * Defines if mipmaps should not be generated (default is false)
  142659. */
  142660. noMipmap: boolean;
  142661. /**
  142662. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142663. * but the standard material would require them in Gamma space) (default is true)
  142664. */
  142665. gammaSpace: boolean;
  142666. /**
  142667. * Gets the loaded texture
  142668. */
  142669. texture: EquiRectangularCubeTexture;
  142670. /**
  142671. * Callback called when the task is successful
  142672. */
  142673. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142674. /**
  142675. * Callback called when the task is successful
  142676. */
  142677. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142678. /**
  142679. * Creates a new EquiRectangularCubeTextureAssetTask object
  142680. * @param name defines the name of the task
  142681. * @param url defines the location of the file to load
  142682. * @param size defines the desired size (the more it increases the longer the generation will be)
  142683. * If the size is omitted this implies you are using a preprocessed cubemap.
  142684. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142685. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142686. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142687. * (default is true)
  142688. */
  142689. constructor(
  142690. /**
  142691. * Defines the name of the task
  142692. */
  142693. name: string,
  142694. /**
  142695. * Defines the location of the file to load
  142696. */
  142697. url: string,
  142698. /**
  142699. * Defines the desired size (the more it increases the longer the generation will be)
  142700. */
  142701. size: number,
  142702. /**
  142703. * Defines if mipmaps should not be generated (default is false)
  142704. */
  142705. noMipmap?: boolean,
  142706. /**
  142707. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142708. * but the standard material would require them in Gamma space) (default is true)
  142709. */
  142710. gammaSpace?: boolean);
  142711. /**
  142712. * Execute the current task
  142713. * @param scene defines the scene where you want your assets to be loaded
  142714. * @param onSuccess is a callback called when the task is successfully executed
  142715. * @param onError is a callback called if an error occurs
  142716. */
  142717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142718. }
  142719. /**
  142720. * This class can be used to easily import assets into a scene
  142721. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142722. */
  142723. export class AssetsManager {
  142724. private _scene;
  142725. private _isLoading;
  142726. protected _tasks: AbstractAssetTask[];
  142727. protected _waitingTasksCount: number;
  142728. protected _totalTasksCount: number;
  142729. /**
  142730. * Callback called when all tasks are processed
  142731. */
  142732. onFinish: (tasks: AbstractAssetTask[]) => void;
  142733. /**
  142734. * Callback called when a task is successful
  142735. */
  142736. onTaskSuccess: (task: AbstractAssetTask) => void;
  142737. /**
  142738. * Callback called when a task had an error
  142739. */
  142740. onTaskError: (task: AbstractAssetTask) => void;
  142741. /**
  142742. * Callback called when a task is done (whatever the result is)
  142743. */
  142744. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142745. /**
  142746. * Observable called when all tasks are processed
  142747. */
  142748. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142749. /**
  142750. * Observable called when a task had an error
  142751. */
  142752. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142753. /**
  142754. * Observable called when all tasks were executed
  142755. */
  142756. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142757. /**
  142758. * Observable called when a task is done (whatever the result is)
  142759. */
  142760. onProgressObservable: Observable<IAssetsProgressEvent>;
  142761. /**
  142762. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142764. */
  142765. useDefaultLoadingScreen: boolean;
  142766. /**
  142767. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142768. * when all assets have been downloaded.
  142769. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142770. */
  142771. autoHideLoadingUI: boolean;
  142772. /**
  142773. * Creates a new AssetsManager
  142774. * @param scene defines the scene to work on
  142775. */
  142776. constructor(scene: Scene);
  142777. /**
  142778. * Add a MeshAssetTask to the list of active tasks
  142779. * @param taskName defines the name of the new task
  142780. * @param meshesNames defines the name of meshes to load
  142781. * @param rootUrl defines the root url to use to locate files
  142782. * @param sceneFilename defines the filename of the scene file
  142783. * @returns a new MeshAssetTask object
  142784. */
  142785. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142786. /**
  142787. * Add a TextFileAssetTask to the list of active tasks
  142788. * @param taskName defines the name of the new task
  142789. * @param url defines the url of the file to load
  142790. * @returns a new TextFileAssetTask object
  142791. */
  142792. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142793. /**
  142794. * Add a BinaryFileAssetTask to the list of active tasks
  142795. * @param taskName defines the name of the new task
  142796. * @param url defines the url of the file to load
  142797. * @returns a new BinaryFileAssetTask object
  142798. */
  142799. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142800. /**
  142801. * Add a ImageAssetTask to the list of active tasks
  142802. * @param taskName defines the name of the new task
  142803. * @param url defines the url of the file to load
  142804. * @returns a new ImageAssetTask object
  142805. */
  142806. addImageTask(taskName: string, url: string): ImageAssetTask;
  142807. /**
  142808. * Add a TextureAssetTask to the list of active tasks
  142809. * @param taskName defines the name of the new task
  142810. * @param url defines the url of the file to load
  142811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142812. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142813. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142814. * @returns a new TextureAssetTask object
  142815. */
  142816. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142817. /**
  142818. * Add a CubeTextureAssetTask to the list of active tasks
  142819. * @param taskName defines the name of the new task
  142820. * @param url defines the url of the file to load
  142821. * @param extensions defines the extension to use to load the cube map (can be null)
  142822. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142823. * @param files defines the list of files to load (can be null)
  142824. * @returns a new CubeTextureAssetTask object
  142825. */
  142826. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142827. /**
  142828. *
  142829. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142830. * @param taskName defines the name of the new task
  142831. * @param url defines the url of the file to load
  142832. * @param size defines the size you want for the cubemap (can be null)
  142833. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142834. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142835. * @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)
  142836. * @param reserved Internal use only
  142837. * @returns a new HDRCubeTextureAssetTask object
  142838. */
  142839. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142840. /**
  142841. *
  142842. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142843. * @param taskName defines the name of the new task
  142844. * @param url defines the url of the file to load
  142845. * @param size defines the size you want for the cubemap (can be null)
  142846. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142847. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142848. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142849. * @returns a new EquiRectangularCubeTextureAssetTask object
  142850. */
  142851. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142852. /**
  142853. * Remove a task from the assets manager.
  142854. * @param task the task to remove
  142855. */
  142856. removeTask(task: AbstractAssetTask): void;
  142857. private _decreaseWaitingTasksCount;
  142858. private _runTask;
  142859. /**
  142860. * Reset the AssetsManager and remove all tasks
  142861. * @return the current instance of the AssetsManager
  142862. */
  142863. reset(): AssetsManager;
  142864. /**
  142865. * Start the loading process
  142866. * @return the current instance of the AssetsManager
  142867. */
  142868. load(): AssetsManager;
  142869. /**
  142870. * Start the loading process as an async operation
  142871. * @return a promise returning the list of failed tasks
  142872. */
  142873. loadAsync(): Promise<void>;
  142874. }
  142875. }
  142876. declare module BABYLON {
  142877. /**
  142878. * Wrapper class for promise with external resolve and reject.
  142879. */
  142880. export class Deferred<T> {
  142881. /**
  142882. * The promise associated with this deferred object.
  142883. */
  142884. readonly promise: Promise<T>;
  142885. private _resolve;
  142886. private _reject;
  142887. /**
  142888. * The resolve method of the promise associated with this deferred object.
  142889. */
  142890. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142891. /**
  142892. * The reject method of the promise associated with this deferred object.
  142893. */
  142894. get reject(): (reason?: any) => void;
  142895. /**
  142896. * Constructor for this deferred object.
  142897. */
  142898. constructor();
  142899. }
  142900. }
  142901. declare module BABYLON {
  142902. /**
  142903. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142904. */
  142905. export class MeshExploder {
  142906. private _centerMesh;
  142907. private _meshes;
  142908. private _meshesOrigins;
  142909. private _toCenterVectors;
  142910. private _scaledDirection;
  142911. private _newPosition;
  142912. private _centerPosition;
  142913. /**
  142914. * Explodes meshes from a center mesh.
  142915. * @param meshes The meshes to explode.
  142916. * @param centerMesh The mesh to be center of explosion.
  142917. */
  142918. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142919. private _setCenterMesh;
  142920. /**
  142921. * Get class name
  142922. * @returns "MeshExploder"
  142923. */
  142924. getClassName(): string;
  142925. /**
  142926. * "Exploded meshes"
  142927. * @returns Array of meshes with the centerMesh at index 0.
  142928. */
  142929. getMeshes(): Array<Mesh>;
  142930. /**
  142931. * Explodes meshes giving a specific direction
  142932. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142933. */
  142934. explode(direction?: number): void;
  142935. }
  142936. }
  142937. declare module BABYLON {
  142938. /**
  142939. * Class used to help managing file picking and drag'n'drop
  142940. */
  142941. export class FilesInput {
  142942. /**
  142943. * List of files ready to be loaded
  142944. */
  142945. static get FilesToLoad(): {
  142946. [key: string]: File;
  142947. };
  142948. /**
  142949. * Callback called when a file is processed
  142950. */
  142951. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142952. private _engine;
  142953. private _currentScene;
  142954. private _sceneLoadedCallback;
  142955. private _progressCallback;
  142956. private _additionalRenderLoopLogicCallback;
  142957. private _textureLoadingCallback;
  142958. private _startingProcessingFilesCallback;
  142959. private _onReloadCallback;
  142960. private _errorCallback;
  142961. private _elementToMonitor;
  142962. private _sceneFileToLoad;
  142963. private _filesToLoad;
  142964. /**
  142965. * Creates a new FilesInput
  142966. * @param engine defines the rendering engine
  142967. * @param scene defines the hosting scene
  142968. * @param sceneLoadedCallback callback called when scene is loaded
  142969. * @param progressCallback callback called to track progress
  142970. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142971. * @param textureLoadingCallback callback called when a texture is loading
  142972. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142973. * @param onReloadCallback callback called when a reload is requested
  142974. * @param errorCallback callback call if an error occurs
  142975. */
  142976. 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);
  142977. private _dragEnterHandler;
  142978. private _dragOverHandler;
  142979. private _dropHandler;
  142980. /**
  142981. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142982. * @param elementToMonitor defines the DOM element to track
  142983. */
  142984. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  142985. /**
  142986. * Release all associated resources
  142987. */
  142988. dispose(): void;
  142989. private renderFunction;
  142990. private drag;
  142991. private drop;
  142992. private _traverseFolder;
  142993. private _processFiles;
  142994. /**
  142995. * Load files from a drop event
  142996. * @param event defines the drop event to use as source
  142997. */
  142998. loadFiles(event: any): void;
  142999. private _processReload;
  143000. /**
  143001. * Reload the current scene from the loaded files
  143002. */
  143003. reload(): void;
  143004. }
  143005. }
  143006. declare module BABYLON {
  143007. /**
  143008. * Defines the root class used to create scene optimization to use with SceneOptimizer
  143009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143010. */
  143011. export class SceneOptimization {
  143012. /**
  143013. * Defines the priority of this optimization (0 by default which means first in the list)
  143014. */
  143015. priority: number;
  143016. /**
  143017. * Gets a string describing the action executed by the current optimization
  143018. * @returns description string
  143019. */
  143020. getDescription(): string;
  143021. /**
  143022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143023. * @param scene defines the current scene where to apply this optimization
  143024. * @param optimizer defines the current optimizer
  143025. * @returns true if everything that can be done was applied
  143026. */
  143027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143028. /**
  143029. * Creates the SceneOptimization object
  143030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143031. * @param desc defines the description associated with the optimization
  143032. */
  143033. constructor(
  143034. /**
  143035. * Defines the priority of this optimization (0 by default which means first in the list)
  143036. */
  143037. priority?: number);
  143038. }
  143039. /**
  143040. * Defines an optimization used to reduce the size of render target textures
  143041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143042. */
  143043. export class TextureOptimization extends SceneOptimization {
  143044. /**
  143045. * Defines the priority of this optimization (0 by default which means first in the list)
  143046. */
  143047. priority: number;
  143048. /**
  143049. * 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
  143050. */
  143051. maximumSize: number;
  143052. /**
  143053. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143054. */
  143055. step: number;
  143056. /**
  143057. * Gets a string describing the action executed by the current optimization
  143058. * @returns description string
  143059. */
  143060. getDescription(): string;
  143061. /**
  143062. * Creates the TextureOptimization object
  143063. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143064. * @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
  143065. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143066. */
  143067. constructor(
  143068. /**
  143069. * Defines the priority of this optimization (0 by default which means first in the list)
  143070. */
  143071. priority?: number,
  143072. /**
  143073. * 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
  143074. */
  143075. maximumSize?: number,
  143076. /**
  143077. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143078. */
  143079. step?: number);
  143080. /**
  143081. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143082. * @param scene defines the current scene where to apply this optimization
  143083. * @param optimizer defines the current optimizer
  143084. * @returns true if everything that can be done was applied
  143085. */
  143086. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143087. }
  143088. /**
  143089. * Defines an optimization used to increase or decrease the rendering resolution
  143090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143091. */
  143092. export class HardwareScalingOptimization extends SceneOptimization {
  143093. /**
  143094. * Defines the priority of this optimization (0 by default which means first in the list)
  143095. */
  143096. priority: number;
  143097. /**
  143098. * Defines the maximum scale to use (2 by default)
  143099. */
  143100. maximumScale: number;
  143101. /**
  143102. * Defines the step to use between two passes (0.5 by default)
  143103. */
  143104. step: number;
  143105. private _currentScale;
  143106. private _directionOffset;
  143107. /**
  143108. * Gets a string describing the action executed by the current optimization
  143109. * @return description string
  143110. */
  143111. getDescription(): string;
  143112. /**
  143113. * Creates the HardwareScalingOptimization object
  143114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143115. * @param maximumScale defines the maximum scale to use (2 by default)
  143116. * @param step defines the step to use between two passes (0.5 by default)
  143117. */
  143118. constructor(
  143119. /**
  143120. * Defines the priority of this optimization (0 by default which means first in the list)
  143121. */
  143122. priority?: number,
  143123. /**
  143124. * Defines the maximum scale to use (2 by default)
  143125. */
  143126. maximumScale?: number,
  143127. /**
  143128. * Defines the step to use between two passes (0.5 by default)
  143129. */
  143130. step?: number);
  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 remove shadows
  143141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143142. */
  143143. export class ShadowsOptimization 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 post-processes off
  143159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143160. */
  143161. export class PostProcessesOptimization 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 used to turn lens flares off
  143177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143178. */
  143179. export class LensFlaresOptimization extends SceneOptimization {
  143180. /**
  143181. * Gets a string describing the action executed by the current optimization
  143182. * @return description string
  143183. */
  143184. getDescription(): string;
  143185. /**
  143186. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143187. * @param scene defines the current scene where to apply this optimization
  143188. * @param optimizer defines the current optimizer
  143189. * @returns true if everything that can be done was applied
  143190. */
  143191. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143192. }
  143193. /**
  143194. * Defines an optimization based on user defined callback.
  143195. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143196. */
  143197. export class CustomOptimization extends SceneOptimization {
  143198. /**
  143199. * Callback called to apply the custom optimization.
  143200. */
  143201. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143202. /**
  143203. * Callback called to get custom description
  143204. */
  143205. onGetDescription: () => string;
  143206. /**
  143207. * Gets a string describing the action executed by the current optimization
  143208. * @returns 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 particles off
  143221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143222. */
  143223. export class ParticlesOptimization 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 turn render targets off
  143239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143240. */
  143241. export class RenderTargetsOptimization extends SceneOptimization {
  143242. /**
  143243. * Gets a string describing the action executed by the current optimization
  143244. * @return description string
  143245. */
  143246. getDescription(): string;
  143247. /**
  143248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143249. * @param scene defines the current scene where to apply this optimization
  143250. * @param optimizer defines the current optimizer
  143251. * @returns true if everything that can be done was applied
  143252. */
  143253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143254. }
  143255. /**
  143256. * Defines an optimization used to merge meshes with compatible materials
  143257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143258. */
  143259. export class MergeMeshesOptimization extends SceneOptimization {
  143260. private static _UpdateSelectionTree;
  143261. /**
  143262. * Gets or sets a boolean which defines if optimization octree has to be updated
  143263. */
  143264. static get UpdateSelectionTree(): boolean;
  143265. /**
  143266. * Gets or sets a boolean which defines if optimization octree has to be updated
  143267. */
  143268. static set UpdateSelectionTree(value: boolean);
  143269. /**
  143270. * Gets a string describing the action executed by the current optimization
  143271. * @return description string
  143272. */
  143273. getDescription(): string;
  143274. private _canBeMerged;
  143275. /**
  143276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143277. * @param scene defines the current scene where to apply this optimization
  143278. * @param optimizer defines the current optimizer
  143279. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143280. * @returns true if everything that can be done was applied
  143281. */
  143282. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143283. }
  143284. /**
  143285. * Defines a list of options used by SceneOptimizer
  143286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143287. */
  143288. export class SceneOptimizerOptions {
  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. * Gets the list of optimizations to apply
  143299. */
  143300. optimizations: SceneOptimization[];
  143301. /**
  143302. * Creates a new list of options used by SceneOptimizer
  143303. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143304. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143305. */
  143306. constructor(
  143307. /**
  143308. * Defines the target frame rate to reach (60 by default)
  143309. */
  143310. targetFrameRate?: number,
  143311. /**
  143312. * Defines the interval between two checkes (2000ms by default)
  143313. */
  143314. trackerDuration?: number);
  143315. /**
  143316. * Add a new optimization
  143317. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143318. * @returns the current SceneOptimizerOptions
  143319. */
  143320. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143321. /**
  143322. * Add a new custom optimization
  143323. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143324. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143325. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143326. * @returns the current SceneOptimizerOptions
  143327. */
  143328. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143329. /**
  143330. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143331. * @param targetFrameRate defines the target frame rate (60 by default)
  143332. * @returns a SceneOptimizerOptions object
  143333. */
  143334. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143335. /**
  143336. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143337. * @param targetFrameRate defines the target frame rate (60 by default)
  143338. * @returns a SceneOptimizerOptions object
  143339. */
  143340. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143341. /**
  143342. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143343. * @param targetFrameRate defines the target frame rate (60 by default)
  143344. * @returns a SceneOptimizerOptions object
  143345. */
  143346. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143347. }
  143348. /**
  143349. * Class used to run optimizations in order to reach a target frame rate
  143350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143351. */
  143352. export class SceneOptimizer implements IDisposable {
  143353. private _isRunning;
  143354. private _options;
  143355. private _scene;
  143356. private _currentPriorityLevel;
  143357. private _targetFrameRate;
  143358. private _trackerDuration;
  143359. private _currentFrameRate;
  143360. private _sceneDisposeObserver;
  143361. private _improvementMode;
  143362. /**
  143363. * Defines an observable called when the optimizer reaches the target frame rate
  143364. */
  143365. onSuccessObservable: Observable<SceneOptimizer>;
  143366. /**
  143367. * Defines an observable called when the optimizer enables an optimization
  143368. */
  143369. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143370. /**
  143371. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143372. */
  143373. onFailureObservable: Observable<SceneOptimizer>;
  143374. /**
  143375. * Gets a boolean indicating if the optimizer is in improvement mode
  143376. */
  143377. get isInImprovementMode(): boolean;
  143378. /**
  143379. * Gets the current priority level (0 at start)
  143380. */
  143381. get currentPriorityLevel(): number;
  143382. /**
  143383. * Gets the current frame rate checked by the SceneOptimizer
  143384. */
  143385. get currentFrameRate(): number;
  143386. /**
  143387. * Gets or sets the current target frame rate (60 by default)
  143388. */
  143389. get targetFrameRate(): number;
  143390. /**
  143391. * Gets or sets the current target frame rate (60 by default)
  143392. */
  143393. set targetFrameRate(value: number);
  143394. /**
  143395. * Gets or sets the current interval between two checks (every 2000ms by default)
  143396. */
  143397. get trackerDuration(): number;
  143398. /**
  143399. * Gets or sets the current interval between two checks (every 2000ms by default)
  143400. */
  143401. set trackerDuration(value: number);
  143402. /**
  143403. * Gets the list of active optimizations
  143404. */
  143405. get optimizations(): SceneOptimization[];
  143406. /**
  143407. * Creates a new SceneOptimizer
  143408. * @param scene defines the scene to work on
  143409. * @param options defines the options to use with the SceneOptimizer
  143410. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143411. * @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)
  143412. */
  143413. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143414. /**
  143415. * Stops the current optimizer
  143416. */
  143417. stop(): void;
  143418. /**
  143419. * Reset the optimizer to initial step (current priority level = 0)
  143420. */
  143421. reset(): void;
  143422. /**
  143423. * Start the optimizer. By default it will try to reach a specific framerate
  143424. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143425. */
  143426. start(): void;
  143427. private _checkCurrentState;
  143428. /**
  143429. * Release all resources
  143430. */
  143431. dispose(): void;
  143432. /**
  143433. * Helper function to create a SceneOptimizer with one single line of code
  143434. * @param scene defines the scene to work on
  143435. * @param options defines the options to use with the SceneOptimizer
  143436. * @param onSuccess defines a callback to call on success
  143437. * @param onFailure defines a callback to call on failure
  143438. * @returns the new SceneOptimizer object
  143439. */
  143440. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143441. }
  143442. }
  143443. declare module BABYLON {
  143444. /**
  143445. * Class used to serialize a scene into a string
  143446. */
  143447. export class SceneSerializer {
  143448. /**
  143449. * Clear cache used by a previous serialization
  143450. */
  143451. static ClearCache(): void;
  143452. /**
  143453. * Serialize a scene into a JSON compatible object
  143454. * @param scene defines the scene to serialize
  143455. * @returns a JSON compatible object
  143456. */
  143457. static Serialize(scene: Scene): any;
  143458. /**
  143459. * Serialize a mesh into a JSON compatible object
  143460. * @param toSerialize defines the mesh to serialize
  143461. * @param withParents defines if parents must be serialized as well
  143462. * @param withChildren defines if children must be serialized as well
  143463. * @returns a JSON compatible object
  143464. */
  143465. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143466. }
  143467. }
  143468. declare module BABYLON {
  143469. /**
  143470. * Class used to host texture specific utilities
  143471. */
  143472. export class TextureTools {
  143473. /**
  143474. * Uses the GPU to create a copy texture rescaled at a given size
  143475. * @param texture Texture to copy from
  143476. * @param width defines the desired width
  143477. * @param height defines the desired height
  143478. * @param useBilinearMode defines if bilinear mode has to be used
  143479. * @return the generated texture
  143480. */
  143481. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143482. }
  143483. }
  143484. declare module BABYLON {
  143485. /**
  143486. * This represents the different options available for the video capture.
  143487. */
  143488. export interface VideoRecorderOptions {
  143489. /** Defines the mime type of the video. */
  143490. mimeType: string;
  143491. /** Defines the FPS the video should be recorded at. */
  143492. fps: number;
  143493. /** Defines the chunk size for the recording data. */
  143494. recordChunckSize: number;
  143495. /** The audio tracks to attach to the recording. */
  143496. audioTracks?: MediaStreamTrack[];
  143497. }
  143498. /**
  143499. * This can help with recording videos from BabylonJS.
  143500. * This is based on the available WebRTC functionalities of the browser.
  143501. *
  143502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143503. */
  143504. export class VideoRecorder {
  143505. private static readonly _defaultOptions;
  143506. /**
  143507. * Returns whether or not the VideoRecorder is available in your browser.
  143508. * @param engine Defines the Babylon Engine.
  143509. * @returns true if supported otherwise false.
  143510. */
  143511. static IsSupported(engine: Engine): boolean;
  143512. private readonly _options;
  143513. private _canvas;
  143514. private _mediaRecorder;
  143515. private _recordedChunks;
  143516. private _fileName;
  143517. private _resolve;
  143518. private _reject;
  143519. /**
  143520. * True when a recording is already in progress.
  143521. */
  143522. get isRecording(): boolean;
  143523. /**
  143524. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143525. * @param engine Defines the BabylonJS Engine you wish to record.
  143526. * @param options Defines options that can be used to customize the capture.
  143527. */
  143528. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143529. /**
  143530. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143531. */
  143532. stopRecording(): void;
  143533. /**
  143534. * Starts recording the canvas for a max duration specified in parameters.
  143535. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143536. * If null no automatic download will start and you can rely on the promise to get the data back.
  143537. * @param maxDuration Defines the maximum recording time in seconds.
  143538. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143539. * @return A promise callback at the end of the recording with the video data in Blob.
  143540. */
  143541. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143542. /**
  143543. * Releases internal resources used during the recording.
  143544. */
  143545. dispose(): void;
  143546. private _handleDataAvailable;
  143547. private _handleError;
  143548. private _handleStop;
  143549. }
  143550. }
  143551. declare module BABYLON {
  143552. /**
  143553. * Class containing a set of static utilities functions for screenshots
  143554. */
  143555. export class ScreenshotTools {
  143556. /**
  143557. * Captures a screenshot of the current rendering
  143558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143559. * @param engine defines the rendering engine
  143560. * @param camera defines the source camera
  143561. * @param size This parameter can be set to a single number or to an object with the
  143562. * following (optional) properties: precision, width, height. If a single number is passed,
  143563. * it will be used for both width and height. If an object is passed, the screenshot size
  143564. * will be derived from the parameters. The precision property is a multiplier allowing
  143565. * rendering at a higher or lower resolution
  143566. * @param successCallback defines the callback receives a single parameter which contains the
  143567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143568. * src parameter of an <img> to display it
  143569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143570. * Check your browser for supported MIME types
  143571. */
  143572. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143573. /**
  143574. * Captures a screenshot of the current rendering
  143575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143576. * @param engine defines the rendering engine
  143577. * @param camera defines the source camera
  143578. * @param size This parameter can be set to a single number or to an object with the
  143579. * following (optional) properties: precision, width, height. If a single number is passed,
  143580. * it will be used for both width and height. If an object is passed, the screenshot size
  143581. * will be derived from the parameters. The precision property is a multiplier allowing
  143582. * rendering at a higher or lower resolution
  143583. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143584. * Check your browser for supported MIME types
  143585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143586. * to the src parameter of an <img> to display it
  143587. */
  143588. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143589. /**
  143590. * Generates an image screenshot from the specified camera.
  143591. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143592. * @param engine The engine to use for rendering
  143593. * @param camera The camera to use for rendering
  143594. * @param size This parameter can be set to a single number or to an object with the
  143595. * following (optional) properties: precision, width, height. If a single number is passed,
  143596. * it will be used for both width and height. If an object is passed, the screenshot size
  143597. * will be derived from the parameters. The precision property is a multiplier allowing
  143598. * rendering at a higher or lower resolution
  143599. * @param successCallback The callback receives a single parameter which contains the
  143600. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143601. * src parameter of an <img> to display it
  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. */
  143609. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143610. /**
  143611. * Generates an image screenshot from the specified camera.
  143612. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143613. * @param engine The engine to use for rendering
  143614. * @param camera The camera to use for rendering
  143615. * @param size This parameter can be set to a single number or to an object with the
  143616. * following (optional) properties: precision, width, height. If a single number is passed,
  143617. * it will be used for both width and height. If an object is passed, the screenshot size
  143618. * will be derived from the parameters. The precision property is a multiplier allowing
  143619. * rendering at a higher or lower resolution
  143620. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143621. * Check your browser for supported MIME types
  143622. * @param samples Texture samples (default: 1)
  143623. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143624. * @param fileName A name for for the downloaded file.
  143625. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143626. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143627. * to the src parameter of an <img> to display it
  143628. */
  143629. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143630. /**
  143631. * Gets height and width for screenshot size
  143632. * @private
  143633. */
  143634. private static _getScreenshotSize;
  143635. }
  143636. }
  143637. declare module BABYLON {
  143638. /**
  143639. * Interface for a data buffer
  143640. */
  143641. export interface IDataBuffer {
  143642. /**
  143643. * Reads bytes from the data buffer.
  143644. * @param byteOffset The byte offset to read
  143645. * @param byteLength The byte length to read
  143646. * @returns A promise that resolves when the bytes are read
  143647. */
  143648. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143649. /**
  143650. * The byte length of the buffer.
  143651. */
  143652. readonly byteLength: number;
  143653. }
  143654. /**
  143655. * Utility class for reading from a data buffer
  143656. */
  143657. export class DataReader {
  143658. /**
  143659. * The data buffer associated with this data reader.
  143660. */
  143661. readonly buffer: IDataBuffer;
  143662. /**
  143663. * The current byte offset from the beginning of the data buffer.
  143664. */
  143665. byteOffset: number;
  143666. private _dataView;
  143667. private _dataByteOffset;
  143668. /**
  143669. * Constructor
  143670. * @param buffer The buffer to read
  143671. */
  143672. constructor(buffer: IDataBuffer);
  143673. /**
  143674. * Loads the given byte length.
  143675. * @param byteLength The byte length to load
  143676. * @returns A promise that resolves when the load is complete
  143677. */
  143678. loadAsync(byteLength: number): Promise<void>;
  143679. /**
  143680. * Read a unsigned 32-bit integer from the currently loaded data range.
  143681. * @returns The 32-bit integer read
  143682. */
  143683. readUint32(): number;
  143684. /**
  143685. * Read a byte array from the currently loaded data range.
  143686. * @param byteLength The byte length to read
  143687. * @returns The byte array read
  143688. */
  143689. readUint8Array(byteLength: number): Uint8Array;
  143690. /**
  143691. * Read a string from the currently loaded data range.
  143692. * @param byteLength The byte length to read
  143693. * @returns The string read
  143694. */
  143695. readString(byteLength: number): string;
  143696. /**
  143697. * Skips the given byte length the currently loaded data range.
  143698. * @param byteLength The byte length to skip
  143699. */
  143700. skipBytes(byteLength: number): void;
  143701. }
  143702. }
  143703. declare module BABYLON {
  143704. /**
  143705. * Class for storing data to local storage if available or in-memory storage otherwise
  143706. */
  143707. export class DataStorage {
  143708. private static _Storage;
  143709. private static _GetStorage;
  143710. /**
  143711. * Reads a string from the data storage
  143712. * @param key The key to read
  143713. * @param defaultValue The value if the key doesn't exist
  143714. * @returns The string value
  143715. */
  143716. static ReadString(key: string, defaultValue: string): string;
  143717. /**
  143718. * Writes a string to the data storage
  143719. * @param key The key to write
  143720. * @param value The value to write
  143721. */
  143722. static WriteString(key: string, value: string): void;
  143723. /**
  143724. * Reads a boolean from the data storage
  143725. * @param key The key to read
  143726. * @param defaultValue The value if the key doesn't exist
  143727. * @returns The boolean value
  143728. */
  143729. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143730. /**
  143731. * Writes a boolean to the data storage
  143732. * @param key The key to write
  143733. * @param value The value to write
  143734. */
  143735. static WriteBoolean(key: string, value: boolean): void;
  143736. /**
  143737. * Reads a number from the data storage
  143738. * @param key The key to read
  143739. * @param defaultValue The value if the key doesn't exist
  143740. * @returns The number value
  143741. */
  143742. static ReadNumber(key: string, defaultValue: number): number;
  143743. /**
  143744. * Writes a number to the data storage
  143745. * @param key The key to write
  143746. * @param value The value to write
  143747. */
  143748. static WriteNumber(key: string, value: number): void;
  143749. }
  143750. }
  143751. declare module BABYLON {
  143752. /**
  143753. * Options used for hit testing
  143754. */
  143755. export interface IWebXRLegacyHitTestOptions {
  143756. /**
  143757. * Only test when user interacted with the scene. Default - hit test every frame
  143758. */
  143759. testOnPointerDownOnly?: boolean;
  143760. /**
  143761. * The node to use to transform the local results to world coordinates
  143762. */
  143763. worldParentNode?: TransformNode;
  143764. }
  143765. /**
  143766. * Interface defining the babylon result of raycasting/hit-test
  143767. */
  143768. export interface IWebXRLegacyHitResult {
  143769. /**
  143770. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143771. */
  143772. transformationMatrix: Matrix;
  143773. /**
  143774. * The native hit test result
  143775. */
  143776. xrHitResult: XRHitResult | XRHitTestResult;
  143777. }
  143778. /**
  143779. * The currently-working hit-test module.
  143780. * Hit test (or Ray-casting) is used to interact with the real world.
  143781. * For further information read here - https://github.com/immersive-web/hit-test
  143782. */
  143783. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143784. /**
  143785. * options to use when constructing this feature
  143786. */
  143787. readonly options: IWebXRLegacyHitTestOptions;
  143788. private _direction;
  143789. private _mat;
  143790. private _onSelectEnabled;
  143791. private _origin;
  143792. /**
  143793. * The module's name
  143794. */
  143795. static readonly Name: string;
  143796. /**
  143797. * The (Babylon) version of this module.
  143798. * This is an integer representing the implementation version.
  143799. * This number does not correspond to the WebXR specs version
  143800. */
  143801. static readonly Version: number;
  143802. /**
  143803. * Populated with the last native XR Hit Results
  143804. */
  143805. lastNativeXRHitResults: XRHitResult[];
  143806. /**
  143807. * Triggered when new babylon (transformed) hit test results are available
  143808. */
  143809. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143810. /**
  143811. * Creates a new instance of the (legacy version) hit test feature
  143812. * @param _xrSessionManager an instance of WebXRSessionManager
  143813. * @param options options to use when constructing this feature
  143814. */
  143815. constructor(_xrSessionManager: WebXRSessionManager,
  143816. /**
  143817. * options to use when constructing this feature
  143818. */
  143819. options?: IWebXRLegacyHitTestOptions);
  143820. /**
  143821. * execute a hit test with an XR Ray
  143822. *
  143823. * @param xrSession a native xrSession that will execute this hit test
  143824. * @param xrRay the ray (position and direction) to use for ray-casting
  143825. * @param referenceSpace native XR reference space to use for the hit-test
  143826. * @param filter filter function that will filter the results
  143827. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143828. */
  143829. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143830. /**
  143831. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143832. * @param event the (select) event to use to select with
  143833. * @param referenceSpace the reference space to use for this hit test
  143834. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143835. */
  143836. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143837. /**
  143838. * attach this feature
  143839. * Will usually be called by the features manager
  143840. *
  143841. * @returns true if successful.
  143842. */
  143843. attach(): boolean;
  143844. /**
  143845. * detach this feature.
  143846. * Will usually be called by the features manager
  143847. *
  143848. * @returns true if successful.
  143849. */
  143850. detach(): boolean;
  143851. /**
  143852. * Dispose this feature and all of the resources attached
  143853. */
  143854. dispose(): void;
  143855. protected _onXRFrame(frame: XRFrame): void;
  143856. private _onHitTestResults;
  143857. private _onSelect;
  143858. }
  143859. }
  143860. declare module BABYLON {
  143861. /**
  143862. * Options used in the plane detector module
  143863. */
  143864. export interface IWebXRPlaneDetectorOptions {
  143865. /**
  143866. * The node to use to transform the local results to world coordinates
  143867. */
  143868. worldParentNode?: TransformNode;
  143869. }
  143870. /**
  143871. * A babylon interface for a WebXR plane.
  143872. * A Plane is actually a polygon, built from N points in space
  143873. *
  143874. * Supported in chrome 79, not supported in canary 81 ATM
  143875. */
  143876. export interface IWebXRPlane {
  143877. /**
  143878. * a babylon-assigned ID for this polygon
  143879. */
  143880. id: number;
  143881. /**
  143882. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143883. */
  143884. polygonDefinition: Array<Vector3>;
  143885. /**
  143886. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143887. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143888. */
  143889. transformationMatrix: Matrix;
  143890. /**
  143891. * the native xr-plane object
  143892. */
  143893. xrPlane: XRPlane;
  143894. }
  143895. /**
  143896. * The plane detector is used to detect planes in the real world when in AR
  143897. * For more information see https://github.com/immersive-web/real-world-geometry/
  143898. */
  143899. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143900. private _options;
  143901. private _detectedPlanes;
  143902. private _enabled;
  143903. private _lastFrameDetected;
  143904. /**
  143905. * The module's name
  143906. */
  143907. static readonly Name: string;
  143908. /**
  143909. * The (Babylon) version of this module.
  143910. * This is an integer representing the implementation version.
  143911. * This number does not correspond to the WebXR specs version
  143912. */
  143913. static readonly Version: number;
  143914. /**
  143915. * Observers registered here will be executed when a new plane was added to the session
  143916. */
  143917. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143918. /**
  143919. * Observers registered here will be executed when a plane is no longer detected in the session
  143920. */
  143921. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143922. /**
  143923. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143924. * This can execute N times every frame
  143925. */
  143926. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143927. /**
  143928. * construct a new Plane Detector
  143929. * @param _xrSessionManager an instance of xr Session manager
  143930. * @param _options configuration to use when constructing this feature
  143931. */
  143932. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143933. /**
  143934. * Dispose this feature and all of the resources attached
  143935. */
  143936. dispose(): void;
  143937. protected _onXRFrame(frame: XRFrame): void;
  143938. private _init;
  143939. private _updatePlaneWithXRPlane;
  143940. /**
  143941. * avoiding using Array.find for global support.
  143942. * @param xrPlane the plane to find in the array
  143943. */
  143944. private findIndexInPlaneArray;
  143945. }
  143946. }
  143947. declare module BABYLON {
  143948. /**
  143949. * Configuration options of the anchor system
  143950. */
  143951. export interface IWebXRAnchorSystemOptions {
  143952. /**
  143953. * Should a new anchor be added every time a select event is triggered
  143954. */
  143955. addAnchorOnSelect?: boolean;
  143956. /**
  143957. * should the anchor system use plane detection.
  143958. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143959. */
  143960. usePlaneDetection?: boolean;
  143961. /**
  143962. * a node that will be used to convert local to world coordinates
  143963. */
  143964. worldParentNode?: TransformNode;
  143965. }
  143966. /**
  143967. * A babylon container for an XR Anchor
  143968. */
  143969. export interface IWebXRAnchor {
  143970. /**
  143971. * A babylon-assigned ID for this anchor
  143972. */
  143973. id: number;
  143974. /**
  143975. * Transformation matrix to apply to an object attached to this anchor
  143976. */
  143977. transformationMatrix: Matrix;
  143978. /**
  143979. * The native anchor object
  143980. */
  143981. xrAnchor: XRAnchor;
  143982. }
  143983. /**
  143984. * An implementation of the anchor system of WebXR.
  143985. * Note that the current documented implementation is not available in any browser. Future implementations
  143986. * will use the frame to create an anchor and not the session or a detected plane
  143987. * For further information see https://github.com/immersive-web/anchors/
  143988. */
  143989. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  143990. private _options;
  143991. private _enabled;
  143992. private _hitTestModule;
  143993. private _lastFrameDetected;
  143994. private _onSelect;
  143995. private _planeDetector;
  143996. private _trackedAnchors;
  143997. /**
  143998. * The module's name
  143999. */
  144000. static readonly Name: string;
  144001. /**
  144002. * The (Babylon) version of this module.
  144003. * This is an integer representing the implementation version.
  144004. * This number does not correspond to the WebXR specs version
  144005. */
  144006. static readonly Version: number;
  144007. /**
  144008. * Observers registered here will be executed when a new anchor was added to the session
  144009. */
  144010. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  144011. /**
  144012. * Observers registered here will be executed when an anchor was removed from the session
  144013. */
  144014. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  144015. /**
  144016. * Observers registered here will be executed when an existing anchor updates
  144017. * This can execute N times every frame
  144018. */
  144019. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144020. /**
  144021. * constructs a new anchor system
  144022. * @param _xrSessionManager an instance of WebXRSessionManager
  144023. * @param _options configuration object for this feature
  144024. */
  144025. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144026. /**
  144027. * Add anchor at a specific XR point.
  144028. *
  144029. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144030. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144031. * @returns a promise the fulfills when the anchor was created
  144032. */
  144033. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144034. /**
  144035. * attach this feature
  144036. * Will usually be called by the features manager
  144037. *
  144038. * @returns true if successful.
  144039. */
  144040. attach(): boolean;
  144041. /**
  144042. * detach this feature.
  144043. * Will usually be called by the features manager
  144044. *
  144045. * @returns true if successful.
  144046. */
  144047. detach(): boolean;
  144048. /**
  144049. * Dispose this feature and all of the resources attached
  144050. */
  144051. dispose(): void;
  144052. /**
  144053. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144054. * @param hitTestModule the hit-test module to use.
  144055. */
  144056. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144057. /**
  144058. * set the plane detector to use in order to create anchors from frames
  144059. * @param planeDetector the plane-detector module to use
  144060. * @param enable enable plane-anchors. default is true
  144061. */
  144062. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144063. protected _onXRFrame(frame: XRFrame): void;
  144064. /**
  144065. * avoiding using Array.find for global support.
  144066. * @param xrAnchor the plane to find in the array
  144067. */
  144068. private _findIndexInAnchorArray;
  144069. private _updateAnchorWithXRFrame;
  144070. }
  144071. }
  144072. declare module BABYLON {
  144073. /**
  144074. * Options interface for the background remover plugin
  144075. */
  144076. export interface IWebXRBackgroundRemoverOptions {
  144077. /**
  144078. * Further background meshes to disable when entering AR
  144079. */
  144080. backgroundMeshes?: AbstractMesh[];
  144081. /**
  144082. * flags to configure the removal of the environment helper.
  144083. * If not set, the entire background will be removed. If set, flags should be set as well.
  144084. */
  144085. environmentHelperRemovalFlags?: {
  144086. /**
  144087. * Should the skybox be removed (default false)
  144088. */
  144089. skyBox?: boolean;
  144090. /**
  144091. * Should the ground be removed (default false)
  144092. */
  144093. ground?: boolean;
  144094. };
  144095. /**
  144096. * don't disable the environment helper
  144097. */
  144098. ignoreEnvironmentHelper?: boolean;
  144099. }
  144100. /**
  144101. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144102. */
  144103. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144104. /**
  144105. * read-only options to be used in this module
  144106. */
  144107. readonly options: IWebXRBackgroundRemoverOptions;
  144108. /**
  144109. * The module's name
  144110. */
  144111. static readonly Name: string;
  144112. /**
  144113. * The (Babylon) version of this module.
  144114. * This is an integer representing the implementation version.
  144115. * This number does not correspond to the WebXR specs version
  144116. */
  144117. static readonly Version: number;
  144118. /**
  144119. * registered observers will be triggered when the background state changes
  144120. */
  144121. onBackgroundStateChangedObservable: Observable<boolean>;
  144122. /**
  144123. * constructs a new background remover module
  144124. * @param _xrSessionManager the session manager for this module
  144125. * @param options read-only options to be used in this module
  144126. */
  144127. constructor(_xrSessionManager: WebXRSessionManager,
  144128. /**
  144129. * read-only options to be used in this module
  144130. */
  144131. options?: IWebXRBackgroundRemoverOptions);
  144132. /**
  144133. * attach this feature
  144134. * Will usually be called by the features manager
  144135. *
  144136. * @returns true if successful.
  144137. */
  144138. attach(): boolean;
  144139. /**
  144140. * detach this feature.
  144141. * Will usually be called by the features manager
  144142. *
  144143. * @returns true if successful.
  144144. */
  144145. detach(): boolean;
  144146. /**
  144147. * Dispose this feature and all of the resources attached
  144148. */
  144149. dispose(): void;
  144150. protected _onXRFrame(_xrFrame: XRFrame): void;
  144151. private _setBackgroundState;
  144152. }
  144153. }
  144154. declare module BABYLON {
  144155. /**
  144156. * Options for the controller physics feature
  144157. */
  144158. export class IWebXRControllerPhysicsOptions {
  144159. /**
  144160. * Should the headset get its own impostor
  144161. */
  144162. enableHeadsetImpostor?: boolean;
  144163. /**
  144164. * Optional parameters for the headset impostor
  144165. */
  144166. headsetImpostorParams?: {
  144167. /**
  144168. * The type of impostor to create. Default is sphere
  144169. */
  144170. impostorType: number;
  144171. /**
  144172. * the size of the impostor. Defaults to 10cm
  144173. */
  144174. impostorSize?: number | {
  144175. width: number;
  144176. height: number;
  144177. depth: number;
  144178. };
  144179. /**
  144180. * Friction definitions
  144181. */
  144182. friction?: number;
  144183. /**
  144184. * Restitution
  144185. */
  144186. restitution?: number;
  144187. };
  144188. /**
  144189. * The physics properties of the future impostors
  144190. */
  144191. physicsProperties?: {
  144192. /**
  144193. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144194. * Note that this requires a physics engine that supports mesh impostors!
  144195. */
  144196. useControllerMesh?: boolean;
  144197. /**
  144198. * The type of impostor to create. Default is sphere
  144199. */
  144200. impostorType?: number;
  144201. /**
  144202. * the size of the impostor. Defaults to 10cm
  144203. */
  144204. impostorSize?: number | {
  144205. width: number;
  144206. height: number;
  144207. depth: number;
  144208. };
  144209. /**
  144210. * Friction definitions
  144211. */
  144212. friction?: number;
  144213. /**
  144214. * Restitution
  144215. */
  144216. restitution?: number;
  144217. };
  144218. /**
  144219. * the xr input to use with this pointer selection
  144220. */
  144221. xrInput: WebXRInput;
  144222. }
  144223. /**
  144224. * Add physics impostor to your webxr controllers,
  144225. * including naive calculation of their linear and angular velocity
  144226. */
  144227. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144228. private readonly _options;
  144229. private _attachController;
  144230. private _controllers;
  144231. private _debugMode;
  144232. private _delta;
  144233. private _headsetImpostor?;
  144234. private _headsetMesh?;
  144235. private _lastTimestamp;
  144236. private _tmpQuaternion;
  144237. private _tmpVector;
  144238. /**
  144239. * The module's name
  144240. */
  144241. static readonly Name: string;
  144242. /**
  144243. * The (Babylon) version of this module.
  144244. * This is an integer representing the implementation version.
  144245. * This number does not correspond to the webxr specs version
  144246. */
  144247. static readonly Version: number;
  144248. /**
  144249. * Construct a new Controller Physics Feature
  144250. * @param _xrSessionManager the corresponding xr session manager
  144251. * @param _options options to create this feature with
  144252. */
  144253. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144254. /**
  144255. * @hidden
  144256. * enable debugging - will show console outputs and the impostor mesh
  144257. */
  144258. _enablePhysicsDebug(): void;
  144259. /**
  144260. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144261. * @param xrController the controller to add
  144262. */
  144263. addController(xrController: WebXRInputSource): void;
  144264. /**
  144265. * attach this feature
  144266. * Will usually be called by the features manager
  144267. *
  144268. * @returns true if successful.
  144269. */
  144270. attach(): boolean;
  144271. /**
  144272. * detach this feature.
  144273. * Will usually be called by the features manager
  144274. *
  144275. * @returns true if successful.
  144276. */
  144277. detach(): boolean;
  144278. /**
  144279. * Get the headset impostor, if enabled
  144280. * @returns the impostor
  144281. */
  144282. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144283. /**
  144284. * Get the physics impostor of a specific controller.
  144285. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144286. * @param controller the controller or the controller id of which to get the impostor
  144287. * @returns the impostor or null
  144288. */
  144289. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144290. /**
  144291. * Update the physics properties provided in the constructor
  144292. * @param newProperties the new properties object
  144293. */
  144294. setPhysicsProperties(newProperties: {
  144295. impostorType?: number;
  144296. impostorSize?: number | {
  144297. width: number;
  144298. height: number;
  144299. depth: number;
  144300. };
  144301. friction?: number;
  144302. restitution?: number;
  144303. }): void;
  144304. protected _onXRFrame(_xrFrame: any): void;
  144305. private _detachController;
  144306. }
  144307. }
  144308. declare module BABYLON {
  144309. /**
  144310. * Options used for hit testing (version 2)
  144311. */
  144312. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144313. /**
  144314. * Do not create a permanent hit test. Will usually be used when only
  144315. * transient inputs are needed.
  144316. */
  144317. disablePermanentHitTest?: boolean;
  144318. /**
  144319. * Enable transient (for example touch-based) hit test inspections
  144320. */
  144321. enableTransientHitTest?: boolean;
  144322. /**
  144323. * Offset ray for the permanent hit test
  144324. */
  144325. offsetRay?: Vector3;
  144326. /**
  144327. * Offset ray for the transient hit test
  144328. */
  144329. transientOffsetRay?: Vector3;
  144330. /**
  144331. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144332. */
  144333. useReferenceSpace?: boolean;
  144334. }
  144335. /**
  144336. * Interface defining the babylon result of hit-test
  144337. */
  144338. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144339. /**
  144340. * The input source that generated this hit test (if transient)
  144341. */
  144342. inputSource?: XRInputSource;
  144343. /**
  144344. * Is this a transient hit test
  144345. */
  144346. isTransient?: boolean;
  144347. /**
  144348. * Position of the hit test result
  144349. */
  144350. position: Vector3;
  144351. /**
  144352. * Rotation of the hit test result
  144353. */
  144354. rotationQuaternion: Quaternion;
  144355. }
  144356. /**
  144357. * The currently-working hit-test module.
  144358. * Hit test (or Ray-casting) is used to interact with the real world.
  144359. * For further information read here - https://github.com/immersive-web/hit-test
  144360. *
  144361. * Tested on chrome (mobile) 80.
  144362. */
  144363. export class WebXRHitTest extends WebXRAbstractFeature {
  144364. /**
  144365. * options to use when constructing this feature
  144366. */
  144367. readonly options: IWebXRHitTestOptions;
  144368. private _tmpMat;
  144369. private _tmpPos;
  144370. private _tmpQuat;
  144371. private _transientXrHitTestSource;
  144372. private _xrHitTestSource;
  144373. private initHitTestSource;
  144374. /**
  144375. * The module's name
  144376. */
  144377. static readonly Name: string;
  144378. /**
  144379. * The (Babylon) version of this module.
  144380. * This is an integer representing the implementation version.
  144381. * This number does not correspond to the WebXR specs version
  144382. */
  144383. static readonly Version: number;
  144384. /**
  144385. * When set to true, each hit test will have its own position/rotation objects
  144386. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144387. * the developers will clone them or copy them as they see fit.
  144388. */
  144389. autoCloneTransformation: boolean;
  144390. /**
  144391. * Populated with the last native XR Hit Results
  144392. */
  144393. lastNativeXRHitResults: XRHitResult[];
  144394. /**
  144395. * Triggered when new babylon (transformed) hit test results are available
  144396. */
  144397. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144398. /**
  144399. * Use this to temporarily pause hit test checks.
  144400. */
  144401. paused: boolean;
  144402. /**
  144403. * Creates a new instance of the hit test feature
  144404. * @param _xrSessionManager an instance of WebXRSessionManager
  144405. * @param options options to use when constructing this feature
  144406. */
  144407. constructor(_xrSessionManager: WebXRSessionManager,
  144408. /**
  144409. * options to use when constructing this feature
  144410. */
  144411. options?: IWebXRHitTestOptions);
  144412. /**
  144413. * attach this feature
  144414. * Will usually be called by the features manager
  144415. *
  144416. * @returns true if successful.
  144417. */
  144418. attach(): boolean;
  144419. /**
  144420. * detach this feature.
  144421. * Will usually be called by the features manager
  144422. *
  144423. * @returns true if successful.
  144424. */
  144425. detach(): boolean;
  144426. /**
  144427. * Dispose this feature and all of the resources attached
  144428. */
  144429. dispose(): void;
  144430. protected _onXRFrame(frame: XRFrame): void;
  144431. private _processWebXRHitTestResult;
  144432. }
  144433. }
  144434. declare module BABYLON {
  144435. /**
  144436. * The motion controller class for all microsoft mixed reality controllers
  144437. */
  144438. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144439. protected readonly _mapping: {
  144440. defaultButton: {
  144441. valueNodeName: string;
  144442. unpressedNodeName: string;
  144443. pressedNodeName: string;
  144444. };
  144445. defaultAxis: {
  144446. valueNodeName: string;
  144447. minNodeName: string;
  144448. maxNodeName: string;
  144449. };
  144450. buttons: {
  144451. "xr-standard-trigger": {
  144452. rootNodeName: string;
  144453. componentProperty: string;
  144454. states: string[];
  144455. };
  144456. "xr-standard-squeeze": {
  144457. rootNodeName: string;
  144458. componentProperty: string;
  144459. states: string[];
  144460. };
  144461. "xr-standard-touchpad": {
  144462. rootNodeName: string;
  144463. labelAnchorNodeName: string;
  144464. touchPointNodeName: string;
  144465. };
  144466. "xr-standard-thumbstick": {
  144467. rootNodeName: string;
  144468. componentProperty: string;
  144469. states: string[];
  144470. };
  144471. };
  144472. axes: {
  144473. "xr-standard-touchpad": {
  144474. "x-axis": {
  144475. rootNodeName: string;
  144476. };
  144477. "y-axis": {
  144478. rootNodeName: string;
  144479. };
  144480. };
  144481. "xr-standard-thumbstick": {
  144482. "x-axis": {
  144483. rootNodeName: string;
  144484. };
  144485. "y-axis": {
  144486. rootNodeName: string;
  144487. };
  144488. };
  144489. };
  144490. };
  144491. /**
  144492. * The base url used to load the left and right controller models
  144493. */
  144494. static MODEL_BASE_URL: string;
  144495. /**
  144496. * The name of the left controller model file
  144497. */
  144498. static MODEL_LEFT_FILENAME: string;
  144499. /**
  144500. * The name of the right controller model file
  144501. */
  144502. static MODEL_RIGHT_FILENAME: string;
  144503. profileId: string;
  144504. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144505. protected _getFilenameAndPath(): {
  144506. filename: string;
  144507. path: string;
  144508. };
  144509. protected _getModelLoadingConstraints(): boolean;
  144510. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144511. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144512. protected _updateModel(): void;
  144513. }
  144514. }
  144515. declare module BABYLON {
  144516. /**
  144517. * The motion controller class for oculus touch (quest, rift).
  144518. * This class supports legacy mapping as well the standard xr mapping
  144519. */
  144520. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144521. private _forceLegacyControllers;
  144522. private _modelRootNode;
  144523. /**
  144524. * The base url used to load the left and right controller models
  144525. */
  144526. static MODEL_BASE_URL: string;
  144527. /**
  144528. * The name of the left controller model file
  144529. */
  144530. static MODEL_LEFT_FILENAME: string;
  144531. /**
  144532. * The name of the right controller model file
  144533. */
  144534. static MODEL_RIGHT_FILENAME: string;
  144535. /**
  144536. * Base Url for the Quest controller model.
  144537. */
  144538. static QUEST_MODEL_BASE_URL: string;
  144539. profileId: string;
  144540. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144541. protected _getFilenameAndPath(): {
  144542. filename: string;
  144543. path: string;
  144544. };
  144545. protected _getModelLoadingConstraints(): boolean;
  144546. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144547. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144548. protected _updateModel(): void;
  144549. /**
  144550. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144551. * between the touch and touch 2.
  144552. */
  144553. private _isQuest;
  144554. }
  144555. }
  144556. declare module BABYLON {
  144557. /**
  144558. * The motion controller class for the standard HTC-Vive controllers
  144559. */
  144560. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144561. private _modelRootNode;
  144562. /**
  144563. * The base url used to load the left and right controller models
  144564. */
  144565. static MODEL_BASE_URL: string;
  144566. /**
  144567. * File name for the controller model.
  144568. */
  144569. static MODEL_FILENAME: string;
  144570. profileId: string;
  144571. /**
  144572. * Create a new Vive motion controller object
  144573. * @param scene the scene to use to create this controller
  144574. * @param gamepadObject the corresponding gamepad object
  144575. * @param handness the handness of the controller
  144576. */
  144577. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144578. protected _getFilenameAndPath(): {
  144579. filename: string;
  144580. path: string;
  144581. };
  144582. protected _getModelLoadingConstraints(): boolean;
  144583. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144584. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144585. protected _updateModel(): void;
  144586. }
  144587. }
  144588. declare module BABYLON {
  144589. /**
  144590. * A cursor which tracks a point on a path
  144591. */
  144592. export class PathCursor {
  144593. private path;
  144594. /**
  144595. * Stores path cursor callbacks for when an onchange event is triggered
  144596. */
  144597. private _onchange;
  144598. /**
  144599. * The value of the path cursor
  144600. */
  144601. value: number;
  144602. /**
  144603. * The animation array of the path cursor
  144604. */
  144605. animations: Animation[];
  144606. /**
  144607. * Initializes the path cursor
  144608. * @param path The path to track
  144609. */
  144610. constructor(path: Path2);
  144611. /**
  144612. * Gets the cursor point on the path
  144613. * @returns A point on the path cursor at the cursor location
  144614. */
  144615. getPoint(): Vector3;
  144616. /**
  144617. * Moves the cursor ahead by the step amount
  144618. * @param step The amount to move the cursor forward
  144619. * @returns This path cursor
  144620. */
  144621. moveAhead(step?: number): PathCursor;
  144622. /**
  144623. * Moves the cursor behind by the step amount
  144624. * @param step The amount to move the cursor back
  144625. * @returns This path cursor
  144626. */
  144627. moveBack(step?: number): PathCursor;
  144628. /**
  144629. * Moves the cursor by the step amount
  144630. * If the step amount is greater than one, an exception is thrown
  144631. * @param step The amount to move the cursor
  144632. * @returns This path cursor
  144633. */
  144634. move(step: number): PathCursor;
  144635. /**
  144636. * Ensures that the value is limited between zero and one
  144637. * @returns This path cursor
  144638. */
  144639. private ensureLimits;
  144640. /**
  144641. * Runs onchange callbacks on change (used by the animation engine)
  144642. * @returns This path cursor
  144643. */
  144644. private raiseOnChange;
  144645. /**
  144646. * Executes a function on change
  144647. * @param f A path cursor onchange callback
  144648. * @returns This path cursor
  144649. */
  144650. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144651. }
  144652. }
  144653. declare module BABYLON {
  144654. /** @hidden */
  144655. export var blurPixelShader: {
  144656. name: string;
  144657. shader: string;
  144658. };
  144659. }
  144660. declare module BABYLON {
  144661. /** @hidden */
  144662. export var pointCloudVertexDeclaration: {
  144663. name: string;
  144664. shader: string;
  144665. };
  144666. }
  144667. // Mixins
  144668. interface Window {
  144669. mozIndexedDB: IDBFactory;
  144670. webkitIndexedDB: IDBFactory;
  144671. msIndexedDB: IDBFactory;
  144672. webkitURL: typeof URL;
  144673. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144674. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144675. WebGLRenderingContext: WebGLRenderingContext;
  144676. MSGesture: MSGesture;
  144677. CANNON: any;
  144678. AudioContext: AudioContext;
  144679. webkitAudioContext: AudioContext;
  144680. PointerEvent: any;
  144681. Math: Math;
  144682. Uint8Array: Uint8ArrayConstructor;
  144683. Float32Array: Float32ArrayConstructor;
  144684. mozURL: typeof URL;
  144685. msURL: typeof URL;
  144686. VRFrameData: any; // WebVR, from specs 1.1
  144687. DracoDecoderModule: any;
  144688. setImmediate(handler: (...args: any[]) => void): number;
  144689. }
  144690. interface HTMLCanvasElement {
  144691. requestPointerLock(): void;
  144692. msRequestPointerLock?(): void;
  144693. mozRequestPointerLock?(): void;
  144694. webkitRequestPointerLock?(): void;
  144695. /** Track wether a record is in progress */
  144696. isRecording: boolean;
  144697. /** Capture Stream method defined by some browsers */
  144698. captureStream(fps?: number): MediaStream;
  144699. }
  144700. interface CanvasRenderingContext2D {
  144701. msImageSmoothingEnabled: boolean;
  144702. }
  144703. interface MouseEvent {
  144704. mozMovementX: number;
  144705. mozMovementY: number;
  144706. webkitMovementX: number;
  144707. webkitMovementY: number;
  144708. msMovementX: number;
  144709. msMovementY: number;
  144710. }
  144711. interface Navigator {
  144712. mozGetVRDevices: (any: any) => any;
  144713. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144714. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144715. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144716. webkitGetGamepads(): Gamepad[];
  144717. msGetGamepads(): Gamepad[];
  144718. webkitGamepads(): Gamepad[];
  144719. }
  144720. interface HTMLVideoElement {
  144721. mozSrcObject: any;
  144722. }
  144723. interface Math {
  144724. fround(x: number): number;
  144725. imul(a: number, b: number): number;
  144726. }
  144727. interface WebGLRenderingContext {
  144728. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144729. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144730. vertexAttribDivisor(index: number, divisor: number): void;
  144731. createVertexArray(): any;
  144732. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144733. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144734. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144735. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144736. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144737. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144738. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144739. // Queries
  144740. createQuery(): WebGLQuery;
  144741. deleteQuery(query: WebGLQuery): void;
  144742. beginQuery(target: number, query: WebGLQuery): void;
  144743. endQuery(target: number): void;
  144744. getQueryParameter(query: WebGLQuery, pname: number): any;
  144745. getQuery(target: number, pname: number): any;
  144746. MAX_SAMPLES: number;
  144747. RGBA8: number;
  144748. READ_FRAMEBUFFER: number;
  144749. DRAW_FRAMEBUFFER: number;
  144750. UNIFORM_BUFFER: number;
  144751. HALF_FLOAT_OES: number;
  144752. RGBA16F: number;
  144753. RGBA32F: number;
  144754. R32F: number;
  144755. RG32F: number;
  144756. RGB32F: number;
  144757. R16F: number;
  144758. RG16F: number;
  144759. RGB16F: number;
  144760. RED: number;
  144761. RG: number;
  144762. R8: number;
  144763. RG8: number;
  144764. UNSIGNED_INT_24_8: number;
  144765. DEPTH24_STENCIL8: number;
  144766. MIN: number;
  144767. MAX: number;
  144768. /* Multiple Render Targets */
  144769. drawBuffers(buffers: number[]): void;
  144770. readBuffer(src: number): void;
  144771. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144772. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144773. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144774. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144775. // Occlusion Query
  144776. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144777. ANY_SAMPLES_PASSED: number;
  144778. QUERY_RESULT_AVAILABLE: number;
  144779. QUERY_RESULT: number;
  144780. }
  144781. interface WebGLProgram {
  144782. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144783. }
  144784. interface EXT_disjoint_timer_query {
  144785. QUERY_COUNTER_BITS_EXT: number;
  144786. TIME_ELAPSED_EXT: number;
  144787. TIMESTAMP_EXT: number;
  144788. GPU_DISJOINT_EXT: number;
  144789. QUERY_RESULT_EXT: number;
  144790. QUERY_RESULT_AVAILABLE_EXT: number;
  144791. queryCounterEXT(query: WebGLQuery, target: number): void;
  144792. createQueryEXT(): WebGLQuery;
  144793. beginQueryEXT(target: number, query: WebGLQuery): void;
  144794. endQueryEXT(target: number): void;
  144795. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144796. deleteQueryEXT(query: WebGLQuery): void;
  144797. }
  144798. interface WebGLUniformLocation {
  144799. _currentState: any;
  144800. }
  144801. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144802. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144803. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144804. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144805. interface WebGLRenderingContext {
  144806. readonly RASTERIZER_DISCARD: number;
  144807. readonly DEPTH_COMPONENT24: number;
  144808. readonly TEXTURE_3D: number;
  144809. readonly TEXTURE_2D_ARRAY: number;
  144810. readonly TEXTURE_COMPARE_FUNC: number;
  144811. readonly TEXTURE_COMPARE_MODE: number;
  144812. readonly COMPARE_REF_TO_TEXTURE: number;
  144813. readonly TEXTURE_WRAP_R: number;
  144814. readonly HALF_FLOAT: number;
  144815. readonly RGB8: number;
  144816. readonly RED_INTEGER: number;
  144817. readonly RG_INTEGER: number;
  144818. readonly RGB_INTEGER: number;
  144819. readonly RGBA_INTEGER: number;
  144820. readonly R8_SNORM: number;
  144821. readonly RG8_SNORM: number;
  144822. readonly RGB8_SNORM: number;
  144823. readonly RGBA8_SNORM: number;
  144824. readonly R8I: number;
  144825. readonly RG8I: number;
  144826. readonly RGB8I: number;
  144827. readonly RGBA8I: number;
  144828. readonly R8UI: number;
  144829. readonly RG8UI: number;
  144830. readonly RGB8UI: number;
  144831. readonly RGBA8UI: number;
  144832. readonly R16I: number;
  144833. readonly RG16I: number;
  144834. readonly RGB16I: number;
  144835. readonly RGBA16I: number;
  144836. readonly R16UI: number;
  144837. readonly RG16UI: number;
  144838. readonly RGB16UI: number;
  144839. readonly RGBA16UI: number;
  144840. readonly R32I: number;
  144841. readonly RG32I: number;
  144842. readonly RGB32I: number;
  144843. readonly RGBA32I: number;
  144844. readonly R32UI: number;
  144845. readonly RG32UI: number;
  144846. readonly RGB32UI: number;
  144847. readonly RGBA32UI: number;
  144848. readonly RGB10_A2UI: number;
  144849. readonly R11F_G11F_B10F: number;
  144850. readonly RGB9_E5: number;
  144851. readonly RGB10_A2: number;
  144852. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144853. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144854. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144855. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144856. readonly DEPTH_COMPONENT32F: number;
  144857. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144858. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144859. 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;
  144860. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144861. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144862. readonly TRANSFORM_FEEDBACK: number;
  144863. readonly INTERLEAVED_ATTRIBS: number;
  144864. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144865. createTransformFeedback(): WebGLTransformFeedback;
  144866. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144867. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144868. beginTransformFeedback(primitiveMode: number): void;
  144869. endTransformFeedback(): void;
  144870. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144871. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144872. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144873. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144874. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144875. }
  144876. interface ImageBitmap {
  144877. readonly width: number;
  144878. readonly height: number;
  144879. close(): void;
  144880. }
  144881. interface WebGLQuery extends WebGLObject {
  144882. }
  144883. declare var WebGLQuery: {
  144884. prototype: WebGLQuery;
  144885. new(): WebGLQuery;
  144886. };
  144887. interface WebGLSampler extends WebGLObject {
  144888. }
  144889. declare var WebGLSampler: {
  144890. prototype: WebGLSampler;
  144891. new(): WebGLSampler;
  144892. };
  144893. interface WebGLSync extends WebGLObject {
  144894. }
  144895. declare var WebGLSync: {
  144896. prototype: WebGLSync;
  144897. new(): WebGLSync;
  144898. };
  144899. interface WebGLTransformFeedback extends WebGLObject {
  144900. }
  144901. declare var WebGLTransformFeedback: {
  144902. prototype: WebGLTransformFeedback;
  144903. new(): WebGLTransformFeedback;
  144904. };
  144905. interface WebGLVertexArrayObject extends WebGLObject {
  144906. }
  144907. declare var WebGLVertexArrayObject: {
  144908. prototype: WebGLVertexArrayObject;
  144909. new(): WebGLVertexArrayObject;
  144910. };
  144911. // Type definitions for WebVR API
  144912. // Project: https://w3c.github.io/webvr/
  144913. // Definitions by: six a <https://github.com/lostfictions>
  144914. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144915. interface VRDisplay extends EventTarget {
  144916. /**
  144917. * Dictionary of capabilities describing the VRDisplay.
  144918. */
  144919. readonly capabilities: VRDisplayCapabilities;
  144920. /**
  144921. * z-depth defining the far plane of the eye view frustum
  144922. * enables mapping of values in the render target depth
  144923. * attachment to scene coordinates. Initially set to 10000.0.
  144924. */
  144925. depthFar: number;
  144926. /**
  144927. * z-depth defining the near plane of the eye view frustum
  144928. * enables mapping of values in the render target depth
  144929. * attachment to scene coordinates. Initially set to 0.01.
  144930. */
  144931. depthNear: number;
  144932. /**
  144933. * An identifier for this distinct VRDisplay. Used as an
  144934. * association point in the Gamepad API.
  144935. */
  144936. readonly displayId: number;
  144937. /**
  144938. * A display name, a user-readable name identifying it.
  144939. */
  144940. readonly displayName: string;
  144941. readonly isConnected: boolean;
  144942. readonly isPresenting: boolean;
  144943. /**
  144944. * If this VRDisplay supports room-scale experiences, the optional
  144945. * stage attribute contains details on the room-scale parameters.
  144946. */
  144947. readonly stageParameters: VRStageParameters | null;
  144948. /**
  144949. * Passing the value returned by `requestAnimationFrame` to
  144950. * `cancelAnimationFrame` will unregister the callback.
  144951. * @param handle Define the hanle of the request to cancel
  144952. */
  144953. cancelAnimationFrame(handle: number): void;
  144954. /**
  144955. * Stops presenting to the VRDisplay.
  144956. * @returns a promise to know when it stopped
  144957. */
  144958. exitPresent(): Promise<void>;
  144959. /**
  144960. * Return the current VREyeParameters for the given eye.
  144961. * @param whichEye Define the eye we want the parameter for
  144962. * @returns the eye parameters
  144963. */
  144964. getEyeParameters(whichEye: string): VREyeParameters;
  144965. /**
  144966. * Populates the passed VRFrameData with the information required to render
  144967. * the current frame.
  144968. * @param frameData Define the data structure to populate
  144969. * @returns true if ok otherwise false
  144970. */
  144971. getFrameData(frameData: VRFrameData): boolean;
  144972. /**
  144973. * Get the layers currently being presented.
  144974. * @returns the list of VR layers
  144975. */
  144976. getLayers(): VRLayer[];
  144977. /**
  144978. * Return a VRPose containing the future predicted pose of the VRDisplay
  144979. * when the current frame will be presented. The value returned will not
  144980. * change until JavaScript has returned control to the browser.
  144981. *
  144982. * The VRPose will contain the position, orientation, velocity,
  144983. * and acceleration of each of these properties.
  144984. * @returns the pose object
  144985. */
  144986. getPose(): VRPose;
  144987. /**
  144988. * Return the current instantaneous pose of the VRDisplay, with no
  144989. * prediction applied.
  144990. * @returns the current instantaneous pose
  144991. */
  144992. getImmediatePose(): VRPose;
  144993. /**
  144994. * The callback passed to `requestAnimationFrame` will be called
  144995. * any time a new frame should be rendered. When the VRDisplay is
  144996. * presenting the callback will be called at the native refresh
  144997. * rate of the HMD. When not presenting this function acts
  144998. * identically to how window.requestAnimationFrame acts. Content should
  144999. * make no assumptions of frame rate or vsync behavior as the HMD runs
  145000. * asynchronously from other displays and at differing refresh rates.
  145001. * @param callback Define the eaction to run next frame
  145002. * @returns the request handle it
  145003. */
  145004. requestAnimationFrame(callback: FrameRequestCallback): number;
  145005. /**
  145006. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  145007. * Repeat calls while already presenting will update the VRLayers being displayed.
  145008. * @param layers Define the list of layer to present
  145009. * @returns a promise to know when the request has been fulfilled
  145010. */
  145011. requestPresent(layers: VRLayer[]): Promise<void>;
  145012. /**
  145013. * Reset the pose for this display, treating its current position and
  145014. * orientation as the "origin/zero" values. VRPose.position,
  145015. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  145016. * updated when calling resetPose(). This should be called in only
  145017. * sitting-space experiences.
  145018. */
  145019. resetPose(): void;
  145020. /**
  145021. * The VRLayer provided to the VRDisplay will be captured and presented
  145022. * in the HMD. Calling this function has the same effect on the source
  145023. * canvas as any other operation that uses its source image, and canvases
  145024. * created without preserveDrawingBuffer set to true will be cleared.
  145025. * @param pose Define the pose to submit
  145026. */
  145027. submitFrame(pose?: VRPose): void;
  145028. }
  145029. declare var VRDisplay: {
  145030. prototype: VRDisplay;
  145031. new(): VRDisplay;
  145032. };
  145033. interface VRLayer {
  145034. leftBounds?: number[] | Float32Array | null;
  145035. rightBounds?: number[] | Float32Array | null;
  145036. source?: HTMLCanvasElement | null;
  145037. }
  145038. interface VRDisplayCapabilities {
  145039. readonly canPresent: boolean;
  145040. readonly hasExternalDisplay: boolean;
  145041. readonly hasOrientation: boolean;
  145042. readonly hasPosition: boolean;
  145043. readonly maxLayers: number;
  145044. }
  145045. interface VREyeParameters {
  145046. /** @deprecated */
  145047. readonly fieldOfView: VRFieldOfView;
  145048. readonly offset: Float32Array;
  145049. readonly renderHeight: number;
  145050. readonly renderWidth: number;
  145051. }
  145052. interface VRFieldOfView {
  145053. readonly downDegrees: number;
  145054. readonly leftDegrees: number;
  145055. readonly rightDegrees: number;
  145056. readonly upDegrees: number;
  145057. }
  145058. interface VRFrameData {
  145059. readonly leftProjectionMatrix: Float32Array;
  145060. readonly leftViewMatrix: Float32Array;
  145061. readonly pose: VRPose;
  145062. readonly rightProjectionMatrix: Float32Array;
  145063. readonly rightViewMatrix: Float32Array;
  145064. readonly timestamp: number;
  145065. }
  145066. interface VRPose {
  145067. readonly angularAcceleration: Float32Array | null;
  145068. readonly angularVelocity: Float32Array | null;
  145069. readonly linearAcceleration: Float32Array | null;
  145070. readonly linearVelocity: Float32Array | null;
  145071. readonly orientation: Float32Array | null;
  145072. readonly position: Float32Array | null;
  145073. readonly timestamp: number;
  145074. }
  145075. interface VRStageParameters {
  145076. sittingToStandingTransform?: Float32Array;
  145077. sizeX?: number;
  145078. sizeY?: number;
  145079. }
  145080. interface Navigator {
  145081. getVRDisplays(): Promise<VRDisplay[]>;
  145082. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145083. }
  145084. interface Window {
  145085. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145086. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145087. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145088. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145089. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145090. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145091. }
  145092. interface Gamepad {
  145093. readonly displayId: number;
  145094. }
  145095. type XRSessionMode =
  145096. | "inline"
  145097. | "immersive-vr"
  145098. | "immersive-ar";
  145099. type XRReferenceSpaceType =
  145100. | "viewer"
  145101. | "local"
  145102. | "local-floor"
  145103. | "bounded-floor"
  145104. | "unbounded";
  145105. type XREnvironmentBlendMode =
  145106. | "opaque"
  145107. | "additive"
  145108. | "alpha-blend";
  145109. type XRVisibilityState =
  145110. | "visible"
  145111. | "visible-blurred"
  145112. | "hidden";
  145113. type XRHandedness =
  145114. | "none"
  145115. | "left"
  145116. | "right";
  145117. type XRTargetRayMode =
  145118. | "gaze"
  145119. | "tracked-pointer"
  145120. | "screen";
  145121. type XREye =
  145122. | "none"
  145123. | "left"
  145124. | "right";
  145125. interface XRSpace extends EventTarget {
  145126. }
  145127. interface XRRenderState {
  145128. depthNear?: number;
  145129. depthFar?: number;
  145130. inlineVerticalFieldOfView?: number;
  145131. baseLayer?: XRWebGLLayer;
  145132. }
  145133. interface XRInputSource {
  145134. handedness: XRHandedness;
  145135. targetRayMode: XRTargetRayMode;
  145136. targetRaySpace: XRSpace;
  145137. gripSpace: XRSpace | undefined;
  145138. gamepad: Gamepad | undefined;
  145139. profiles: Array<string>;
  145140. }
  145141. interface XRSessionInit {
  145142. optionalFeatures?: XRReferenceSpaceType[];
  145143. requiredFeatures?: XRReferenceSpaceType[];
  145144. }
  145145. interface XRSession extends XRAnchorCreator {
  145146. addEventListener: Function;
  145147. removeEventListener: Function;
  145148. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145149. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145150. requestAnimationFrame: Function;
  145151. end(): Promise<void>;
  145152. renderState: XRRenderState;
  145153. inputSources: Array<XRInputSource>;
  145154. // hit test
  145155. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145156. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145157. // legacy AR hit test
  145158. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145159. // legacy plane detection
  145160. updateWorldTrackingState(options: {
  145161. planeDetectionState?: { enabled: boolean; }
  145162. }): void;
  145163. }
  145164. interface XRReferenceSpace extends XRSpace {
  145165. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145166. onreset: any;
  145167. }
  145168. type XRPlaneSet = Set<XRPlane>;
  145169. type XRAnchorSet = Set<XRAnchor>;
  145170. interface XRFrame {
  145171. session: XRSession;
  145172. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145173. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145174. // AR
  145175. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145176. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145177. // Anchors
  145178. trackedAnchors?: XRAnchorSet;
  145179. // Planes
  145180. worldInformation: {
  145181. detectedPlanes?: XRPlaneSet;
  145182. };
  145183. }
  145184. interface XRViewerPose extends XRPose {
  145185. views: Array<XRView>;
  145186. }
  145187. interface XRPose {
  145188. transform: XRRigidTransform;
  145189. emulatedPosition: boolean;
  145190. }
  145191. interface XRWebGLLayerOptions {
  145192. antialias?: boolean;
  145193. depth?: boolean;
  145194. stencil?: boolean;
  145195. alpha?: boolean;
  145196. multiview?: boolean;
  145197. framebufferScaleFactor?: number;
  145198. }
  145199. declare var XRWebGLLayer: {
  145200. prototype: XRWebGLLayer;
  145201. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145202. };
  145203. interface XRWebGLLayer {
  145204. framebuffer: WebGLFramebuffer;
  145205. framebufferWidth: number;
  145206. framebufferHeight: number;
  145207. getViewport: Function;
  145208. }
  145209. declare class XRRigidTransform {
  145210. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145211. position: DOMPointReadOnly;
  145212. orientation: DOMPointReadOnly;
  145213. matrix: Float32Array;
  145214. inverse: XRRigidTransform;
  145215. }
  145216. interface XRView {
  145217. eye: XREye;
  145218. projectionMatrix: Float32Array;
  145219. transform: XRRigidTransform;
  145220. }
  145221. interface XRInputSourceChangeEvent {
  145222. session: XRSession;
  145223. removed: Array<XRInputSource>;
  145224. added: Array<XRInputSource>;
  145225. }
  145226. interface XRInputSourceEvent extends Event {
  145227. readonly frame: XRFrame;
  145228. readonly inputSource: XRInputSource;
  145229. }
  145230. // Experimental(er) features
  145231. declare class XRRay {
  145232. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145233. origin: DOMPointReadOnly;
  145234. direction: DOMPointReadOnly;
  145235. matrix: Float32Array;
  145236. }
  145237. declare enum XRHitTestTrackableType {
  145238. "point",
  145239. "plane"
  145240. }
  145241. interface XRHitResult {
  145242. hitMatrix: Float32Array;
  145243. }
  145244. interface XRTransientInputHitTestResult {
  145245. readonly inputSource: XRInputSource;
  145246. readonly results: Array<XRHitTestResult>;
  145247. }
  145248. interface XRHitTestResult {
  145249. getPose(baseSpace: XRSpace): XRPose | undefined;
  145250. }
  145251. interface XRHitTestSource {
  145252. cancel(): void;
  145253. }
  145254. interface XRTransientInputHitTestSource {
  145255. cancel(): void;
  145256. }
  145257. interface XRHitTestOptionsInit {
  145258. space: XRSpace;
  145259. entityTypes?: Array<XRHitTestTrackableType>;
  145260. offsetRay?: XRRay;
  145261. }
  145262. interface XRTransientInputHitTestOptionsInit {
  145263. profile: string;
  145264. entityTypes?: Array<XRHitTestTrackableType>;
  145265. offsetRay?: XRRay;
  145266. }
  145267. interface XRAnchor {
  145268. // remove?
  145269. id?: string;
  145270. anchorSpace: XRSpace;
  145271. lastChangedTime: number;
  145272. detach(): void;
  145273. }
  145274. interface XRPlane extends XRAnchorCreator {
  145275. orientation: "Horizontal" | "Vertical";
  145276. planeSpace: XRSpace;
  145277. polygon: Array<DOMPointReadOnly>;
  145278. lastChangedTime: number;
  145279. }
  145280. interface XRAnchorCreator {
  145281. // AR Anchors
  145282. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145283. }